List of usage examples for java.util Queue isEmpty
boolean isEmpty();
From source file:de.saxsys.synchronizefx.core.metamodel.executors.RepairingSingleValuePropertyCommandExecutor.java
@Override public void execute(final SetPropertyValue command) { @SuppressWarnings("unchecked") final Property<Object> property = (Property<Object>) objectRegistry.getByIdOrFail(command.getPropertyId()); final Queue<UUID> localCommands = propertyToChangeLog.get(property); if (!(localCommands == null || localCommands.isEmpty())) { if (localCommands.peek().equals(command.getCommandId())) { localCommands.poll();/* w w w .j ava2s .co m*/ } return; } executor.execute(command); }
From source file:com.stehno.sanctuary.core.scan.DefaultDirectoryScanner.java
/** * Scans the given directory for changes. The directory passed in will be used as the root * of the changeset and the stored files. * //from w ww . j ava 2 s.c om * @param directory * @return a populated change set. */ @Override public ChangeSet scanDirectory(final File directory) { Assert.isTrue(directory != null && directory.isDirectory(), "A non-null directory must be specified."); if (log.isDebugEnabled()) log.debug("Scanning: " + directory); final ChangeSet changeSet = new ChangeSet(directory); final Queue<File> directories = new LinkedList<File>(); directories.add(directory); while (!directories.isEmpty()) { final File scanningDir = directories.poll(); for (final File item : scanningDir.listFiles()) { if (item.isDirectory()) { directories.add(item); } else { changeSet.addFileStatus(localStore.fileStatus(item), item); } } } // figure out the deleted files for (final String path : localStore.listFilePaths()) { final File file = new File(path); if (!file.exists()) { changeSet.addFileStatus(FileStatus.DELETED, file); } } return changeSet; }
From source file:org.polymap.rhei.batik.engine.PanelContextInjector.java
@Override public void run() { Queue<Class> types = new ArrayDeque(16); types.add(panel.getClass());/*from ww w . j a va 2s . c o m*/ while (!types.isEmpty()) { Class type = types.remove(); if (type.getSuperclass() != null) { types.add(type.getSuperclass()); } for (Field f : type.getDeclaredFields()) { // ContextProperty if (Context.class.isAssignableFrom(f.getType())) { f.setAccessible(true); Type ftype = f.getGenericType(); if (ftype instanceof ParameterizedType) { // set try { f.set(panel, new ContextPropertyInstance(f, context)); log.debug("injected: " + f.getName() + " (" + panel.getClass().getSimpleName() + ")"); continue; } catch (Exception e) { throw new RuntimeException(e); } } else { throw new IllegalStateException("ContextProperty has no type param: " + f.getName()); } } // @Context annotation Scope annotation = f.getAnnotation(Scope.class); if (annotation != null) { f.setAccessible(true); throw new UnsupportedOperationException("Injecting context property as direct member."); // Object value = context.get( f.getType() ); // // try { // f.set( panel, value ); // log.info( "injected: " + f.getName() + " <- " + value ); // } // catch (Exception e) { // throw new RuntimeException( e ); // } } } } }
From source file:org.jboss.on.plugins.tomcat.test.TomcatPluginTest.java
private Set<Resource> findResource(Resource parent, String typeName) { Set<Resource> foundResources = new HashSet<Resource>(); Queue<Resource> discoveryQueue = new LinkedList<Resource>(); discoveryQueue.add(parent);//from w ww . j av a 2s . c o m while (!discoveryQueue.isEmpty()) { Resource currentResource = discoveryQueue.poll(); log.info("Discovered resource of type: " + currentResource.getResourceType().getName()); if (currentResource.getResourceType().getName().equals(typeName)) { foundResources.add(currentResource); } for (Resource child : currentResource.getChildResources()) { discoveryQueue.add(child); } } return foundResources; }
From source file:org.kuali.rice.krad.uif.util.ComponentUtils.java
public static void updateChildIdsWithSuffixNested(Component component, String idSuffix) { @SuppressWarnings("unchecked") Queue<LifecycleElement> elementQueue = RecycleUtils.getInstance(LinkedList.class); try {/* www .j ava 2 s. c o m*/ elementQueue.addAll(ViewLifecycleUtils.getElementsForLifecycle(component).values()); while (!elementQueue.isEmpty()) { LifecycleElement currentElement = elementQueue.poll(); if (currentElement == null) { continue; } if (currentElement instanceof Component) { updateIdWithSuffix((Component) currentElement, idSuffix); elementQueue.addAll(((Component) currentElement).getPropertyReplacerComponents()); } elementQueue.addAll(ViewLifecycleUtils.getElementsForLifecycle(currentElement).values()); } } finally { elementQueue.clear(); RecycleUtils.recycle(elementQueue); } }
From source file:com.comphenix.xp.parser.text.PresetParser.java
@Override public PresetQuery parse(String text) throws ParsingException { if (text.length() == 0) // Empty names are not legal in YAML, so this shouldn't be possible throw new IllegalArgumentException("Key must have some characters."); Queue<String> tokens = getParameterQueue(text); List<String> presetNames = textParsing.parse(tokens); List<String> worldNames = textParsing.parse(tokens); if (!tokens.isEmpty()) throw ParsingException.fromFormat("Unknown preset tokens: ", StringUtils.join(tokens, ", ")); return new PresetQuery(presetNames, worldNames); }
From source file:org.esigate.http.OutgoingRequestContext.java
/** * remove attribute and restore previous attribute value * /*w w w. j ava2s . co m*/ * @param id * attribute name * @param restore * restore previous attribute value * @return attribute value */ public Object removeAttribute(String id, boolean restore) { Object value = removeAttribute(id); if (restore) { String historyAttribute = id + "history"; Queue<Object> history = (Queue<Object>) getAttribute(historyAttribute); if (history != null && !history.isEmpty()) { Object previous = history.remove(); setAttribute(id, previous); } } return value; }
From source file:net.cellcloud.talk.HttpHeartbeatHandler.java
@Override protected void doGet(HttpRequest request, HttpResponse response) throws IOException { HttpSession session = request.getSession(); if (null != session) { // // w w w . j av a 2s.c o m session.heartbeat(); // ?? Queue<Message> queue = session.getQueue(); if (!queue.isEmpty()) { ArrayList<String> identifiers = new ArrayList<String>(queue.size()); ArrayList<Primitive> primitives = new ArrayList<Primitive>(queue.size()); for (int i = 0, size = queue.size(); i < size; ++i) { // ? Message message = queue.poll(); // Packet packet = Packet.unpack(message.get()); if (null != packet) { // ????? byte[] primData = packet.getSubsegment(0); ByteArrayInputStream stream = new ByteArrayInputStream(primData); // ??? Primitive prim = new Primitive(Nucleus.getInstance().getTagAsString()); prim.read(stream); // identifiers.add(Utils.bytes2String(packet.getSubsegment(1))); primitives.add(prim); } } JSONArray jsonPrimitives = this.convert(identifiers, primitives); JSONObject json = new JSONObject(); try { json.put(Primitives, jsonPrimitives); } catch (JSONException e) { Logger.log(getClass(), e, LogLevel.ERROR); } // ? this.respondWithOk(response, json); } else { this.respondWithOk(response); } } else { this.respond(response, HttpResponse.SC_INTERNAL_SERVER_ERROR); } }
From source file:org.wso2.carbon.dataservices.core.DBUtils.java
/** * This method is used to embed syntaxes associated with UDT attribute notations to * a queue of string tokens extracted from a UDT parameter. * * @param tokens Queue of string tokens * @param syntaxQueue Syntax embedded tokens * @param isIndex Flag to determine whether a particular string token is an inidex * or a column name/*from w w w .j av a 2 s . c o m*/ */ public static void getSyntaxEmbeddedQueue(Queue<String> tokens, Queue<String> syntaxQueue, boolean isIndex) { if (!tokens.isEmpty()) { if ("[".equals(tokens.peek())) { isIndex = true; tokens.poll(); syntaxQueue.add("INEDX_START"); syntaxQueue.add(tokens.poll()); } else if ("]".equals(tokens.peek())) { isIndex = false; tokens.poll(); syntaxQueue.add("INDEX_END"); } else if (".".equals(tokens.peek())) { tokens.poll(); syntaxQueue.add("DOT"); syntaxQueue.add("COLUMN"); syntaxQueue.add(tokens.poll()); } else { if (isIndex) { syntaxQueue.add("INDEX"); syntaxQueue.add(tokens.poll()); } else { syntaxQueue.add("COLUMN"); syntaxQueue.add(tokens.poll()); } } getSyntaxEmbeddedQueue(tokens, syntaxQueue, isIndex); } }
From source file:eu.stratosphere.nephele.streaming.taskmanager.runtime.chaining.StreamChain.java
@SuppressWarnings({ "rawtypes", "unchecked" }) void executeMapper(final Record record, final int chainIndex) throws Exception { final StreamChainLink chainLink = this.chainLinks.get(chainIndex); final Mapper mapper = chainLink.getMapper(); chainLink.getInputGate().reportRecordReceived(record, 0); mapper.map(record);/*ww w. j a v a2s. co m*/ final StreamOutputGate outputGate = chainLink.getOutputGate(); final Queue outputCollector = mapper.getOutputCollector(); if (chainIndex == this.chainLinks.size() - 1) { while (!outputCollector.isEmpty()) { outputGate.writeRecord((Record) outputCollector.poll()); } } else { while (!outputCollector.isEmpty()) { final Record outputRecord = (Record) outputCollector.poll(); outputGate.reportRecordEmitted(outputRecord); this.executeMapper(RecordUtils.createCopy(outputRecord), chainIndex + 1); } } }