Java Code Examples for java.util.Hashtable.get()

The following are Jave code examples for showing how to use get() of the java.util.Hashtable class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: AgentWorkbench   File: Language.java   View Source Code Vote up 6 votes
/**
 * Translate the already known language-headers (e. g. 'LANG_EN') 
 * and give them an proper German expression.
 */
public static String getLanguageName(String langHeader) {
	
	Hashtable<String, String> headDescriptions = new Hashtable<String, String>();
	// --- prepare internal language descriptions -----------
	headDescriptions.put(Language.DE, translate("Deutsch"));
	headDescriptions.put(Language.EN, translate("Englisch"));
	headDescriptions.put(Language.IT, translate("Italienisch"));
	headDescriptions.put(Language.ES, translate("Spanisch"));
	headDescriptions.put(Language.FR, translate("Französisch"));

	String langHeaderWork = langHeader.toUpperCase();
	String langHeaderD = headDescriptions.get(langHeaderWork);
	if ( langHeaderD == null ) {
		langHeaderD = langHeaderWork;
	}		
	return langHeaderD;		
}
 
Example 2
Project: logistimo-web-service   File: AuthenticateOutput.java   View Source Code Vote up 6 votes
public static JSONObject addSMSParameters(Hashtable smsData) throws JSONException {
  JSONObject json = new JSONObject();
  String value = null;
  if ((value = (String) smsData.get(JsonTagsZ.GATEWAY_PHONE_NUMBER)) != null && !value
      .equals("")) {
    json.put(JsonTagsZ.GATEWAY_PHONE_NUMBER, value);
  }
  if ((value = (String) smsData.get(JsonTagsZ.GATEWAY_ROUTING_KEYWORD)) != null && !value
      .equals("")) {
    json.put(JsonTagsZ.GATEWAY_ROUTING_KEYWORD, value);
  }
  if ((value = (String) smsData.get(JsonTagsZ.SENDER_ID)) != null && !value.equals("")) {
    json.put(JsonTagsZ.SENDER_ID, value);
  }
  // Add to container JSON
  return json;
}
 
Example 3
Project: Mujeed-Arabic-Prolog   File: Variable.java   View Source Code Vote up 5 votes
/**
 * définition de standardizeVariablesApart de Variable: mettre à jour <b>newVars</b>
 * @param newVars les variables et leurs binding 
 * @return retourner le Variable courant
 */

public PCExpression standardizeVariablesApart(Hashtable<Variable, Variable> newVars) {
	Variable newVar = newVars.get(this); // Try to see if the current
											// expression already has a
											// substitute variable.
	if (newVar == null) { // if not create one.
		newVar = new Variable(this);
		newVars.put(this, newVar);
	}
	return newVar;
}
 
Example 4
Project: ramus   File: ColumnBody.java   View Source Code Vote up 5 votes
public ColumnBody(Hashtable<String, String> attributes) {
    super(attributes);
    String text = attributes.get("Text");
    if (text == null)
        text = "";
    this.text = text;
}
 
