@Override protected void initFlow(HierarchicalConfiguration flowCfg) { // int node = flowCfg.getInt("[@node]"); int inLink = flowCfg.getInt("[@inLink]", -1); int outLink = flowCfg.getInt("[@outLink]", -1); // int next = flowCfg.getInt("[@next]"); int no = flowCfg.getInt("[@no]", 0); Node node; Node next; if (inLink != -1) { Link link = idToLinkMap.get(Id.create(inLink, Link.class)); node = link.getFromNode(); next = link.getToNode(); } else { Link link = idToLinkMap.get(Id.create(outLink, Link.class)); node = link.getToNode(); next = link.getFromNode(); } int nodeId = Integer.parseInt(node.getId().toString()); int nextId = Integer.parseInt(next.getId().toString()); flows[nodeId] = new MATSimFlow(nodeId, inLink, outLink, nextId, no); }
// Called when we click on "release resource" button public void doFreeResource( StaplerRequest res, StaplerResponse rsp, @QueryParameter("resourceName") String resourceName) throws IOException, InterruptedException { // For each resource for (RessourcesMonitor rm : list) { // Check if the resource is the one chosen by the user if (rm.getRessource().equals(resourceName) && rm.getBuild()) { // Get the Id by resource name DefaultIdType p = new DefaultIdType(resourceName); // "null" for params not used // Only used to get the Id Id i = p.allocate(false, null, CriticalBlockStart.pam, null, null); // Cleanup only if the job is currently using the resource // So we get the name of the job that uses the resource and we look in the list AbstractBuild get = IdAllocationManager.ids.get(resourceName); if (get != null) { if (get.getProject().getName().equals(rm.getJobName())) { // Release resource i.cleanUp(); } } } } // Redirectsto the administration panel rsp.sendRedirect(res.getContextPath() + getUrlName()); }
private Charger createCharger(Attributes atts) { Id<Charger> id = Id.create(atts.getValue("id"), Charger.class); Link link = links.get(Id.createLinkId(atts.getValue("link"))); double power_kW = ReaderUtils.getDouble(atts, "power", DEFAULT_CHARGER_POWER_kW); int plugs = ReaderUtils.getInt(atts, "capacity", DEFAULT_CHARGER_CAPACITY); return new ChargerImpl(id, power_kW * EvUnitConversions.W_PER_kW, plugs, link); }
public void testId() throws Exception { AttributesImpl attributes = new AttributesImpl(); handler.startElement(null, null, "id", attributes); Id expected = new Id(); Id actual = (Id) stack.peek(); assertEquals(expected, actual); assertEquals("unknown", actual.process(null)); }
public static boolean isAutoIncrement(Field field) { Id id = field.getAnnotation(Id.class); if (id != null) { Class<?> type = field.getType(); // ONLY long ID can be auto_incremented if (id.value() == Generator.AUTO_INCREMENT && (Long.TYPE == type || Long.class.isAssignableFrom(type))) { return true; } } return false; }
private void buildId(Field field) { Class<?> type = field.getType(); Id id = field.getAnnotation(Id.class); if (id != null) { // ONLY long ID can be auto_incremented if (id.value() == Generator.AUTO_INCREMENT && (Long.TYPE == type || Long.class.isAssignableFrom(type))) { generatedKeys.add(field); } else { insertFields.add(field); } keys.add(field); allFields.add(field); allExtendedFields.add(field); } }
@POST @Consumes("application/json") public Response post(StaticAnnouncement announcement, @Context UriInfo uriInfo) { if (!nodeInfo.getEnvironment().equals(announcement.getEnvironment())) { return Response.status(BAD_REQUEST) .entity( format( "Environment mismatch. Expected: %s, Provided: %s", nodeInfo.getEnvironment(), announcement.getEnvironment())) .build(); } Id<Service> id = Id.random(); String location = Objects.firstNonNull(announcement.getLocation(), "/somewhere/" + id); Service service = Service.copyOf(announcement).setId(id).setLocation(location).build(); store.put(service); URI uri = UriBuilder.fromUri(uriInfo.getBaseUri()) .path(StaticAnnouncementResource.class) .path("{id}") .build(id); return Response.created(uri).entity(service).build(); }
@Override public Iterable<Measurement> measure() { final long timestamp = clock.wallTime(); final MemoryPoolMXBean mbean = ref.get(); final List<Measurement> ms = new ArrayList<>(); if (mbean != null) { final String typeKey = "memtype"; final String type = mbean.getName(); final MemoryUsage usage = mbean.getUsage(); ms.add(new Measurement(usedId.withTag(typeKey, type), timestamp, usage.getUsed())); ms.add(new Measurement(committedId.withTag(typeKey, type), timestamp, usage.getCommitted())); ms.add(new Measurement(maxId.withTag(typeKey, type), timestamp, usage.getMax())); } return ms; }
@Override public int hashCode() { int result = id != null ? id.hashCode() : 0; result = 31 * result + (type != null ? type.hashCode() : 0); result = 31 * result + (properties != null ? properties.hashCode() : 0); return result; }
@Bean public JLoadScenario exampleSimpleJaggerLoadScenario() { JTestDefinition jTestDefinition = JTestDefinition.builder(Id.of("td_example"), new ExampleEndpointsProvider()).build(); JLoadProfile jLoadProfileRps = JLoadProfileRps.builder(RequestsPerSecond.of(10)).withMaxLoadThreads(10).withWarmUpTimeInSeconds(10).build(); JTerminationCriteria jTerminationCriteria = JTerminationCriteriaIterations.of(IterationsNumber.of(500), MaxDurationInSeconds.of(30)); JLoadTest jLoadTest = JLoadTest.builder(Id.of("lt_example"), jTestDefinition, jLoadProfileRps, jTerminationCriteria).build(); JParallelTestsGroup jParallelTestsGroup = JParallelTestsGroup.builder(Id.of("ptg_example"), jLoadTest).build(); // To launch your load scenario, set 'jagger.load.scenario.id.to.execute' property's value equal to the load scenario id // You can do it via system properties or in the 'environment.properties' file return JLoadScenario.builder(Id.of("ls_example"), jParallelTestsGroup).build(); }
public static Proto.Node toProto(Node node) { return Proto.Node.newBuilder() .setId(Id.toProtoSpace(node.id)) .setX(node.position.x) .setY(node.position.y) .setColour(node.colour.colour) .build(); }
public void fromMap(Map<String, Object> m) { super.fromMap(m); String cls = Objects.get(String.class, m, "dataSource"); try { setDataSource((Class<? extends DistributedDataSource>) Class.forName(cls)); } catch (Throwable e) { throw S1SystemError.wrap(e); } }
public static List<ChargerLocation> createLocationsInZones(Iterable<Zone> zones, double power) { List<ChargerLocation> locations = new ArrayList<>(); for (Zone z : zones) { locations.add( new ChargerLocation(Id.create(z.getId(), ChargerLocation.class), z.getCoord(), power)); } return locations; }
/** * Creates a MondrianOlap4jCellSetAxisMetaData. * * @param cellSetMetaData Cell set axis metadata * @param queryAxis Query axis */ MondrianOlap4jCellSetAxisMetaData( MondrianOlap4jCellSetMetaData cellSetMetaData, QueryAxis queryAxis) { if (queryAxis == null) { queryAxis = new QueryAxis( false, null, AxisOrdinal.StandardAxisOrdinal.SLICER, QueryAxis.SubtotalVisibility.Undefined); } this.queryAxis = queryAxis; this.cellSetMetaData = cellSetMetaData; // populate property list for (Id id : queryAxis.getDimensionProperties()) { propertyList.add(Property.StandardMemberProperty.valueOf(id.toStringArray()[0])); } }
public static void init() { Add.init(); Address.init(); Align.init(); Alloc.init(); Anchor.init(); And.init(); Bad.init(); Bitcast.init(); Block.init(); Builtin.init(); Call.init(); Cmp.init(); Cond.init(); Confirm.init(); Const.init(); Conv.init(); CopyB.init(); Deleted.init(); Div.init(); Dummy.init(); End.init(); Eor.init(); Free.init(); IJmp.init(); Id.init(); Jmp.init(); Load.init(); Member.init(); Minus.init(); Mod.init(); Mul.init(); Mulh.init(); Mux.init(); NoMem.init(); Not.init(); Offset.init(); Or.init(); Phi.init(); Pin.init(); Proj.init(); Raise.init(); Return.init(); Sel.init(); Shl.init(); Shr.init(); Shrs.init(); Size.init(); Start.init(); Store.init(); Sub.init(); Switch.init(); Sync.init(); Tuple.init(); Unknown.init(); }
public Syntax internalDeepCopy(Token start, Token end) { Syntax copy = new DotMethodCallExp( start, end, (methodName == null ? null : (Id) methodName.internalDeepCopy(start, end)), (subpat == null ? null : (Cmd) subpat.internalDeepCopy(start, end))); return copy; }
@SuppressWarnings("unchecked") public static <T> T getEntity( final DbUtils db, final Cursor cursor, Class<T> entityType, long findCacheSequence) { if (db == null || cursor == null) return null; EntityTempCache.setSeq(findCacheSequence); try { Table table = Table.get(db, entityType); Id id = table.id; String idColumnName = id.getColumnName(); int idIndex = id.getIndex(); if (idIndex < 0) { idIndex = cursor.getColumnIndex(idColumnName); } Object idValue = id.getColumnConverter().getFieldValue(cursor, idIndex); T entity = EntityTempCache.get(entityType, idValue); if (entity == null) { entity = entityType.newInstance(); id.setValue2Entity(entity, cursor, idIndex); EntityTempCache.put(entityType, idValue, entity); } else { return entity; } int columnCount = cursor.getColumnCount(); for (int i = 0; i < columnCount; i++) { String columnName = cursor.getColumnName(i); Column column = table.columnMap.get(columnName); if (column != null) { column.setValue2Entity(entity, cursor, i); } } // init finder for (Finder finder : table.finderMap.values()) { finder.setValue2Entity(entity, null, 0); } return entity; } catch (Throwable e) { LogUtils.e(e.getMessage(), e); } return null; }
public Syntax internalDeepCopy(Token start, Token end) { Syntax copy = new ClsPatDef( start, end, (id == null ? null : (Id) id.internalDeepCopy(start, end)), (List<Id>) (deepCopyList(formals, start, end)), (body == null ? null : (Cmd) body.internalDeepCopy(start, end))); return copy; }
private void prepareMatrices(String statusMatrixFile) { wrs = new WeightedRandomSelection<Id<Zone>>(); Matrix avestatus = MatrixUtils.readMatrices(statusMatrixFile).getMatrix("avg"); for (Map.Entry<String, ArrayList<Entry>> fromLOR : avestatus.getFromLocations().entrySet()) { if (BerlinZoneUtils.isInBerlin(fromLOR.getKey())) { wrs.add( Id.create(fromLOR.getKey(), Zone.class), MatrixUtils.calculateTotalValue(fromLOR.getValue())); } } }
/** {@inheritDoc} */ @Override public boolean equals(final Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } return id.equals(((Node) obj).getId()); }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } DynamicServiceAnnouncement that = (DynamicServiceAnnouncement) o; if (id != null ? !id.equals(that.id) : that.id != null) { return false; } if (properties != null ? !properties.equals(that.properties) : that.properties != null) { return false; } if (type != null ? !type.equals(that.type) : that.type != null) { return false; } return true; }
public static void main(String[] args) { String dir = "d:\\PP-rad\\poznan\\"; String networkFile = dir + "network.xml"; String linkStats = dir + "40.linkstats.txt.gz"; String polygonFile = dir + "poznan_polygon\\poznan_city_polygon.shp"; boolean includeBorderLinks = false; String filteredLinkStats = dir + "40.linkstats-filtered.txt.gz"; Geometry polygonGeometry = PolygonBasedFilter.readPolygonGeometry(polygonFile); Predicate<Link> linkInsidePolygonPredicate = PolygonBasedFilter.createLinkInsidePolygonPredicate(polygonGeometry, includeBorderLinks); Scenario scenario = ScenarioUtils.createScenario(VrpConfigUtils.createConfig()); MatsimNetworkReader nr = new MatsimNetworkReader(scenario); nr.readFile(networkFile); Map<Id<Link>, ? extends Link> linkMap = scenario.getNetwork().getLinks(); try (BufferedReader br = IOUtils.getBufferedReader(linkStats); PrintWriter pw = new PrintWriter(IOUtils.getBufferedWriter(filteredLinkStats))) { String header = br.readLine(); pw.println(header); String line; while ((line = br.readLine()) != null) { String linkId = new StringTokenizer(line).nextToken(); // linkId - first column Link link = linkMap.get(Id.create(linkId, Link.class)); if (linkInsidePolygonPredicate.apply(link)) { pw.println(line); } } } catch (IOException e) { throw new RuntimeException(e); } }
public static Node fromProto(Proto.Node nodeProto) { return new Node( Id.fromProtoSpace(nodeProto.getId()), new Point(nodeProto.getX(), nodeProto.getY()), new NodeColour(nodeProto.getColour())); }
@Override public void inferType(Scope scope) { type.inferType(scope); setType(type.getType()); }
public String getId() { if (id == null) setId(_id.get$id()); return id; }
// 循环处理每个需要处理的程序对象 public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { // 定义一个文件输出流,用于生成额外的文件 PrintStream ps = null; try { // 遍历每个被@Persistent修饰的class文件 for (Element t : roundEnv.getElementsAnnotatedWith(Persistent.class)) { // 获取正在处理的类名 Name clazzName = t.getSimpleName(); // 获取类定义前的@Persistent Annotation Persistent per = t.getAnnotation(Persistent.class); // 创建文件输出流 ps = new PrintStream(new FileOutputStream(clazzName + ".hbm.xml")); // 执行输出 ps.println("<?xml version=\"1.0\"?>"); ps.println("<!DOCTYPE hibernate-mapping PUBLIC"); ps.println(" \"-//Hibernate/Hibernate " + "Mapping DTD 3.0//EN\""); ps.println(" \"http://www.hibernate.org/dtd/" + "hibernate-mapping-3.0.dtd\">"); ps.println("<hibernate-mapping>"); ps.print(" <class name=\"" + t); // 输出per的table()的值 ps.println("\" table=\"" + per.table() + "\">"); for (Element f : t.getEnclosedElements()) { // 只处理成员变量上的Annotation if (f.getKind() == ElementKind.FIELD) // ① { // 获取成员变量定义前的@Id Annotation Id id = f.getAnnotation(Id.class); // ② // 当@Id Annotation存在时输出<id.../>元素 if (id != null) { ps.println( " <id name=\"" + f.getSimpleName() + "\" column=\"" + id.column() + "\" type=\"" + id.type() + "\">"); ps.println(" <generator class=\"" + id.generator() + "\"/>"); ps.println(" </id>"); } // 获取成员变量定义前的@Property Annotation Property p = f.getAnnotation(Property.class); // ③ // 当@Property Annotation存在时输出<property.../>元素 if (p != null) { ps.println( " <property name=\"" + f.getSimpleName() + "\" column=\"" + p.column() + "\" type=\"" + p.type() + "\"/>"); } } } ps.println(" </class>"); ps.println("</hibernate-mapping>"); } } catch (Exception ex) { ex.printStackTrace(); } finally { if (ps != null) { try { ps.close(); } catch (Exception ex) { ex.printStackTrace(); } } } return true; }
/** {@inheritDoc} */ @Override public int hashCode() { return id.hashCode(); }
@Override protected void onPostExecute(String result) { // TODO Auto-generated method stub super.onPostExecute(result); Ed1.setText(""); Ed2.setText(""); Ed3.setText(""); Ed4.setText(""); if (done_is == true) { ConditionClas.Toastmethod(LogView.this, " " + MessageDisplay_Submit); } if (Methodcall.equalsIgnoreCase("submit")) { ConditionClas.Toastmethod(LogView.this, " " + MessageDisplay); } else if (Methodcall.equalsIgnoreCase("show")) { System.out.println("inside showLog_reps " + SiteList.Log_reps); System.out.println("inside show Exc_Namel " + SiteList.Exc_Name); System.out.println("inside showLog_Date " + SiteList.Log_Date); System.out.println("inside show Log_Ints " + SiteList.Log_Ints); System.out.println("inside show Log_Sets " + SiteList.Log_Sets); System.out.println("inside show exc_Name " + method(exc_Name)); Log_reps.clear(); Exc_Namel.clear(); Log_Date.clear(); Log_Ints.clear(); Log_Sets.clear(); for (int i = 0; i < SiteList.Exc_Name.size(); i++) { // if(SiteList.Exc_Name.get(i).toLowerCase(). // contains(method(exc_Name).toLowerCase())) if (SiteList.Exces_Id.get(i).toLowerCase().contains(Id.toLowerCase())) { Log_reps.add(SiteList.Log_reps.get(i)); Exc_Namel.add(SiteList.Exc_Name.get(i)); Log_Date.add(SiteList.Log_Date.get(i)); Log_Ints.add(SiteList.Log_Ints.get(i)); Log_Sets.add(SiteList.Log_Sets.get(i)); } } System.out.println("inside show"); System.out.println("inside showLog_reps " + Log_reps); System.out.println("inside show Exc_Namel " + Exc_Namel); System.out.println("inside showLog_Date " + Log_Date); System.out.println("inside show Log_Ints " + Log_Ints); System.out.println("inside show Log_Sets " + Log_Sets); System.out.println("StatusStatusStatus " + Status); System.out.println("MessageDisplay " + MessageDisplay); // if (Status.equalsIgnoreCase("success")) // // { System.out.println("inside if "); System.out.println("MessageDisplay " + MessageDisplay); Excercise.setAdapter(new CustomListExcercise()); // VideoList.setAdapter() VideoList.setAdapter(new CustomListVideo()); // } // // else // // { // System.out.println(" in side elese " + // "MessageDisplay "+MessageDisplay); // // twoValue[0] = " Error"; // VideoList.setAdapter(new ArrayAdapter<String>(LogView.this, // android.R.layout.simple_list_item_1 , // android.R.id.text1 ,twoValue )); // ConditionClas.Toastmethod(LogView.this, MessageDisplay); // // Excercise.setAdapter(new ArrayAdapter<String>(LogView.this, // android.R.layout.simple_list_item_1 , // android.R.id.text1 ,twoValue )); // ConditionClas.Toastmethod(LogView.this, MessageDisplay); // // // } /* This part checks is the log link hit was successful * so on basis of that it shall set an adapter */ if (StatusLog.equalsIgnoreCase("success")) { System.out.println("inside if StatusLog "); if (MesageList.length() > 0) { // SelectList.setAdapter(new CustomList()); updateTable(); } else { // SelectList.setAdapter(new ArrayAdapter<String>(LogView.this, // android.R.layout.simple_list_item_1 , // android.R.id.text1 ,SiteList.Error )); } } } dialog.dismiss(); }
public Model toMavenModel() { Model model = new Model(); model.setBuild(new Build()); model.setDescription(description); model.setUrl(url); model.setName(projectId.getArtifact()); model.setGroupId(projectId.getGroup()); model.setVersion(projectId.getVersion()); model.setArtifactId(projectId.getArtifact()); model.setModelVersion("4.0.0"); // parent if (parent != null) { model.setParent(parent); } model.setPackaging(packaging); if (properties != null) { Properties modelProperties = new Properties(); for (Property p : properties) { modelProperties.setProperty(p.getKey(), p.getValue()); } model.setProperties(modelProperties); } // Add jar repository urls. if (null != repositories) { for (String repoUrl : repositories.getRepositories()) { Repository repository = new Repository(); repository.setId(Integer.toString(repoUrl.hashCode())); repository.setUrl(repoUrl); model.addRepository(repository); } } // Add dependency management if (overrides != null) { DependencyManagement depMan = new DependencyManagement(); for (Id dep : overrides) { Dependency dependency = new Dependency(); dependency.setGroupId(dep.getGroup()); dependency.setArtifactId(dep.getArtifact()); dependency.setVersion(dep.getVersion()); // JVZ: We need to parse these dependency.setType("jar"); if (null != dep.getClassifier()) { dependency.setClassifier(dep.getClassifier()); } depMan.addDependency(dependency); } model.setDependencyManagement(depMan); } // Add project dependencies. if (deps != null) { for (Id dep : deps) { Dependency dependency = new Dependency(); dependency.setGroupId(dep.getGroup()); dependency.setArtifactId(dep.getArtifact()); dependency.setVersion(dep.getVersion()); // JVZ: We need to parse these dependency.setType("jar"); if (null != dep.getClassifier()) { dependency.setClassifier(dep.getClassifier()); } model.addDependency(dependency); } } if (modules != null) { model.setModules(modules); } if (pluginOverrides != null) { PluginManagement management = new PluginManagement(); management.setPlugins(pluginOverrides); model.getBuild().setPluginManagement(management); } if (plugins != null) { model.getBuild().setPlugins(plugins); } // Optional source dirs customization. if (dirs != null) { Build build = new Build(); String srcDir = dirs.get("src"); String testDir = dirs.get("test"); if (null != srcDir) build.setSourceDirectory(srcDir); if (null != testDir) build.setTestSourceDirectory(testDir); model.setBuild(build); } if (null != scm) { Scm scm = new Scm(); scm.setConnection(this.scm.getConnection()); scm.setDeveloperConnection(this.scm.getDeveloperConnection()); scm.setUrl(this.scm.getUrl()); model.setScm(scm); } return model; }
public static ChargerLocation createLocation(long id, double x, double y, double power) { return new ChargerLocation(Id.create(id, ChargerLocation.class), new Coord(x, y), power); }