List of usage examples for java.util Hashtable Hashtable
public Hashtable()
From source file:br.unifei.edu.eco009.steamlansync.cache.SteamCache.java
public static void bootstrap() { chunks = new Hashtable<String, HttpChunkContents>(); cache = JCS.getInstance("chunks"); }
From source file:Main.java
static Hashtable hashtableClone(Hashtable ht1, Hashtable ht2) { if (ht1 == null && ht2 == null) return null; Hashtable htresp = new Hashtable(); if (ht1 != null) { Enumeration e = ht1.keys(); while (e.hasMoreElements()) { Object element = e.nextElement(); htresp.put(element, ht1.get(element)); }/* www.jav a2 s .c o m*/ } if (ht2 != null) { Enumeration e = ht2.keys(); while (e.hasMoreElements()) { Object element = e.nextElement(); htresp.put(element, ht2.get(element)); } } return htresp; }
From source file:Main.java
/** * Create a Hashtable from a key, value, key, value... style * Enumeration.//from w w w . j ava 2s .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:Main.java
public static <K, V> Hashtable<K, V> newHashtable() { return new Hashtable<K, V>(); }
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 .jav a 2 s . com*/ 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
private static ByteBuffer convertImageData(BufferedImage bufferedImage) { ByteBuffer imageBuffer;//from w w w. ja v a 2s . co m WritableRaster raster; BufferedImage texImage; // for a texture if (bufferedImage.getColorModel().hasAlpha()) { raster = Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE, bufferedImage.getWidth(), bufferedImage.getHeight(), 4, null); texImage = new BufferedImage(glAlphaColorModel, raster, false, new Hashtable<Object, Object>()); } else { raster = Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE, bufferedImage.getWidth(), bufferedImage.getHeight(), 3, null); texImage = new BufferedImage(glColorModel, raster, false, new Hashtable<Object, Object>()); } // copy the source image into the produced image Graphics g = texImage.getGraphics(); g.setColor(new Color(0f, 0f, 0f, 0f)); g.fillRect(0, 0, bufferedImage.getWidth(), bufferedImage.getHeight()); g.drawImage(bufferedImage, 0, 0, null); // build a byte buffer from the temporary image // that be used by OpenGL to produce a texture. byte[] data = ((DataBufferByte) bufferedImage.getRaster().getDataBuffer()).getData(); imageBuffer = ByteBuffer.allocateDirect(data.length); imageBuffer.order(ByteOrder.nativeOrder()); imageBuffer.put(data, 0, data.length); imageBuffer.flip(); return imageBuffer; }
From source file:Main.java
/** * Applies a stylesheet to a given xml document. * * @param xmlDocument the xml document to be transformed * @param xsltFilename the filename of the stylesheet * @return the transformed xml document/* w w w . j a va2 s. c o m*/ * @throws Exception */ public static Document transformDocument(Document xmlDocument, String xsltFilename) throws TransformerException, ParserConfigurationException { return transformDocument(xmlDocument, new Hashtable<String, String>(), xsltFilename); }
From source file:Main.java
public static Hashtable<Integer, Vector<Integer>> getNodeMembership(final Vector<Vector<Integer>> CmtyVV) { Hashtable<Integer, Vector<Integer>> NIDComVH = new Hashtable<Integer, Vector<Integer>>(); for (int CID = 0; CID < CmtyVV.size(); CID++) { for (Integer NID : CmtyVV.get(CID)) { if (!NIDComVH.contains(NID)) { Vector<Integer> v = new Vector<Integer>(); v.add(CID);//from w w w. j a va 2 s.c o m NIDComVH.put(NID, v); } else { Vector<Integer> v = NIDComVH.get(NID); v.add(CID); NIDComVH.put(NID, v); } } } return NIDComVH; }
From source file:Main.java
public static Hashtable parameterMapToHashtable(Map m) { Hashtable ret = new Hashtable(); ret.putAll(m);//ww w . j av a2s. com for (Iterator i = ret.keySet().iterator(); i.hasNext();) { Object key = i.next(); String[] value = (String[]) ret.get(key); try { ret.put(key, value[0]); } catch (ArrayIndexOutOfBoundsException e) { // This should not happen but if it does just continue // processing. } } return ret; }
From source file:Main.java
public static Hashtable emptyIfNull(Hashtable h) { return h == null ? new Hashtable() : h; }