Example 5
Project: logistimo-web-service   File: JsonUtil.java   View Source Code Vote up 5 votes
public static void addRelatedKioskData(JSONObject json, Vector relatedKiosks, String type)
    throws JSONException {
  if (relatedKiosks != null) {
    JSONArray relatedKiosksJson = new JSONArray();
    // If relatedKiosks is null or empty, send an empty JSONArray in the response.
    if (!relatedKiosks.isEmpty()) {
      Enumeration en = relatedKiosks.elements();
      while (en.hasMoreElements()) {
        Hashtable v = (Hashtable) en.nextElement();
        JSONObject relatedKioskJson = new JSONObject();
        relatedKioskJson.put(JsonTagsZ.KIOSK_ID, (String) v.get(JsonTagsZ.KIOSK_ID));
        relatedKioskJson.put(JsonTagsZ.NAME, (String) v.get(JsonTagsZ.NAME));
        relatedKioskJson.put(JsonTagsZ.CITY, (String) v.get(JsonTagsZ.CITY));
        String value = null;
        if ((value = (String) v.get(JsonTagsZ.STATE)) != null && value.length() > 0) {
          relatedKioskJson.put(JsonTagsZ.STATE, value);
        }
        if ((value = (String) v.get(JsonTagsZ.DISTRICT)) != null && value.length() > 0) {
          relatedKioskJson.put(JsonTagsZ.DISTRICT, value);
        }
        if ((value = (String) v.get(JsonTagsZ.TALUK)) != null && value.length() > 0) {
          relatedKioskJson.put(JsonTagsZ.TALUK, value);
        }
        if ((value = (String) v.get(JsonTagsZ.STREET_ADDRESS)) != null && value.length() > 0) {
          relatedKioskJson.put(JsonTagsZ.STREET_ADDRESS, value);
        }
        if ((value = (String) v.get(JsonTagsZ.PINCODE)) != null && value.length() > 0) {
          relatedKioskJson.put(JsonTagsZ.PINCODE, value);
        }
        if ((value = (String) v.get(JsonTagsZ.PAYABLE)) != null && value.length() > 0) {
          relatedKioskJson.put(JsonTagsZ.PAYABLE, value);
        }
        if ((value = (String) v.get(JsonTagsZ.CREDIT_LIMIT)) != null && value.length() > 0) {
          relatedKioskJson.put(JsonTagsZ.CREDIT_LIMIT, value);
        }
        if ((value = (String) v.get(JsonTagsZ.ROUTE_INDEX)) != null) {
          relatedKioskJson.put(JsonTagsZ.ROUTE_INDEX, value);
        }
        if ((value = (String) v.get(JsonTagsZ.ROUTE_TAG)) != null) {
          relatedKioskJson.put(JsonTagsZ.ROUTE_TAG, value);
        }
        if ((value = (String) v.get(JsonTagsZ.LATITUDE)) != null) {
          relatedKioskJson.put(JsonTagsZ.LATITUDE, value);
        }
        if ((value = (String) v.get(JsonTagsZ.LONGITUDE)) != null) {
          relatedKioskJson.put(JsonTagsZ.LONGITUDE, value);
        }
        if ((value = (String) v.get(JsonTagsZ.GEO_ACCURACY)) != null) {
          relatedKioskJson.put(JsonTagsZ.GEO_ACCURACY, value);
        }
        if ((value = (String) v.get(JsonTagsZ.GEO_ERROR_CODE)) != null) {
          relatedKioskJson.put(JsonTagsZ.GEO_ERROR_CODE, value);
        }
        if ((value = (String) v.get(JsonTagsZ.CUSTOM_KIOSKID)) != null) {
          relatedKioskJson.put(JsonTagsZ.CUSTOM_KIOSKID, value);
        }
        if ((value = (String) v.get(JsonTagsZ.DISABLE_BATCH_MGMT)) != null) {
          relatedKioskJson.put(JsonTagsZ.DISABLE_BATCH_MGMT, value);
        }
        // Add users, if any
        Vector users = (Vector) v.get(JsonTagsZ.USERS);
        if (users != null && !users.isEmpty()) {
          addKioskUsers(relatedKioskJson, users);
        }

        // Add to array
        relatedKiosksJson.put(relatedKioskJson);
      }
    }
    // Update kiosk object
    json.put(type, relatedKiosksJson);
  }
}
 
