Java Code Examples for java.util.Vector#size()

The following examples show how to use java.util.Vector#size() . 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: X11FontManager.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected String[] getNativeNames(String fontFileName,
        String platformName) {
    Vector nativeNames;
    if ((nativeNames=(Vector)xlfdMap.get(fontFileName))==null) {
        if (platformName == null) {
            return null;
        } else {
            /* back-stop so that at least the name used in the
             * font configuration file is known as a native name
             */
            String []natNames = new String[1];
            natNames[0] = platformName;
            return natNames;
        }
    } else {
        int len = nativeNames.size();
        return (String[])nativeNames.toArray(new String[len]);
    }
}
 
Example 2
Source File: ZoneView.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * Break up the zone at the given index into pieces
 * of an acceptable size.
 */
void splitZone(int index, int offs0, int offs1) {
    // divide the old zone into a new set of bins
    Element elem = getElement();
    Document doc = elem.getDocument();
    Vector<View> zones = new Vector<View>();
    int offs = offs0;
    do {
        offs0 = offs;
        offs = Math.min(getDesiredZoneEnd(offs0), offs1);
        zones.addElement(createZone(offs0, offs));
    } while (offs < offs1);
    View oldZone = getView(index);
    View[] newZones = new View[zones.size()];
    zones.copyInto(newZones);
    replace(index, 1, newZones);
}
 
Example 3
Source File: DwgUtil.java    From hortonmachine with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Obtain the int value of a handle given in binary format 
 * 
 * @param layerHandle Handle in binary format
 * @return int Int value of the handle
 */
public static int handleBinToHandleInt(Vector layerHandle) {
	byte[] layerBytes = new byte[]{0,0,0,0};
	if (layerHandle.size()>2) layerBytes[3] = (byte)((Integer)layerHandle.get(2)).intValue();
	if (layerHandle.size()>3) {
		layerBytes[3] = (byte)((Integer)layerHandle.get(3)).intValue();
		layerBytes[2] = (byte)((Integer)layerHandle.get(2)).intValue();
	}
	if (layerHandle.size()>4) {
		layerBytes[3] = (byte)((Integer)layerHandle.get(4)).intValue();
		layerBytes[2] = (byte)((Integer)layerHandle.get(3)).intValue();
		layerBytes[1] = (byte)((Integer)layerHandle.get(2)).intValue();
	}
	if (layerHandle.size()>5) {
		layerBytes[3] = (byte)((Integer)layerHandle.get(5)).intValue();
		layerBytes[2] = (byte)((Integer)layerHandle.get(4)).intValue();
		layerBytes[1] = (byte)((Integer)layerHandle.get(3)).intValue();
		layerBytes[0] = (byte)((Integer)layerHandle.get(2)).intValue();
	}
	int layer = ByteUtils.bytesToInt(layerBytes, new int[]{0});
	return layer;
}
 
Example 4
Source File: TabsDlg.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public TabsDlg(String title, Vector panels)
{
    super(new JFrame(), title, true);
    okListener = null;
    cancelListener = null;
    applyListener = null;
    Container pane = getContentPane();
    pane.setLayout(new BorderLayout());
    tabsPanel = new JTabbedPane();
    int numPanels = panels.size();
    for(int i = 0; i < numPanels; i++)
    {
        JPanel panel = (JPanel)panels.elementAt(i);
        tabsPanel.addTab(panel.getName(), panel);
    }

    pane.add(tabsPanel, "Center");
    pane.add(createButtonPanel(), "South");
    pack();
    CommonUI.centerComponent(this);
}
 
Example 5
Source File: IndMichigan.java    From KEEL with GNU General Public License v3.0 6 votes vote down vote up
IndMichigan(Vector<Integer> ant,fuzzy[][] x,Vector<Vector<Float>> y,Vector<fuzzyPartition> pentradas,int classes, int COST, int alfa,
  Vector<Float> values_classes,Vector<Vector<fuzzy>> pesos,int asign_weight_rule,
  String label,Vector<fuzzy> p) throws IOException 
{

 individuo= new fuzzyRule(pentradas,classes, asign_weight_rule);
 Integer[]a= new Integer[ant.size()];
 for(int i=0;i<ant.size();i++)
 {
  a[i]= ant.get(i);
 }
 individuo.setantecedent(a);
 individuo.calculateconsequent(x, y, pentradas, classes,COST,alfa,values_classes,pesos,label,p);

 X=x;
 Y=y;

}
 
