Java Code Examples for java.util.TreeSet#iterator()

The following examples show how to use java.util.TreeSet#iterator() . These examples are extracted from open source projects. 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
private CSVField csvBuildExamPeriod(ExamAssignmentProxy examAssignment, TreeSet exams, boolean isEditable) {
    StringBuffer sb = new StringBuffer();
    for (Iterator i=exams.iterator();i.hasNext();) {
        Exam exam = (Exam)i.next();
        if (examAssignment!=null && examAssignment.getExamTypeId().equals(exam.getExamType().getUniqueId())) {
            ExamAssignment ea = examAssignment.getAssignment(exam.getUniqueId());
            if (ea==null && !isShowExamName()) continue;
            sb.append(ea==null?"":ea.getPeriodAbbreviation());
        } else {
            if (exam.getAssignedPeriod()==null && !isShowExamName()) continue;
            sb.append(exam.getAssignedPeriod()==null?"":exam.getAssignedPeriod().getAbbreviation());
        }
        if (i.hasNext()) sb.append("\n");
    }
    
    CSVField cell = createCell();
    addText(cell, sb.toString(), true);
    return cell;
}
 
Example 2
Source Project: unitime   File: DatePattern.java    License: Apache License 2.0 6 votes vote down vote up
public String getPatternString() {
	
	StringBuffer sb = new StringBuffer();
	boolean first = true;
	HashMap dates = getPatternDateStringHashMaps();
	TreeSet ts = new TreeSet();
	ts.addAll(dates.keySet());
	for(Iterator it = ts.iterator(); it.hasNext();){
		Date startDate = (Date) it.next();
		Date endDate = (Date) dates.get(startDate);
		Formats.Format<Date> df = Formats.getDateFormat(Formats.Pattern.DATE_SHORT);
		String startDateStr = df.format(startDate);
		String endDateStr = df.format(endDate);
		if (first){
			first = false;
		} else {
			sb.append(", ");
		}
		sb.append(startDateStr);
		if (!startDateStr.equals(endDateStr)){
			sb.append("-" + endDateStr);
		}
	}
	return sb.toString();
}
 
Example 3
Source Project: unitime   File: Class_.java    License: Apache License 2.0 6 votes vote down vote up
public String instructorText(String instructorNameFormat, String separator){
	if (getClassInstructors() == null) return "";
	
	TreeSet sortedInstructors = new TreeSet(new InstructorComparator());
	sortedInstructors.addAll(this.getClassInstructors());

	StringBuffer sb = new StringBuffer();
	
	for (Iterator it = sortedInstructors.iterator(); it.hasNext();) {
		ClassInstructor ci = (ClassInstructor) it.next();
		sb.append(ci.getInstructor().getName(instructorNameFormat));
		if (it.hasNext()) sb.append(separator);
	}
	
	return sb.toString();
}
 
Example 4
@Override
public int compareTo(TreeSet<T> other) {
	TreeSet<T> set = other;
	Iterator<T> iterThis = iterator();
	Iterator<T> iterOther = set.iterator();
	
	while (iterThis.hasNext() && iterOther.hasNext()) {
		T first = iterThis.next();
		T second = iterOther.next();
		int cmp = first.compareTo(second);
		if (cmp == 0) {
			continue;
		}
		return cmp;
	}
	if (iterThis.hasNext()) {
		return 1;
	}
	if (iterOther.hasNext()) {
		return -1;
	}
	return 0;
}
 
