public final int[] getIntArray(int argLength) { if (!aints.containsKey(argLength)) { aints.put(argLength, new int[argLength]); } assert (aints.get(argLength).length == argLength) : "Array not built with correct length"; return aints.get(argLength); }
private static final String coarsenUPOSTag(String uPOS) { if (coarserUPOSMap.containsKey(uPOS)) { return coarserUPOSMap.get(uPOS); } return uPOS; }
void putSanitizeName(RType rType, String sanitizeName, String rawName) { HashMap<String, String> sanitizeNameMap; if (!sanitizeTypeMap.containsKey(rType)) { sanitizeNameMap = new HashMap<>(); sanitizeTypeMap.put(rType, sanitizeNameMap); } else { sanitizeNameMap = sanitizeTypeMap.get(rType); } if (!sanitizeNameMap.containsKey(sanitizeName)) { sanitizeNameMap.put(sanitizeName, rawName); } }
public static <V> HashMap<V, Integer> multi_set(List<V> list) { HashMap<V, Integer> rtn = new HashMap<>(); for (V v : list) { int cnt = 1; if (rtn.containsKey(v)) { cnt += rtn.get(v); } rtn.put(v, cnt); } return rtn; }
HashMap<ByteBuffer, byte[]> kvs = new HashMap<ByteBuffer, byte[]>(); byte[] k1 = new byte[]{1,2 ,3}; byte[] k2 = new byte[]{1,2 ,3}; byte[] val = new byte[]{12,23,43,4}; kvs.put(ByteBuffer.wrap(k1), val); System.out.println(kvs.containsKey(ByteBuffer.wrap(k2)));
void addAlias(String alias) throws IllegalArgumentException { names.add(alias); if (options.containsKey(alias)) { throw new IllegalArgumentException("** Programmer error! Option " + alias + " already defined"); } options.put(alias, this); }
/** Returns the old values of any changed properties. */ public List<Object> getOldValues() { List<Object> oldValues = new ArrayList<Object>(); for (String propertyName : getDirtyProperties()) { if (oldCollectionValues().containsKey(propertyName)) { oldValues.add(oldCollectionValues.get(propertyName)); } else { try { Method g = getter(propertyName); if (g == null) { throw new IllegalArgumentException("No such property: " + propertyName); } oldValues.add(g.invoke(proxyObject, null)); } catch (Exception e) { throw new RuntimeException(e); } } } return oldValues; }
private void handleUpload(final HttpServletRequest req, final HttpServletResponse resp, final Map<String, Object> multipart, final Session session) throws ServletException, IOException { final HashMap<String, String> ret = new HashMap<>(); final String projectName = (String) multipart.get("project"); ajaxHandleUpload(req, resp, ret, multipart, session); if (ret.containsKey("error")) { setErrorMessageInCookie(resp, ret.get("error")); } if (ret.containsKey("warn")) { setWarnMessageInCookie(resp, ret.get("warn")); } resp.sendRedirect(req.getRequestURI() + "?project=" + projectName); }
@Override public ValueNumberFrame getFactAfterLocation(Location location) { if (TRACE) { System.out.println("getting fact after " + location); } ValueNumberFrame fact = factAfterLocationMap.get(location); if (fact == null) { if (TRACE) { System.out .println("Initialized fact after " + location + " @ " + Integer.toHexString(System.identityHashCode(location)) + " in " + Integer.toHexString(System.identityHashCode(this)) + " : " + factAfterLocationMap.containsKey(location)); } fact = createFact(); makeFactTop(fact); factAfterLocationMap.put(location, fact); } return fact; }
/** * @ast method * @aspect InnerClasses * @declaredat /Users/eric/Documents/workspaces/clara-soot/JastAddJ/Java1.4Backend/InnerClasses.jrag:173 */ public ASTNode getAccessor(ASTNode source, String name) { ArrayList key = new ArrayList(2); key.add(source); key.add(name); if (accessorMap == null || !accessorMap.containsKey(key)) return null; return (ASTNode) accessorMap.get(key); }
public static Request addToNavbar(Request r, String name) { assert (!_navbar.containsKey(name)); ArrayList<MenuItem> arl = new ArrayList(); boolean useNewTab = false; arl.add(new MenuItem(r, name, useNewTab)); _navbar.put(name, arl); _navbarOrdering.add(name); return r; }
private soot.SootMethod addGetMethodAccessMeth(soot.SootClass conClass, polyglot.ast.Call call) { if ((InitialResolver.v().getPrivateMethodGetAccessMap() != null) && (InitialResolver.v().getPrivateMethodGetAccessMap() .containsKey(new polyglot.util.IdentityKey(call.methodInstance())))) { return InitialResolver.v().getPrivateMethodGetAccessMap().get(new polyglot.util.IdentityKey(call.methodInstance())); } String name = "access$" + soot.javaToJimple.InitialResolver.v().getNextPrivateAccessCounter() + "00"; ArrayList paramTypes = new ArrayList(); if (!call.methodInstance().flags().isStatic()) { // add this param type // paramTypes.add(Util.getSootType(call.methodInstance().container())); paramTypes.add(conClass.getType()); } ArrayList sootParamsTypes = getSootParamsTypes(call); paramTypes.addAll(sootParamsTypes); soot.SootMethod meth = Scene.v().makeSootMethod(name, paramTypes, Util.getSootType(call.methodInstance().returnType()), soot.Modifier.STATIC); PrivateMethodAccMethodSource pmams = new PrivateMethodAccMethodSource(call.methodInstance()); conClass.addMethod(meth); meth.setActiveBody(pmams.getBody(meth, null)); InitialResolver.v().addToPrivateMethodGetAccessMap(call, meth); meth.addTag(new soot.tagkit.SyntheticTag()); return meth; }
@Override public Double getCost( Relationship relationship, Direction direction ) { if ( !dirs.containsKey( relationship ) ) { dirs.put( relationship, direction ); } return 1.0; } }
public static <V> HashMap<V, Integer> multi_set(List<V> list) { HashMap<V, Integer> rtn = new HashMap<V, Integer>(); for (V v : list) { int cnt = 1; if (rtn.containsKey(v)) { cnt += rtn.get(v); } rtn.put(v, cnt); } return rtn; }
public synchronized <T> AopFactory addMapping(Class<T> from, Class<? extends T> to) { if (from == null || to == null) { throw new IllegalArgumentException("The parameter from and to can not be null"); } if (mapping == null) { mapping = new HashMap<Class<?>, Class<?>>(128, 0.25F); } else if (mapping.containsKey(from)) { throw new RuntimeException("Class already mapped : " + from.getName()); } mapping.put(from, to); return this; }
if(getPoints().size() != shape.getPoints().size()) return false; if(DEBUG) System.out.println("comparing shapes:"); if(DEBUG) System.out.println("points1: "); HashMap points1 = new HashMap(); Iterator it = getPointsIterator(); while(it.hasNext()){ ShapePoint point = (ShapePoint) it.next(); points1.put( ""+((int) point.x)+","+((int) point.y), null); if(DEBUG) System.out.println(((int) point.x)+", "+((int) point.y)); if(DEBUG) System.out.println("points2: "); HashMap points2 = new HashMap(); it = shape.getPointsIterator(); while(it.hasNext()){ ShapePoint point = (ShapePoint) it.next(); points2.put( ""+((int) point.x)+","+((int) point.y), null); if(DEBUG) System.out.println(((int) point.x)+", "+((int) point.y)); while(it.hasNext()){ String key = (String) it.next(); if(!points2.containsKey(key)) { if (DEBUG) System.out.println("\tare not equal");
public final float[] getFloatArray(int argLength) { if (!afloats.containsKey(argLength)) { afloats.put(argLength, new float[argLength]); } assert (afloats.get(argLength).length == argLength) : "Array not built with correct length"; return afloats.get(argLength); }
if ( distances.containsKey( node ) ) distances.put( node, (int) depth ); if ( !distances.containsKey( targetNode ) ) targetPreds.add( relationship );
public void createAndSetScheduleOptions(final Object obj) { final HashMap<String, Object> schedObj = (HashMap<String, Object>) obj; if (schedObj.containsKey("executionOptions")) { final ExecutionOptions execOptions = ExecutionOptions.createFromObject(schedObj.get("executionOptions")); this.executionOptions = execOptions; } else if (schedObj.containsKey("flowOptions")) { final ExecutionOptions execOptions = ExecutionOptions.createFromObject(schedObj.get("flowOptions")); this.executionOptions = execOptions; execOptions.setConcurrentOption(ExecutionOptions.CONCURRENT_OPTION_SKIP); } else { this.executionOptions = new ExecutionOptions(); this.executionOptions .setConcurrentOption(ExecutionOptions.CONCURRENT_OPTION_SKIP); } if (schedObj.containsKey("slaOptions")) { final List<Object> slaOptionsObject = (List<Object>) schedObj.get("slaOptions"); final List<SlaOption> slaOptions = new ArrayList<>(); for (final Object slaObj : slaOptionsObject) { slaOptions.add(SlaOption.fromObject(slaObj)); } this.slaOptions = slaOptions; } }
public static Edge fromObject(final Object obj) { final HashMap<String, Object> edgeObj = (HashMap<String, Object>) obj; final String source = (String) edgeObj.get("source"); final String target = (String) edgeObj.get("target"); final String error = (String) edgeObj.get("error"); final Edge edge = new Edge(source, target); edge.setError(error); if (edgeObj.containsKey("guides")) { final Map<String, Object> guideMap = (Map<String, Object>) edgeObj.get("guides"); final List<Object> values = (List<Object>) guideMap.get("values"); final String type = (String) guideMap.get("type"); final ArrayList<Point2D> valuePoints = new ArrayList<>(); for (final Object pointObj : values) { final Map<String, Double> point = (Map<String, Double>) pointObj; final Double x = point.get("x"); final Double y = point.get("y"); valuePoints.add(new Point2D.Double(x, y)); } edge.setGuides(type, valuePoints); } return edge; }