List of usage examples for org.apache.commons.lang ArrayUtils indexOf
public static int indexOf(boolean[] array, boolean valueToFind)
Finds the index of the given value in the array.
From source file:com.my.diff.MyDKCSVFileSource.java
private int[] getHeaderColumnNameIndices(String[] names_) { if (names_ == null) return null; int[] indices = new int[names_.length]; Arrays.fill(indices, -1);/*from w ww .j a va 2 s. c om*/ for (int i = 0, j = 0; i < names_.length; i++) { int foundAt = ArrayUtils.indexOf(_headerColumnNames, names_[i]); if (foundAt < 0) throw new RuntimeException(String.format("no value in _headerColumnNames for %s", names_[i])); indices[j++] = foundAt; } return DKArrayUtil.compactFill(indices, -1); }
From source file:net.mumie.coursecreator.graph.cells.SubComponentConstants.java
public static boolean isSubSectionCategory(int cat) { int lower = ArrayUtils.indexOf(categories, CAT_PRELEARN); return (cat >= lower); }
From source file:com.bluexml.side.util.libs.eclipse.pages.PageControlsHelper.java
public static void initializeCombo(final String id, Map<String, Object> allowedValues, final Map<String, Object> values, final Combo archetypeIdControl) { String[] items = allowedValues.keySet().toArray(new String[allowedValues.size()]); archetypeIdControl.setItems(items);// www .j a v a 2 s .c o m Object string = values.get(id); if (string != null) { archetypeIdControl.select(ArrayUtils.indexOf(items, string)); } }
From source file:net.sf.firemox.Magic.java
/** * Creates new form Magic/* ww w. j a v a 2 s . c o m*/ */ private Magic() { super(); initComponents(); // list all installed Look&Feel UIListener uiListener = new UIListener(); UIManager.LookAndFeelInfo[] uimTMP = UIManager.getInstalledLookAndFeels(); final List<Pair<String, String>> lfList = new ArrayList<Pair<String, String>>(); for (LookAndFeelInfo lookAndFeel : uimTMP) { Pair<String, String> info = new Pair<String, String>(lookAndFeel.getName(), lookAndFeel.getClassName()); if (!lfList.contains(info)) { lfList.add(info); } } // list all SkinLF themes final File[] themes = MToolKit.getFile("lib").listFiles(new FileFilter() { public boolean accept(File f) { return f != null && f.getName().endsWith(".zip"); } }); int maxIndex = Configuration.getConfiguration().getMaxIndex("themes.skinlf.caches.cache"); List<Pair<String, String>> knownThemes = new ArrayList<Pair<String, String>>(); for (int i = 0; i < maxIndex + 1; i++) { String file = Configuration.getConfiguration() .getString("themes.skinlf.caches.cache(" + i + ").[@file]"); int index = ArrayUtils.indexOf(themes, MToolKit.getFile(file)); if (index >= 0) { themes[index] = null; Pair<String, String> skin = new Pair<String, String>( Configuration.getConfiguration().getString("themes.skinlf.caches.cache(" + i + ").[@name]"), file); knownThemes.add(skin); lfList.add(skin); } } for (File theme : themes) { if (theme != null) { // a new theme --> will be cached try { final List<Node> properties = new XmlParser().parse(new ZipResourceLoader(theme.toURI().toURL()) .getResourceAsStream("skinlf-themepack.xml")).getNodes("property"); PROPERTIES: for (int j = 0; j < properties.size(); j++) { if ("skin.name".equals(properties.get(j).getAttribute("name"))) { // skin name found String relativePath = MToolKit.getRelativePath(theme.getCanonicalPath()); Pair<String, String> skin = new Pair<String, String>( properties.get(j).getAttribute("value"), "zip:" + relativePath); lfList.add(skin); knownThemes.add(new Pair<String, String>(properties.get(j).getAttribute("value"), relativePath)); break PROPERTIES; } } } catch (Exception e) { Log.error("Error in " + theme, e); } } } Configuration.getConfiguration().clearProperty("themes.skinlf.caches"); for (int index = 0; index < knownThemes.size(); index++) { Pair<String, String> skin = knownThemes.get(index); Configuration.getConfiguration().setProperty("themes.skinlf.caches.cache(" + index + ").[@name]", skin.key); Configuration.getConfiguration().setProperty("themes.skinlf.caches.cache(" + index + ").[@file]", skin.value); } // create look and feel menu items Collections.sort(lfList); lookAndFeels = new JRadioButtonMenuItem[lfList.size() + 1]; ButtonGroup group5 = new ButtonGroup(); for (int i = 0; i < lfList.size(); i++) { final String lfName = lfList.get(i).key; final String lfClassName = lfList.get(i).value; lookAndFeels[i] = new JRadioButtonMenuItem(lfName); if (lookAndFeelName.equalsIgnoreCase(lfClassName)) { // this the current l&f lookAndFeels[i].setSelected(true); } if (!SkinLF.isSkinLF(lfClassName)) { lookAndFeels[i].setEnabled(MToolKit.isAvailableLookAndFeel(lfClassName)); } group5.add(lookAndFeels[i]); lookAndFeels[i].setActionCommand(lfClassName); themeMenu.add(lookAndFeels[i], i); lookAndFeels[i].addActionListener(uiListener); } lfList.clear(); initialdelayMenu.addActionListener(this); dismissdelayMenu.addActionListener(this); ConnectionManager.enableConnectingTools(false); // read auto mana option MCommonVars.autoMana = Configuration.getBoolean("automana", true); autoManaMenu.setSelected(MCommonVars.autoMana); // Force to initialize the TBS settings MToolKit.tbsName = null; setMdb(Configuration.getString("lastTBS", IdConst.TBS_DEFAULT)); // set the autoStack mode MCommonVars.autoStack = Configuration.getBoolean("autostack", false); autoPlayMenu.setSelected(MCommonVars.autoStack); // read maximum displayed colored mana in context PayMana.thresholdColored = Configuration.getInt("threshold-colored", 6); ZoneManager.updateLookAndFeel(); // pack this frame pack(); // Maximize this frame setExtendedState(Frame.MAXIMIZED_BOTH); if (batchMode != -1) { final String deckFile = Configuration.getString(Configuration.getString("decks.deck(0)")); try { Deck batchDeck = DeckReader.getDeck(this, deckFile); switch (batchMode) { case BATCH_SERVER: ConnectionManager.server = new Server(batchDeck, null); ConnectionManager.server.start(); break; case BATCH_CLIENT: ConnectionManager.client = new Client(batchDeck, null); ConnectionManager.client.start(); break; default: } } catch (Throwable e) { throw new RuntimeException("Error in batch mode : ", e); } } }
From source file:com.ge.research.semtk.load.DataCleaner.java
/** * Specify a column to split// w w w. j a va2s. c o m * @param columnHeader (e.g. "personnel") * @param delimiter (e.g. "~") * @throws Exception */ public void addSplit(String columnHeader, String delimiter) throws Exception { // error if column does not exist if (headers.indexOf(columnHeader) == -1) { throw new Exception("Cannot clean nonexistent column " + columnHeader); } // error if delimiter is unsupported if (ArrayUtils.indexOf(UNSUPPORTED_SPLIT_DELIMITERS, delimiter) > -1) { throw new Exception("Cannot yet support splitting on delimiter " + delimiter); } // error if there is already a split on this column if (columnsToSplit.get(columnHeader) != null) { throw new Exception("Already splitting column using " + columnsToSplit.get(columnHeader) + ", cannot add another split"); } // add the split columnsToSplit.put(columnHeader, delimiter); }
From source file:com.jaspersoft.studio.property.descriptor.returnvalue.InputReturnValueDialog.java
/** * Initialize the from and to control with the passed container and attach * the modify listeners to them/* w w w . j a va2 s . c om*/ */ protected void initializeVariables() { if (rvContainer.getToVariable() != null) { int index = ArrayUtils.indexOf(toVariables, rvContainer.getToVariable()); if (index == ArrayUtils.INDEX_NOT_FOUND) index = 0; toVariable.select(index); } else { toVariable.select(0); } if (rvContainer.getFromVariable() != null) { fromVariable.setText(rvContainer.getFromVariable()); } toVariable.addModifyListener(widgetModified); fromVariable.addModifyListener(widgetModified); }
From source file:jef.tools.string.StringSpliterEx.java
/** * setKeyOfAny?key???//from w w w. jav a2 s. com * key1= "<","[" key2=">","]" <????>?? * @param key1 * @param key2 * @return */ public int setKeyPairOfAny(String[] key1, String[] key2) { if (key1.length < key2.length) { throw new IllegalArgumentException("the length between two input keys do not equals!"); } StringSpliter sp = new StringSpliter(source); sp.setKeyOfAny(key1); if (sp.getKeyword() != null) { this.keyword1 = sp.getKeyword(); int n = ArrayUtils.indexOf(key1, this.keyword1.toString()); if (n > key2.length - 1) {//key1??key2 return RESULT_KEY1_ONLY; } String realKey2 = key2[n]; sp = new StringSpliter(sp.getRight()); if (findMode == MODE_FROM_ENDS) { sp.setMode(StringSpliter.MODE_FROM_RIGHT); } sp.setKey(realKey2); this.keyword2 = sp.getKeyword(); if (sp.getKeyword() != null) { return RESULT_BOTH_KEY; } else { return RESULT_KEY1_ONLY; } } else { if (findMode == MODE_FROM_ENDS) { sp.setMode(StringSpliter.MODE_FROM_RIGHT); } sp.setKeyOfAny(key2); this.keyword2 = sp.getKeyword(); if (sp.getKeyword() != null) { return RESULT_KEY2_ONLY; } else { return RESULT_NO_KEY; } } }
From source file:com.blockwithme.hacktors.Mobile.java
/** Tries to find some equipment of the mobile. */ public int findItem(final Item theItem) { return ArrayUtils.indexOf(equipment, theItem); }
From source file:morphy.timeseal.TimesealCoder.java
public static byte[][] splitBytes(byte[] bytes, byte splitByte) { byte[] bytesToProcess = bytes; ArrayList<Byte[]> bytesList = new ArrayList<Byte[]>(); int idx;// ww w .j a v a 2s . c o m while ((idx = ArrayUtils.indexOf(bytesToProcess, splitByte)) != -1) { bytesList.add(ArrayUtils.toObject(Arrays.copyOfRange(bytesToProcess, 0, idx))); if (idx + 1 < bytesToProcess.length) { bytesToProcess = Arrays.copyOfRange(bytesToProcess, idx + 1, bytesToProcess.length); } } bytesList.add(ArrayUtils.toObject(bytesToProcess)); byte[][] newBytes = new byte[bytesList.size()][]; Byte[][] objBytesArray = bytesList.toArray(new Byte[bytesList.size()][0]); for (int i = 0; i < objBytesArray.length; i++) { newBytes[i] = ArrayUtils.toPrimitive(objBytesArray[i]); } return newBytes; }
From source file:net.sf.firemox.token.Register.java
@Override public String toString() { if (on != null) return on.toString(); int index = ArrayUtils.indexOf(REGISTER_VALUES, ordinal); if (index != -1) return REGISTER_NAMES[index]; return "?"; }