List of usage examples for java.util Vector removeElementAt
public synchronized void removeElementAt(int index)
From source file:com.duroty.utils.mail.MessageUtilities.java
/** * DOCUMENT ME!// ww w . java 2s .co m * * @param dmailParts DOCUMENT ME! * @param contentType DOCUMENT ME! * @param buffer DOCUMENT ME! * * @return DOCUMENT ME! * * @throws MessagingException DOCUMENT ME! */ protected static StringBuffer scanDmailParts(Vector dmailParts, StringBuffer buffer, boolean chooseHtml, String breakLine) throws MessagingException { if ((buffer.length() == 0) && (dmailParts != null)) { int size = dmailParts.size(); int j = 0; for (int i = 0; i < size; i++) { //message/rfc822 MailPart dmailPart = (MailPart) dmailParts.get(j); //ContentType xctype = MessageUtilities.getContentType(dmailPart.getContentType()); ContentType xctype = MessageUtilities.getContentType(dmailPart.getPart()); if (xctype.match("text/plain") && !chooseHtml) { String xjcharset = xctype.getParameter("charset"); if (xjcharset == null) { // not present, assume ASCII character encoding try { Header xheader; Enumeration xe = dmailPart.getPart().getAllHeaders(); for (; xe.hasMoreElements();) { xheader = (Header) xe.nextElement(); String aux = xheader.getName().toLowerCase().trim(); if (aux.indexOf("subject") > -1) { int pos1 = aux.indexOf("=?"); int pos2 = aux.indexOf("?q?"); if ((pos1 > -1) && (pos2 > -1)) { xjcharset = aux.substring(pos1, pos2); } break; } } } catch (Exception ex) { } if (xjcharset == null) { xjcharset = Charset.defaultCharset().displayName(); // US-ASCII in JAVA terms } } //String str = JavaScriptFilter.apply(buff.toString()); xjcharset = MimeUtility.javaCharset(xjcharset); MessageUtilities.decodeTextPlain(buffer, dmailPart.getPart(), breakLine, xjcharset); dmailParts.removeElementAt(j); break; } else if (xctype.match("text/html") && chooseHtml) { String xjcharset = xctype.getParameter("charset"); if (xjcharset == null) { // not present, assume ASCII character encoding try { Header xheader; Enumeration xe = dmailPart.getPart().getAllHeaders(); for (; xe.hasMoreElements();) { xheader = (Header) xe.nextElement(); String aux = xheader.getName().toLowerCase().trim(); if (aux.indexOf("subject") > -1) { int pos1 = aux.indexOf("=?"); int pos2 = aux.indexOf("?q?"); if ((pos1 > -1) && (pos2 > -1)) { xjcharset = aux.substring(pos1, pos2); } break; } } } catch (Exception ex) { } if (xjcharset == null) { xjcharset = Charset.defaultCharset().displayName(); // US-ASCII in JAVA terms } } xjcharset = MimeUtility.javaCharset(xjcharset); MessageUtilities.decodeTextHtml(buffer, dmailPart.getPart(), xjcharset); dmailParts.removeElementAt(j); break; } else { j++; } } } return buffer; }
From source file:com.netscape.cms.logging.LogFile.java
/** * Read all entries whose logLevel>=lowLevel && log source = source * to at most maxLine entries(from end)// w w w . ja va 2 s .c o m * If the parameter is -1, it's ignored and return all entries * * @param maxLine The maximum lines to be returned * @param lowLevel The lowest log level to be returned * @param source The particular log source to be returned * @param fName The log file name to be read. If it's null, read the current * log file */ public Vector<LogEntry> readEntry(int maxLine, int lowLevel, LogSource source, String fName) { Vector<LogEntry> mEntries = new Vector<LogEntry>(); String fileName = mFileName; BufferedReader fBuffer; int lineNo = 0; // lineNo of the current entry in the log file int line = 0; // line of readed valid entries String firstLine = null; // line buffer String nextLine = null; String entry = null; LogEntry logEntry = null; /* this variable is added to accormodate misplaced multiline entries write out buffered log entry when next entry is parsed successfully this implementation is assuming parsing is more time consuming than condition check */ LogEntry preLogEntry = null; if (fName != null) { fileName = fName; } try { //XXX think about this fBuffer = new BufferedReader(new FileReader(fileName)); do { try { nextLine = fBuffer.readLine(); if (nextLine != null) { if ((nextLine.length() == 0) || (nextLine.charAt(0) == ' ')) { // It's a continuous line entry = null; if (nextLine.length() > 1) firstLine = firstLine + "\n" + nextLine.substring(1); else firstLine = firstLine + "\n"; } else { // It's a new entry entry = firstLine; firstLine = nextLine; } // parse the previous entry, the current one is buffered if (entry != null) { try { logEntry = new LogEntry(entry); // if parse succeed, write out previous entry if (preLogEntry != null) { if ((Integer.parseInt(preLogEntry.getLevel()) >= lowLevel) && ((Integer.parseInt(preLogEntry.getSource()) == source.value()) || (source == ILogger.S_ALL))) { mEntries.addElement(preLogEntry); if (maxLine == -1) { line++; } else if (line < maxLine) { line++; } else { mEntries.removeElementAt(0); } } } preLogEntry = logEntry; } catch (ParseException e) { if (preLogEntry != null) { preLogEntry.appendDetail(entry); } else { firstLine = firstLine + "\n" + nextLine; } entry = null; logEntry = null; } } } lineNo++; } catch (IOException e) { CMS.getLogger().log(ILogger.EV_SYSTEM, ILogger.S_OTHER, ILogger.LL_FAILURE, CMS.getLogMessage("LOGGING_READ_ERROR", fileName, Integer.toString(lineNo))); } } while (nextLine != null); // need to process the last 2 entries of the file if (firstLine != null) { if (logEntry != null) { preLogEntry = logEntry; } entry = firstLine; try { logEntry = new LogEntry(entry); /* System.out.println( Integer.toString(Integer.parseInt(logEntry.getLevel())) +","+Integer.toString(lowLevel)+","+ Integer.toString(Integer.parseInt(logEntry.getSource())) +","+Integer.toString(source) ); */ if (preLogEntry != null) { if ((Integer.parseInt(preLogEntry.getLevel()) >= lowLevel) && ((Integer.parseInt(preLogEntry.getSource()) == source.value()) || (source == ILogger.S_ALL))) { mEntries.addElement(preLogEntry); if (maxLine == -1) { line++; } else if (line < maxLine) { line++; } else { mEntries.removeElementAt(0); } } } preLogEntry = logEntry; } catch (ParseException e) { preLogEntry.appendDetail(entry); } if (preLogEntry != null) { if ((Integer.parseInt(preLogEntry.getLevel()) >= lowLevel) && ((Integer.parseInt(preLogEntry.getSource()) == source.value()) || (source == ILogger.S_ALL))) { // parse the entry, pass to UI mEntries.addElement(preLogEntry); if (maxLine == -1) { line++; } else if (line < maxLine) { line++; } else { mEntries.removeElementAt(0); } } } } // end: last entry try { fBuffer.close(); } catch (IOException e) { CMS.getLogger().log(ILogger.EV_SYSTEM, ILogger.S_OTHER, ILogger.LL_FAILURE, "logging:" + fileName + " failed to close for reading"); } } catch (FileNotFoundException e) { CMS.getLogger().log(ILogger.EV_SYSTEM, ILogger.S_OTHER, ILogger.LL_FAILURE, CMS.getLogMessage("LOGGING_FILE_NOT_FOUND", fileName)); } return mEntries; }
From source file:org.apache.axis.wsdl.toJava.JavaGeneratorFactory.java
/** * Messages, PortTypes, Bindings, and Services can share the same name. If they do in this * Definition, force their names to be suffixed with _PortType and _Service, respectively. * * @param symbolTable/*w ww .ja v a2 s . c om*/ */ protected void resolveNameClashes(SymbolTable symbolTable) { // Keep a list of anonymous types so we don't try to resolve them twice. HashSet anonTypes = new HashSet(); List collisionCandidates = new ArrayList(); // List of vector of SymbolTable entry List localParts = new ArrayList(); // all localparts in all symboltable entries for (Iterator i = symbolTable.getHashMap().keySet().iterator(); i.hasNext();) { QName qName = (QName) i.next(); String localPart = qName.getLocalPart(); if (!localParts.contains(localPart)) localParts.add(localPart); } Map pkg2NamespacesMap = emitter.getNamespaces().getPkg2NamespacesMap(); for (Iterator i = pkg2NamespacesMap.values().iterator(); i.hasNext();) { Vector namespaces = (Vector) i.next(); // namepaces mapped to same package // Combine entry vectors, which have the same entry name, into a new entry vector. for (int j = 0; j < localParts.size(); j++) { Vector v = new Vector(); for (int k = 0; k < namespaces.size(); k++) { QName qName = new QName((String) namespaces.get(k), (String) localParts.get(j)); if (symbolTable.getHashMap().get(qName) != null) { v.addAll((Vector) symbolTable.getHashMap().get(qName)); } } if (v.size() > 0) { collisionCandidates.add(v); } } } Iterator it = collisionCandidates.iterator(); while (it.hasNext()) { Vector v = new Vector((Vector) it.next()); // New vector we can temporarily add to it // Remove MessageEntries since they are not mapped int index = 0; while (index < v.size()) { if (v.elementAt(index) instanceof MessageEntry) { // Need to resolve a Exception message. MessageEntry msgEntry = (MessageEntry) v.elementAt(index); if (msgEntry.getDynamicVar(EXCEPTION_CLASS_NAME) == null) { v.removeElementAt(index); } else { index++; } } else { index++; } } if (v.size() > 1) { boolean resolve = true; // Common Special Case: // If a Type and Element have the same QName, and the Element // references the Type, then they are the same class so // don't bother mangling. if (v.size() == 2 && ((v.elementAt(0) instanceof Element && v.elementAt(1) instanceof Type) || (v.elementAt(1) instanceof Element && v.elementAt(0) instanceof Type))) { Element e; if (v.elementAt(0) instanceof Element) { e = (Element) v.elementAt(0); } else { e = (Element) v.elementAt(1); } BooleanHolder forElement = new BooleanHolder(); QName eType = Utils.getTypeQName(e.getNode(), forElement, false); if ((eType != null) && !forElement.value) { resolve = false; } } // Other Special Case: // If the names are already different, no mangling is needed. if (resolve) { resolve = false; // Assume false String name = null; for (int i = 0; (i < v.size()) && !resolve; ++i) { SymTabEntry entry = (SymTabEntry) v.elementAt(i); if ((entry instanceof MessageEntry) || (entry instanceof BindingEntry)) { // Need to resolve a exception class name String exceptionClassName = (String) entry.getDynamicVar(EXCEPTION_CLASS_NAME); if (exceptionClassName != null) { if (name == null) { name = exceptionClassName; } else if (name.equals(exceptionClassName)) { resolve = true; } } } else if (name == null) { name = entry.getName(); } else if (name.equals(entry.getName())) { resolve = true; // Need to do resolution } } } // Full Mangle if resolution is necessary. if (resolve) { boolean firstType = true; for (int i = 0; i < v.size(); ++i) { SymTabEntry entry = (SymTabEntry) v.elementAt(i); if (entry instanceof Element) { entry.setName(mangleName(entry.getName(), ELEMENT_SUFFIX)); // If this global element was defined using // an anonymous type, then need to change the // java name of the anonymous type to match. QName anonQName = new QName(entry.getQName().getNamespaceURI(), SymbolTable.ANON_TOKEN + entry.getQName().getLocalPart()); TypeEntry anonType = symbolTable.getType(anonQName); if (anonType != null) { anonType.setName(entry.getName()); anonTypes.add(anonType); } } else if (entry instanceof TypeEntry) { // Search all other types for java names that match this one. // The sameJavaClass method returns true if the java names are // the same (ignores [] ). if (firstType) { firstType = false; Iterator types = symbolTable.getTypeIndex().values().iterator(); while (types.hasNext()) { TypeEntry type = (TypeEntry) types.next(); if ((type != entry) && (type.getBaseType() == null) && sameJavaClass(entry.getName(), type.getName())) { v.add(type); } } } // If this is an anonymous type, it's name was resolved in // the previous if block. Don't reresolve it. if (!anonTypes.contains(entry)) { // In case that other entry in name collision among // PortTypeEntry, ServiceEntry and BindingEntry boolean needResolve = false; // check collision of TypeEntry with PortTypeEntry, ServiceEtnry and/or BindingEntry for (int j = 0; j < v.size(); j++) { SymTabEntry e = (SymTabEntry) v.elementAt(j); if ((e instanceof PortTypeEntry || e instanceof ServiceEntry || e instanceof BindingEntry)) { needResolve = true; break; } } if (!needResolve) { continue; } // Appended Suffix for avoiding name collisions (JAX-RPC 1.1) Boolean isComplexTypeFault = (Boolean) entry.getDynamicVar(COMPLEX_TYPE_FAULT); if ((isComplexTypeFault != null) && isComplexTypeFault.booleanValue()) { entry.setName(mangleName(entry.getName(), EXCEPTION_SUFFIX)); } else { entry.setName(mangleName(entry.getName(), TYPE_SUFFIX)); } // should update the class name of ElementEntry which references this type entry Map elementIndex = symbolTable.getElementIndex(); List elements = new ArrayList(elementIndex.values()); for (int j = 0; j < elementIndex.size(); j++) { TypeEntry te = (TypeEntry) elements.get(j); TypeEntry ref = te.getRefType(); if (ref != null && entry.getQName().equals(ref.getQName())) { te.setName(entry.getName()); } } // Need to resolve a complex-type exception message. if ((isComplexTypeFault != null) && isComplexTypeFault.booleanValue()) { // SHOULD update the exception class name of a referencing message entry. List messageEntries = symbolTable.getMessageEntries(); for (int j = 0; j < messageEntries.size(); j++) { MessageEntry messageEntry = (MessageEntry) messageEntries.get(j); Boolean isComplexTypeFaultMsg = (Boolean) messageEntry .getDynamicVar(COMPLEX_TYPE_FAULT); if ((isComplexTypeFaultMsg != null) && (isComplexTypeFaultMsg.booleanValue())) { QName exceptionDataType = (QName) messageEntry .getDynamicVar(EXCEPTION_DATA_TYPE); if (((TypeEntry) entry).getQName().equals(exceptionDataType)) { String className = (String) messageEntry .getDynamicVar(EXCEPTION_CLASS_NAME); messageEntry.setDynamicVar(EXCEPTION_CLASS_NAME, className + EXCEPTION_SUFFIX); } } } } } } else if (entry instanceof PortTypeEntry) { entry.setName(mangleName(entry.getName(), PORT_TYPE_SUFFIX)); // "_Port" --> "_PortType" for JAX-RPC 1.1 } else if (entry instanceof ServiceEntry) { entry.setName(mangleName(entry.getName(), SERVICE_SUFFIX)); } else if (entry instanceof MessageEntry) { Boolean complexTypeFault = (Boolean) entry.getDynamicVar(COMPLEX_TYPE_FAULT); if ((complexTypeFault == null) || !complexTypeFault.booleanValue()) { String exceptionClassName = (String) entry.getDynamicVar(EXCEPTION_CLASS_NAME); entry.setDynamicVar(EXCEPTION_CLASS_NAME, exceptionClassName + EXCEPTION_SUFFIX); } } // else if (entry instanceof MessageEntry) { // we don't care about messages // } else if (entry instanceof BindingEntry) { BindingEntry bEntry = (BindingEntry) entry; // If there is no literal use, then we never see a // class named directly from the binding name. They // all have suffixes: Stub, Skeleton, Impl. // If there IS literal use, then the SDI will be // named after the binding name, so there is the // possibility of a name clash. if (bEntry.hasLiteral()) { entry.setName(mangleName(entry.getName(), BINDING_SUFFIX)); } } } } } } }
From source file:org.bench4Q.agent.rbe.EB.java
/** * @param state/*ww w.j a v a2 s .co m*/ * @param url * @return bolean */ public boolean getHTML(int state, String url) { double tolerance = tolerance(curState); html = ""; int statusCode; GetMethod httpget = new GetMethod(url); httpget.getParams().setCookiePolicy(CookiePolicy.IGNORE_COOKIES); if (tolerance != 0) { httpget.getParams().setSoTimeout((int) (tolerance * 1000)); } try { statusCode = HttpClientFactory.getInstance().executeMethod(httpget); if (statusCode != HttpStatus.SC_OK) { EBStats.getEBStats().error(state, "HTTP response ERROR: " + statusCode, url); return false; } BufferedReader bin = new BufferedReader(new InputStreamReader(httpget.getResponseBodyAsStream())); StringBuilder result = new StringBuilder(); String s; while ((s = bin.readLine()) != null) { result.append(s); } html = new String(result); } catch (Exception e) { EBStats.getEBStats().error(state, "get methed ERROR.", url); return false; } finally { // always release the connection after we're done httpget.releaseConnection(); } if (!m_args.isGetImage()) { return true; } Vector<ImageReader> imageRd = new Vector<ImageReader>(0); URL u; try { u = new URL(url); } catch (MalformedURLException e) { EBStats.getEBStats().error(state, "get image ERROR.", url); return false; } findImg(html, u, imgPat, srcPat, quotePat, imageRd); findImg(html, u, inputPat, srcPat, quotePat, imageRd); while (imageRd.size() > 0) { int max = imageRd.size(); int min = Math.max(max - RBEUtil.maxImageRd, 0); int i; try { for (i = min; i < max; i++) { ImageReader rd = (ImageReader) imageRd.elementAt(i); if (!rd.readImage(state)) { imageRd.removeElementAt(i); i--; max--; } } } catch (InterruptedException inte) { EBStats.getEBStats().error(state, "get image ERROR.", url); return true; } } return true; }
From source file:org.fusesource.meshkeeper.distribution.provisioner.embedded.Execute.java
/** * Patch the current environment with the new values from the user. * @return the patched environment./*www . j a va 2 s . co m*/ */ @SuppressWarnings("unchecked") private String[] patchEnvironment() { // On OpenVMS Runtime#exec() doesn't support the environment array, // so we only return the new values which then will be set in // the generated DCL script, inheriting the parent process environment if (Os.isFamily("openvms")) { return env; } Vector<String> osEnv = (Vector<String>) getProcEnvironment().clone(); for (int i = 0; i < env.length; i++) { String keyValue = env[i]; // Get key including "=" String key = keyValue.substring(0, keyValue.indexOf('=') + 1); if (environmentCaseInSensitive) { // Nb: using default locale as key is a env name key = key.toLowerCase(); } int size = osEnv.size(); // Find the key in the current enviroment copy // and remove it. for (int j = 0; j < size; j++) { String osEnvItem = (String) osEnv.elementAt(j); String convertedItem = environmentCaseInSensitive ? osEnvItem.toLowerCase() : osEnvItem; if (convertedItem.startsWith(key)) { osEnv.removeElementAt(j); if (environmentCaseInSensitive) { // Use the original casiness of the key keyValue = osEnvItem.substring(0, key.length()) + keyValue.substring(key.length()); } break; } } // Add the key to the enviromnent copy osEnv.addElement(keyValue); } return (String[]) (osEnv.toArray(new String[osEnv.size()])); }
From source file:org.globus.gsi.ptls.PureTLSUtil.java
/** * Returns the base name of a proxy. Strips all * "cn=proxy" or "cn=limited proxy" components. * * @deprecated Only works with Globus legacy proxies. *///from w w w.j a v a2s. c om public static X509Name getBase(DistinguishedName name) { X509Name nm = dupName(name); Vector dn = nm.getName(); int len = dn.size(); for (int i = len - 1; i >= 0; i--) { Vector rdn = (Vector) dn.elementAt(i); // checks only first ava entry String[] ava = (String[]) rdn.elementAt(0); if (ava[0].equalsIgnoreCase("CN") && (ava[1].equalsIgnoreCase("proxy") || ava[1].equalsIgnoreCase("limited proxy"))) { dn.removeElementAt(i); } else { break; } } return new X509Name(dn); }
From source file:org.hyperic.util.exec.Execute.java
/** * Patch the current environment with the new values from the user. * @return the patched environment/* w ww . j a v a2s . com*/ */ private String[] patchEnvironment() { Vector osEnv = (Vector) getProcEnvironment().clone(); for (int i = 0; i < env.length; i++) { int pos = env[i].indexOf('='); // Get key including "=" String key = env[i].substring(0, pos + 1); int size = osEnv.size(); for (int j = 0; j < size; j++) { if (((String) osEnv.elementAt(j)).startsWith(key)) { osEnv.removeElementAt(j); break; } } osEnv.addElement(env[i]); } String[] result = new String[osEnv.size()]; osEnv.copyInto(result); return result; }
From source file:org.isatools.isacreator.gui.formelements.SubForm.java
protected void removeColumn(int curColDelete) { if ((curColDelete == -1) || (curColDelete == 0)) { return;/*w w w .j a v a2 s .c o m*/ } if (defaultTableModel.getColumnCount() == 2 && curColDelete == (defaultTableModel.getColumnCount() - 1)) { clearColumn(curColDelete); return; } else { clearColumn(curColDelete); } if (fieldType == FieldTypes.ASSAY && (dataEntryForm != null) && !uneditableRecords.contains(curColDelete)) { clearColumn(curColDelete); return; } DefaultTableModel model = (DefaultTableModel) scrollTable.getModel(); // get the column. because 1 was added on previously to take account of the first column, we need to remove // it this time since the column indexes are now coming from the table. TableColumn col = scrollTable.getColumnModel().getColumn(curColDelete - 1); int columnModelIndex = col.getModelIndex(); Vector data = model.getDataVector(); Vector<String> colIds = new Vector<String>(); for (int i = 0; i < model.getColumnCount(); i++) { colIds.addElement(model.getColumnName(i)); } scrollTable.removeColumn(col); colIds.removeElementAt(columnModelIndex); // remove any data present in the column on deletion for (Object aData : data) { Vector row = (Vector) aData; row.removeElementAt(columnModelIndex); } model.setDataVector(data, colIds); // decrease each column index after deleted column by 1 so that indexes can be kept intact. Enumeration columnEnumeration = scrollTable.getColumnModel().getColumns(); while (columnEnumeration.hasMoreElements()) { TableColumn c = (TableColumn) columnEnumeration.nextElement(); if (c.getModelIndex() >= columnModelIndex) { c.setModelIndex(c.getModelIndex() - 1); } } if (fieldType == FieldTypes.ASSAY && uneditableRecords.contains(defaultTableModel.getColumnCount() - 1)) { uneditableRecords.remove(defaultTableModel.getColumnCount() - 1); } // update the model model.fireTableStructureChanged(); updateTables(); }
From source file:org.isatools.isacreator.spreadsheet.SpreadsheetFunctions.java
/** * Remove a column from the spreadsheet.getTable(), delete all the data associated with the column in the model, and keep indices * intact by decreasing the index of every column after the one deleted by one to stop fragmentation. * * @param model - @see SpreadsheetModel to be acted on * @param columnToRemove - @see TableColumn representing column to remove. *///from w w w .jav a2 s.com private void deleteColumn(SpreadsheetModel model, TableColumn columnToRemove) { int columnModelIndex = columnToRemove.getModelIndex(); Vector data = model.getDataVector(); Vector colIds = model.getColumnIdentifiers(); spreadsheet.getTable().removeColumn(columnToRemove); colIds.removeElementAt(columnModelIndex); // remove any data present in the column on deletion for (Object aData : data) { Vector row = (Vector) aData; row.removeElementAt(columnModelIndex); } model.setDataVector(data, colIds); // decrease each column index after deleted column by 1 so that indexes can be kept intact. Enumeration spreadsheetColumns = spreadsheet.getTable().getColumnModel().getColumns(); while (spreadsheetColumns.hasMoreElements()) { TableColumn c = (TableColumn) spreadsheetColumns.nextElement(); if (c.getModelIndex() >= columnModelIndex) { c.setModelIndex(c.getModelIndex() - 1); } } // update the model model.fireTableStructureChanged(); }
From source file:org.sakaiproject.calendar.tool.CalendarAction.java
protected Vector getNewEvents(int year, int month, int day, CalendarActionState state, RunData rundata, int time, int numberofcycles, Context context, CalendarEventVector CalendarEventVectorObj) { boolean firstTime = true; // Don't need to do complex checking the first time. Vector events = new Vector(); // A vector of vectors, each of the vectors containing a range of previous events. Time timeObj = TimeService.newTimeLocal(year, month, day, time, 00, 00, 000); long duration = ((30 * 60) * (1000)); Time updatedTime = TimeService.newTime(timeObj.getTime() + duration); /*** include the start time ***/ TimeRange timeRangeObj = TimeService.newTimeRange(timeObj, updatedTime, true, false); for (int range = 0; range <= numberofcycles; range++) { Iterator calEvent = null; calEvent = CalendarEventVectorObj.getEvents(timeRangeObj); Vector vectorObj = new Vector(); // EventDisplay of calevent. EventDisplayClass eventDisplayObj; Vector newVectorObj = null; // Ones we haven't see before? boolean swapflag = true; EventDisplayClass eventdisplayobj = null; if (calEvent.hasNext()) // While we still have more events in this range. {//from w ww.ja va2s . c o m int i = 0; // Size of vectorObj while (calEvent.hasNext()) { eventdisplayobj = new EventDisplayClass(); eventdisplayobj.setEvent((CalendarEvent) calEvent.next(), false, i); vectorObj.add(i, eventdisplayobj); // Copy into vector, wrapping in EventDisplay i++; } // while if (firstTime) // First range { events.add(range, vectorObj); firstTime = false; } else { while (swapflag == true) { swapflag = false; for (int mm = 0; mm < events.size(); mm++) // Loop through all the previous ranges. { // Vector evectorObj = (Vector) events.elementAt(mm); // One vector range. if (!evectorObj.isEmpty()) { for (int eom = 0; eom < evectorObj.size(); eom++) // loop through previous range. { if (!"".equals(evectorObj.elementAt(eom))) { // Event ID. String eomId = (((EventDisplayClass) evectorObj.elementAt(eom)).getEvent()) .getId(); newVectorObj = new Vector(); for (int mv = 0; mv < vectorObj.size(); mv++) // Loop back through the current range. { if (!"".equals(vectorObj.elementAt(mv))) { String vectorId = (((EventDisplayClass) vectorObj.elementAt(mv)) .getEvent()).getId(); if (vectorId.equals(eomId)) // Exists in a previous range. { eventDisplayObj = (EventDisplayClass) vectorObj.elementAt(mv); eventDisplayObj.setFlag(true); if (mv != eom) // index of current range, { swapflag = true; vectorObj.removeElementAt(mv); for (int x = 0; x < eom; x++) { if (!vectorObj.isEmpty()) { newVectorObj.add(x, vectorObj.elementAt(0)); // Copy data into new array. vectorObj.removeElementAt(0); } else { newVectorObj.add(x, ""); } } // for newVectorObj.add(eom, eventDisplayObj); // Add the one that's out of position. int neweom = eom; neweom = neweom + 1; while (vectorObj.isEmpty() == false) { newVectorObj.add(neweom, vectorObj.elementAt(0)); vectorObj.removeElementAt(0); neweom++; } for (int vv = 0; vv < newVectorObj.size(); vv++) { vectorObj.add(vv, newVectorObj.elementAt(vv)); } } // if } // if } // if } //for } // if } // for } // if } // for } // while events.add(range, vectorObj); } // if - else firstTime timeRangeObj.shiftForward(1800000); } else { events.add(range, vectorObj); timeRangeObj.shiftForward(1800000); } } // for return events; }