Example 6
Project: logistimo-web-service   File: JsonUtil.java   View Source Code Vote up 5 votes
public static void addErrorData(JSONObject json, Vector errors) throws JSONException {
  if (errors == null || errors.isEmpty()) {
    throw new JSONException("No error data found");
  }
  JSONArray array = new JSONArray();
  Enumeration en = errors.elements();
  while (en.hasMoreElements()) {
    Hashtable error = (Hashtable) en.nextElement();
    // Form error JSON object
    JSONObject e = new JSONObject();
    e.put(JsonTagsZ.MATERIAL_ID, (String) error.get(JsonTagsZ.MATERIAL_ID));
    e.put(JsonTagsZ.MESSAGE, (String) error.get(JsonTagsZ.MESSAGE));
    String value = null;
    if ((value = (String) error.get(JsonTagsZ.QUANTITY)) != null && !value.equals("")) {
      e.put(JsonTagsZ.QUANTITY, (String) error.get(JsonTagsZ.QUANTITY));
    }
    if ((value = (String) error.get(JsonTagsZ.ERROR_CODE)) != null && !value.equals("")) {
      e.put(JsonTagsZ.ERROR_CODE, (String) error.get(JsonTagsZ.ERROR_CODE));
    }
    if ((value = (String) error.get(JsonTagsZ.TIMESTAMP)) != null && !value.equals("")) {
      e.put(JsonTagsZ.TIMESTAMP, (String) error.get(JsonTagsZ.TIMESTAMP));
    }
    // Add batches, if any
    Vector batches = (Vector) error.get(JsonTagsZ.BATCHES);
    if (batches != null && !batches.isEmpty()) {
      addBatchErrorData(e, batches);
    }
    // Add to JSON array
    array.put(e);
  }
  // Add to json object
  json.put(JsonTagsZ.ERRORS, array);
}
 
Example 7
Project: tomcat7   File: Registry.java   View Source Code Vote up 5 votes
/** Return an int ID for faster access. Will be used for notifications
 * and for other operations we want to optimize. 
 *
 * @param domain Namespace 
 * @param name  Type of the notification
 * @return  An unique id for the domain:name combination
 * @since 1.1
 */
@Override
public synchronized int getId( String domain, String name) {
    if( domain==null) {
        domain="";
    }
    Hashtable<String,Integer> domainTable = idDomains.get(domain);
    if( domainTable == null ) {
        domainTable = new Hashtable<String,Integer>();
        idDomains.put( domain, domainTable); 
    }
    if( name==null ) {
        name="";
    }
    Integer i = domainTable.get(name);
    
    if( i!= null ) {
        return i.intValue();
    }

    int id[] = ids.get(domain);
    if( id == null ) {
        id=new int[1];
        ids.put( domain, id); 
    }
    int code=id[0]++;
    domainTable.put( name, Integer.valueOf( code ));
    return code;
}
 
Example 8
Project: ramus   File: UserTemplate.java   View Source Code Vote up 5 votes
private Crosspoint getCrosspoint(final DataPlugin dataPlugin,
                                 final Hashtable<Long, Long> trans, final InputStream stream)
        throws IOException {
    long id;
    Crosspoint c;
    id = DataLoader.readLong(stream);
    final Long cId = trans.get(id);
    if (cId == null) {
        c = dataPlugin.createCrosspoint();
        trans.put(id, c.getGlobalId());
    } else
        c = dataPlugin.findCrosspointByGlobalId(cId);
    return c;
}
 
Example 9
Project: ChronoBike   File: CGlobalEntityCounter.java   View Source Code Vote up 5 votes
protected CItemCounter GetIC(Hashtable<String, CItemCounter> tab, String cs)
{
	CItemCounter ic = tab.get(cs);
	if (ic == null)
	{
		ic = new CItemCounter();
		ic.m_ItemName = cs ;
		tab.put(cs, ic);
	}
	return ic ;
}
 
Example 10
Project: unitimes   File: Location.java   View Source Code Vote up 5 votes
public static Hashtable<Long, Set<Long>> findExamLocationTable(Long periodId) {
    Hashtable<Long,Set<Long>> table = new Hashtable();
    for (Iterator i = (new LocationDAO()).getSession()
                .createQuery("select distinct r.uniqueId, x.uniqueId from Exam x inner join x.assignedRooms r where x.assignedPeriod.uniqueId=:periodId")
                .setLong("periodId",periodId)
                .setCacheable(true).list().iterator();i.hasNext();) {
        Object[] o = (Object[])i.next();
        Set<Long> exams = table.get((Long)o[0]);
        if (exams == null) { exams = new HashSet<Long>(); table.put((Long)o[0], exams); }
        exams.add((Long)o[1]);
    }
    return table;
}
 
