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

The following are Jave code examples for showing how to use keys() 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: openjdk-jdk10   File: ArrayTable.java   View Source Code Vote up 6 votes
public Object clone() {
    ArrayTable newArrayTable = new ArrayTable();
    if (isArray()) {
        Object[] array = (Object[])table;
        for (int i = 0 ;i < array.length-1 ; i+=2) {
            newArrayTable.put(array[i], array[i+1]);
        }
    } else {
        Hashtable<?,?> tmp = (Hashtable)table;
        Enumeration<?> keys = tmp.keys();
        while (keys.hasMoreElements()) {
            Object o = keys.nextElement();
            newArrayTable.put(o,tmp.get(o));
        }
    }
    return newArrayTable;
}
 
Example 2
Project: ipack   File: PolicyMappings.java   View Source Code Vote up 6 votes
/**
 * Creates a new <code>PolicyMappings</code> instance.
 *
 * @param mappings a <code>HashMap</code> value that maps
 *                 <code>String</code> oids
 *                 to other <code>String</code> oids.
 * @deprecated use CertPolicyId constructors.
 */
public PolicyMappings(Hashtable mappings)
{
    ASN1EncodableVector dev = new ASN1EncodableVector();
    Enumeration it = mappings.keys();

    while (it.hasMoreElements())
    {
        String idp = (String)it.nextElement();
        String sdp = (String)mappings.get(idp);
        ASN1EncodableVector dv = new ASN1EncodableVector();
        dv.add(new ASN1ObjectIdentifier(idp));
        dv.add(new ASN1ObjectIdentifier(sdp));
        dev.add(new DERSequence(dv));
    }

    seq = new DERSequence(dev);
}
 
Example 3
Project: jdk8u-jdk   File: JComponent.java   View Source Code Vote up 6 votes
/**
 * Unregisters all the previously registered
 * <code>WHEN_IN_FOCUSED_WINDOW</code> <code>KeyStroke</code> bindings.
 */
private void unregisterWithKeyboardManager() {
    Hashtable<KeyStroke, KeyStroke> registered =
            (Hashtable<KeyStroke, KeyStroke>)getClientProperty
                            (WHEN_IN_FOCUSED_WINDOW_BINDINGS);

    if (registered != null && registered.size() > 0) {
        Enumeration<KeyStroke> keys = registered.keys();

        while (keys.hasMoreElements()) {
            KeyStroke ks = keys.nextElement();
            unregisterWithKeyboardManager(ks);
        }
    }
    putClientProperty(WHEN_IN_FOCUSED_WINDOW_BINDINGS, null);
}
 
Example 4
Project: jerrydog   File: CGIServlet.java   View Source Code Vote up 6 votes
/**
 * Gets a string for input to a POST cgi script
 *
 * @param  params   Hashtable of query parameters to be passed to
 *                  the CGI script
 * @return          for use as input to the CGI script
 */

protected String getPostInput(Hashtable params) {
    String lineSeparator = System.getProperty("line.separator");
    Enumeration paramNames = params.keys();
    StringBuffer postInput = new StringBuffer("");
    StringBuffer qs = new StringBuffer("");
    if (paramNames != null && paramNames.hasMoreElements()) {
        while (paramNames.hasMoreElements()) {
            String k = (String) paramNames.nextElement();
            String v = params.get(k).toString();
            if ((k.indexOf("=") < 0) && (v.indexOf("=") < 0)) {
                postInput.append(k);
                qs.append(k);
                postInput.append("=");
                qs.append("=");
                postInput.append(v);
                qs.append(v);
                postInput.append(lineSeparator);
                qs.append("&");
            }
        }
    }
    qs.append(lineSeparator);
    return qs.append(postInput).toString();
}
 
Example 5
Project: OpenJSharp   File: ArrayTable.java   View Source Code Vote up 6 votes
public Object clone() {
    ArrayTable newArrayTable = new ArrayTable();
    if (isArray()) {
        Object[] array = (Object[])table;
        for (int i = 0 ;i < array.length-1 ; i+=2) {
            newArrayTable.put(array[i], array[i+1]);
        }
    } else {
        Hashtable<?,?> tmp = (Hashtable)table;
        Enumeration<?> keys = tmp.keys();
        while (keys.hasMoreElements()) {
            Object o = keys.nextElement();
            newArrayTable.put(o,tmp.get(o));
        }
    }
    return newArrayTable;
}
 