Example 6
Source File: AbstractSector.java    From ramus with GNU General Public License v3.0 6 votes vote down vote up
private void getNullStreamedSectors(Vector<Sector> v) {
    if (rec)
        return;
    rec = true;
    try {
        if (getStream() == null) {
            if (v.indexOf(this) < 0)
                v.add(this);
        } else
            return;

        final int oLen = v.size();
        getNullStreamedSectors(getStart().getCrosspoint(), v);
        getNullStreamedSectors(getEnd().getCrosspoint(), v);

        final int len = v.size();

        for (int i = oLen; i < len; i++)
            ((AbstractSector) v.get(i)).getNullStreamedSectors(v);
    } finally {
        rec = false;
    }
}
 
Example 7
Source File: BucketTable.java    From The-NOC-List with Apache License 2.0 5 votes vote down vote up
public int numContents(String key)
{
	Vector contents = get(key);
	
	if (contents == null)
		return -1;
	else
		return contents.size();
}
 
Example 8
Source File: AudioSystem.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Obtains information about all source lines of a particular type that are supported
 * by the installed mixers.
 * @param info a <code>Line.Info</code> object that specifies the kind of
 * lines about which information is requested
 * @return an array of <code>Line.Info</code> objects describing source lines matching
 * the type requested.  If no matching source lines are supported, an array of length 0
 * is returned.
 *
 * @see Mixer#getSourceLineInfo(Line.Info)
 */
public static Line.Info[] getSourceLineInfo(Line.Info info) {

    Vector vector = new Vector();
    Line.Info[] currentInfoArray;

    Mixer mixer;
    Line.Info fullInfo = null;
    Mixer.Info[] infoArray = getMixerInfo();

    for (int i = 0; i < infoArray.length; i++) {

        mixer = getMixer(infoArray[i]);

        currentInfoArray = mixer.getSourceLineInfo(info);
        for (int j = 0; j < currentInfoArray.length; j++) {
            vector.addElement(currentInfoArray[j]);
        }
    }

    Line.Info[] returnedArray = new Line.Info[vector.size()];

    for (int i = 0; i < returnedArray.length; i++) {
        returnedArray[i] = (Line.Info)vector.get(i);
    }

    return returnedArray;
}
 
Example 9
Source File: LocalMember.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * May inline copies of all the arguments of the given method.
 */
static public LocalMember[] copyArguments(Context ctx, MemberDefinition field) {
    Vector v = field.getArguments();
    LocalMember res[] = new LocalMember[v.size()];
    v.copyInto(res);
    for (int i = 0; i < res.length; i++) {
        res[i] = res[i].copyInline(ctx);
    }
    return res;
}
 
Example 10
Source File: Style.java    From ramus with GNU General Public License v3.0 5 votes vote down vote up
public static void main(final String[] args) {
    try {
        final FileInputStream is = new FileInputStream("d:/test.html");
        final FileOutputStream o = new FileOutputStream("d:/res1.txt");
        final Source source = new Source(is);
        final List<StartTag> list = source
                .getAllStartTags(HTMLElementName.STYLE);
        final Iterator<StartTag> iterator = list.iterator();
        String text = "";
        final PrintStream out = new PrintStream(o);
        while (iterator.hasNext()) {
            final StartTag tag = iterator.next();
            final Segment s = new Segment(source, tag.getEnd(), tag
                    .getElement().getEndTag().getBegin());
            text += s.toString();
            // out.println(text);
            // out.println("---------------");
        }
        is.close();
        final Vector<Style> styles = new Vector<Style>();
        getStyles(text, styles, createCounter());
        for (int i = 0; i < styles.size(); i++) {
            out.println(styles.get(i));
        }
        o.close();
    } catch (final IOException e) {
        e.printStackTrace();
    }
}
 
Example 11
Source File: DataPersister.java    From yahnac with Apache License 2.0 5 votes vote down vote up
public int persistComments(Vector<ContentValues> commentsVector, Long storyId) {
    contentResolver.delete(HNewsContract.CommentsEntry.CONTENT_COMMENTS_URI,
            HNewsContract.CommentsEntry.ITEM_ID + " = ?",
            new String[]{storyId.toString()});

    ContentValues[] cvArray = new ContentValues[commentsVector.size()];
    commentsVector.toArray(cvArray);
    return contentResolver.bulkInsert(HNewsContract.CommentsEntry.CONTENT_COMMENTS_URI, cvArray);
}
 
Example 12
Source File: FlowList.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public FlowList append(FlowList right) {
    if (_elements == null) {
        _elements = right._elements;
    }
    else {
        final Vector temp = right._elements;
        if (temp != null) {
            final int n = temp.size();
            for (int i = 0; i < n; i++) {
                _elements.addElement(temp.elementAt(i));
            }
        }
    }
    return this;
}
 
Example 13
Source File: XSDHandler.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private void updateImportList(Vector importedSrc, Vector importedDst)
{
    final int size = importedSrc.size();

    for (int i=0; i<size; i++) {
        final SchemaGrammar sg = (SchemaGrammar) importedSrc.elementAt(i);
        if (!containedImportedGrammar(importedDst, sg)) {
            importedDst.add(sg);
        }
    }
}
 
