List of usage examples for java.util Hashtable get
@SuppressWarnings("unchecked") public synchronized V get(Object key)
From source file:com.htm.query.jxpath.JXpathQueryEvaluator.java
public List<?> evaluateQuery(IQuery query) throws com.htm.exceptions.IllegalArgumentException { log.debug("JXPath: Evaluating XPath query '" + query.getQuery() + "' within context " + jXpathContext.getContextBean()); if (query instanceof XPathQueryImpl) { XPathQueryImpl xpath = (XPathQueryImpl) query; Hashtable<String, String> namespaces = xpath.getNamespaces(); if (namespaces != null) { for (String key : namespaces.keySet()) { this.jXpathContext.registerNamespace(key, namespaces.get(key)); }//from w w w . j a v a2 s. c o m } } try { // TODO if a jdom object is addressed by an xpath expression that is // no leaf node // then the values of all leaf nodes are returned. This ha to be // handled somehow // Object result = this.jXpathContext.getValue(query.getQuery()); // // /* Return empty list if xpath query doesn't match any property */ // if (result == null) { // log.debug("JXPath: Query didn't match"); // return new ArrayList<Object>(); // } else if (result instanceof List<?>) { // log.debug("JXPath: Query matched. Result type " // + result.getClass().getName()); // return (List<?>) result; // // } else { // log.debug("JXPath: Query matched. Result type " // + result.getClass().getName()); // List<Object> resultList = new ArrayList<Object>(); // resultList.add(result); // // return resultList; // } // if (log.isDebugEnabled()) { // log.debug("Evaluating all paths for query'" + query.getQuery() + "'"); // Iterator paths = this.jXpathContext.iteratePointers("/taskParentContext/properties/child::*"); // Pointer path; // while (paths.hasNext()) { // path = (Pointer) paths.next(); // log.debug("Path found: " + path.asPath()); // } // } ArrayList<Object> list = new ArrayList<Object>(); Iterator iterator = this.jXpathContext.iteratePointers(query.getQuery()); Pointer pointer; while (iterator.hasNext()) { pointer = (Pointer) iterator.next(); log.debug("JXPath pointer: " + pointer.asPath()); list.add(pointer.getNode()); } return list; } catch (Exception e) { log.error(e.getMessage(), e); throw new InvalidQueryException(e); } }
From source file:org.hdiv.web.multipart.HDIVMultipartResolver.java
/** * Return the multipart files as Map of field name to MultipartFile instance. *//*from w ww .ja v a2 s. c o m*/ public MultiValueMap<String, MultipartFile> getMultipartFileElements(Hashtable fileElements) { MultiValueMap<String, MultipartFile> multipartFiles = new LinkedMultiValueMap<String, MultipartFile>(); for (Object key : fileElements.keySet()) { multipartFiles.add((String) key, (MultipartFile) fileElements.get(key)); } return multipartFiles; }
From source file:eionet.gdem.dcm.business.StylesheetManager.java
/** * Gets conversion types/* ww w . j a v a 2s .c om*/ * @return Conversion types * @throws DCMException If an error occurs. */ public ConvTypeHolder getConvTypes() throws DCMException { ConvTypeHolder ctHolder = new ConvTypeHolder(); ArrayList convs; try { convs = new ArrayList(); Vector convTypes = convTypeDao.getConvTypes(); for (int i = 0; i < convTypes.size(); i++) { Hashtable hash = (Hashtable) convTypes.get(i); String conv_type = (String) hash.get("conv_type"); ConvType conv = new ConvType(); conv.setConvType(conv_type); convs.add(conv); } ctHolder.setConvTypes(convs); } catch (Exception e) { e.printStackTrace(); LOGGER.error("Error getting conv types", e); throw new DCMException(BusinessConstants.EXCEPTION_GENERAL); } return ctHolder; }
From source file:algorithm.F5SteganographyTest.java
@Test public void f5SteganographyAlgorithmTest() { try {// w w w. j av a 2 s . co m File carrier = TestDataProvider.JPG_FILE; File payload = TestDataProvider.TXT_FILE; F5Steganography algorithm = new F5Steganography(); // Test encapsulation: List<File> payloadList = new ArrayList<File>(); payloadList.add(payload); File outputFile = algorithm.encapsulate(carrier, payloadList); assertNotNull(outputFile); // Test restore: Hashtable<String, RestoredFile> outputHash = new Hashtable<String, RestoredFile>(); for (RestoredFile file : algorithm.restore(outputFile)) { outputHash.put(file.getName(), file); } assertEquals(outputHash.size(), 2); RestoredFile restoredCarrier = outputHash.get(carrier.getName()); RestoredFile restoredPayload = outputHash.get(payload.getName()); assertNotNull(restoredCarrier); assertNotNull(restoredPayload); // only original payload can be restored, not carrier assertEquals(FileUtils.checksumCRC32(payload), FileUtils.checksumCRC32(restoredPayload)); assertEquals(FileUtils.checksumCRC32(outputFile), FileUtils.checksumCRC32(restoredCarrier)); // check restoration metadata: assertEquals("" + carrier.getAbsolutePath(), restoredCarrier.originalFilePath); assertEquals("" + payload.getAbsolutePath(), restoredPayload.originalFilePath); assertEquals(algorithm, restoredCarrier.algorithm); // This can't be true for steganography algorithms: // assertTrue(restoredCarrier.checksumValid); assertTrue(restoredPayload.checksumValid); assertTrue(restoredCarrier.wasCarrier); assertFalse(restoredCarrier.wasPayload); assertTrue(restoredPayload.wasPayload); assertFalse(restoredPayload.wasCarrier); assertTrue(restoredCarrier.relatedFiles.contains(restoredPayload)); assertFalse(restoredCarrier.relatedFiles.contains(restoredCarrier)); assertTrue(restoredPayload.relatedFiles.contains(restoredCarrier)); assertFalse(restoredPayload.relatedFiles.contains(restoredPayload)); } catch (IOException e) { e.printStackTrace(); } }
From source file:algorithm.OpenStegoRandomLSBSteganographyTest.java
@Test public void openStegoRandomLsbSteganographyAlgorithmTest() { try {/*w w w. j a v a 2s . co m*/ File carrier = TestDataProvider.PNG_FILE; File payload = TestDataProvider.TXT_FILE; OpenStegoRandomLSBSteganography algorithm = new OpenStegoRandomLSBSteganography(); // Test encapsulation: List<File> payloadList = new ArrayList<File>(); payloadList.add(payload); File outputFile = algorithm.encapsulate(carrier, payloadList); assertNotNull(outputFile); // Test restore: Hashtable<String, RestoredFile> outputHash = new Hashtable<String, RestoredFile>(); for (RestoredFile file : algorithm.restore(outputFile)) { outputHash.put(file.getName(), file); } assertEquals(outputHash.size(), 2); RestoredFile restoredCarrier = outputHash.get(carrier.getName()); RestoredFile restoredPayload = outputHash.get(payload.getName()); assertNotNull(restoredCarrier); assertNotNull(restoredPayload); // can only restore original payload with this algorithm, not // carrier! assertEquals(FileUtils.checksumCRC32(payload), FileUtils.checksumCRC32(restoredPayload)); // check restoration metadata: assertEquals("" + carrier.getAbsolutePath(), restoredCarrier.originalFilePath); assertEquals("" + payload.getAbsolutePath(), restoredPayload.originalFilePath); assertEquals(algorithm, restoredCarrier.algorithm); // This can't be true for steganography algorithms: // assertTrue(restoredCarrier.checksumValid); assertTrue(restoredPayload.checksumValid); assertTrue(restoredCarrier.wasCarrier); assertFalse(restoredCarrier.wasPayload); assertTrue(restoredPayload.wasPayload); assertFalse(restoredPayload.wasCarrier); assertTrue(restoredCarrier.relatedFiles.contains(restoredPayload)); assertFalse(restoredCarrier.relatedFiles.contains(restoredCarrier)); assertTrue(restoredPayload.relatedFiles.contains(restoredCarrier)); assertFalse(restoredPayload.relatedFiles.contains(restoredPayload)); } catch (IOException e) { e.printStackTrace(); } }
From source file:de.micromata.genome.util.runtime.jndi.SimpleNamingContextBuilder.java
/** * Simple InitialContextFactoryBuilder implementation, creating a new SimpleNamingContext instance. * /*from w w w.j av a 2 s .c om*/ * @see SimpleNamingContext */ @Override public InitialContextFactory createInitialContextFactory(Hashtable<?, ?> environment) { if (activated == null && environment != null) { Object icf = environment.get(Context.INITIAL_CONTEXT_FACTORY); if (icf != null) { Class<?> icfClass; if (icf instanceof Class) { icfClass = (Class<?>) icf; } else if (icf instanceof String) { icfClass = resolveClassName((String) icf, getClass().getClassLoader()); } else { throw new IllegalArgumentException("Invalid value type for environment key [" + Context.INITIAL_CONTEXT_FACTORY + "]: " + icf.getClass().getName()); } if (!InitialContextFactory.class.isAssignableFrom(icfClass)) { throw new IllegalArgumentException("Specified class does not implement [" + InitialContextFactory.class.getName() + "]: " + icf); } try { return (InitialContextFactory) icfClass.newInstance(); } catch (Throwable ex) { throw new IllegalStateException("Cannot instantiate specified InitialContextFactory: " + icf, ex); } } } // Default case... return new InitialContextFactory() { @Override @SuppressWarnings("unchecked") public Context getInitialContext(Hashtable<?, ?> environment) { return new SimpleNamingContext("", boundObjects, (Hashtable<String, Object>) environment); } }; }
From source file:RedGreenGriffin.java
public BranchGroup createSceneGraph(int i) { System.out.println("Creating scene for: " + URLString); // Create the root of the branch graph BranchGroup objRoot = new BranchGroup(); try {/*ww w . j a v a 2 s. co m*/ Transform3D myTransform3D = new Transform3D(); myTransform3D.setTranslation(new Vector3f(+0.0f, -0.15f, -3.6f)); TransformGroup objTrans = new TransformGroup(myTransform3D); objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); Transform3D t = new Transform3D(); TransformGroup tg = new TransformGroup(t); tg.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); tg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objTrans.addChild(tg); URL url = new URL(URLString); ObjectFile f = new ObjectFile(); f.setFlags(ObjectFile.RESIZE | ObjectFile.TRIANGULATE | ObjectFile.STRIPIFY); System.out.println("About to load"); Scene s = f.load(url); Transform3D myTrans = new Transform3D(); myTrans.setTranslation(new Vector3f(eyeOffset, -eyeOffset, 0F)); TransformGroup mytg = new TransformGroup(myTrans); //mytg.addChild(s.getSceneGroup()); tg.addChild(mytg); Transform3D myTrans2 = new Transform3D(); myTrans2.setTranslation(new Vector3f(-eyeOffset, +eyeOffset, 0F)); TransformGroup mytg2 = new TransformGroup(myTrans2); //mytg2.addChild(s.getSceneGroup()); Hashtable table = s.getNamedObjects(); for (Enumeration e = table.keys(); e.hasMoreElements();) { Object key = e.nextElement(); System.out.println(key); Object obj = table.get(key); System.out.println(obj.getClass().getName()); Shape3D shape = (Shape3D) obj; //shape.setCapability(Shape3D.ALLOW_APPEARANCE_WRITE); Appearance ap = new Appearance(); Color3f black = new Color3f(0.0f, 0.0f, 0.0f); Color3f red = new Color3f(0.7f, .0f, .15f); Color3f green = new Color3f(0f, .7f, .15f); ap.setMaterial(new Material(green, black, green, black, 1.0f)); Appearance ap2 = new Appearance(); ap2.setMaterial(new Material(red, black, red, black, 1.0f)); float transparencyValue = 0.5f; TransparencyAttributes t_attr = new TransparencyAttributes(TransparencyAttributes.BLENDED, transparencyValue, TransparencyAttributes.BLEND_SRC_ALPHA, TransparencyAttributes.BLEND_ONE); ap2.setTransparencyAttributes(t_attr); ap2.setRenderingAttributes(new RenderingAttributes()); ap.setTransparencyAttributes(t_attr); ap.setRenderingAttributes(new RenderingAttributes()); // bg.addChild(ap); shape.setAppearance(ap); mytg2.addChild(new Shape3D(shape.getGeometry(), ap2)); mytg.addChild(new Shape3D(shape.getGeometry(), ap)); } tg.addChild(mytg2); System.out.println("Finished Loading"); BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0); Color3f light1Color = new Color3f(.9f, 0.9f, 0.9f); Vector3f light1Direction = new Vector3f(4.0f, -7.0f, -12.0f); DirectionalLight light1 = new DirectionalLight(light1Color, light1Direction); light1.setInfluencingBounds(bounds); objTrans.addChild(light1); // Set up the ambient light Color3f ambientColor = new Color3f(1.0f, .4f, 0.3f); AmbientLight ambientLightNode = new AmbientLight(ambientColor); ambientLightNode.setInfluencingBounds(bounds); objTrans.addChild(ambientLightNode); MouseRotate behavior = new MouseRotate(); behavior.setTransformGroup(tg); objTrans.addChild(behavior); // Create the translate behavior node MouseTranslate behavior3 = new MouseTranslate(); behavior3.setTransformGroup(tg); objTrans.addChild(behavior3); behavior3.setSchedulingBounds(bounds); KeyNavigatorBehavior keyNavBeh = new KeyNavigatorBehavior(tg); keyNavBeh.setSchedulingBounds(new BoundingSphere(new Point3d(), 1000.0)); objTrans.addChild(keyNavBeh); behavior.setSchedulingBounds(bounds); objRoot.addChild(objTrans); } catch (Throwable t) { System.out.println("Error: " + t); } return objRoot; }
From source file:info.novatec.testit.livingdoc.repository.FileSystemRepositoryTest.java
@SuppressWarnings("unchecked") private void assertNamesInHierarchy(Hashtable<Object, Object> branch, List<String> names) { Iterator<Object> iter = branch.keySet().iterator(); while (iter.hasNext()) { String name = (String) iter.next(); Vector<Object> child = (Vector<Object>) branch.get(name); assertTrue(names.contains(child.get(0))); assertNamesInHierarchy((Hashtable<Object, Object>) child.get(3), names); }// w w w .java2 s . co m }
From source file:org.hdiv.web.validator.AbstractEditableParameterValidator.java
/** * Obtains the errors from request detected by HDIV during the validation process of the editable parameters. * // www . ja v a 2 s . c o m * @param errors * errors detected by HDIV during the validation process of the editable parameters. */ @SuppressWarnings("unchecked") protected void validateEditableParameters(Errors errors) { RequestAttributes attr = RequestContextHolder.getRequestAttributes(); if (attr == null) { // This is not a web request return; } Hashtable<String, String[]> parameters = (Hashtable<String, String[]>) attr .getAttribute(Constants.EDITABLE_PARAMETER_ERROR, 0); if (parameters != null && parameters.size() > 0) { for (String param : parameters.keySet()) { String[] unauthorizedValues = parameters.get(param); this.rejectParamValues(param, unauthorizedValues, errors); } } }
From source file:hu.sztaki.lpds.dcibridge.util.io.HttpHandler.java
public InputStream getStream(Hashtable<String, String> pValue) throws IOException { List<NameValuePair> nvps = new ArrayList<NameValuePair>(); Enumeration<String> enm = pValue.keys(); String key;// w w w .jav a2s . c o m while (enm.hasMoreElements()) { key = enm.nextElement(); nvps.add(new BasicNameValuePair(key, pValue.get(key))); } httpPost.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8)); HttpResponse response = httpclient.execute(httpPost); HttpEntity entity = response.getEntity(); return entity.getContent(); }