List of usage examples for java.util Vector isEmpty
public synchronized boolean isEmpty()
From source file:org.freeplane.main.addons.AddOnProperties.java
private String getContentOfFirstElement(Vector<XMLElement> xmlElements) { if (xmlElements == null || xmlElements.isEmpty()) return null; return xmlElements.get(0).getContent(); }
From source file:org.freeplane.main.addons.AddOnProperties.java
private Map<String, String> parseAttributesToProperties(Vector<XMLElement> xmlElements) { if (xmlElements == null || xmlElements.isEmpty()) return Collections.emptyMap(); return propertiesToStringMap(xmlElements.get(0).getAttributes()); }
From source file:cm.aptoide.pt.RemoteInTab.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); File local_path = new File(LOCAL_PATH); if (!local_path.exists()) local_path.mkdir();/*w w w . java 2 s . c o m*/ File icon_path = new File(ICON_PATH); if (!icon_path.exists()) icon_path.mkdir(); db = new DbHandler(this); sPref = getSharedPreferences("aptoide_prefs", MODE_PRIVATE); prefEdit = sPref.edit(); prefEdit.putBoolean("update", true); prefEdit.commit(); myTabHost = getTabHost(); myTabHost.addTab(myTabHost.newTabSpec("avail") .setIndicator("Available", getResources().getDrawable(android.R.drawable.ic_menu_add)) .setContent(new Intent(this, TabAvailable.class))); myTabHost.addTab(myTabHost.newTabSpec("inst") .setIndicator("Installed", getResources().getDrawable(android.R.drawable.ic_menu_agenda)) .setContent(new Intent(this, TabInstalled.class))); myTabHost.addTab(myTabHost.newTabSpec("updt") .setIndicator("Updates", getResources().getDrawable(android.R.drawable.ic_menu_info_details)) .setContent(new Intent(this, TabUpdates.class))); myTabHost.setPersistentDrawingCache(ViewGroup.PERSISTENT_SCROLLING_CACHE); Vector<ServerNode> srv_lst = db.getServers(); if (srv_lst.isEmpty()) { Intent call = new Intent(this, ManageRepo.class); call.putExtra("empty", true); call.putExtra("uri", "http://apps.aptoide.org"); startActivityForResult(call, NEWREPO_FLAG); } Intent i = getIntent(); if (i.hasExtra("uri")) { Intent call = new Intent(this, ManageRepo.class); call.putExtra("uri", i.getStringExtra("uri")); startActivityForResult(call, NEWREPO_FLAG); } else if (i.hasExtra("newrepo")) { Intent call = new Intent(this, ManageRepo.class); call.putExtra("newrepo", i.getStringExtra("newrepo")); startActivityForResult(call, NEWREPO_FLAG); } }
From source file:org.uva.itast.TestOMRProcessor.java
/** * Check that the recognition do not generate any errors with current configuration * @param testPath/*from w w w . ja va 2s . co m*/ * @throws IOException * @throws ZipException */ private void detectErrors(File testPath) throws ZipException, IOException { Vector<PageImage> errores; // deteccin de errores processor.setMedianFilter(true); errores = processor.processPath(testPath.getAbsolutePath()); //se leen las pginas escaneadas assertTrue("Errors encountered" + errores, errores.isEmpty()); }
From source file:org.apache.axis.client.AdminClient.java
/** * submit the input stream's contents to the endpoint, return the results as a string. * The input stream is always closed after the call, whether the request worked or not * @param opts options -can be null//www . ja v a2 s . c om * @param input -input stream for request * @return * @throws Exception if the call was null * @throws AxisFault if the invocation returned an empty response */ public String process(Options opts, InputStream input) throws Exception { try { if (call == null) { //validate that the call is not null throw new Exception(Messages.getMessage("nullCall00")); } if (opts != null) { //process options if supplied processOpts(opts); } call.setUseSOAPAction(true); call.setSOAPActionURI("urn:AdminService"); Vector result = null; Object[] params = new Object[] { new SOAPBodyElement(input) }; result = (Vector) call.invoke(params); if (result == null || result.isEmpty()) { throw new AxisFault(Messages.getMessage("nullResponse00")); } SOAPBodyElement body = (SOAPBodyElement) result.elementAt(0); return body.toString(); } finally { input.close(); } }
From source file:org.freeplane.main.addons.AddOnProperties.java
protected List<String> parseBinaries(Vector<XMLElement> xmlElements) { final List<String> result = new ArrayList<String>(); if (xmlElements != null && !xmlElements.isEmpty()) { for (XMLElement xmlElement : xmlElements.get(0).getChildren()) { result.add(xmlElement.getAttribute("name", null)); }// ww w . j a v a 2s .c o m } return result; }
From source file:org.freeplane.main.addons.AddOnProperties.java
private List<String[]> parseDeinstallationRules(Vector<XMLElement> xmlElements) { final List<String[]> result = new ArrayList<String[]>(); if (xmlElements != null && !xmlElements.isEmpty()) { for (XMLElement xmlElement : xmlElements.get(0).getChildren()) { result.add(new String[] { xmlElement.getName(), xmlElement.getContent() }); }//from w w w.ja v a 2 s.c o m } return result; }
From source file:ca.uqac.info.trace.generation.PetriNetGenerator.java
@Override public EventTrace generate() { if (super.m_clockAsSeed) setSeed(System.currentTimeMillis()); EventTrace trace = new EventTrace(); RandomPicker<Transition> transition_picker = new RandomPicker<Transition>(super.m_random); // We choose the number of messages to produce int n_messages = super.m_random.nextInt(super.m_maxMessages + 1 - super.m_minMessages) + super.m_minMessages; for (int i = 0; i < n_messages; i++) { if (super.m_verboseLevel > 0) System.out.println("Generating message " + i); // Get enabled transitions Vector<Transition> enabled_trans = new Vector<Transition>(); for (Transition trans : m_transitions) { if (trans.isEnabled()) { enabled_trans.add(trans); }/*from w ww.j ava 2 s. co m*/ } if (enabled_trans.isEmpty()) { // No next state: we are in a dead end break; } // Pick one such transition Transition t = transition_picker.pick(enabled_trans); // Emit event Node n = trace.getNode(); Node n2 = trace.createElement("name"); Node n3 = trace.createTextNode(t.m_label); n2.appendChild(n3); n.appendChild(n2); Event e = new Event(n); trace.add(e); // Fire transition t.fire(); } return trace; }
From source file:org.xwiki.extension.repository.xwiki.internal.resources.AbstractExtensionRESTResource.java
protected BaseObject getExtensionVersionObject(XWikiDocument extensionDocument, String version) { if (version == null) { Vector<BaseObject> objects = extensionDocument .getObjects(XWikiRepositoryModel.EXTENSIONVERSION_CLASSNAME); if (objects.isEmpty()) { return null; } else {/* w ww .j av a 2 s . c o m*/ return objects.lastElement(); } } return extensionDocument.getObject(XWikiRepositoryModel.EXTENSIONVERSION_CLASSNAME, "version", version, false); }
From source file:edu.umn.cs.spatialHadoop.util.Parallel.java
public static <T> List<T> forEach(int start, int end, RunnableRange<T> r, int parallelism) throws InterruptedException { Vector<T> results = new Vector<T>(); if (end <= start) return results; final Vector<Throwable> exceptions = new Vector<Throwable>(); Thread.UncaughtExceptionHandler h = new Thread.UncaughtExceptionHandler() { public void uncaughtException(Thread th, Throwable ex) { exceptions.add(ex);//from w ww. j a v a 2s .c om } }; // Put an upper bound on parallelism to avoid empty ranges if (parallelism > (end - start)) parallelism = end - start; if (parallelism == 1) { // Avoid creating threads results.add(r.run(start, end)); } else { LOG.info("Creating " + parallelism + " threads"); final int[] partitions = new int[parallelism + 1]; for (int i_thread = 0; i_thread <= parallelism; i_thread++) partitions[i_thread] = i_thread * (end - start) / parallelism + start; final Vector<RunnableRangeThread<T>> threads = new Vector<RunnableRangeThread<T>>(); for (int i_thread = 0; i_thread < parallelism; i_thread++) { RunnableRangeThread<T> thread = new RunnableRangeThread<T>(r, partitions[i_thread], partitions[i_thread + 1]); thread.setUncaughtExceptionHandler(h); threads.add(thread); threads.lastElement().start(); } for (int i_thread = 0; i_thread < parallelism; i_thread++) { threads.get(i_thread).join(); results.add(threads.get(i_thread).getResult()); } if (!exceptions.isEmpty()) throw new RuntimeException(exceptions.size() + " unhandled exceptions", exceptions.firstElement()); } return results; }