List of usage examples for java.util Vector remove
public synchronized E remove(int index)
From source file:edu.ku.brc.specify.dbsupport.SpecifyDeleteHelper.java
/** * @param si// w w w.j ava 2 s . com * @param level * @param excludeCls * @param excludeFromRequirement * @return * @throws SQLException */ public boolean checkRequiredRecs(final StackItem si, final int level, final int id, final Class<?> excludeCls, final int[] excludeFromRequirement) throws SQLException { Vector<Integer> ids = getIds(si.getSql() + id, level); if (si.getTableInfo().getClassObj().equals(excludeCls)) { for (int exid : excludeFromRequirement) { int idx = ids.indexOf(exid); if (idx != -1) { ids.remove(idx); //assuming no dups in ids } } } if (ids.size() > 0) { return true; } // for (StackItem s : si.getStack()) // { // if (checkRequiredRecs(s, level+1, excludeCls, excludeFromRequirement)) // { // return true; // } // } return false; }
From source file:org.apache.jasper.compiler.JspUtil.java
/** * Checks if all mandatory attributes are present and if all attributes * present have valid names. Checks attributes specified as XML-style * attributes as well as attributes specified using the jsp:attribute * standard action. //from w w w.ja v a 2 s . co m */ public static void checkAttributes(String typeOfTag, Node n, ValidAttribute[] validAttributes, ErrorDispatcher err) throws JasperException { Attributes attrs = n.getAttributes(); Mark start = n.getStart(); boolean valid = true; // AttributesImpl.removeAttribute is broken, so we do this... int tempLength = (attrs == null) ? 0 : attrs.getLength(); Vector temp = new Vector(tempLength, 1); for (int i = 0; i < tempLength; i++) { String qName = attrs.getQName(i); if ((!qName.equals("xmlns")) && (!qName.startsWith("xmlns:"))) temp.addElement(qName); } // Add names of attributes specified using jsp:attribute Node.Nodes tagBody = n.getBody(); if (tagBody != null) { int numSubElements = tagBody.size(); for (int i = 0; i < numSubElements; i++) { Node node = tagBody.getNode(i); if (node instanceof Node.NamedAttribute) { String attrName = node.getAttributeValue("name"); temp.addElement(attrName); // Check if this value appear in the attribute of the node if (n.getAttributeValue(attrName) != null) { err.jspError(n, "jsp.error.duplicate.name.jspattribute", attrName); } } else { // Nothing can come before jsp:attribute, and only // jsp:body can come after it. break; } } } /* * First check to see if all the mandatory attributes are present. * If so only then proceed to see if the other attributes are valid * for the particular tag. */ String missingAttribute = null; for (int i = 0; i < validAttributes.length; i++) { int attrPos; if (validAttributes[i].mandatory) { attrPos = temp.indexOf(validAttributes[i].name); if (attrPos != -1) { temp.remove(attrPos); valid = true; } else { valid = false; missingAttribute = validAttributes[i].name; break; } } } // If mandatory attribute is missing then the exception is thrown if (!valid) err.jspError(start, "jsp.error.mandatory.attribute", typeOfTag, missingAttribute); // Check to see if there are any more attributes for the specified tag. int attrLeftLength = temp.size(); if (attrLeftLength == 0) return; // Now check to see if the rest of the attributes are valid too. String attribute = null; for (int j = 0; j < attrLeftLength; j++) { valid = false; attribute = (String) temp.elementAt(j); for (int i = 0; i < validAttributes.length; i++) { if (attribute.equals(validAttributes[i].name)) { valid = true; break; } } if (!valid) err.jspError(start, "jsp.error.invalid.attribute", typeOfTag, attribute); } // XXX *could* move EL-syntax validation here... (sb) }
From source file:org.apache.struts2.jasper.compiler.JspUtil.java
/** * Checks if all mandatory attributes are present and if all attributes * present have valid names. Checks attributes specified as XML-style * attributes as well as attributes specified using the jsp:attribute * standard action./*from w w w .j ava 2 s .c o m*/ * * @param typeOfTag type of tag * @param n node * @param validAttributes valid attributes * @param err error dispatcher * @throws JasperException in case of Jasper errors */ public static void checkAttributes(String typeOfTag, Node n, ValidAttribute[] validAttributes, ErrorDispatcher err) throws JasperException { Attributes attrs = n.getAttributes(); Mark start = n.getStart(); boolean valid = true; // AttributesImpl.removeAttribute is broken, so we do this... int tempLength = (attrs == null) ? 0 : attrs.getLength(); Vector temp = new Vector(tempLength, 1); for (int i = 0; i < tempLength; i++) { String qName = attrs.getQName(i); if ((!qName.equals("xmlns")) && (!qName.startsWith("xmlns:"))) temp.addElement(qName); } // Add names of attributes specified using jsp:attribute Node.Nodes tagBody = n.getBody(); if (tagBody != null) { int numSubElements = tagBody.size(); for (int i = 0; i < numSubElements; i++) { Node node = tagBody.getNode(i); if (node instanceof Node.NamedAttribute) { String attrName = node.getAttributeValue("name"); temp.addElement(attrName); // Check if this value appear in the attribute of the node if (n.getAttributeValue(attrName) != null) { err.jspError(n, "jsp.error.duplicate.name.jspattribute", attrName); } } else { // Nothing can come before jsp:attribute, and only // jsp:body can come after it. break; } } } /* * First check to see if all the mandatory attributes are present. * If so only then proceed to see if the other attributes are valid * for the particular tag. */ String missingAttribute = null; for (ValidAttribute validAttribute : validAttributes) { int attrPos; if (validAttribute.mandatory) { attrPos = temp.indexOf(validAttribute.name); if (attrPos != -1) { temp.remove(attrPos); valid = true; } else { valid = false; missingAttribute = validAttribute.name; break; } } } // If mandatory attribute is missing then the exception is thrown if (!valid) err.jspError(start, "jsp.error.mandatory.attribute", typeOfTag, missingAttribute); // Check to see if there are any more attributes for the specified tag. int attrLeftLength = temp.size(); if (attrLeftLength == 0) return; // Now check to see if the rest of the attributes are valid too. String attribute = null; for (int j = 0; j < attrLeftLength; j++) { valid = false; attribute = (String) temp.elementAt(j); for (ValidAttribute validAttribute : validAttributes) { if (attribute.equals(validAttribute.name)) { valid = true; break; } } if (!valid) err.jspError(start, "jsp.error.invalid.attribute", typeOfTag, attribute); } // XXX *could* move EL-syntax validation here... (sb) }
From source file:edu.ku.brc.util.HelpIndexer.java
protected void processFile(final File file, final Vector<String> lines) { // System.out.println("processing file: " + file.getName()); LineIterator it;/*ww w . ja va 2 s .c o m*/ try { it = FileUtils.lineIterator(file, "UTF-8"); } catch (IOException ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(HelpIndexer.class, ex); System.out.println("error processing file: " + file.getName()); return; } String target = getTarget(file); String title = getFileTitle(file); boolean removeTitleEntry = false; if (title != null) { String tline = "<indexitem text=\"" + title; if (target != null) { tline += "\" target=\"" + target; } tline += "\">"; lines.add(tline); removeTitleEntry = true; } if (target != null) { try { while (it.hasNext()) { String line = it.nextLine(); //System.out.println(line); if (isIndexLine(line)) { System.out.println("indexing " + file.getName() + ": " + line); String indexEntry = processIndexLine(line, target); if (indexEntry != null) { lines.add(" " + indexEntry); removeTitleEntry = false; } } } } finally { LineIterator.closeQuietly(it); } } if (title != null && !removeTitleEntry) { lines.add("</indexitem>"); } if (removeTitleEntry) { lines.remove(lines.size() - 1); } }
From source file:org.graphwalker.ModelBasedTesting.java
private void interractivePath(InputStream in) throws InterruptedException { Vector<String> stepPair = new Vector<String>(); String req = ""; for (char input = '0'; true; input = Util.getInput()) { logger.debug("Recieved: '" + input + "'"); switch (input) { case '2': return; case '0': if (!hasNextStep() && (stepPair.size() == 0)) { return; }//from ww w . j av a 2 s .c o m if (stepPair.size() == 0) { stepPair = new Vector<String>(Arrays.asList(getNextStep())); req = getRequirement(getMachine().getLastEdge()); } else { req = getRequirement(getMachine().getCurrentVertex()); } if (req.length() > 0) { req = "/" + req; } System.out.print(stepPair.remove(0) + req); String addInfo = ""; System.out.println(); if (stepPair.size() == 1) { logExecution(getMachine().getLastEdge(), addInfo); if (isUseStatisticsManager()) { getStatisticsManager().addProgress(getMachine().getLastEdge()); } } else { logExecution(getMachine().getCurrentVertex(), addInfo); if (isUseStatisticsManager()) { getStatisticsManager().addProgress(getMachine().getCurrentVertex()); } } break; default: throw new RuntimeException("Unsupported input recieved."); } } }
From source file:edu.ku.brc.specify.tools.datamodelgenerator.DatamodelGenerator.java
@SuppressWarnings("unchecked") protected void removeCascadeRule(Class<?> cls, Method method) { try {// w w w.j a va 2 s .com File f = new File(srcCodeDir.getAbsoluteFile() + File.separator + cls.getSimpleName() + ".java"); if (!f.exists()) { log.error("Can't locate source file[" + f.getAbsolutePath() + "]"); return; } List<String> strLines = FileUtils.readLines(f); Vector<String> lines = new Vector<String>(); String methodName = method.getName() + "("; int inx = 0; for (String line : strLines) { if (line.indexOf(methodName) > -1 && line.indexOf("public") > -1) { int i = inx; int stop = i - 10; System.out.println("[" + strLines.get(i) + "]"); while (!StringUtils.contains(strLines.get(i), "@Cascade") && i > stop) { i--; System.out.println("[" + strLines.get(i) + "]"); } if (i < stop || StringUtils.contains(strLines.get(i), "@Cascade")) { lines.remove(i); } } lines.add(line); inx++; } FileUtils.writeLines(f, lines); } catch (IOException ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(DatamodelGenerator.class, ex); ex.printStackTrace(); } }
From source file:com.apache.fastandroid.novel.view.readview.PageFactory.java
/** * //from www.j av a 2 s . c o m */ private void pageUp() { String strParagraph = ""; Vector<String> lines = new Vector<>(); // ? int paraSpace = 0; mPageLineCount = mVisibleHeight / (mFontSize + mLineSpace); while ((lines.size() < mPageLineCount) && (curBeginPos > 0)) { Vector<String> paraLines = new Vector<>(); // ? byte[] parabuffer = readParagraphBack(curBeginPos); // 1.?? curBeginPos -= parabuffer.length; // 2.??? try { strParagraph = new String(parabuffer, charset); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } strParagraph = strParagraph.replaceAll("\r\n", " "); strParagraph = strParagraph.replaceAll("\n", " "); while (strParagraph.length() > 0) { // 3.?lines int paintSize = mPaint.breakText(strParagraph, true, mVisibleWidth, null); paraLines.add(strParagraph.substring(0, paintSize)); strParagraph = strParagraph.substring(paintSize); } lines.addAll(0, paraLines); while (lines.size() > mPageLineCount) { // 4.?? try { curBeginPos += lines.get(0).getBytes(charset).length; // 5.??????? lines.remove(0); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } } curEndPos = curBeginPos; // 6.??? paraSpace += mLineSpace; mPageLineCount = (mVisibleHeight - paraSpace) / (mFontSize + mLineSpace); // ?? } }
From source file:org.geworkbench.engine.ccm.ComponentConfigurationManager.java
/** * Removes the component with resourceName. * /* w w w .j a v a 2 s .c o m*/ * @param folderName * @param ccmFileName * @return Returns false if component was not successfully removed, else * true. */ @SuppressWarnings("unchecked") public boolean removeComponent(String folderName, String filename) { /* * Container Summary: * * ComponentRegistry Section listeners = new TypeMap<List>(); * acceptors = new HashMap<Class, List<Class>>(); * synchModels = new HashMap<Class, SynchModel>(); * components = new ArrayList(); * idToDescriptor = new HashMap<String, PluginDescriptor>(); * nameToComponentResource = new HashMap<String, ComponentResource>(); */ ComponentRegistry componentRegistry = ComponentRegistry.getRegistry(); /* validation */ if (StringUtils.isEmpty(folderName)) { log.error("Input resource is null. Returning ..."); return false; } List<String> list = Arrays.asList(files); if (!list.contains(folderName)) { return false; } // FIXME why parse again? can't we get this info another way? /* parse the ccm.xml file */ PluginComponent ccmComponent = null; if (filename.endsWith(COMPONENT_DESCRIPTOR_EXTENSION)) { ccmComponent = getPluginsFromFile(new File(filename)); } else { return false; } if (ccmComponent == null) return false; /* GET THE VARIOUS MAPS/VECTORS FROM THE PLUGIN REGISTRY */ /* plugin registry component vector */ Vector<PluginDescriptor> componentVector = PluginRegistry.getComponentVector(); /* plugin registry visual area map */ HashMap<PluginDescriptor, String> visualAreaMap = PluginRegistry.getVisualAreaMap(); /* plugin registry used ids */ Vector<String> usedIds = PluginRegistry.getUsedIds(); // FIXME Can't we get the PluginDesriptor we want other than from the // ccm.xml file? // beginning of processing the plugin final String pluginClazzName = ccmComponent.getClazz(); PluginDescriptor pluginDescriptor = PluginRegistry.getPluginDescriptor(ccmComponent.getPluginId()); if (pluginDescriptor != null) { /* START THE REMOVAL PROCESS IN THE PLUGIN REGISTRY */ /* PluginRegistry.visualAreaMap */ for (Entry<PluginDescriptor, String> entry : visualAreaMap.entrySet()) { Object pluginDescriptor1 = entry.getKey(); Class<?> clazz = pluginDescriptor1.getClass(); String proxiedClazzName = clazz.getName(); // TODO Replace $$ parse methods with clazzName = clazz.getSuperclass() String[] temp = StringUtils.split(proxiedClazzName, "$$"); String clazzName = temp[0]; if (StringUtils.equals(pluginClazzName, clazzName)) { visualAreaMap.remove(entry.getKey()); break; } } /* PluginRegistry.visualAreaMap */ String id = ccmComponent.getPluginId(); if (PluginDescriptor.idExists(id)) { usedIds.remove(id); } /* PluginRegistry.compontentVector */ if (componentVector.contains(pluginDescriptor)) { componentVector.remove(pluginDescriptor); } /* START THE REMOVAL PROCESS IN THE COMPONENT REGISTRY */ componentRegistry.removeComponent(pluginClazzName); componentRegistry.removePlugin(ccmComponent.getPluginId()); } // end of processing the plugin /* ComponentRegistry.idToDescriptor */ /* If other Plugins are using the same Component Resource, don't remove the Resource */ int foldersInUse = 0; for (int i = 0; i < componentVector.size(); i++) { PluginDescriptor pd = componentVector.get(i); if (pd == null) { continue; } ComponentResource componentResource = pd.getResource(); if (componentResource == null) { continue; } String name = componentResource.getName(); if (name == null) { continue; } if (name.equalsIgnoreCase(folderName)) { foldersInUse++; } } if (foldersInUse < 1) { componentRegistry.removeComponentResource(folderName); } return true; }
From source file:nl.systemsgenetics.eqtlinteractionanalyser.eqtlinteractionanalyser.TestEQTLDatasetForInteractions.java
private void initGenotypes(boolean permute, HashMap hashSamples, String[] cohorts) { datasetGenotypes = new ExpressionDataset(inputDir + "/bigTableLude.txt.Genotypes.binary", '\t', null, hashSamples);/*from ww w. j a v a2s. c o m*/ if (permute) { System.out.println("WARNING: PERMUTING GENOTYPE DATA!!!!"); if (cohorts == null) { cohorts = new String[] { "LLDeep", "LLS", "RS", "CODAM" }; } int[] permSampleIDs = new int[datasetGenotypes.nrSamples]; for (int p = 0; p < cohorts.length; p++) { Vector vecSamples = new Vector(); for (int s = 0; s < datasetGenotypes.nrSamples; s++) { //if (datasetGenotypes.sampleNames[s].startsWith(cohorts[p])) { vecSamples.add(s); //} } for (int s = 0; s < datasetGenotypes.nrSamples; s++) { //if (datasetGenotypes.sampleNames[s].startsWith(cohorts[p])) { int randomSample = ((Integer) vecSamples .remove((int) ((double) vecSamples.size() * Math.random()))).intValue(); permSampleIDs[s] = randomSample; //} } } ExpressionDataset datasetGenotypes2 = new ExpressionDataset(datasetGenotypes.nrProbes, datasetGenotypes.nrSamples); datasetGenotypes2.probeNames = datasetGenotypes.probeNames; datasetGenotypes2.sampleNames = datasetGenotypes.sampleNames; datasetGenotypes2.recalculateHashMaps(); for (int p = 0; p < datasetGenotypes2.nrProbes; p++) { for (int s = 0; s < datasetGenotypes2.nrSamples; s++) { datasetGenotypes2.rawData[p][s] = datasetGenotypes.rawData[p][permSampleIDs[s]]; } } datasetGenotypes = datasetGenotypes2; } }
From source file:skoa.helpers.Graficos.java
private void unificarDatosFicheros() { Vector<String> nombresFicheros2 = new Vector<String>(nombresFicheros); //Copiamos los nombres String nombreFicheroEscogido; String nombreFicheroReferencia = nombresFicheros2.get(0); //Se coge el 1 fichero de referencia, al que se le irn aadiendo los datos. nombresFicheros2.remove(0); crearFicheroTemporal(nombreFicheroReferencia); for (int i = 0; i < nombresFicheros2.size(); i++) { nombreFicheroEscogido = nombresFicheros2.elementAt(i); File archivo = new File(ruta + nombreFicheroEscogido); FileReader fr = null;// w ww .j a va 2s . c o m BufferedReader linea = null; String line; try { fr = new FileReader(archivo); linea = new BufferedReader(fr); while ((line = linea.readLine()) != null) { //Lectura del fichero incluirDatos(line); } } catch (Exception e) { e.printStackTrace(); } finally { try { if (null != fr) fr.close(); //Se cierra si todo va bien. } catch (Exception e2) { //Sino salta una excepcion. e2.printStackTrace(); } } } //fin for }