Example 14
Source File: AxesWalker.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * Find a clone that corresponds to the key argument.
 *
 * @param key The original AxesWalker for which there may be a clone.
 * @param cloneList vector of sources in odd elements, and the
 *                  corresponding clones in even vectors, may be null.
 *
 * @return A clone that corresponds to the key, or null if key not found.
 */
static AxesWalker findClone(AxesWalker key, Vector cloneList)
{
  if(null != cloneList)
  {
    // First, look for clone on list.
    int n = cloneList.size();
    for (int i = 0; i < n; i+=2)
    {
      if(key == cloneList.elementAt(i))
        return (AxesWalker)cloneList.elementAt(i+1);
    }
  }
  return null;
}
 
Example 15
Source File: SQLPrms.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * which ddl statments will be used in the test
 * @return int array used by DDLStmtsFactory
 */
@SuppressWarnings("unchecked")
public static int[] getDDLs() {
  Vector ddls = TestConfig.tab().vecAt(SQLPrms.ddlOperations, new HydraVector());
  int[] ddlArr = new int [ddls.size()];
  String[] strArr = new String[ddls.size()];
  for (int i = 0; i < ddls.size(); i++) {
    strArr[i] = (String)ddls.elementAt(i); //get what ddl ops are in the tests
  }

  for (int i =0; i<strArr.length; i++) {
    ddlArr[i] = DDLStmtsFactory.getInt(strArr[i]); //convert to int array
  }
  return ddlArr;
}
 
Example 16
Source File: DefaultStyledDocument.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Joins the two elements carving out a hole for the
 * given removed range.
 */
Element join(Element p, Element left, Element right, int rmOffs0, int rmOffs1) {
    if (left.isLeaf() && right.isLeaf()) {
        return createLeafElement(p, left.getAttributes(), left.getStartOffset(),
                                 right.getEndOffset());
    } else if ((!left.isLeaf()) && (!right.isLeaf())) {
        // join two branch elements.  This copies the children before
        // the removal range on the left element, and after the removal
        // range on the right element.  The two elements on the edge
        // are joined if possible and needed.
        Element to = createBranchElement(p, left.getAttributes());
        int ljIndex = left.getElementIndex(rmOffs0);
        int rjIndex = right.getElementIndex(rmOffs1);
        Element lj = left.getElement(ljIndex);
        if (lj.getStartOffset() >= rmOffs0) {
            lj = null;
        }
        Element rj = right.getElement(rjIndex);
        if (rj.getStartOffset() == rmOffs1) {
            rj = null;
        }
        Vector<Element> children = new Vector<Element>();

        // transfer the left
        for (int i = 0; i < ljIndex; i++) {
            children.addElement(clone(to, left.getElement(i)));
        }

        // transfer the join/middle
        if (canJoin(lj, rj)) {
            Element e = join(to, lj, rj, rmOffs0, rmOffs1);
            children.addElement(e);
        } else {
            if (lj != null) {
                children.addElement(cloneAsNecessary(to, lj, rmOffs0, rmOffs1));
            }
            if (rj != null) {
                children.addElement(cloneAsNecessary(to, rj, rmOffs0, rmOffs1));
            }
        }

        // transfer the right
        int n = right.getElementCount();
        for (int i = (rj == null) ? rjIndex : rjIndex + 1; i < n; i++) {
            children.addElement(clone(to, right.getElement(i)));
        }

        // install the children
        Element[] c = new Element[children.size()];
        children.copyInto(c);
        ((BranchElement)to).replace(0, 0, c);
        return to;
    } else {
        throw new StateInvariantError(
            "No support to join leaf element with non-leaf element");
    }
}
 
Example 17
Source File: DefaultTreeSelectionModel.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
  * Removes paths from the selection.  If any of the paths in paths
  * are in the selection the TreeSelectionListeners are notified.
  * This has no effect if <code>paths</code> is null.
  *
  * @param paths the paths to remove from the selection
  */
