List of usage examples for org.apache.commons.lang ArrayUtils remove
private static Object remove(Object array, int index)
Removes the element at the specified position from the specified array.
From source file:com.google.gdt.eclipse.designer.smartgwt.model.widgets.VersionTest.java
/** * Some users try to use old version of SmartGWT, but tell us that they use new version. We should * check version and fail with good message. * <p>//from ww w . j a v a 2s . c o m * http://fogbugz.instantiations.com/fogbugz/default.asp?48002 */ @DisposeProjectAfter public void test_oldVersion() throws Exception { dontUseSharedGWTState(); // replace SmartGWT jar, use old version { IClasspathEntry[] entries = m_javaProject.getRawClasspath(); for (int i = 0; i < entries.length; i++) { IClasspathEntry entry = entries[i]; if (entry.getPath().toString().endsWith("smartgwt.jar")) { entries = (IClasspathEntry[]) ArrayUtils.remove(entries, i); break; } } m_javaProject.setRawClasspath(entries, null); waitForAutoBuild(); // add jar for version 2.1 m_testProject.addExternalJar(SmartGwtTests.LOCATION_OLD + "/smartgwt.jar"); } // try to parse, failure expected try { parseJavaInfo("// filler filler filler filler filler", "public class Test implements EntryPoint {", " public void onModuleLoad() {", " RootPanel.get();", " }", "}"); fail(); } catch (DesignerException e) { assertEquals(IExceptionConstants.INCORRECT_VERSION, e.getCode()); } }
From source file:de.berlin.magun.nfcmime.core.RfidDAO.java
/** * Reads URI records from NDEF records//from w w w .j a v a 2 s . c o m * @param tag * @return an ArrayList of URIs, represented as Strings. */ public ArrayList<String> getUriRecords(Tag tag) { readRecords(tag); if (this.records != null) { ArrayList<String> uriStrings = new ArrayList<String>(); for (int i = 0; i < this.records.length; i++) { if (this.records[i].getTnf() == NdefRecord.TNF_WELL_KNOWN && Arrays.equals(this.records[i].getType(), NdefRecord.RTD_URI)) { uriStrings.add(EncodingUtils.getString(ArrayUtils.remove(records[i].getPayload(), 0), "UTF-8")); } } return uriStrings; } else { return null; } }
From source file:com.contrastsecurity.ide.eclipse.core.ContrastCoreActivator.java
public static void removeOrganization(final int position) { String[] orgArray = getOrganizationList(); String organization = orgArray[position]; orgArray = (String[]) ArrayUtils.remove(orgArray, position); saveOrganizationList(orgArray, false); prefs.remove(organization);/*from www . ja va2 s .c om*/ flushPrefs(); }
From source file:net.bible.android.view.activity.settings.SettingsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { // change theme according to light sensor UiUtils.applyTheme(this); super.onCreate(savedInstanceState); // allow partial integration with And Bible framework - without this TTS stops // putting this before the below ensures any error dialog will be displayed in front of the settings screen and not the previous screen // see onStop for paired iAmNoLongerCurrent method call CurrentActivityHolder.getInstance().setCurrentActivity(this); try {//from www . j a v a2 s. com addPreferencesFromResource(R.xml.settings); //If no light sensor exists switch to old boolean check box // see here for method: http://stackoverflow.com/questions/4081533/how-to-remove-android-preferences-from-the-screen Preference unusedNightModePreference = getPreferenceScreen() .findPreference(ScreenSettings.getUnusedNightModePreferenceKey()); getPreferenceScreen().removePreference(unusedNightModePreference); // if no tilt sensor then remove tilt-to-scroll setting if (!PageTiltScrollControl.isTiltSensingPossible()) { Preference tiltToScrollPreference = getPreferenceScreen() .findPreference(PageTiltScrollControl.TILT_TO_SCROLL_PREFERENCE_KEY); getPreferenceScreen().removePreference(tiltToScrollPreference); } // only JellyBean supports Malayalam so remove ml for older versions of Android if (!CommonUtils.isJellyBeanPlus()) { ListPreference localePref = (ListPreference) getPreferenceScreen().findPreference(LOCALE_PREF); CharSequence[] entries = localePref.getEntries(); CharSequence[] entryValues = localePref.getEntryValues(); int mlIndex = ArrayUtils.indexOf(entryValues, "ml"); if (mlIndex != -1) { Log.d(TAG, "removing Malayalam from preference list"); localePref.setEntries(ArrayUtils.remove(entries, mlIndex)); localePref.setEntryValues(ArrayUtils.remove(entryValues, mlIndex)); } } addScreenTimeoutSettings(); } catch (Exception e) { Log.e(TAG, "Error preparing preference screen", e); Dialogs.getInstance().showErrorMsg(R.string.error_occurred); } }
From source file:de.berlin.magun.nfcmime.core.RfidDAO.java
/** * Checks all NDEF records against the CRC value contained in the last record. * @return true, if the checksum is correct. *//*from ww w . ja v a 2 s . c o m*/ public boolean verifyMimeRecords() { CrcGenerator generator = new CrcGenerator(); NdefRecord checksumRecord = this.records[this.records.length - 1]; NdefRecord[] payloadRecords = (NdefRecord[]) ArrayUtils.remove(this.records, this.records.length - 1); if (checksumRecord.getTnf() == NdefRecord.TNF_MIME_MEDIA && EncodingUtils.getString(checksumRecord.getPayload(), "UTF-8").startsWith("crc32:")) { String checksumStr = EncodingUtils.getString(checksumRecord.getPayload(), "UTF--8"); long checksum = Long.parseLong(checksumStr.substring(checksumStr.indexOf("crc32:") + 6)); return generator.checkHash(payloadRecords, checksum); } else { return false; } }
From source file:com.predic8.membrane.osgi.CoreActivator.java
private String[] fixArguments(String[] args) { int i = ArrayUtils.indexOf(args, "-product"); if (i == -1)// w ww . j av a 2s . c om return args; return (String[]) ArrayUtils.remove(ArrayUtils.remove(args, i), i); }
From source file:net.navasoft.madcoin.backend.services.rest.impl.Provider.java
/** * Sets the policies./*from w ww .j a v a2 s . co m*/ * * @param policies * the new policies * @since 8/09/2014, 01:45:38 AM */ @Override public void setPolicies(Object... policies) { if (policies.length > 2) { inicioVentanas = (Calendar[]) Array.newInstance(Calendar.class, (policies.length - 2) / 2); finVentanas = (Calendar[]) Array.newInstance(Calendar.class, (policies.length - 2) / 2); Arrays.fill(inicioVentanas, Calendar.getInstance()); Arrays.fill(finVentanas, Calendar.getInstance()); } providerPreferrence = (ScopeProvider) policies[policies.length - 2]; providerContact = (String) policies[policies.length - 1]; policies = ArrayUtils.remove(policies, policies.length - 2); policies = ArrayUtils.remove(policies, policies.length - 1); int ini = 0; int fini = 0; for (int contadorMultiplos = 0; contadorMultiplos < policies.length; contadorMultiplos++) { if (contadorMultiplos % 2 == 0) { java.util.Date horario = (Date) policies[contadorMultiplos]; inicioVentanas[ini].setTime(horario); ini++; } else { java.util.Date horario = (Date) policies[contadorMultiplos]; finVentanas[fini].setTime(horario); fini++; } } }
From source file:com.evolveum.midpoint.repo.sql.OrgClosureTest.java
private void loadOrgStructure(String parentOid, int[] TREE_SIZE, int[] USER_SIZE, String oidPrefix, OperationResult result) throws Exception { if (TREE_SIZE.length == 0) { return;//from w ww . j ava2 s.c o m } for (int i = 0; i < TREE_SIZE[0]; i++) { String newOidPrefix = (TREE_SIZE[0] - i) + "a" + oidPrefix; PrismObject<OrgType> org = createOrg(parentOid, i, newOidPrefix); LOGGER.info("Creating {}, total {}", org, count); String oid = repositoryService.addObject(org, null, result); count++; for (int u = 0; u < USER_SIZE[0]; u++) { PrismObject<UserType> user = createUser(oid, i, u, newOidPrefix); repositoryService.addObject(user, null, result); count++; } loadOrgStructure(oid, ArrayUtils.remove(TREE_SIZE, 0), ArrayUtils.remove(USER_SIZE, 0), newOidPrefix + i, result); } }
From source file:PatternFinder.java
private List<String> getFileNames(String search, List<String> fileNames, Path dir) { try (DirectoryStream<Path> stream = Files.newDirectoryStream(dir)) { for (Path path : stream) { if (path.toFile().isDirectory()) { getFileNames(search, fileNames, path); } else { String fileName = path.toAbsolutePath().getFileName().toString(); String[] data = search.split("-"); if (data[0] != null && (data[0].equals("atoms") || data[0].equals("molecules") || data[0].equals("organisms"))) data = (String[]) ArrayUtils.remove(data, 0); String differentSearchTerm = String.join("-", data).toLowerCase(); //Search for patternlab identifier in filesystem if (fileName.contains(differentSearchTerm) || fileName.contains(search)) { fileNames.add(path.toAbsolutePath().toString()); }/*from w ww .j a v a 2 s. co m*/ } } } catch (IOException e) { //e.printStackTrace(); } return fileNames; }
From source file:com.aionengine.gameserver.restrictions.RestrictionsManager.java
public synchronized static void deactivate(Restrictions restriction) { for (RestrictionMode mode : RestrictionMode.VALUES) { Restrictions[] restrictions = RESTRICTIONS[mode.ordinal()]; for (int index; (index = ArrayUtils.indexOf(restrictions, restriction)) != -1;) restrictions = (Restrictions[]) ArrayUtils.remove(restrictions, index); RESTRICTIONS[mode.ordinal()] = restrictions; }// w w w . j a va 2 s . co m }