Example 6
Project: phone-simulator   File: EnumeratedBase.java   View Source Code Vote up 5 votes
protected static Integer doCreateInstance(String s, Hashtable<String, Integer> stringMap, Hashtable<Integer, String> intMap) {
    if (s == null)
        return null;

    String sx = s.toLowerCase();
    Enumeration<String> enS = stringMap.keys();
    while (enS.hasMoreElements()) {
        String s1 = enS.nextElement();
        if (s1.toLowerCase().equals(sx)) {
            return stringMap.get(s1);
        }
    }

    try {
        int i2 = Integer.parseInt(s);
        Enumeration<Integer> enI = intMap.keys();
        while (enI.hasMoreElements()) {
            int i1 = enI.nextElement();
            if (i1 == i2) {
                return i1;
            }
        }
    } catch (Exception e) {

    }

    return null;
}
 
Example 7
Project: ipack   File: X509Extensions.java   View Source Code Vote up 5 votes
/**
 * Constructor from a table of extensions with ordering.
 * <p>
 * It's is assumed the table contains OID/String pairs.
 * @deprecated use Extensions
 */
public X509Extensions(
    Vector      ordering,
    Hashtable   extensions)
{
    Enumeration e;

    if (ordering == null)
    {
        e = extensions.keys();
    }
    else
    {
        e = ordering.elements();
    }

    while (e.hasMoreElements())
    {
        this.ordering.addElement(ASN1ObjectIdentifier.getInstance(e.nextElement()));
    }

    e = this.ordering.elements();

    while (e.hasMoreElements())
    {
        ASN1ObjectIdentifier     oid = ASN1ObjectIdentifier.getInstance(e.nextElement());
        X509Extension           ext = (X509Extension)extensions.get(oid);

        this.extensions.put(oid, ext);
    }
}
 
Example 8
Project: jdk8u-jdk   File: SwitchData.java   View Source Code Vote up 5 votes
/**
 * Create a new enumeration from the hashtable.  Each key in the
 * hash table will be an Integer, with the value being a label.  The
 * enumeration returns the keys in sorted order.
 */
SwitchDataEnumeration(Hashtable<Integer,Label> tab) {
    table = new Integer[tab.size()];
    int i = 0;
    for (Enumeration<Integer> e = tab.keys() ; e.hasMoreElements() ; ) {
        table[i++] = e.nextElement();
    }
    Arrays.sort(table);
    current_index = 0;
}
 
Example 9
Project: lams   File: CGIServlet.java   View Source Code Vote up 5 votes
/**
 * Converts a Hashtable to a String array by converting each
 * key/value pair in the Hashtable to a String in the form
 * "key=value" (hashkey + "=" + hash.get(hashkey).toString())
 *
 * @param  h   Hashtable to convert
 *
 * @return     converted string array
 *
 * @exception  NullPointerException   if a hash key has a null value
 *
 */
protected String[] hashToStringArray(Hashtable<String,?> h)
    throws NullPointerException {
    Vector<String> v = new Vector<String>();
    Enumeration<String> e = h.keys();
    while (e.hasMoreElements()) {
        String k = e.nextElement();
        v.add(k + "=" + h.get(k).toString());
    }
    String[] strArr = new String[v.size()];
    v.copyInto(strArr);
    return strArr;
}
 
Example 10
Project: ipack   File: IETFUtils.java   View Source Code Vote up 5 votes
public static String[] findAttrNamesForOID(
    ASN1ObjectIdentifier oid,
    Hashtable            lookup)
{
    int count = 0;
    for (Enumeration en = lookup.elements(); en.hasMoreElements();)
    {
        if (oid.equals(en.nextElement()))
        {
            count++;
        }
    }

    String[] aliases = new String[count];
    count = 0;

    for (Enumeration en = lookup.keys(); en.hasMoreElements();)
    {
        String key = (String)en.nextElement();
        if (oid.equals(lookup.get(key)))
        {
            aliases[count++] = key;
        }
    }

    return aliases;
}
 