Example 11
Project: unitimes   File: CachedClassAssignmentProxy.java   View Source Code Vote up 5 votes
public void setCache(Collection classesOrClassIds) {
	Vector classesOrClassIdsVect = (classesOrClassIds instanceof Vector ? (Vector)classesOrClassIds : new Vector(classesOrClassIds));
	Hashtable newAssignments = iProxy.getAssignmentTable(classesOrClassIdsVect);
	Hashtable newInfos = iProxy.getAssignmentInfoTable(classesOrClassIdsVect);
	for (Enumeration e=classesOrClassIdsVect.elements();e.hasMoreElements();) {
		Object classOrClassId = e.nextElement();
		if (classOrClassId instanceof Object[]) classOrClassId = ((Object[])classOrClassId)[0];
		Long classId = (classOrClassId instanceof Class_ ? ((Class_)classOrClassId).getUniqueId() : (Long)classOrClassId);
		Assignment assignment = (Assignment) newAssignments.get(classId);
		iAssignmentTable.put(classId, (assignment==null?sNULL:assignment));
		AssignmentPreferenceInfo info = (AssignmentPreferenceInfo) newInfos.get(classId);
		iAssignmentInfoTable.put(classId, (info==null?sNULL:info));
	}
}
 
Example 12
Project: lams   File: ProxyDirContext.java   View Source Code Vote up 5 votes
/**
 * Builds a proxy directory context using the given environment.
 */
public ProxyDirContext(Hashtable env, DirContext dirContext) {
    this.env = env;
    this.dirContext = dirContext;
    if (dirContext instanceof BaseDirContext) {
        // Initialize parameters based on the associated dir context, like
        // the caching policy.
        BaseDirContext baseDirContext = (BaseDirContext) dirContext;
        if (baseDirContext.isCached()) {
            try {
                cache = (ResourceCache) 
                    Class.forName(cacheClassName).newInstance();
            } catch (Exception e) {
                //FIXME
                e.printStackTrace();
            }
            cache.setCacheMaxSize(baseDirContext.getCacheMaxSize());
            cacheTTL = baseDirContext.getCacheTTL();
            cacheObjectMaxSize = baseDirContext.getCacheObjectMaxSize();
            // cacheObjectMaxSize must be less than cacheMaxSize
            // Set a sensible limit
            if (cacheObjectMaxSize > baseDirContext.getCacheMaxSize()/32) {
                cacheObjectMaxSize = baseDirContext.getCacheMaxSize()/32;
            }
        }
    }
    hostName = (String) env.get(HOST);
    contextName = (String) env.get(CONTEXT);
}
 
Example 13
Project: ramus   File: ProjectionConnectionPlugin.java   View Source Code Vote up 5 votes
@SuppressWarnings("unchecked")
@Override
public Connection getConnection(Data data, Qualifier qualifier, String name) {
    Hashtable<String, EConnection> hash = (Hashtable<String, EConnection>) data
            .get("Projections.Hash");
    List<String> nulls = (List<String>) data.get("Projections.Nulls");
    if (hash == null) {
        hash = new Hashtable<String, EConnection>();
        data.put("Projections.Hash", hash);
    }

    if (nulls == null) {
        nulls = new Vector<String>();
        data.put("Projections.Nulls", nulls);
    }

    EConnection connection = hash.get(name);
    if (connection == null) {
        if (nulls.indexOf(name) >= 0)
            return null;
        for (Attribute attribute : data.getAttributes()) {
            if ((attribute.getName().equals(name) && (attribute
                    .getAttributeType().toString()
                    .equals("Core.ElementList")))) {
                ElementListPropertyPersistent property = (ElementListPropertyPersistent) data
                        .getEngine().getAttribute(null, attribute);
                if (property != null) {
                    connection = new EConnection(attribute, property);
                }
            }
        }
    }
    if (connection == null)
        nulls.add(name);
    else
        hash.put(name, connection);
    return connection;
}
 
Example 14
Project: apache-tomcat-7.0.73-with-comment   File: DataSource.java   View Source Code Vote up 5 votes
/**
 * Creates the ObjectName for the ConnectionPoolMBean object to be registered
 * @param original the ObjectName for the DataSource
 * @return the ObjectName for the ConnectionPoolMBean
 * @throws MalformedObjectNameException
 */
