Example usage for java.util Hashtable put

List of usage examples for java.util Hashtable put

Introduction

In this page you can find the example usage for java.util Hashtable put.

Prototype

public synchronized V put(K key, V value) 

Source Link

Document

Maps the specified key to the specified value in this hashtable.

Usage

From source file:Main.java

public static Hashtable<String, String> errorCodes() {
    Hashtable<String, String> errors = new Hashtable<String, String>(13);
    errors.put("ERR1", "Invalid data format and/or syntax!");
    errors.put("ERR2", "No data was sent!");
    errors.put("ERR3", "Invalid Command Sent!");
    errors.put("ERR4", "Missing/Empty Command Argument(s) Recvd.");
    errors.put("ERR5", "Invalid command syntax!");
    errors.put("ERR6", "Invalid Auth Syntax!");
    errors.put("ERR7", "Access Denied!");
    errors.put("ERR8", "Server Timeout, Too Busy to Handle Request!");
    errors.put("ERR9", "Unknown Data Transmission Error");
    errors.put("ERR10", "Auth required.");
    errors.put("ERR11", "Invalid Auth.");
    errors.put("ERR12", "Not logged in.");
    errors.put("ERR13", "Incorrect Username/Password!");
    errors.put("ERR14", "Invalid Login Command Syntax.");
    errors.put("ERR19", "Unknown Auth Error");
    return errors;
}

From source file:Main.java

public static Hashtable<String, String> errorCodes() {
    Hashtable<String, String> errors = new Hashtable<String, String>(13);
    errors.put("ERR1", "Invalid, null or missing data was passed by the client! (ErrCode=1)");
    errors.put("ERR2", "Invalid or missing data separator in client data. (ErrCode=2");
    errors.put("ERR3",
            "Data not formatted properly for the parser. Possible command/syntax mismatch. (ErrCode=3)");
    errors.put("ERR4", "Cient passed no discernable data. Possibly null. (ErrCode=4)");
    errors.put("ERR5",
            "Parsing Failed!! Client passed non-parsable data. No parameters/data-blocks were found, looks like data, really just gibberish. (ErrCode=5)");
    errors.put("ERR6", "Authentication: Invalid, missing or garbled command syntax! (ErrCode=6)");
    errors.put("ERR7",
            "Access to server denied! Reason: Server may be deactivated or have too many clients. (ErrCode=7)");
    errors.put("ERR8", "Authentication: IO exception occured while communicating with the server. (ErrCode=8)");
    errors.put("ERR9", "Invalid password was passed by the client, double check and try again. (ErrCode=9)");
    errors.put("ERR20", "SendBarcode: Received invalid, garbled or unknown response from server. (ErrCode=20)");
    errors.put("ERR21",
            "SendBarcode: Unknown exception occured while communicating with the server. (ErrCode=20)");
    errors.put("ERR99", "General Unknown exception has occured. (ErrCode=99)");
    errors.put("ERR50", "Invalid Host/IP. (ErrCode=50)");
    errors.put("ERR51", "Cannont connect to server. (ErrCode=51)");
    errors.put("ERR52", "Server Timeout, Too busy to handle request! (ErrCode=52)");
    errors.put("ERR101",
            "Server encountered an unknown error when attempting to 'type' the barcode. (ErrCode=101)");
    return errors;
}

From source file:CutPasteSample.java

public static Action findAction(Action actions[], String key) {
    Hashtable commands = new Hashtable();
    for (int i = 0; i < actions.length; i++) {
        Action action = actions[i];
        commands.put(action.getValue(Action.NAME), action);
    }/*from   ww  w.  j  a v  a2s  .c o  m*/
    return (Action) commands.get(key);
}

From source file:Main.java

/**
 * Create a Hashtable from a key, value, key, value... style
 * Enumeration.//from  w  w w  .j  a va2  s. c o  m
 */
public static Hashtable createHashtable(Enumeration e) {
    Hashtable result = new Hashtable();
    while (e.hasMoreElements())
        result.put(e.nextElement(), e.nextElement());
    return result;
}

From source file:Util.java

/*********************************************************************
* Removes duplicate elements from the array.
*********************************************************************/
public static Object[] removeDuplicates(Object[] array)
//////////////////////////////////////////////////////////////////////
{

    Hashtable hashtable = new Hashtable();

    for (int i = 0; i < array.length; i++) {
        hashtable.put(array[i], array[i]);
    }//from  w  ww  .j  av a2 s  . co m

    Object[] newArray = (Object[]) Array.newInstance(array.getClass().getComponentType(), hashtable.size());

    int index = 0;

    Enumeration enumeration = hashtable.elements();

    while (enumeration.hasMoreElements()) {
        newArray[index++] = enumeration.nextElement();
    }

    return newArray;
}

From source file:Main.java

/**
 * Method getHashtableFromVector./*from ww w  .j  a  va2s  .c  om*/
 * @param vector Vector
 * @return Hashtable
 */
public static Hashtable getHashtableFromVector(Vector vector) {
    Hashtable hashtable = new Hashtable(vector.size());

    for (int i = 0; i < vector.size(); i++) {
        hashtable.put(vector.elementAt(i), vector.elementAt(i));
    }

    return hashtable;
}

From source file:edu.harvard.mcz.imagecapture.BarcodeReadTest.java

public static String checkForBarcode(BufferedImage image) {
    // Check the entire image for a barcode and return.
    String returnValue = "";
    LuminanceSource source = new BufferedImageLuminanceSource(image);
    Result result;/*from  www . j  av a  2  s  .  c om*/
    BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
    try {
        QRCodeReader reader = new QRCodeReader();
        Hashtable<DecodeHintType, Object> hints = null;
        hints = new Hashtable<DecodeHintType, Object>(3);
        hints.put(DecodeHintType.TRY_HARDER, Boolean.TRUE);
        result = reader.decode(bitmap, hints);
        returnValue = result.getText();
    } catch (ReaderException e) {
        e.printStackTrace();
        returnValue = "";
    }
    return returnValue;
}

From source file:CutPasteSample.java

private static Action findAction(Action actions[], String key) {
    Hashtable<Object, Action> commands = new Hashtable<Object, Action>();
    for (int i = 0; i < actions.length; i++) {
        Action action = actions[i];
        commands.put(action.getValue(Action.NAME), action);
    }/*w  w w.j a va2 s  .co  m*/
    return commands.get(key);
}

From source file:Main.java

private static void collectPaths(String path, Hashtable<String, String> allPaths, Element el) {
    String newPath = path + el.getLocalName() + "/";
    allPaths.put(newPath, "1");
    for (Iterator<Element> it = childElements(el).iterator(); it.hasNext();)
        collectPaths(newPath, allPaths, it.next());
}

From source file:Main.java

protected static void expandTree(JTree tree, TreePath path, Hashtable lookedAt) {
    Object node = path.getLastPathComponent();
    if (lookedAt.containsKey(node))
        return;/*from   w  w w  .j  a  va  2  s . c o m*/
    lookedAt.put(node, node);

    Vector paths = new Vector();
    tree.makeVisible(path);
    int childCount = tree.getModel().getChildCount(node);
    for (int i = 0; i < childCount; i++) {
        Object child = tree.getModel().getChild(node, i);
        TreePath p = path.pathByAddingChild(child);
        expandTree(tree, p, lookedAt);
    }
}