Example 11
Project: jerrydog   File: CGIServlet.java   View Source Code Vote up 5 votes
/**
 * Converts a Hashtable to a String array by converting each
 * key/value pair in the Hashtable to a String in the form
 * "key=value" (hashkey + "=" + hash.get(hashkey).toString())
 *
 * @param  h   Hashtable to convert
 *
 * @return     converted string array
 *
 * @exception  NullPointerException   if a hash key has a null value
 *
 */
protected String[] hashToStringArray(Hashtable h)
    throws NullPointerException {
    Vector v = new Vector();
    Enumeration e = h.keys();
    while (e.hasMoreElements()) {
        String k = e.nextElement().toString();
        v.add(k + "=" + h.get(k));
    }
    String[] strArr = new String[v.size()];
    v.copyInto(strArr);
    return strArr;
}
 
Example 12
Project: MaxSim   File: BuildConfig.java   View Source Code Vote up 5 votes
public Vector<String> matchesAdditionalGeneratedPath(String fullPath) {
    Vector<String> rv = new Vector<String>();
    Hashtable<String, String> v = (Hashtable<String, String>)BuildConfig.getField(this.toString(), "AdditionalGeneratedFile");
    if (v != null) {
        for (Enumeration<String> e=v.keys(); e.hasMoreElements(); ) {
            String key = e.nextElement();
            String val = v.get(key);

            if (fullPath.endsWith(expandFormat(key))) {
                rv.add(expandFormat(val));
            }
        }
    }
    return rv;
}
 
Example 13
Project: joai-project   File: RepositoryManager.java   View Source Code Vote up 5 votes
/**
 *  Gets all possible metadata formats that are available for a given ID.
 *
 * @param  id  The id for the record.
 * @return     The metadataFormats available.
 */
public List getAvailableFormatsList(String id) {
	Hashtable formats = getAvailableFormats(id);
	List fmts = new ArrayList(formats.size());
	Enumeration enumeration = formats.keys();

	while (enumeration.hasMoreElements())
		fmts.add(enumeration.nextElement());
	return fmts;
}
 
Example 14
Project: monarch   File: IntMapCheckJUnitTest.java   View Source Code Vote up 5 votes
static void entest3(Hashtable ht, int size) {
  int sum = 0;

  timer.start("Iterf Enumeration Key  ", size);
  Enumeration en = ht.keys();
  for (int i = 0; i < size; ++i) {
    if (en.nextElement() != MISSING)
      ++sum;
  }
  timer.finish();
  reallyAssert(sum == size);
}
 
Example 15
Project: openjdk-jdk10   File: BuildConfig.java   View Source Code Vote up 5 votes
public Vector<String> matchesAdditionalGeneratedPath(String fullPath) {
    Vector<String> rv = new Vector<String>();
    Hashtable<String, String> v = (Hashtable<String, String>)BuildConfig.getField(this.toString(), "AdditionalGeneratedFile");
    if (v != null) {
        for (Enumeration<String> e=v.keys(); e.hasMoreElements(); ) {
            String key = e.nextElement();
            String val = v.get(key);

            if (fullPath.endsWith(expandFormat(key))) {
                rv.add(expandFormat(val));
            }
        }
    }
    return rv;
}
 
Example 16
Project: Proyecto-DASI   File: TablaEstadosControl.java   View Source Code Vote up 5 votes
/**
 *  Expresa la tabla en texto
 *
 *@return    Texto con la tabla de estados
 */
public String toString()
{
	String dev = "LEYENDA:   Estado: input/accion -> estado siguiente";
	dev += "\n------------------------------------------------------";
	java.util.Enumeration nombres = clasificacionEstados.keys();

	String input = "";
	String accion = "";
	String estsig = "";
	String id = "";
	while (nombres.hasMoreElements())
	{
		id = (String) nombres.nextElement();

		Hashtable inp = (Hashtable) inputsDeEstados.get(id);
		if (!inp.isEmpty())
		{
			java.util.Enumeration inps = inp.keys();
			while (inps.hasMoreElements())
			{
				input = (String) inps.nextElement();
				Operacion op = (Operacion) inp.get(input);
				accion = op.accionSemantica;
				estsig = op.estadoSiguiente;
				dev += "\n" + id + ": " + input + " / " + accion + " -> " + estsig;
			}

		}
		else
		{
			dev += "\n" + id + " <- ES UN ESTADO FINAL";
		}

	}
	return dev += "\n------------------------------------------------------";
}
 
