List of usage examples for java.util Vector addElement
public synchronized void addElement(E obj)
From source file:graphics.MainWindow.java
private Vector setNeighbours(int CellID) { Vector<Integer> neighbours = new Vector<Integer>(); int ID = CellID - 1; if (ID >= 0 && this.World.contain(ID)) { neighbours.addElement(new Integer(ID)); }/*from w w w . ja v a 2 s.c om*/ ID = CellID + 1; if (ID < 16 && this.World.contain(ID)) { neighbours.addElement(new Integer(ID)); } ID = CellID - 4; if (ID >= 0 && this.World.contain(ID)) { neighbours.addElement(new Integer(ID)); } ID = CellID + 4; if (ID < 16 && this.World.contain(ID)) { neighbours.addElement(new Integer(ID)); } return neighbours; }
From source file:edu.indiana.lib.osid.base.repository.http.RepositoryManager.java
public org.osid.shared.LongValueIterator getAssetDates(org.osid.shared.Id assetId) throws org.osid.repository.RepositoryException { if (assetId == null) { throw new org.osid.repository.RepositoryException(org.osid.shared.SharedException.NULL_ARGUMENT); }// ww w . ja va 2 s . c om java.util.Vector result = new java.util.Vector(); try { org.osid.repository.RepositoryIterator repositoryIterator = getRepositories(); while (repositoryIterator.hasNextRepository()) { org.osid.repository.Repository nextRepository = repositoryIterator.nextRepository(); org.osid.shared.LongValueIterator longValueIterator = repository.getAssetDates(assetId); while (longValueIterator.hasNextLongValue()) { result.addElement(new Long(longValueIterator.nextLongValue())); } } return new LongValueIterator(result); } catch (Throwable t) { _log.error(t.getMessage()); throw new org.osid.repository.RepositoryException(org.osid.OsidException.OPERATION_FAILED); } }
From source file:org.apache.jmeter.util.JMeterUtils.java
/** * Instantiate a vector of classes/*from w w w .j ava2s . co m*/ * * @param v * Description of Parameter * @param className * Description of Parameter * @return Description of the Returned Value * @deprecated (3.0) not used out of this class */ @Deprecated public static Vector<Object> instantiate(Vector<String> v, String className) { Vector<Object> i = new Vector<>(); try { Class<?> c = Class.forName(className); Enumeration<String> elements = v.elements(); while (elements.hasMoreElements()) { String name = elements.nextElement(); try { Object o = Class.forName(name).newInstance(); if (c.isInstance(o)) { i.addElement(o); } } catch (ClassNotFoundException e) { log.error("Error loading class " + name + ": class is not found"); } catch (IllegalAccessException e) { log.error("Error loading class " + name + ": does not have access"); } catch (InstantiationException e) { log.error("Error loading class " + name + ": could not instantiate"); } catch (NoClassDefFoundError e) { log.error("Error loading class " + name + ": couldn't find class " + e.getMessage()); } } } catch (ClassNotFoundException e) { log.error("Error loading class " + className + ": class is not found"); } return i; }
From source file:edu.ku.brc.specify.dbsupport.customqueries.CatalogedByYearCustomQuery.java
public List<QueryResultsContainerIFace> getQueryDefinition() { int numYears = 10; Vector<QueryResultsContainerIFace> list = new Vector<QueryResultsContainerIFace>(); Calendar now = Calendar.getInstance(); int year = now.get(Calendar.YEAR) - 1; for (int yr = year - numYears + 1; yr <= year; yr++) { String sql = QueryAdjusterForDomain.getInstance().adjustSQL( "SELECT count(*) FROM collectionobject WHERE CollectionMemberID = COLMEMID AND YEAR(CatalogedDate) = " + yr);//from w ww. j a va 2 s . c om QueryResultsContainer ndbrc = new QueryResultsContainer(sql); ndbrc.add(new QueryResultsDataObj(Integer.toString(yr))); ndbrc.add(new QueryResultsDataObj(1, 1)); list.addElement(ndbrc); } return list; }
From source file:IconDemoApplet.java
protected Vector parseParameters() { Vector pix = new Vector(10); //start with 10, grows if necessary int i = 0; //parameters index must start at 0 String paramName = "IMAGE" + i; String paramValue;//from w w w .j av a 2 s.c o m while ((paramValue = getParameter(paramName)) != null) { Photo pic = new Photo(paramValue, getCaption(i), getWidth(i), getHeight(i)); pix.addElement(pic); i++; paramName = "IMAGE" + i; } //Get the name of the directory that contains the image files. imagedir = getParameter("IMAGEDIR"); if (imagedir != null) imagedir = imagedir + "/"; return pix; }
From source file:com.nokia.example.lwuit.rlinks.network.operation.CommentsLoadOperation.java
/** * Recursively parse the given listingJsonObject for Comments, adding them * into the Vector specified. Will call itself until the comment tree is * whole (until there are no more child JSON objects to parse). * * @param comments Vector of comments//from w w w .j a v a 2 s.co m * @param listingJsonObject JSON object (comment listing) to parse * @param level Depth level * @throws JSONException In case of a parsing error */ protected void recursivelyAddReplies(Vector comments, JSONObject listingJsonObject, int level) throws JSONException { JSONArray childrenJsonArray = listingJsonObject.getJSONObject("data").getJSONArray("children"); // Reuse the same objects to avoid unnecessary overhead JSONObject thingDataObj; CommentThing comment; for (int i = 0, len = childrenJsonArray.length(); i < len && !aborted; i++) { thingDataObj = childrenJsonArray.getJSONObject(i).getJSONObject("data"); try { // Create a comment item and append it to the list comment = CommentThing.fromJson(thingDataObj); comment.setLevel(level); comments.addElement(comment); } catch (JSONException e) { System.out.println("Could not parse comment JSON: " + e.getMessage()); } // Process any further replies JSONObject repliesJsonObject = thingDataObj.optJSONObject("replies"); if (repliesJsonObject != null) { recursivelyAddReplies(comments, repliesJsonObject, level + 1); } } }
From source file:edu.indiana.lib.osid.base.repository.http.RepositoryManager.java
public org.osid.repository.AssetIterator getAssetsBySearch(org.osid.repository.Repository[] repositories, java.io.Serializable searchCriteria, org.osid.shared.Type searchType, org.osid.shared.Properties searchProperties) throws org.osid.repository.RepositoryException { if (repositories == null) { throw new org.osid.repository.RepositoryException(org.osid.shared.SharedException.NULL_ARGUMENT); }/*www . j a va 2 s . c o m*/ try { java.util.Vector results = new java.util.Vector(); for (int j = 0; j < repositories.length; j++) { org.osid.repository.Repository nextRepository = repositories[j]; //optionally add a separate thread here try { org.osid.repository.AssetIterator assetIterator = nextRepository .getAssetsBySearch(searchCriteria, searchType, searchProperties); while (assetIterator.hasNextAsset()) { results.addElement(assetIterator.nextAsset()); } } catch (Throwable t) { _log.warn(t.getMessage()); } } return new AssetIterator(results); } catch (Throwable t) { _log.error(t.getMessage()); throw new org.osid.repository.RepositoryException(org.osid.OsidException.OPERATION_FAILED); } }
From source file:JavaViewer.java
/** * Event.detail line start offset (input) Event.text line text (input) * LineStyleEvent.styles Enumeration of StyleRanges, need to be in order. * (output) LineStyleEvent.background line background color (output) */// ww w .jav a2 s. c om public void lineGetStyle(LineStyleEvent event) { Vector styles = new Vector(); int token; StyleRange lastStyle; // If the line is part of a block comment, create one style for the // entire line. if (inBlockComment(event.lineOffset, event.lineOffset + event.lineText.length())) { styles.addElement(new StyleRange(event.lineOffset, event.lineText.length(), getColor(COMMENT), null)); event.styles = new StyleRange[styles.size()]; styles.copyInto(event.styles); return; } Color defaultFgColor = ((Control) event.widget).getForeground(); scanner.setRange(event.lineText); token = scanner.nextToken(); while (token != EOF) { if (token == OTHER) { // do nothing for non-colored tokens } else if (token != WHITE) { Color color = getColor(token); // Only create a style if the token color is different than the // widget's default foreground color and the token's style is // not // bold. Keywords are bolded. if ((!color.equals(defaultFgColor)) || (token == KEY)) { StyleRange style = new StyleRange(scanner.getStartOffset() + event.lineOffset, scanner.getLength(), color, null); if (token == KEY) { style.fontStyle = SWT.BOLD; } if (styles.isEmpty()) { styles.addElement(style); } else { // Merge similar styles. Doing so will improve // performance. lastStyle = (StyleRange) styles.lastElement(); if (lastStyle.similarTo(style) && (lastStyle.start + lastStyle.length == style.start)) { lastStyle.length += style.length; } else { styles.addElement(style); } } } } else if ((!styles.isEmpty()) && ((lastStyle = (StyleRange) styles.lastElement()).fontStyle == SWT.BOLD)) { int start = scanner.getStartOffset() + event.lineOffset; lastStyle = (StyleRange) styles.lastElement(); // A font style of SWT.BOLD implies that the last style // represents a java keyword. if (lastStyle.start + lastStyle.length == start) { // Have the white space take on the style before it to // minimize the number of style ranges created and the // number of font style changes during rendering. lastStyle.length += scanner.getLength(); } } token = scanner.nextToken(); } event.styles = new StyleRange[styles.size()]; styles.copyInto(event.styles); }
From source file:gate.DocumentFormat.java
public synchronized void addStatusListener(StatusListener l) { @SuppressWarnings("unchecked") Vector<StatusListener> v = statusListeners == null ? new Vector<StatusListener>(2) : (Vector<StatusListener>) statusListeners.clone(); if (!v.contains(l)) { v.addElement(l); statusListeners = v;/* ww w . j a va 2 s . co m*/ } }
From source file:org.apache.jk.server.JkMain.java
private void preProcessProperties() { Enumeration keys = props.keys(); Vector v = new Vector(); while (keys.hasMoreElements()) { String key = (String) keys.nextElement(); Object newName = replacements.get(key); if (newName != null) { v.addElement(key); }/* w w w . j a v a 2 s . com*/ } keys = v.elements(); while (keys.hasMoreElements()) { String key = (String) keys.nextElement(); Object propValue = props.getProperty(key); String replacement = (String) replacements.get(key); props.put(replacement, propValue); if (log.isDebugEnabled()) log.debug("Substituting " + key + " " + replacement + " " + propValue); } }