Java Code Examples for java.util.Vector#elementAt()
The following examples show how to use
java.util.Vector#elementAt() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Util.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
public static String printMembers(Vector v) { StringBuffer sb=new StringBuffer("("); boolean first=true; Object el; if(v != null) { for(int i=0; i < v.size(); i++) { if(!first) sb.append(", "); else first=false; el=v.elementAt(i); if(el instanceof Address) sb.append(el); else sb.append(el); } } sb.append(')'); return sb.toString(); }
Example 2
Source File: WordTable.java From The-NOC-List with Apache License 2.0 | 6 votes |
public WordTable(Vector senses) { String sense = null, lex = null; for (int i = 0; i < senses.size(); i++) { sense = (String)senses.elementAt(i); if (sense == null) continue; int dot = sense.lastIndexOf((int)'.'); if (dot > 0) lex = sense.substring(0, dot); else lex = sense; if (rootTable.get(lex) == null) allWords.add(lex); rootTable.put(lex, sense); } }
Example 3
Source File: JMenuBar.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
/** * Implemented to be a <code>MenuElement</code> -- returns the * menus in this menu bar. * This is the reason for implementing the <code>MenuElement</code> * interface -- so that the menu bar can be treated the same as * other menu elements. * @return an array of menu items in the menu bar. */ public MenuElement[] getSubElements() { MenuElement result[]; Vector<MenuElement> tmp = new Vector<MenuElement>(); int c = getComponentCount(); int i; Component m; for(i=0 ; i < c ; i++) { m = getComponent(i); if(m instanceof MenuElement) tmp.addElement((MenuElement) m); } result = new MenuElement[tmp.size()]; for(i=0,c=tmp.size() ; i < c ; i++) result[i] = tmp.elementAt(i); return result; }
Example 4
Source File: JPopupMenu.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException { s.defaultReadObject(); Vector<?> values = (Vector)s.readObject(); int indexCounter = 0; int maxCounter = values.size(); if(indexCounter < maxCounter && values.elementAt(indexCounter). equals("invoker")) { invoker = (Component)values.elementAt(++indexCounter); indexCounter++; } if(indexCounter < maxCounter && values.elementAt(indexCounter). equals("popup")) { popup = (Popup)values.elementAt(++indexCounter); indexCounter++; } }
Example 5
Source File: AbstractMixer.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
public final Line.Info[] getTargetLineInfo(Line.Info info) { int i; Vector vec = new Vector(); for (i = 0; i < targetLineInfo.length; i++) { if (info.matches(targetLineInfo[i])) { vec.addElement(targetLineInfo[i]); } } Line.Info[] returnedArray = new Line.Info[vec.size()]; for (i = 0; i < returnedArray.length; i++) { returnedArray[i] = (Line.Info)vec.elementAt(i); } return returnedArray; }
Example 6
Source File: WinGammaPlatform.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
void tagV(String name, Vector attrs) { String s[] = new String[attrs.size()]; for (int i = 0; i < attrs.size(); i++) { s[i] = (String) attrs.elementAt(i); } startTagPrim(name, s, true); }
Example 7
Source File: XSConstraints.java From hottub with GNU General Public License v2.0 | 5 votes |
private static void checkNSRecurseCheckCardinality(Vector children, int min1, int max1, SubstitutionGroupHandler dSGHandler, XSParticleDecl wildcard, int min2, int max2, boolean checkWCOccurrence) throws XMLSchemaException { // check Occurrence ranges if (checkWCOccurrence && !checkOccurrenceRange(min1,max1,min2,max2)) { throw new XMLSchemaException("rcase-NSRecurseCheckCardinality.2", new Object[]{ Integer.toString(min1), max1==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(max1), Integer.toString(min2), max2==SchemaSymbols.OCCURRENCE_UNBOUNDED?"unbounded":Integer.toString(max2)}); } // Check that each member of the group is a valid restriction of the wildcard int count = children.size(); try { for (int i = 0; i < count; i++) { XSParticleDecl particle1 = (XSParticleDecl)children.elementAt(i); particleValidRestriction(particle1, dSGHandler, wildcard, null, false); } } // REVISIT: should we really just ignore original cause of this error? // how can we report it? catch (XMLSchemaException e) { throw new XMLSchemaException("rcase-NSRecurseCheckCardinality.1", null); } }
Example 8
Source File: FunctionCall.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * Return the signature of the current method */ private String getMethodSignature(Vector argsType) { final StringBuffer buf = new StringBuffer(_className); buf.append('.').append(_fname.getLocalPart()).append('('); int nArgs = argsType.size(); for (int i = 0; i < nArgs; i++) { final Type intType = (Type)argsType.elementAt(i); buf.append(intType.toString()); if (i < nArgs - 1) buf.append(", "); } buf.append(')'); return buf.toString(); }
Example 9
Source File: XSDHandler.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * Namespace growth * * Go through the import list of a given grammar and for each imported * grammar, check to see if the grammar bucket has a newer version. * If a new instance is found, we update the import list with the * newer version. */ private void updateImportListFor(SchemaGrammar grammar) { Vector importedGrammars = grammar.getImportedGrammars(); if (importedGrammars != null) { for (int i=0; i<importedGrammars.size(); i++) { SchemaGrammar isg1 = (SchemaGrammar) importedGrammars.elementAt(i); SchemaGrammar isg2 = fGrammarBucket.getGrammar(isg1.getTargetNamespace()); if (isg2 != null && isg1 != isg2) { importedGrammars.set(i, isg2); } } } }
Example 10
Source File: Score.java From jmg with GNU General Public License v2.0 | 5 votes |
/** * Returns the all Parts in this Score as a array * @return Part[] An array containing all Part objects in this score */ public Part[] getPartArray(){ Vector vct = (Vector) this.partList.clone(); Part[] partArray = new Part[vct.size()]; for(int i=0;i< partArray.length;i++){ partArray[i] = (Part) vct.elementAt(i); } return partArray; }
Example 11
Source File: AffectiveProfile.java From The-NOC-List with Apache License 2.0 | 5 votes |
private void calculateTransFormulas(KnowledgeBaseModule transformulas) { Vector quals = transformulas.getAllFrames(); for (int q = 0; q < quals.size(); q++) { String quality = (String)quals.elementAt(q); Vector formulas = transformulas.getFieldValues("Formulas", quality); if (formulas == null) continue; int prev = getValue(quality); for (int f = 0; f < formulas.size(); f++) { String formula = (String)formulas.elementAt(f); int value = calculateFormula(formula); System.out.println(quality + " (" + formula + ") = " + value); if (value > prev) dimensions.putMax(quality, value); } } }
Example 12
Source File: Resolver.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
/** * Find the URN for a given system identifier. * * @param systemId The system ID to locate. * * @return A (single) URN that maps to the systemId. */ public String resolveSystemReverse(String systemId) throws MalformedURLException, IOException { Vector resolved = resolveAllSystemReverse(systemId); if (resolved != null && resolved.size() > 0) { return (String) resolved.elementAt(0); } else { return null; } }
Example 13
Source File: Helper24.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * **/ protected void writeHelperFactories () { Vector init = ((ValueEntry)entry).initializers (); if (init != null) { stream.println (); for (int i = 0; i < init.size (); i++) { MethodEntry element = (MethodEntry) init.elementAt (i); element.valueMethod (true); //tag value method if not tagged previously ((MethodGen24) element.generator ()). helperFactoryMethod (symbolTable, element, entry, stream); } } }
Example 14
Source File: SyntaxTreeNode.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Return true if the node only produces Text content. * * A node is a Text element if it is Text, xsl:value-of, xsl:number, * or a combination of these nested in a control instruction (xsl:if or * xsl:choose). * * If the doExtendedCheck flag is true, xsl:call-template and xsl:apply-templates * are also considered as Text elements. * * @param node A node * @param doExtendedCheck If this flag is true, <xsl:call-template> and * <xsl:apply-templates> are also considered as Text elements. * * @return true if the node of Text type */ private boolean isTextElement(SyntaxTreeNode node, boolean doExtendedCheck) { if (node instanceof ValueOf || node instanceof Number || node instanceof Text) { return true; } else if (node instanceof If) { return doExtendedCheck ? isAdaptiveRTF(node) : isSimpleRTF(node); } else if (node instanceof Choose) { Vector contents = node.getContents(); for (int i = 0; i < contents.size(); i++) { SyntaxTreeNode item = (SyntaxTreeNode)contents.elementAt(i); if (item instanceof Text || ((item instanceof When || item instanceof Otherwise) && ((doExtendedCheck && isAdaptiveRTF(item)) || (!doExtendedCheck && isSimpleRTF(item))))) continue; else return false; } return true; } else if (doExtendedCheck && (node instanceof CallTemplate || node instanceof ApplyTemplates)) return true; else return false; }
Example 15
Source File: XSGrammarBucket.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
/** * put a schema grammar and any grammars imported by it (directly or * inderectly) into the registry. when a grammar with the same target * namespace is already in the bucket, and different from the one being * added, it's an error, and no grammar will be added into the bucket. * * @param grammar the grammar to put in the registry * @param deep whether to add imported grammars * @return whether the process succeeded */ public boolean putGrammar(SchemaGrammar grammar, boolean deep) { // whether there is one with the same tns SchemaGrammar sg = getGrammar(grammar.fTargetNamespace); if (sg != null) { // if the one we have is different from the one passed, it's an error return sg == grammar; } // not deep import, then just add this one grammar if (!deep) { putGrammar(grammar); return true; } // get all imported grammars, and make a copy of the Vector, so that // we can recursively process the grammars, and add distinct ones // to the same vector Vector currGrammars = (Vector)grammar.getImportedGrammars(); if (currGrammars == null) { putGrammar(grammar); return true; } Vector grammars = ((Vector)currGrammars.clone()); SchemaGrammar sg1, sg2; Vector gs; // for all (recursively) imported grammars for (int i = 0; i < grammars.size(); i++) { // get the grammar sg1 = (SchemaGrammar)grammars.elementAt(i); // check whether the bucket has one with the same tns sg2 = getGrammar(sg1.fTargetNamespace); if (sg2 == null) { // we need to add grammars imported by sg1 too gs = sg1.getImportedGrammars(); // for all grammars imported by sg2, but not in the vector // we add them to the vector if(gs == null) continue; for (int j = gs.size() - 1; j >= 0; j--) { sg2 = (SchemaGrammar)gs.elementAt(j); if (!grammars.contains(sg2)) grammars.addElement(sg2); } } // we found one with the same target namespace // if the two grammars are not the same object, then it's an error else if (sg2 != sg1) { return false; } } // now we have all imported grammars stored in the vector. add them putGrammar(grammar); for (int i = grammars.size() - 1; i >= 0; i--) putGrammar((SchemaGrammar)grammars.elementAt(i)); return true; }
Example 16
Source File: Plot.java From opt4j with MIT License | 4 votes |
private void _fillPlot() { if (_xyInvalid) { // Recalculate the boundaries based on currently visible data _xBottom = Double.MAX_VALUE; _xTop = -Double.MAX_VALUE; _yBottom = Double.MAX_VALUE; _yTop = -Double.MAX_VALUE; for (int dataset = 0; dataset < _points.size(); dataset++) { Vector<PlotPoint> points = _points.elementAt(dataset); for (int index = 0; index < points.size(); index++) { PlotPoint pt = points.elementAt(index); if (pt.x < _xBottom) { _xBottom = pt.x; } if (pt.x > _xTop) { _xTop = pt.x; } if (pt.y < _yBottom) { _yBottom = pt.y; } if (pt.y > _yTop) { _yTop = pt.y; } } } } _xyInvalid = false; // If this is a bar graph, then make sure the Y range includes 0 if (_bars) { if (_yBottom > 0.0) { _yBottom = 0.0; } if (_yTop < 0.0) { _yTop = 0.0; } } super.fillPlot(); }
Example 17
Source File: SetOfIntegerSyntax.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
/** * Accumulate the given range (lb .. ub) into the canonical array form * into the given vector of int[] objects. */ private static void accumulate(Vector ranges, int lb,int ub) { // Make sure range is non-null. if (lb <= ub) { // Stick range at the back of the vector. ranges.add(new int[] {lb, ub}); // Work towards the front of the vector to integrate the new range // with the existing ranges. for (int j = ranges.size()-2; j >= 0; -- j) { // Get lower and upper bounds of the two ranges being compared. int[] rangea = (int[]) ranges.elementAt (j); int lba = rangea[0]; int uba = rangea[1]; int[] rangeb = (int[]) ranges.elementAt (j+1); int lbb = rangeb[0]; int ubb = rangeb[1]; /* If the two ranges overlap or are adjacent, coalesce them. * The two ranges overlap if the larger lower bound is less * than or equal to the smaller upper bound. The two ranges * are adjacent if the larger lower bound is one greater * than the smaller upper bound. */ if (Math.max(lba, lbb) - Math.min(uba, ubb) <= 1) { // The coalesced range is from the smaller lower bound to // the larger upper bound. ranges.setElementAt(new int[] {Math.min(lba, lbb), Math.max(uba, ubb)}, j); ranges.remove (j+1); } else if (lba > lbb) { /* If the two ranges don't overlap and aren't adjacent but * are out of order, swap them. */ ranges.setElementAt (rangeb, j); ranges.setElementAt (rangea, j+1); } else { /* If the two ranges don't overlap and aren't adjacent and * aren't out of order, we're done early. */ break; } } } }
Example 18
Source File: NaccacheSternEngine.java From RipplePower with Apache License 2.0 | 4 votes |
/** * Initializes this algorithm. Must be called before all other Functions. * * @see org.ripple.bouncycastle.crypto.AsymmetricBlockCipher#init(boolean, * org.ripple.bouncycastle.crypto.CipherParameters) */ public void init(boolean forEncryption, CipherParameters param) { this.forEncryption = forEncryption; if (param instanceof ParametersWithRandom) { param = ((ParametersWithRandom) param).getParameters(); } key = (NaccacheSternKeyParameters)param; // construct lookup table for faster decryption if necessary if (!this.forEncryption) { if (debug) { System.out.println("Constructing lookup Array"); } NaccacheSternPrivateKeyParameters priv = (NaccacheSternPrivateKeyParameters)key; Vector primes = priv.getSmallPrimes(); lookup = new Vector[primes.size()]; for (int i = 0; i < primes.size(); i++) { BigInteger actualPrime = (BigInteger)primes.elementAt(i); int actualPrimeValue = actualPrime.intValue(); lookup[i] = new Vector(); lookup[i].addElement(ONE); if (debug) { System.out.println("Constructing lookup ArrayList for " + actualPrimeValue); } BigInteger accJ = ZERO; for (int j = 1; j < actualPrimeValue; j++) { accJ = accJ.add(priv.getPhi_n()); BigInteger comp = accJ.divide(actualPrime); lookup[i].addElement(priv.getG().modPow(comp, priv.getModulus())); } } } }
Example 19
Source File: TLAExpr.java From tlaplus with MIT License | 4 votes |
public TLAToken lastToken() { Vector line = (Vector) this.tokens.elementAt(this.tokens.size()-1); return (TLAToken) line.elementAt(line.size()-1); }
Example 20
Source File: XslAttribute.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
/** * Parses the attribute's contents. Special care taken for namespaces. */ public void parseContents(Parser parser) { boolean generated = false; final SymbolTable stable = parser.getSymbolTable(); String name = getAttribute("name"); String namespace = getAttribute("namespace"); QName qname = parser.getQName(name, false); final String prefix = qname.getPrefix(); if (((prefix != null) && (prefix.equals(XMLNS_PREFIX)))||(name.equals(XMLNS_PREFIX))) { reportError(this, parser, ErrorMsg.ILLEGAL_ATTR_NAME_ERR, name); return; } _isLiteral = Util.isLiteral(name); if (_isLiteral) { if (!XML11Char.isXML11ValidQName(name)) { reportError(this, parser, ErrorMsg.ILLEGAL_ATTR_NAME_ERR, name); return; } } // Ignore attribute if preceeded by some other type of element final SyntaxTreeNode parent = getParent(); final Vector siblings = parent.getContents(); for (int i = 0; i < parent.elementCount(); i++) { SyntaxTreeNode item = (SyntaxTreeNode)siblings.elementAt(i); if (item == this) break; // These three objects result in one or more attribute output if (item instanceof XslAttribute) continue; if (item instanceof UseAttributeSets) continue; if (item instanceof LiteralAttribute) continue; if (item instanceof Text) continue; // These objects _can_ result in one or more attribute // The output handler will generate an error if not (at runtime) if (item instanceof If) continue; if (item instanceof Choose) continue; if (item instanceof CopyOf) continue; if (item instanceof VariableBase) continue; // Report warning but do not ignore attribute reportWarning(this, parser, ErrorMsg.STRAY_ATTRIBUTE_ERR, name); } // Get namespace from namespace attribute? if (namespace != null && namespace != Constants.EMPTYSTRING) { _prefix = lookupPrefix(namespace); _namespace = new AttributeValueTemplate(namespace, parser, this); } // Get namespace from prefix in name attribute? else if (prefix != null && prefix != Constants.EMPTYSTRING) { _prefix = prefix; namespace = lookupNamespace(prefix); if (namespace != null) { _namespace = new AttributeValueTemplate(namespace, parser, this); } } // Common handling for namespaces: if (_namespace != null) { // Generate prefix if we have none if (_prefix == null || _prefix == Constants.EMPTYSTRING) { if (prefix != null) { _prefix = prefix; } else { _prefix = stable.generateNamespacePrefix(); generated = true; } } else if (prefix != null && !prefix.equals(_prefix)) { _prefix = prefix; } name = _prefix + ":" + qname.getLocalPart(); /* * TODO: The namespace URI must be passed to the parent * element but we don't yet know what the actual URI is * (as we only know it as an attribute value template). */ if ((parent instanceof LiteralElement) && (!generated)) { ((LiteralElement)parent).registerNamespace(_prefix, namespace, stable, false); } } if (parent instanceof LiteralElement) { ((LiteralElement)parent).addAttribute(this); } _name = AttributeValue.create(this, name, parser); parseChildren(parser); }