Example 5
@Override
protected TableCell buildInstructor(PreferenceGroup prefGroup, boolean isEditable){
	TableCell cell = this.initNormalCell("" ,isEditable);
	if (prefGroup instanceof Class_) {
		Class_ aClass = (Class_) prefGroup;
		if (aClass.isDisplayInstructor() && !aClass.getClassInstructors().isEmpty()) {
        	TreeSet sortedInstructors = new TreeSet(new InstructorComparator());
        	sortedInstructors.addAll(aClass.getClassInstructors());
    		for (Iterator i=sortedInstructors.iterator(); i.hasNext();) {
    			ClassInstructor ci = (ClassInstructor)i.next();
        		String label = ci.getInstructor().getName(getInstructorNameFormat());
        		cell.addContent(label + (i.hasNext() ? "<br>" : ""));
    		}
		} else {
			cell.addContent(" &nbsp; ");
		}
        cell.setAlign("left");	
	} else {
		cell.addContent(" &nbsp; ");
	}
    return(cell);    }
 
Example 6
Source Project: Ngram-Graphs   File: FileFormat.java    License: Apache License 2.0 6 votes vote down vote up
public ArrayList getFilesFromCategory(String sCategoryName) {
    ArrayList alRes = new ArrayList();
    String sCurName = sCategoryName;
    String sCurFileName;

    Iterator<TreeSet> iClusters=((LinkedList)clusters.get(sCurName)).iterator();
    while (iClusters.hasNext()) {
        TreeSet tsCur = iClusters.next();

        Iterator<String> iFileNames = tsCur.iterator(); 
        while (iFileNames.hasNext()) {

            StringBuffer sb = new StringBuffer();
            sb.append(baseDir);
            sb.append(System.getProperty("file.separator"));
            sCurFileName = iFileNames.next();
            sb.append(sCurFileName.split("[.]")[1] + System.getProperty("file.separator"));
            sb.append(sCurFileName);
            CategorizedFileEntry cfeCur = new CategorizedFileEntry(sb.toString(),
                    sCurName);
            alRes.add(cfeCur);
        }
    }
    
    return alRes;
}
 
Example 7
Source Project: epcis   File: TraceabilityQueryService.java    License: Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unused")
public String getQuantity(String traceEPC, String traceTarget, String startTime, String endTime, Long fromTimeMil,
		Long toTimeMil, String orderDirection) {

	Document doc = createBaseQueryResults(traceEPC, traceTarget, startTime, endTime, orderDirection);

	// Time processing
	long startTimeMil = 0;
	startTimeMil = TimeUtil.getTimeMil(startTime);

	ChronoGraph g = Configuration.persistentGraph;

	ChronoVertex v = g.getChronoVertex(traceEPC);
	TreeSet<Long> timestamps = v.getTimestamps();

	Iterator<Long> ti = timestamps.iterator();
	Element quantityTrace = doc.createElement("quantityTrace");
	while (ti.hasNext()) {
		Long t = ti.next();
		VertexEvent ve = v.setTimestamp(t);
		Object qObj = ve.getProperty("quantity");
		Object uObj = ve.getProperty("uom");
		Double quantityDouble = null;
		if (qObj != null)
			quantityDouble = ((BsonDouble) qObj).doubleValue();

		String uomString = null;
		if (uObj != null)
			uomString = ((BsonString) uObj).getValue();

		if (quantityDouble != null || uomString != null) {
			Element quantity = doc.createElement("quantity");
			quantity.setTextContent(quantityDouble.toString());
			Element uom = doc.createElement("uom");
			uom.setTextContent(uomString);
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
			Element eventTime = doc.createElement("eventTime");
			Date date = new Date(t);
			String dateString = sdf.format(date);
			eventTime.setTextContent(dateString);
			Element quantityElement = doc.createElement("quantityElement");
			quantityElement.appendChild(eventTime);
			quantityElement.appendChild(quantity);
			quantityElement.appendChild(uom);
			quantityTrace.appendChild(quantityElement);
		}
	}

	Element resultsBody = doc.createElement("resultsBody");
	resultsBody.appendChild(quantityTrace);
	doc.getFirstChild().appendChild(resultsBody);

	return toString(doc);

}
 
Example 8
/**
 * Assígn the values Attributes of a Record to the existing SIMILAR (equal name) Attributes of current Record
 * @param rec Record containing values to assign
 * @return true always
 * @throws PDException In any error
 */