Example 17
Project: OpenJSharp   File: EnvironmentCheck.java   View Source Code Vote up 4 votes
/**
 * Dump a basic Xalan environment report to outWriter.
 *
 * <p>This dumps a simple header and then each of the entries in
 * the Hashtable to our PrintWriter; it does special processing
 * for entries that are .jars found in the classpath.</p>
 *
 * @param h Hashtable of items to report on; presumably
 * filled in by our various check*() methods
 * @return true if your environment appears to have no major
 * problems; false if potential environment problems found
 * @see #appendEnvironmentReport(Node, Document, Hashtable)
 * for an equivalent that appends to a Node instead
 */
protected boolean writeEnvironmentReport(Hashtable h)
{

  if (null == h)
  {
    logMsg("# ERROR: writeEnvironmentReport called with null Hashtable");
    return false;
  }

  boolean errors = false;

  logMsg(
    "#---- BEGIN writeEnvironmentReport($Revision: 1.10 $): Useful stuff found: ----");

  // Fake the Properties-like output
  for (Enumeration keys = h.keys();
       keys.hasMoreElements();
      /* no increment portion */
      )
  {
    Object key = keys.nextElement();
    String keyStr = (String) key;
    try
    {
      // Special processing for classes found..
      if (keyStr.startsWith(FOUNDCLASSES))
      {
        Vector v = (Vector) h.get(keyStr);
        errors |= logFoundJars(v, keyStr);
      }
      // ..normal processing for all other entries
      else
      {
        // Note: we could just check for the ERROR key by itself,
        //    since we now set that, but since we have to go
        //    through the whole hash anyway, do it this way,
        //    which is safer for maintenance
        if (keyStr.startsWith(ERROR))
        {
          errors = true;
        }
        logMsg(keyStr + "=" + h.get(keyStr));
      }
    }
    catch (Exception e)
    {
      logMsg("Reading-" + key + "= threw: " + e.toString());
    }
  }

  logMsg(
    "#----- END writeEnvironmentReport: Useful properties found: -----");

  return errors;
}
 
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: OpenJSharp   File: EnvironmentCheck.java   View Source Code Vote up 4 votes
/**
 * Print out report of .jars found in a classpath.
 *
 * Takes the information encoded from a checkPathForJars()
 * call and dumps it out to our PrintWriter.
 *
 * @param v Vector of Hashtables of .jar file info
 * @param desc description to print out in header
 *
 * @return false if OK, true if any .jars were reported
 * as having errors
 * @see #checkPathForJars(String, String[])
 */
protected boolean logFoundJars(Vector v, String desc)
{

  if ((null == v) || (v.size() < 1))
    return false;

  boolean errors = false;

  logMsg("#---- BEGIN Listing XML-related jars in: " + desc + " ----");

  for (int i = 0; i < v.size(); i++)
  {
    Hashtable subhash = (Hashtable) v.elementAt(i);

    for (Enumeration keys = subhash.keys();
         keys.hasMoreElements();
         /* no increment portion */
        )
    {
      Object key = keys.nextElement();
      String keyStr = (String) key;
      try
      {
        if (keyStr.startsWith(ERROR))
        {
          errors = true;
        }
        logMsg(keyStr + "=" + subhash.get(keyStr));

      }
      catch (Exception e)
      {
        errors = true;
        logMsg("Reading-" + key + "= threw: " + e.toString());
      }
    }
  }

  logMsg("#----- END Listing XML-related jars in: " + desc + " -----");

  return errors;
}
 
Example 20
Project: openjdk-jdk10   File: MyResource.java   View Source Code Vote up 4 votes
@Override
public Enumeration<String> getKeys() {
    final Hashtable<String, Object> h = new Hashtable<>(bundle);
    return h.keys();
}