public void removeSelectionPaths(TreePath[] paths) {
    if (paths != null && selection != null && paths.length > 0) {
        if(!canPathsBeRemoved(paths)) {
            /* Could probably do something more interesting here! */
            clearSelection();
        }
        else {
            Vector<PathPlaceHolder> pathsToRemove = null;

            /* Find the paths that can be removed. */
            for (int removeCounter = paths.length - 1; removeCounter >= 0;
                 removeCounter--) {
                if(paths[removeCounter] != null) {
                    if (uniquePaths.get(paths[removeCounter]) != null) {
                        if(pathsToRemove == null)
                            pathsToRemove = new Vector<PathPlaceHolder>(paths.length);
                        uniquePaths.remove(paths[removeCounter]);
                        pathsToRemove.addElement(new PathPlaceHolder
                                     (paths[removeCounter], false));
                    }
                }
            }
            if(pathsToRemove != null) {
                int         removeCount = pathsToRemove.size();
                TreePath    beginLeadPath = leadPath;

                if(removeCount == selection.length) {
                    selection = null;
                }
                else {
                    Enumeration<TreePath> pEnum = uniquePaths.keys();
                    int                  validCount = 0;

                    selection = new TreePath[selection.length -
                                            removeCount];
                    while (pEnum.hasMoreElements()) {
                        selection[validCount++] = pEnum.nextElement();
                    }
                }
                if (leadPath != null &&
                    uniquePaths.get(leadPath) == null) {
                    if (selection != null) {
                        leadPath = selection[selection.length - 1];
                    }
                    else {
                        leadPath = null;
                    }
                }
                else if (selection != null) {
                    leadPath = selection[selection.length - 1];
                }
                else {
                    leadPath = null;
                }
                updateLeadIndex();

                resetRowSelection();

                notifyPathChange(pathsToRemove, beginLeadPath);
            }
        }
    }
}
 
Example 18
Source File: RegionDescription.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
/**
 * Returns eviction attributes from the vector for LRU memory size.
 */
private static EvictionAttributes getLRUMemoryAttributes(
                       Long key, Vector val, ConfigHashtable tab) {
  Integer maximum = null; // maximum megabytes
  ObjectSizer sizer = null; // object sizer
  EvictionAction action = null; // eviction action

  // read algorithm support fields
  if (val.size() > 1) {
    maximum = tab.getInteger(key, val.get(1));
  }
  if (val.size() > 2) {
    String sizerStr = tab.getString(key, val.get(2));
    if (sizerStr != null) {
      sizer = getObjectSizer(sizerStr, key);
    }
  }
  if (val.size() > 3) {
    String actionStr = tab.getString(key, val.get(3));
    if (actionStr != null) {
      action = getEvictionAction(actionStr, key);
    }
  }
  if (val.size() > 4) {
    String s = BasePrms.nameForKey(key) + " has too many fields: " + val;
    throw new HydraConfigException(s);
  }

  // fill in defaults where needed
  if (maximum == null && (sizer != null || action != null)) {
    maximum = Integer.valueOf(EvictionAttributes.createLRUMemoryAttributes().getMaximum());
  }
  if (sizer == null && action != null) {
    sizer = EvictionAttributes.createLRUMemoryAttributes().getObjectSizer();
  }

  // invoke appropriate constructor
  if (action != null) {
    return EvictionAttributes.createLRUMemoryAttributes(maximum.intValue(), sizer, action);
  } else if (sizer != null) {
    return EvictionAttributes.createLRUMemoryAttributes(maximum.intValue(), sizer);
  } else if (maximum != null) {
    return EvictionAttributes.createLRUMemoryAttributes(maximum.intValue());
  } else {
    return EvictionAttributes.createLRUMemoryAttributes();
  }
}
 
Example 19
Source File: UIManager.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
private static void initializeAuxiliaryLAFs(Properties swingProps)
{
    String auxLookAndFeelNames = swingProps.getProperty(auxiliaryLAFsKey);
    if (auxLookAndFeelNames == null) {
        return;
    }

    Vector<LookAndFeel> auxLookAndFeels = new Vector<LookAndFeel>();

    StringTokenizer p = new StringTokenizer(auxLookAndFeelNames,",");
    String factoryName;

    /* Try to load each LookAndFeel subclass in the list.
     */

    while (p.hasMoreTokens()) {
        String className = p.nextToken();
        try {
            Class lnfClass = SwingUtilities.loadSystemClass(className);
            LookAndFeel newLAF = (LookAndFeel)lnfClass.newInstance();
            newLAF.initialize();
            auxLookAndFeels.addElement(newLAF);
        }
        catch (Exception e) {
            System.err.println("UIManager: failed loading auxiliary look and feel " + className);
        }
    }

    /* If there were problems and no auxiliary look and feels were
     * loaded, make sure we reset auxLookAndFeels to null.
     * Otherwise, we are going to use the MultiLookAndFeel to get
     * all component UI's, so we need to load it now.
     */
    if (auxLookAndFeels.size() == 0) {
        auxLookAndFeels = null;
    }
    else {
        getLAFState().multiLookAndFeel = getMultiLookAndFeel();
        if (getLAFState().multiLookAndFeel == null) {
            auxLookAndFeels = null;
        }
    }

    getLAFState().auxLookAndFeels = auxLookAndFeels;
}
 
Example 20
Source File: XSGrammarBucket.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
/**
 * 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;
}