protected boolean assignSimil(Record rec) throws PDException
{
Attribute AttrOrig;
Attribute AttrDest;
rec.initList();
for (int i = 0; i < rec.NumAttr(); i++)
    {
    AttrOrig=rec.nextAttr();
    AttrDest=getAttr(AttrOrig.getName());
    if (AttrDest!=null)
        {
        if (AttrDest.isMultivalued())
            {
            if (AttrDest!=AttrOrig) // to avoid problems when using the same record
                {
                AttrDest.ClearValues();
                TreeSet V=AttrOrig.getValuesList();    
                for (Iterator it = V.iterator(); it.hasNext();)
                    {
                    AttrDest.AddValue(it.next());                    
                    }
                }
            }
        else
            AttrDest.setValue(AttrOrig.getValue());
        }
    }
return(true);
}
 
Example 9
Source Project: tddl5   File: UnitGroupSequenceDao.java    License: Apache License 2.0 5 votes vote down vote up
public int getUnitindex() throws SequenceException {
    // not unit
    Set<String> units = RouterUnitsHelper.getUnits();
    TreeSet<String> orderUnits = new TreeSet<String>();
    orderUnits.addAll(units);
    if (orderUnits == null || orderUnits.size() == 0) {
        return -1;
    }

    // not unit
    String currentUnit = RouterUnitsHelper.getCurrentUnit();
    if (currentUnit == null) {
        return -1;
    }

    Iterator<String> i = orderUnits.iterator();
    int index = 0;
    while (i.hasNext()) {
        if (i.next().equals(currentUnit)) {
            return index;
        }
        index++;
    }

    StringBuilder err = new StringBuilder("can not find unit in unit list[");
    while (i.hasNext()) {
        err.append(i.next());
        err.append(i.next());
        err.append(" ");
    }
    err.append("],current unit is ");
    err.append(currentUnit);
    throw new SequenceException(err.toString());
}
 
Example 10
Source Project: Ngram-Graphs   File: FileFormat.java    License: Apache License 2.0 5 votes vote down vote up
public ArrayList getTrainingSet() {
    ArrayList alRes = new ArrayList();
    Iterator<String> iNames = clusters.keySet().iterator();
    while (iNames.hasNext()) {
        String sCurName = iNames.next();
        String sCurFileName;
        
        Iterator<TreeSet> iClusters=((LinkedList)clusters.get(sCurName)).iterator();
        while (iClusters.hasNext()) {
            TreeSet tsCur = iClusters.next();
            
            Iterator<String> iFileNames = tsCur.iterator(); 
            while (iFileNames.hasNext()) {
                
                StringBuffer sb = new StringBuffer();
                sb.append(baseDir);
                sb.append(System.getProperty("file.separator"));
                sCurFileName = iFileNames.next();
                sb.append(sCurFileName.split("[.]")[1] + System.getProperty("file.separator"));
                sb.append(sCurFileName);
                CategorizedFileEntry cfeCur = new CategorizedFileEntry(sb.toString(),
                        sCurName);
                alRes.add(cfeCur);
            }
        }
    }
    
    return alRes;
}
 
Example 11
Source Project: datawave   File: ConnectionPoolTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testOrdering() {
    
    TreeSet<ConnectionPool> pools = new TreeSet<>();
    pools.addAll(connectionPools);
    Iterator<ConnectionPool> itr = pools.iterator();
    ConnectionPool p = null;
    
    p = itr.next();
    Assert.assertEquals("INGEST", p.getPoolName());
    Assert.assertEquals("ADMIN", p.getPriority());
    p = itr.next();
    Assert.assertEquals("INGEST", p.getPoolName());
    Assert.assertEquals("HIGH", p.getPriority());
    p = itr.next();
    Assert.assertEquals("INGEST", p.getPoolName());
    Assert.assertEquals("NORMAL", p.getPriority());
    p = itr.next();
    Assert.assertEquals("INGEST", p.getPoolName());
    Assert.assertEquals("LOW", p.getPriority());
    p = itr.next();
    Assert.assertEquals("WAREHOUSE", p.getPoolName());
    Assert.assertEquals("ADMIN", p.getPriority());
    p = itr.next();
    Assert.assertEquals("WAREHOUSE", p.getPoolName());
    Assert.assertEquals("HIGH", p.getPriority());
    p = itr.next();
    Assert.assertEquals("WAREHOUSE", p.getPoolName());
    Assert.assertEquals("NORMAL", p.getPriority());
    p = itr.next();
    Assert.assertEquals("WAREHOUSE", p.getPoolName());
    Assert.assertEquals("LOW", p.getPriority());
}
 