public ObjectName createObjectName(ObjectName original) throws MalformedObjectNameException {
    String domain = ConnectionPool.POOL_JMX_DOMAIN;
    Hashtable<String,String> properties = original.getKeyPropertyList();
    String origDomain = original.getDomain();
    properties.put("type", "ConnectionPool");
    properties.put("class", this.getClass().getName());
    if (original.getKeyProperty("path")!=null || properties.get("context")!=null) {
        //this ensures that if the registration came from tomcat, we're not losing
        //the unique domain, but putting that into as an engine attribute
        properties.put("engine", origDomain);
    }
    ObjectName name = new ObjectName(domain,properties);
    return name;
}
 
Example 15
Project: ramus   File: OtherElementPlugin.java   View Source Code Vote up 4 votes
@Override
public void replaceElements(Engine engine, Element[] oldElements,
                            Element newElement) {

    for (Qualifier qualifier : getAllNotSystemQualifiers(engine)) {
        List<Attribute> attributes = new ArrayList<Attribute>();
        for (Attribute attribute : qualifier.getAttributes()) {
            if ((attribute.getAttributeType().getPluginName()
                    .equals(getName()))
                    && (attribute.getAttributeType().getTypeName()
                    .equals(getTypeName()))) {
                OtherElementPropertyPersistent p = (OtherElementPropertyPersistent) engine
                        .getAttribute(null, attribute);
                if (p.getQualifier() == newElement.getQualifierId())
                    attributes.add(attribute);
            }
        }
        Hashtable<Element, Object[]> hash = engine.getElements(qualifier,
                attributes);
        Enumeration<Element> keys = hash.keys();
        while (keys.hasMoreElements()) {
            Element key = keys.nextElement();
            Object[] objects = hash.get(key);
            int aIndex = 0;
            for (Object object : objects)
                if (object != null) {
                    Long l = (Long) object;
                    for (Element element : oldElements) {
                        if (element.getId() == l.longValue()) {
                            engine.setAttribute(key,
                                    attributes.get(aIndex), newElement
                                            .getId());
                            break;
                        }
                    }
                    aIndex++;
                }
        }
    }

}
 
Example 16
Project: unitimes   File: CurriculaServlet.java   View Source Code Vote up 4 votes
private Hashtable<Long, Hashtable<CourseInterface, Set<Long>>> loadClasfCourse2req(org.hibernate.Session hibSession, Long acadAreaId, Collection<Long> majors, boolean multipleMajors) {
	List<Object[]> lines = null;
	String select = "a.academicClassification.uniqueId, r.courseOffering.uniqueId, r.courseOffering.subjectArea.subjectAreaAbbreviation || ' ' || r.courseOffering.courseNbr, s.uniqueId";
	String from = "CourseRequest r inner join r.courseDemand.student s inner join s.areaClasfMajors a inner join a.major m";
	String where = "s.session.uniqueId = :sessionId and a.academicArea.uniqueId = :areaId";
	if (majors.isEmpty()) {
		// students with no major
		if (!multipleMajors)
			lines = hibSession.createQuery("select " + select + " from " + from + " where " + where)
				.setLong("sessionId", getAcademicSessionId()).setLong("areaId", acadAreaId)
				.setCacheable(true).list();
	} else if (!multipleMajors || majors.size() == 1) {
		// students with one major
		lines = hibSession.createQuery("select " + select + " from " + from + " where " + where + " and m.uniqueId in :majorIds")
				.setLong("sessionId", getAcademicSessionId()).setLong("areaId", acadAreaId)
				.setParameterList("majorIds", majors)
				.setCacheable(true).list();
	} else {
		// students with multiple majors
		Map<String, Long> params = new HashMap<String, Long>();
		int idx = 0;
		for (Long major: majors) {
			if (idx == 0) {
				where += " and m.uniqueId = :m" + idx;
			} else {
				from += " inner join s.areaClasfMajors a" + idx;
				where += " and a.academicArea.uniqueId = :areaId and a" + idx + ".major.uniqueId = :m" + idx;
			}
			params.put("m" + idx, major);
			idx ++;
		}
		org.hibernate.Query q = hibSession.createQuery("select " + select + " from " + from + " where " + where)
				.setLong("sessionId", getAcademicSessionId()).setLong("areaId", acadAreaId);
		for (Map.Entry<String, Long> e: params.entrySet())
			q.setLong(e.getKey(), e.getValue());
		lines = q.setCacheable(true).list();
	}
	Hashtable<Long, Hashtable<CourseInterface, Set<Long>>> clasf2course2enrl = new Hashtable<Long, Hashtable<CourseInterface,Set<Long>>>();
	if (lines != null)
		for (Object[] o : lines) {
			Long clasfId = (Long)o[0];
			Long courseId = (Long)o[1];
			String courseName = (String)o[2];
			Long studentId = (Long)o[3];
			CourseInterface course = new CourseInterface();
			course.setId(courseId);
			course.setCourseName(courseName);
			Hashtable<CourseInterface, Set<Long>> course2enrl = clasf2course2enrl.get(clasfId);
			if (course2enrl == null) {
				course2enrl = new Hashtable<CourseInterface, Set<Long>>();
				clasf2course2enrl.put(clasfId, course2enrl);
			}
			Set<Long> students = course2enrl.get(course);
			if (students == null) {
				students = new HashSet<Long>();
				course2enrl.put(course, students);
			}
			students.add(studentId);
		}
	
	return clasf2course2enrl;
}
 
