List of usage examples for java.util Vector elements
public Enumeration<E> elements()
From source file:com.netscape.cmscore.usrgrp.UGSubsystem.java
protected Enumeration<IUser> lbuildUsers(LDAPSearchResults res) throws EUsrGrpException { Vector<IUser> v = new Vector<IUser>(); while (res.hasMoreElements()) { LDAPEntry entry = (LDAPEntry) res.nextElement(); IUser user = lbuildUser(entry);//from w w w .ja v a 2 s. com v.addElement(user); } return v.elements(); }
From source file:org.apache.axis.message.MessageElement.java
protected MessageElement findElement(Vector vec, String namespace, String localPart) { if (vec.isEmpty()) { return null; }/*w ww . ja va 2 s .c om*/ QName qname = new QName(namespace, localPart); Enumeration e = vec.elements(); MessageElement element; while (e.hasMoreElements()) { element = (MessageElement) e.nextElement(); if (element.getQName().equals(qname)) { return element; } } return null; }
From source file:maui.main.MauiModelBuilder.java
/** * Returns an enumeration describing the available options. * * @return an enumeration of all the available options *//*from ww w .j a v a 2 s . com*/ public Enumeration<Option> listOptions() { Vector<Option> newVector = new Vector<Option>(12); newVector.addElement(new Option("\tSpecifies name of directory.", "l", 1, "-l <directory name>")); newVector.addElement(new Option("\tSpecifies name of model.", "m", 1, "-m <model name>")); newVector.addElement(new Option("\tSpecifies vocabulary name.", "v", 1, "-v <vocabulary name>")); newVector.addElement(new Option("\tSpecifies vocabulary format (text or skos or none).", "f", 1, "-f <vocabulary format>")); newVector.addElement(new Option("\tSpecifies document language (en (default), es, de, fr).", "i", 1, "-i <document language>")); newVector.addElement(new Option("\tSpecifies encoding.", "e", 1, "-e <encoding>")); newVector.addElement(new Option("\tSpecifies wikipedia database and server.", "w", 1, "-w <wikipediaDatabase@wikipediaServer>")); newVector.addElement(new Option("\tTurns debugging mode on.", "d", 0, "-d")); newVector.addElement(new Option("\tSets the maximum phrase length (default: 5).", "x", 1, "-x <length>")); newVector.addElement(new Option("\tSets the minimum phrase length (default: 1).", "y", 1, "-y <length>")); newVector.addElement(new Option("\tSet the minimum number of occurences (default: 2).", "o", 1, "-o")); newVector.addElement(new Option("\tSets the list of stopwords to use (default: StopwordsEnglish).", "s", 1, "-s <name of stopwords class>")); newVector.addElement(new Option("\tSet the stemmer to use (default: SremovalStemmer).", "t", 1, "-t <name of stemmer class>")); return newVector.elements(); }
From source file:org.unitime.timetable.model.Solution.java
public void createDivSecNumbers(org.hibernate.Session hibSession, Vector messages) { Vector assignments = new Vector(getAssignments()); assignments.addAll(new SolutionDAO().getSession() .createQuery("select distinct c from Class_ c, Solution s inner join s.owner.departments d " + "where s.uniqueId = :solutionId and c.managingDept=d and " + "c.uniqueId not in (select a.clazz.uniqueId from s.assignments a)") .setLong("solutionId", getUniqueId().longValue()).list()); HashSet relatedOfferings = new HashSet(); for (Enumeration e = assignments.elements(); e.hasMoreElements();) { Object o = e.nextElement(); Assignment assignment = (o instanceof Assignment ? (Assignment) o : null); Class_ clazz = (assignment == null ? (Class_) o : assignment.getClazz()); relatedOfferings.add(clazz.getSchedulingSubpart().getInstrOfferingConfig().getInstructionalOffering()); }/*from ww w . j a v a 2 s . c o m*/ for (Iterator i = relatedOfferings.iterator(); i.hasNext();) { InstructionalOffering io = (InstructionalOffering) i.next(); for (Iterator j = io.getInstrOfferingConfigs().iterator(); j.hasNext();) { InstrOfferingConfig ioc = (InstrOfferingConfig) j.next(); for (Iterator k = ioc.getSchedulingSubparts().iterator(); k.hasNext();) { SchedulingSubpart subpart = (SchedulingSubpart) k.next(); for (Iterator l = subpart.getClasses().iterator(); l.hasNext();) { Class_ clazz = (Class_) l.next(); if (clazz.getClassSuffix() != null && !getOwner().getDepartments().contains(clazz.getManagingDept())) { Assignment assignment = clazz.getCommittedAssignment(); assignments.add(assignment == null ? (Object) clazz : (Object) assignment); clazz.setClassSuffix(null); } } } } } DivSecAssignmentComparator cmp = new DivSecAssignmentComparator(this, true, false); Collections.sort(assignments, cmp); Assignment lastAssignment = null; SchedulingSubpart lastSubpart = null; Class_ lastClazz = null; int divNum = 1, secNum = 0; HashSet takenDivNums = null; HashSet recompute = new HashSet(); for (Enumeration e = assignments.elements(); e.hasMoreElements();) { Object o = e.nextElement(); Assignment assignment = (o instanceof Assignment ? (Assignment) o : null); Class_ clazz = (assignment == null ? (Class_) o : assignment.getClazz()); if (clazz.getParentClass() != null && clazz.getSchedulingSubpart().getItype() .equals(clazz.getParentClass().getSchedulingSubpart().getItype())) continue; if (lastSubpart == null || !lastSubpart.equals(clazz.getSchedulingSubpart())) { takenDivNums = takenDivisionNumbers(clazz.getSchedulingSubpart()); lastAssignment = null; lastSubpart = null; lastClazz = null; } int nrClasses = clazz.getSchedulingSubpart().getInstrOfferingConfig().getInstructionalOffering() .getNrClasses(clazz.getSchedulingSubpart().getItype()); if (lastAssignment != null && assignment != null) { if (nrClasses >= 100 && cmp.compareTimeLocations(lastAssignment.getClazz(), assignment.getClazz(), lastAssignment.getTimeLocation(), assignment.getTimeLocation()) == 0) { if (lastClazz != null && clazz.getParentClass() != null && !clazz.getParentClass().equals(lastClazz.getParentClass()) && clazz.getParentClass().getDivSecNumber() != null && lastClazz.getParentClass().getDivSecNumber() != null) { if (cmp.compareTimeLocations(lastAssignment.getClazz(), assignment.getClazz(), lastAssignment.getTimeLocation(), assignment.getTimeLocation()) == 0 && clazz.getParentClass().getDivSecNumber().substring(0, 3) .equals(lastClazz.getParentClass().getDivSecNumber().substring(0, 3))) { secNum++; } else { divNum++; secNum = 1; while (takenDivNums.contains(new Integer(divNum))) divNum++; } } else { secNum++; } } else { divNum++; secNum = 1; while (takenDivNums.contains(new Integer(divNum))) divNum++; } } else if (lastClazz != null) { divNum++; secNum = 1; while (takenDivNums.contains(new Integer(divNum))) divNum++; } else { divNum = 1; secNum = 1; while (takenDivNums.contains(new Integer(divNum))) divNum++; } if (divNum == 100 && secNum == 1) { sLog.warn("Division number exceeded 99 for scheduling subpart " + clazz.getSchedulingSubpart().getSchedulingSubpartLabel() + "."); for (Iterator i = clazz.getSchedulingSubpart().getInstrOfferingConfig().getInstructionalOffering() .getInstrOfferingConfigs().iterator(); i.hasNext();) { InstrOfferingConfig cfg = (InstrOfferingConfig) i.next(); for (Iterator j = cfg.getSchedulingSubparts().iterator(); j.hasNext();) { SchedulingSubpart subpart = (SchedulingSubpart) j.next(); if (subpart.getItype().equals(clazz.getSchedulingSubpart().getItype())) recompute.add(subpart); } } } clazz.setClassSuffix(sSufixFormat.format(divNum) + sSufixFormat.format(secNum)); hibSession.update(clazz); lastAssignment = assignment; lastSubpart = clazz.getSchedulingSubpart(); lastClazz = clazz; } if (!recompute.isEmpty()) { HashSet recompute2 = new HashSet(); for (Iterator i = assignments.iterator(); i.hasNext();) { Object o = i.next(); Assignment assignment = (o instanceof Assignment ? (Assignment) o : null); Class_ clazz = (assignment == null ? (Class_) o : assignment.getClazz()); if (recompute.contains(clazz.getSchedulingSubpart())) { clazz.setClassSuffix(null); hibSession.update(clazz); } else { i.remove(); } } cmp = new DivSecAssignmentComparator(this, false, false); Collections.sort(assignments, cmp); lastAssignment = null; lastSubpart = null; lastClazz = null; for (Enumeration e = assignments.elements(); e.hasMoreElements();) { Object o = e.nextElement(); Assignment assignment = (o instanceof Assignment ? (Assignment) o : null); Class_ clazz = (assignment == null ? (Class_) o : assignment.getClazz()); if (lastSubpart == null || !lastSubpart.equals(clazz.getSchedulingSubpart())) { takenDivNums = takenDivisionNumbers(clazz.getSchedulingSubpart()); lastAssignment = null; lastSubpart = null; lastClazz = null; } if (lastAssignment != null && assignment != null) { if (cmp.compareTimeLocations(lastAssignment.getClazz(), assignment.getClazz(), lastAssignment.getTimeLocation(), assignment.getTimeLocation()) == 0) { secNum++; } else { divNum++; secNum = 1; while (takenDivNums.contains(new Integer(divNum))) divNum++; } } else if (lastClazz != null) { divNum++; secNum = 1; while (takenDivNums.contains(new Integer(divNum))) divNum++; } else { divNum = 1; secNum = 1; while (takenDivNums.contains(new Integer(divNum))) divNum++; } if (divNum == 100 && secNum == 1) { sLog.warn("Division number still (fallback) exceeded 99 for scheduling subpart " + clazz.getSchedulingSubpart().getSchedulingSubpartLabel() + "."); for (Iterator i = clazz.getSchedulingSubpart().getInstrOfferingConfig() .getInstructionalOffering().getInstrOfferingConfigs().iterator(); i.hasNext();) { InstrOfferingConfig cfg = (InstrOfferingConfig) i.next(); for (Iterator j = cfg.getSchedulingSubparts().iterator(); j.hasNext();) { SchedulingSubpart subpart = (SchedulingSubpart) j.next(); if (subpart.getItype().equals(clazz.getSchedulingSubpart().getItype())) recompute2.add(subpart); } } } clazz.setClassSuffix(sSufixFormat.format(divNum) + sSufixFormat.format(secNum)); hibSession.update(clazz); lastAssignment = assignment; lastSubpart = clazz.getSchedulingSubpart(); lastClazz = clazz; } if (!recompute2.isEmpty()) { for (Iterator i = assignments.iterator(); i.hasNext();) { Object o = i.next(); Assignment assignment = (o instanceof Assignment ? (Assignment) o : null); Class_ clazz = (assignment == null ? (Class_) o : assignment.getClazz()); if (recompute2.contains(clazz.getSchedulingSubpart())) { clazz.setClassSuffix(null); hibSession.update(clazz); } else { i.remove(); } } cmp = new DivSecAssignmentComparator(this, false, true); Collections.sort(assignments, cmp); lastAssignment = null; lastSubpart = null; lastClazz = null; for (Enumeration e = assignments.elements(); e.hasMoreElements();) { Object o = e.nextElement(); Assignment assignment = (o instanceof Assignment ? (Assignment) o : null); Class_ clazz = (assignment == null ? (Class_) o : assignment.getClazz()); if (lastSubpart == null || cmp.compareSchedulingSubparts(lastSubpart, clazz.getSchedulingSubpart()) != 0) { takenDivNums = takenDivisionNumbers(clazz.getSchedulingSubpart()); lastAssignment = null; lastSubpart = null; lastClazz = null; } if (lastAssignment != null && assignment != null) { if (cmp.compareTimeLocations(lastAssignment.getClazz(), assignment.getClazz(), lastAssignment.getTimeLocation(), assignment.getTimeLocation()) == 0) { secNum++; } else { divNum++; secNum = 1; while (takenDivNums.contains(new Integer(divNum))) divNum++; } } else if (lastClazz != null) { divNum++; secNum = 1; while (takenDivNums.contains(new Integer(divNum))) divNum++; } else { divNum = 1; secNum = 1; while (takenDivNums.contains(new Integer(divNum))) divNum++; } if (divNum == 100 && secNum == 1) { messages.add("Division number exceeded 99 for scheduling subpart " + clazz.getSchedulingSubpart().getSchedulingSubpartLabel() + "."); sLog.warn("Division number still (fallback2) exceeded 99 for scheduling subpart " + clazz.getSchedulingSubpart().getSchedulingSubpartLabel() + "."); } clazz.setClassSuffix(sSufixFormat.format(divNum) + sSufixFormat.format(secNum)); hibSession.update(clazz); lastAssignment = assignment; lastSubpart = clazz.getSchedulingSubpart(); lastClazz = clazz; } } } /* lastSubpart = null; TreeSet otherClasses = new TreeSet(new ClassComparator(ClassComparator.COMPARE_BY_HIERARCHY)); otherClasses.addAll(new SolutionDAO().getSession().createQuery( "select distinct c from Class_ c, Solution s inner join s.owner.departments d "+ "where s.uniqueId = :solutionId and c.managingDept=d and "+ "c.uniqueId not in (select a.clazz.uniqueId from s.assignments a) order by c.schedulingSubpart.uniqueId, c.sectionNumberCache"). setLong("solutionId", getUniqueId().longValue()). list()); for (Iterator i=otherClasses.iterator();i.hasNext();) { Class_ clazz = (Class_)i.next(); if (clazz.getParentClass()!=null && clazz.getSchedulingSubpart().getItype().equals(clazz.getParentClass().getSchedulingSubpart().getItype())) continue; if (clazz.getClassSuffix()!=null) { sLog.warn("This is odd, class "+clazz.getClassLabel()+" already has a div-sec number "+clazz.getClassSuffix()+"."); continue; } if (lastSubpart==null || !lastSubpart.equals(clazz.getSchedulingSubpart())) { takenDivNums = takenDivisionNumbers(clazz.getSchedulingSubpart()); } divNum = 1; while (takenDivNums.contains(new Integer(divNum))) divNum++; if (divNum==100) { messages.add("Division number exceeded 99 for scheduling subpart "+clazz.getSchedulingSubpart().getSchedulingSubpartLabel()+"."); } clazz.setClassSuffix(sSufixFormat.format(divNum)+sSufixFormat.format(1)); takenDivNums.add(new Integer(divNum)); lastSubpart = clazz.getSchedulingSubpart(); hibSession.update(clazz); } */ }
From source file:org.agnitas.web.MailingAttachmentsAction.java
/** * Saves attachement/*from w w w. ja va 2s . co m*/ */ protected void saveAttachment(MailingAttachmentsForm aForm, HttpServletRequest req) { MailingComponent aComp; String aParam; Vector deleteEm = new Vector(); Mailing aMailing = mailingDao.getMailing(aForm.getMailingID(), this.getCompanyID(req)); FormFile newAttachment = aForm.getNewAttachment(); try { double size = newAttachment.getFileSize(); int attachmentMaxSize = Integer.parseInt(AgnUtils.getDefaultValue("attachment.maxSize")); if (size != 0 && size < attachmentMaxSize) { aComp = new MailingComponentImpl(); aComp.setCompanyID(this.getCompanyID(req)); aComp.setMailingID(aForm.getMailingID()); aComp.setType(MailingComponent.TYPE_ATTACHMENT); aComp.setComponentName(aForm.getNewAttachmentName()); aComp.setBinaryBlock(newAttachment.getFileData()); aComp.setEmmBlock(aComp.makeEMMBlock()); aComp.setMimeType(newAttachment.getContentType()); aComp.setTargetID(aForm.getAttachmentTargetID()); aMailing.addComponent(aComp); } else if (size >= attachmentMaxSize) { errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.attachment", AgnUtils.getDefaultValue("attachment.maxSize"))); } } catch (Exception e) { logger.error("saveAttachment: " + e); } Iterator it = aMailing.getComponents().values().iterator(); while (it.hasNext()) { aComp = (MailingComponent) it.next(); switch (aComp.getType()) { case MailingComponent.TYPE_ATTACHMENT: aParam = req.getParameter("delete" + aComp.getId()); if (!StringUtils.isEmpty(aParam)) { deleteEm.add(aComp); } aParam = req.getParameter("target" + aComp.getId()); if (aParam != null) { aComp.setTargetID(Integer.parseInt(aParam)); } break; } } Enumeration en = deleteEm.elements(); while (en.hasMoreElements()) { aMailing.getComponents().remove(((MailingComponent) en.nextElement()).getComponentName()); } mailingDao.saveMailing(aMailing); }
From source file:com.netscape.cmscore.usrgrp.UGSubsystem.java
protected Enumeration<IUser> buildUsers(LDAPSearchResults res) throws EUsrGrpException { Vector<IUser> v = new Vector<IUser>(); if (res != null) { while (res.hasMoreElements()) { LDAPEntry entry = (LDAPEntry) res.nextElement(); IUser user = buildUser(entry); v.addElement(user);//from w w w. java2 s .c om } } // if v contains nothing, just throw exception if (v.size() == 0) { throw new EUsrGrpException(CMS.getUserMessage("CMS_USRGRP_USER_NOT_FOUND")); } return v.elements(); }
From source file:uk.ac.soton.simulation.jsit.core.ModelVersioningAssistant.java
String calcMD5HashForFileList(List<File> pathsToHash, boolean includeHiddenFiles, File[] fileExclusions, String[] filenameExclusions, boolean printFileNames) { Vector<FileInputStream> fileStreams = new Vector<FileInputStream>(); ArrayList<File> workingFileExcludeList = null; if (printFileNames) { logger.info("Found files for hashing:"); }/*from w w w. j av a 2 s . c o m*/ try { if (fileExclusions != null) { workingFileExcludeList = new ArrayList<File>(fileExclusions.length); for (File f : fileExclusions) { assert f.exists(); workingFileExcludeList.add(f.getAbsoluteFile()); } } for (File currPath : pathsToHash) { assert currPath.exists(); if (currPath.isDirectory()) { collectInputStreams(currPath, fileStreams, workingFileExcludeList, filenameExclusions, includeHiddenFiles, printFileNames); } else if (currPath.isFile()) { if (printFileNames) { logger.info("\t" + currPath.getAbsolutePath()); } if (!fileIsExcluded(includeHiddenFiles, workingFileExcludeList, filenameExclusions, currPath)) { fileStreams.add(new FileInputStream(currPath)); } } else { assert false; // Should never happen! } } SequenceInputStream seqStream = new SequenceInputStream(fileStreams.elements()); String md5Hash = DigestUtils.md5Hex(seqStream); seqStream.close(); return md5Hash; } catch (IOException e) { throw new VersionControlException("Error reading files to hash", e); } }
From source file:mypackage.State_Home.java
private Vector doCategorize(JSONArray subscriptions) throws JSONException { Vector out = new Vector(); // GlobalJeS?[?B out.addElement(new Global("Global")); // ?wtB?[h????AGlobal^?[ if (subscriptions == null) { return out; }/* w ww . j av a 2 s .c o m*/ // ?wtB?[h???AGlobal^?[ if (subscriptions.length() == 0) { return out; } // UncategorizedJeS?[?? String streamid_uncategorized = "user/" + _feedlyclient.getID() + "/category/global.uncategorized"; Category _uncategorized = new Category("Uncategorized", streamid_uncategorized, true); // ?wtB?[hJeS?U for (int i = 0; i < subscriptions.length(); i++) { // tB?[h? JSONObject feed_jsonObject = subscriptions.getJSONObject(i); Feed _feed = new Feed(feed_jsonObject); // tB?[hJeS? JSONArray categorys = feed_jsonObject.getJSONArray("categories"); // JeSw???AUncategorizedJeS?[o^?B if (categorys.length() == 0) { _uncategorized.addFeed(_feed); continue; } // tB?[hJeSw? label: for (int j = 0; j < categorys.length(); j++) { // tB?[hJeS? JSONObject category = categorys.getJSONObject(j); String category_name = category.getString("label"); String stream_id = category.getString("id"); // JeS? for (Enumeration e = out.elements(); e.hasMoreElements();) { // JeS? Category _ctgry = (Category) e.nextElement(); // ?vJeS???A?B if (_ctgry.getCategoryName().equals(category_name)) { _ctgry.addFeed(_feed); break label; } } // ?vJeS???AJeS?VK???B Category _new_category = new Category(category_name, stream_id, true); _new_category.addFeed(_feed); out.addElement(_new_category); } } //for // ?UncategorizedJeS?[?i1?tB?[h???j if (_uncategorized.getNumOfFeeds() != 0) { out.addElement(_uncategorized); } return out; }
From source file:maui.main.MauiTopicExtractor.java
/** * Returns an enumeration describing the available options. * * @return an enumeration of all the available options *//*from ww w. j av a 2s .c om*/ public Enumeration<Option> listOptions() { Vector<Option> newVector = new Vector<Option>(15); newVector.addElement(new Option("\tSpecifies name of directory.", "l", 1, "-l <directory name>")); newVector.addElement(new Option("\tSpecifies name of model.", "m", 1, "-m <model name>")); newVector.addElement(new Option("\tSpecifies vocabulary name.", "v", 1, "-v <vocabulary name>")); newVector.addElement(new Option("\tSpecifies vocabulary format.", "f", 1, "-f <vocabulary format>")); newVector.addElement(new Option("\tSpecifies encoding.", "e", 1, "-e <encoding>")); newVector.addElement(new Option("\tSpecifies wikipedia database and server.", "w", 1, "-w <wikipediaDatabase@wikipediaServer>")); newVector.addElement(new Option("\tSpecifies document language (en (default), es, de, fr).", "i", 1, "-i <document language>")); newVector.addElement(new Option("\tSpecifies number of phrases to be output (default: 5).", "n", 1, "-n")); newVector.addElement(new Option("\tSet the stemmer to use (default: SremovalStemmer).", "t", 1, "-t <name of stemmer class>")); newVector.addElement(new Option("\tSet the stopwords class to use (default: EnglishStopwords).", "s", 1, "-s <name of stopwords class>")); newVector.addElement(new Option("\tTurns debugging mode on.", "d", 0, "-d")); newVector.addElement(new Option( "\tBuilds global dictionaries for computing TFIDF from the test collection.", "b", 0, "-b")); newVector.addElement( new Option("\tPrints graph description into a \".gv\" file, in GraphViz format.", "p", 0, "-p")); newVector.addElement(new Option("\tAlso write stemmed phrase and score into \".key\" file.", "a", 0, "-a")); return newVector.elements(); }