Example 12
private List<Instructor> getInstructors(Class_ clazz) {
    if (!clazz.isDisplayInstructor().booleanValue()) return null;
    List<Instructor> ret = new ArrayList<Instructor>();
    TreeSet ts = new TreeSet(clazz.getClassInstructors());
    for (Iterator i=ts.iterator();i.hasNext();) {
        ClassInstructor ci = (ClassInstructor)i.next();
        if (!ci.isLead().booleanValue()) continue;
        if (ci.getResponsibility() != null && ci.getResponsibility().hasOption(TeachingResponsibility.Option.auxiliary)) continue;
        ret.add(new Instructor(ci.getInstructor().getUniqueId(), ci.getInstructor().getExternalUniqueId(), iInstructorNameFormat.format(ci.getInstructor()), ci.getInstructor().getEmail()));
    }
    return ret;
}
 
Example 13
public Iterator iterator() {
    if (this.idToString == null) {
        return null;
    }

    // put them in a treeset first to sort them
    final TreeSet treeSet = new TreeSet(this.idToString.values());
    if (this.hasEmptyValue) {
        treeSet.add("");
    }
    return treeSet.iterator();
}
 
Example 14
Source Project: iaf   File: IbisDebuggerAdvice.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Provides advice for {@link CorePipeLineProcessor#processPipeLine(PipeLine pipeLine, String messageId, Message message, IPipeLineSession pipeLineSession, String firstPipe)}
 */
public PipeLineResult debugPipeLineInputOutputAbort(ProceedingJoinPoint proceedingJoinPoint, PipeLine pipeLine, String correlationId, Message message, IPipeLineSession pipeLineSession) throws Throwable {
	if (!isEnabled()) {
		return (PipeLineResult)proceedingJoinPoint.proceed();
	}
	message = ibisDebugger.pipeLineInput(pipeLine, correlationId, message);
	TreeSet<String> keys = new TreeSet<String>(pipeLineSession.keySet());
	Iterator<String> iterator = keys.iterator();
	while (iterator.hasNext()) {
		String sessionKey = iterator.next();
		Object sessionValue = pipeLineSession.get(sessionKey);
		sessionValue = ibisDebugger.pipeLineSessionKey(correlationId, sessionKey, sessionValue);
		pipeLineSession.put(sessionKey, sessionValue);
	}
	PipeLineResult pipeLineResult = null;
	try {
		PipeLineSessionDebugger pipeLineSessionDebugger = new PipeLineSessionDebugger(pipeLineSession);
		pipeLineSessionDebugger.setIbisDebugger(ibisDebugger);
		Object[] args = proceedingJoinPoint.getArgs();
		args[3] = pipeLineSessionDebugger;
		pipeLineResult = (PipeLineResult)proceedingJoinPoint.proceed(args);
	} catch(Throwable throwable) {
		throw ibisDebugger.pipeLineAbort(pipeLine, correlationId, throwable);
	}
	pipeLineResult.setResult(ibisDebugger.pipeLineOutput(pipeLine, correlationId, pipeLineResult.getResult()));
	return pipeLineResult;
}
 
Example 15
Source Project: AndServer   File: MimeType.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Compares this {@code MediaType} to another alphabetically.
 *
 * @param other media type to compare to.
 */
@Override
public int compareTo(MimeType other) {
    int comp = getType().compareToIgnoreCase(other.getType());
    if (comp != 0) {
        return comp;
    }
    comp = getSubtype().compareToIgnoreCase(other.getSubtype());
    if (comp != 0) {
        return comp;
    }
    comp = getParameters().size() - other.getParameters().size();
    if (comp != 0) {
        return comp;
    }
    TreeSet<String> thisAttributes = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
    thisAttributes.addAll(getParameters().keySet());
    TreeSet<String> otherAttributes = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
    otherAttributes.addAll(other.getParameters().keySet());
    Iterator<String> thisAttributesIterator = thisAttributes.iterator();
    Iterator<String> otherAttributesIterator = otherAttributes.iterator();
    while (thisAttributesIterator.hasNext()) {
        String thisAttribute = thisAttributesIterator.next();
        String otherAttribute = otherAttributesIterator.next();
        comp = thisAttribute.compareToIgnoreCase(otherAttribute);
        if (comp != 0) {
            return comp;
        }
        String thisValue = getParameters().get(thisAttribute);
        String otherValue = other.getParameters().get(otherAttribute);
        if (otherValue == null) {
            otherValue = "";
        }
        comp = thisValue.compareTo(otherValue);
        if (comp != 0) {
            return comp;
        }
    }
    return 0;
}
 
Example 16
Source Project: java-technology-stack   File: MimeType.java    License: MIT License 4 votes vote down vote up
/**
 * Compares this MIME Type to another alphabetically.
 * @param other the MIME Type to compare to
 * @see MimeTypeUtils#sortBySpecificity(List)
 */
@Override
public int compareTo(MimeType other) {
	int comp = getType().compareToIgnoreCase(other.getType());
	if (comp != 0) {
		return comp;
	}
	comp = getSubtype().compareToIgnoreCase(other.getSubtype());
	if (comp != 0) {
		return comp;
	}
	comp = getParameters().size() - other.getParameters().size();
	if (comp != 0) {
		return comp;
	}

	TreeSet<String> thisAttributes = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
	thisAttributes.addAll(getParameters().keySet());
	TreeSet<String> otherAttributes = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
	otherAttributes.addAll(other.getParameters().keySet());
	Iterator<String> thisAttributesIterator = thisAttributes.iterator();
	Iterator<String> otherAttributesIterator = otherAttributes.iterator();

	while (thisAttributesIterator.hasNext()) {
		String thisAttribute = thisAttributesIterator.next();
		String otherAttribute = otherAttributesIterator.next();
		comp = thisAttribute.compareToIgnoreCase(otherAttribute);
		if (comp != 0) {
			return comp;
		}
		if (PARAM_CHARSET.equals(thisAttribute)) {
			Charset thisCharset = getCharset();
			Charset otherCharset = other.getCharset();
			if (thisCharset != otherCharset) {
				if (thisCharset == null) {
					return -1;
				}
				if (otherCharset == null) {
					return 1;
				}
				comp = thisCharset.compareTo(otherCharset);
				if (comp != 0) {
					return comp;
				}
			}
		}
		else {
			String thisValue = getParameters().get(thisAttribute);
			String otherValue = other.getParameters().get(otherAttribute);
			if (otherValue == null) {
				otherValue = "";
			}
			comp = thisValue.compareTo(otherValue);
			if (comp != 0) {
				return comp;
			}
		}
	}

	return 0;
}
 
Example 17
private static final int[] findBorderLabels(ImageStack image) 
{
	int sizeX = image.getWidth();
	int sizeY = image.getHeight();
	int sizeZ = image.getSize();
	
	TreeSet<Integer> labelSet = new TreeSet<Integer>();

	// find labels in front (z=0) and back (z=sizeZ-1) slices
	for (int y = 0; y < sizeY; y++) 
	{
		for (int x = 0; x < sizeX; x++) 
		{
			labelSet.add((int) image.getVoxel(x, y, 0));
			labelSet.add((int) image.getVoxel(x, y, sizeZ - 1));
		}
	}
	
	// find labels in top  (y=0) and bottom (y=sizeY-1) borders
	for (int z = 0; z < sizeZ; z++) 
	{
		for (int x = 0; x < sizeX; x++)
		{
			labelSet.add((int) image.getVoxel(x, 0, z));
			labelSet.add((int) image.getVoxel(x, sizeY - 1, z));
		}
	}
	
	// find labels in left (x=0) and right (x=sizeX-1) borders
	for (int z = 0; z < sizeZ; z++)
	{
		for (int y = 0; y < sizeY; y++) 
		{
			labelSet.add((int) image.getVoxel(0, y, z));
			labelSet.add((int) image.getVoxel(sizeX - 1, y, z));
		}
	}

	// remove label for the background
	labelSet.remove(0);
	
	// convert to an array of int
	int[] labels = new int[labelSet.size()];
	int i = 0 ;
	Iterator<Integer> iter = labelSet.iterator();
	while(iter.hasNext())
	{
		labels[i++] = (int) iter.next();
	}
	
	return labels;
}
 
Example 18
protected void pdfBuildClassOrSubpartRow(ClassAssignmentProxy classAssignment, ExamAssignmentProxy examAssignment, CourseOffering co, PreferenceGroup prefGroup, String indentSpaces, boolean isEditable, String prevLabel, SessionContext context){
 	boolean classLimitDisplayed = false;
 	if (isShowLabel()){
      iPdfTable.addCell(pdfBuildPrefGroupLabel(co, prefGroup, indentSpaces, isEditable, prevLabel));
 	} 
 	if (isShowDivSec()){
 		iPdfTable.addCell(pdfBuildDivisionSection(co, prefGroup, isEditable));
 	}
 	if (isShowDemand()){
 		iPdfTable.addCell(pdfBuildPrefGroupDemand(prefGroup, isEditable));
 	} 
 	if (isShowProjectedDemand()){
 		iPdfTable.addCell(pdfBuildPrefGroupProjectedDemand(prefGroup, isEditable));
 	} 
 	if (isShowLimit()){
 		classLimitDisplayed = true;
 		iPdfTable.addCell(pdfBuildLimit(classAssignment, prefGroup, isEditable));
    	} 
 	if (isShowSnapshotLimit()){
 		classLimitDisplayed = true;
 		iPdfTable.addCell(pdfBuildSnapshotLimit(prefGroup, isEditable));
    	} 
 	if (isShowRoomRatio()){
 		iPdfTable.addCell(pdfBuildRoomLimit(prefGroup, isEditable, classLimitDisplayed));
    	} 
 	if (isShowManager()){
 		iPdfTable.addCell(pdfBuildManager(prefGroup, isEditable));
  	} 
 	if (isShowDatePattern()){
 		iPdfTable.addCell(pdfBuildDatePatternCell(classAssignment, prefGroup, isEditable));
  	} 
 	if (isShowMinPerWk()){
 		iPdfTable.addCell(pdfBuildMinPerWeek(prefGroup, isEditable));
    	} 
 	if (isShowTimePattern()){
 		iPdfTable.addCell(pdfBuildTimePatternCell(prefGroup, isEditable));
 	} 
 	if (isShowPreferences()){
 		iPdfTable.addCell(pdfBuildPreferenceCell(classAssignment,prefGroup, TimePref.class, isEditable));
 		iPdfTable.addCell(pdfBuildPreferenceCell(classAssignment,prefGroup, new Class[] {RoomPref.class, BuildingPref.class, RoomFeaturePref.class, RoomGroupPref.class} , isEditable));
 		if (getDisplayDistributionPrefs()) {
 			iPdfTable.addCell(pdfBuildPreferenceCell(classAssignment,prefGroup, DistributionPref.class, isEditable));
 		}
 	}
 	if (getDisplayInstructorPrefs()) {
iPdfTable.addCell(pdfBuildPreferenceCell(classAssignment,prefGroup, InstructorAttributePref.class, isEditable));
iPdfTable.addCell(pdfBuildPreferenceCell(classAssignment,prefGroup, InstructorPref.class, isEditable));
 	}
 	if (isShowInstructorAssignment()){
 		iPdfTable.addCell(pdfBuildInstructorAssignment(prefGroup, isEditable));
 	}
 	if (isShowInstructor()){
 		iPdfTable.addCell(pdfBuildInstructor(prefGroup, isEditable));
 	}
 	if (getDisplayTimetable() && isShowTimetable()){
 		iPdfTable.addCell(pdfBuildAssignedTime(classAssignment, prefGroup, isEditable));
 		iPdfTable.addCell(pdfBuildAssignedRoom(classAssignment, prefGroup, isEditable));
 		iPdfTable.addCell(pdfBuildAssignedRoomCapacity(classAssignment, prefGroup, isEditable));
 	} 
 	if (isShowTitle()) {
 		iPdfTable.addCell(createCell());
 	}
 	if (isShowCredit()){
 		iPdfTable.addCell(createCell());     		
 	} 
 	if (isShowSubpartCredit()){
 		iPdfTable.addCell(pdfBuildCredit(prefGroup, isEditable));     		
 	} 
 	if (isShowConsent()){
      iPdfTable.addCell(createCell());
 	} 
 	if (isShowSchedulePrintNote()){
 		iPdfTable.addCell(pdfBuildSchedulePrintNote(prefGroup, isEditable, context.getUser()));     		
 	} 
 	if (isShowNote()){
 		iPdfTable.addCell(pdfBuildNote(prefGroup, isEditable, context.getUser()));
 	}
     if (isShowExam()) {
         TreeSet exams = new TreeSet();
         if (prefGroup instanceof Class_) {
             exams = getExams((Class_)prefGroup);
         }
         for (Iterator<Exam> i = exams.iterator(); i.hasNext(); ) {
         	if (!context.hasPermission(i.next(), Right.ExaminationView))
         		i.remove();
         }
         if (isShowExamName()) {
             iPdfTable.addCell(pdfBuildExamName(exams, isEditable));
         }
         if (isShowExamTimetable()) {
             iPdfTable.addCell(pdfBuildExamPeriod(examAssignment, exams, isEditable));
             iPdfTable.addCell(pdfBuildExamRoom(examAssignment, exams, isEditable));
         }
     }
 	
 }
 
Example 19
Source Project: Kylin   File: TrieDictionaryTest.java    License: Apache License 2.0 4 votes vote down vote up
@Test
public void partOverflowTest() {
    ArrayList<String> str = new ArrayList<String>();
    // str.add("");
    str.add("part");
    str.add("par");
    str.add("partition");
    str.add("party");
    str.add("parties");
    str.add("paint");
    String longStr = "paintjkjdfklajkdljfkdsajklfjklsadjkjekjrklewjrklewjklrjklewjkljkljkljkljweklrjewkljrklewjrlkjewkljrkljkljkjlkjjkljkljkljkljlkjlkjlkjljdfadfads" + "dddddddddddddddddddddddddddddddddddddddddddddddddkfjadslkfjdsakljflksadjklfjklsjfkljwelkrjewkljrklewjklrjelkwjrklewjrlkjwkljerklkljlkjrlkwejrk" + "dddddddddddddddddddddddddddddddddddddddddddddddddkfjadslkfjdsakljflksadjklfjklsjfkljwelkrjewkljrklewjklrjelkwjrklewjrlkjwkljerklkljlkjrlkwejrk" + "dddddddddddddddddddddddddddddddddddddddddddddddddkfjadslkfjdsakljflksadjklfjklsjfkljwelkrjewkljrklewjklrjelkwjrklewjrlkjwkljerklkljlkjrlkwejrk" + "dddddddddddddddddddddddddddddddddddddddddddddddddkfjadslkfjdsakljflksadjklfjklsjfkljwelkrjewkljrklewjklrjelkwjrklewjrlkjwkljerklkljlkjrlkwejrk" + "dddddddddddddddddddddddddddddddddddddddddddddddddkfjadslkfjdsakljflksadjklfjklsjfkljwelkrjewkljrklewjklrjelkwjrklewjrlkjwkljerklkljlkjrlkwejrk"
            + "dddddddddddddddddddddddddddddddddddddddddddddddddkfjadslkfjdsakljflksadjklfjklsjfkljwelkrjewkljrklewjklrjelkwjrklewjrlkjwkljerklkljlkjrlkwejrk" + "dddddddddddddddddddddddddddddddddddddddddddddddddkfjadslkfjdsakljflksadjklfjklsjfkljwelkrjewkljrklewjklrjelkwjrklewjrlkjwkljerklkljlkjrlkwejrk";
    System.out.println("The length of the long string is " + longStr.length());
    str.add(longStr);

    str.add("zzzzzz" + longStr);// another long string

    TrieDictionaryBuilder<String> b = newDictBuilder(str);
    TrieDictionary<String> dict = b.build(0);

    TreeSet<String> set = new TreeSet<String>();
    for (String s : str) {
        set.add(s);
    }

    // test serialize
    dict = testSerialize(dict);

    // test basic id<==>value
    Iterator<String> it = set.iterator();
    int id = 0;
    int previousId = -1;
    for (; it.hasNext(); id++) {
        String value = it.next();

        // in case of overflow parts, there exist interpolation nodes
        // they exist to make sure that any node's part is shorter than 255
        int actualId = dict.getIdFromValue(value);
        assertTrue(actualId >= id);
        assertTrue(actualId > previousId);
        previousId = actualId;

        assertEquals(value, dict.getValueFromId(actualId));
    }
}
 
Example 20
Source Project: osp   File: JREFinder.java    License: GNU General Public License v3.0 3 votes vote down vote up
/**
  * Returns all public and private JREs of a given bitness (32 or 64).
  * 
 * Windows: search in \Java
 * 		typical 64-bit jdk: Program Files\Java\jdkX.X.X_XX\jre\bin\javaw.exe
  *    typical 64-bit jre: Program Files\Java\jreX.X.X_XX\bin\javaw.exe
  *                     or Program Files\Java\jreX\bin\javaw.exe
  *                     or Program Files\Java\jre-X\bin\javaw.exe
 * 		typical 32-bit jre: as above, but in Program Files (x86)\Java\
 *
 * OS X: search in: /JavaVirtualMachines
 * 		typical: /System/Library/Java/JavaVirtualMachines/X.X.X.jdk/Contents/Home/bin/javaw.exe ??
 * 
 * Linux: search in: /jvm
 * 		typical: /usr/lib/jvm/java-X-openjdk/jre/bin/javaw.exe
 * 		      or /usr/lib/jvm/java-X.X.X-openjdk/jre/bin/javaw.exe
 * 		      or /usr/lib/jvm/java-X-sun-X.X.X.XX/jre/bin/javaw.exe
 * 		      or /usr/lib/jvm/java-X.X.X-sun/jre/bin/javaw.exe
 *
  * @param vmBitness the bitness desired
  * @return a Set of java JRE directory paths
  */
public TreeSet<File> getJREs(int vmBitness) {
	TreeSet<File> results = findJREs();
	for (Iterator<File> it=results.iterator(); it.hasNext();) {
		String path = it.next().getPath();
		if (vmBitness==32 && !is32BitVM(path)) {
			it.remove();
		}
		else if (vmBitness!=32 && is32BitVM(path)) {
			it.remove();
		}
	}
	return results;
}