Example 17
Project: OpenJSharp   File: Config.java   View Source Code Vote up 4 votes
/**
 * Parses stanza names and values from configuration file to
 * stanzaTable (Hashtable). Hashtable key would be stanza names,
 * (libdefaults, realms, domain_realms, etc), and the hashtable value
 * would be another hashtable which contains the key-value pairs under
 * a stanza name. The value of this sub-hashtable can be another hashtable
 * containing another sub-sub-section or a vector of strings for
 * final values (even if there is only one value defined).
 * <p>
 * For duplicates section names, the latter overwrites the former. For
 * duplicate value names, the values are in a vector in its appearing order.
 * </ol>
 * Please note that this behavior is Java traditional. and it is
 * not the same as the MIT krb5 behavior, where:<ol>
 * <li>Duplicated root sections will be merged
 * <li>For duplicated sub-sections, the former overwrites the latter
 * <li>Duplicate keys for values are always saved in a vector
 * </ol>
 * @param v the strings in the file, never null, might be empty
 * @throws KrbException if there is a file format error
 */
@SuppressWarnings("unchecked")
private Hashtable<String,Object> parseStanzaTable(List<String> v)
        throws KrbException {
    Hashtable<String,Object> current = stanzaTable;
    for (String line: v) {
        // There are 3 kinds of lines
        // 1. a = b
        // 2. a = {
        // 3. }
        if (line.equals("}")) {
            // Go back to parent, see below
            current = (Hashtable<String,Object>)current.remove(" PARENT ");
            if (current == null) {
                throw new KrbException("Unmatched close brace");
            }
        } else {
            int pos = line.indexOf('=');
            if (pos < 0) {
                throw new KrbException("Illegal config content:" + line);
            }
            String key = line.substring(0, pos).trim();
            String value = trimmed(line.substring(pos+1));
            if (value.equals("{")) {
                Hashtable<String,Object> subTable;
                if (current == stanzaTable) {
                    key = key.toLowerCase(Locale.US);
                }
                subTable = new Hashtable<>();
                current.put(key, subTable);
                // A special entry for its parent. Put whitespaces around,
                // so will never be confused with a normal key
                subTable.put(" PARENT ", current);
                current = subTable;
            } else {
                Vector<String> values;
                if (current.containsKey(key)) {
                    Object obj = current.get(key);
                    // If a key first shows as a section and then a value,
                    // this is illegal. However, we haven't really forbid
                    // first value then section, which the final result
                    // is a section.
                    if (!(obj instanceof Vector)) {
                        throw new KrbException("Key " + key
                                + "used for both value and section");
                    }
                    values = (Vector<String>)current.get(key);
                } else {
                    values = new Vector<String>();
                    current.put(key, values);
                }
                values.add(value);
            }
        }
    }
    if (current != stanzaTable) {
        throw new KrbException("Not closed");
    }
    return current;
}
 
Example 18
Project: OpenDA   File: Histogram.java   View Source Code Vote up 4 votes
/** Write plot data information to the specified output stream in PlotML,
 *  but in such a way that the Plot class can read it and reproduce the
 *  histogram.  The ordinary mechanism for saving the histogram
 *  records the raw data and the configuration to be used by this class.
 *  @param output A buffered print writer.
 *  @param dtd The DTD, or null to reference the default.
 */
public synchronized void exportToPlot(PrintWriter output, String dtd) {
    if (dtd == null) {
        output.println("<?xml version=\"1.0\" standalone=\"yes\"?>");
        output.println(
                "<!DOCTYPE plot PUBLIC \"-//UC Berkeley//DTD PlotML 1//EN\"");
        output.println(
                "    \"http://ptolemy.eecs.berkeley.edu/xml/dtd/PlotML_1.dtd\">");
    } else {
        output.println("<?xml version=\"1.0\" standalone=\"no\"?>");
        output.println("<!DOCTYPE plot SYSTEM \"" + dtd + "\">");
    }
    output.println("<plot>");
    output.println("<!-- Ptolemy plot, version " + PTPLOT_RELEASE
            + " , PlotML format. Exported from Histogram. -->");

    super.writeFormat(output);
    output.println(
            "<barGraph width=\""
            + (_barwidth * _binWidth)
            + "\" offset=\""
            + (_baroffset * _binWidth)
            + "\"/>");
    for (int dataset = 0; dataset < _points.size(); dataset++) {
        // Write the dataset directive
        String legend = getLegend(dataset);
        if (legend != null) {
            output.println("<dataset name=\""
                    + legend
                    + "\" connected=\"no\">");
        } else {
            output.println("<dataset connected=\"no\">");
        }
        Hashtable data = (Hashtable)_histogram.elementAt(dataset);
        Enumeration keys = data.keys();
        while (keys.hasMoreElements()) {
            Integer bin = (Integer)keys.nextElement();
            Integer count = (Integer)data.get(bin);
            // The X axis value is a bit complex to get.
            int xValue = (int)(bin.intValue() * _binWidth + _binOffset);
            output.println("<p x=\""
                    + xValue
                    + "\" y=\""
                    + count.intValue()
                    + "\"/>");
        }
        output.println("</dataset>");
    }
    output.println("</plot>");
    output.flush();
}
 
Example 19
Project: lams   File: IntrospectionUtils.java   View Source Code Vote up 4 votes
public static boolean processArgs(Object proxy, String args[],
        String args0[], String args1[], Hashtable aliases) throws Exception {
    for (int i = 0; i < args.length; i++) {
        String arg = args[i];
        if (arg.startsWith("-"))
            arg = arg.substring(1);
        if (aliases != null && aliases.get(arg) != null)
            arg = (String) aliases.get(arg);

        if (args0 != null) {
            boolean set = false;
            for (int j = 0; j < args0.length; j++) {
                if (args0[j].equalsIgnoreCase(arg)) {
                    setProperty(proxy, args0[j], "true");
                    set = true;
                    break;
                }
            }
            if (set)
                continue;
        }
        if (args1 != null) {
            for (int j = 0; j < args1.length; j++) {
                if (args1[j].equalsIgnoreCase(arg)) {
                    i++;
                    if (i >= args.length)
                        return false;
                    setProperty(proxy, arg, args[i]);
                    break;
                }
            }
        } else {
            // if args1 is not specified,assume all other options have param
            i++;
            if (i >= args.length)
                return false;
            setProperty(proxy, arg, args[i]);
        }

    }
    return true;
}
 
Example 20
Project: unitimes   File: StudentCourseRequests.java   View Source Code Vote up 4 votes
@Override
public Double getEnrollmentPriority(Long studentId, Long courseId) {
	Hashtable<Long, Double> priorities = iEnrollmentPriorities.get(studentId);
	return (priorities == null ? null : priorities.get(courseId));
}