List of usage examples for java.util ArrayDeque ArrayDeque
public ArrayDeque()
From source file:net.sf.jasperreports.engine.json.expression.member.evaluation.ArraySliceExpressionEvaluator.java
private List<JRJsonNode> goAnywhereDown(JRJsonNode jrJsonNode) { List<JRJsonNode> result = new ArrayList<>(); Deque<JRJsonNode> stack = new ArrayDeque<>(); if (log.isDebugEnabled()) { log.debug("initial stack population with: " + jrJsonNode.getDataNode()); }// w ww.j av a 2 s . c om // populate the stack initially stack.push(jrJsonNode); while (!stack.isEmpty()) { JRJsonNode stackNode = stack.pop(); JsonNode stackDataNode = stackNode.getDataNode(); addChildrenToStack(stackNode, stack); // process the current stack item if (stackDataNode.isArray()) { if (log.isDebugEnabled()) { log.debug("processing stack element: " + stackDataNode); } ArrayNode newNode = getEvaluationContext().getObjectMapper().createArrayNode(); Integer start = getSliceStart(stackDataNode.size()); if (start >= stackDataNode.size()) { continue; } Integer end = getSliceEnd(stackDataNode.size()); if (end < 0) { continue; } for (int i = start; i < end; i++) { JRJsonNode nodeAtIndex = stackNode.createChild(stackDataNode.get(i)); if (applyFilter(nodeAtIndex)) { newNode.add(nodeAtIndex.getDataNode()); } } if (newNode.size() > 0) { result.add(stackNode.createChild(newNode)); } } } return result; }
From source file:com.redhat.lightblue.util.Error.java
private Error(String errorCode, String msg) { this.context = new ArrayDeque<>(); this.errorCode = errorCode; this.msg = msg; }
From source file:org.polymap.model2.store.geotools.FeatureTypeBuilder.java
protected ComplexType buildComplexType(Class<? extends Composite> compositeClass, String indent) throws Exception { // fields -> properties Collection<PropertyDescriptor> properties = new ArrayList(); // super classes and mixins Deque<Class> stack = new ArrayDeque(); stack.push(compositeClass);/* ww w . ja va 2 s. c o m*/ while (!stack.isEmpty()) { Class type = stack.pop(); log.debug(indent + "Composite: " + type); // super class if (type.getSuperclass() != null && !Entity.class.equals(type.getSuperclass()) && !Composite.class.equals(type.getSuperclass())) { stack.push(type.getSuperclass()); } // mixins CompositeInfoImpl typeInfo = new CompositeInfoImpl(type); //log.debug( indent + " " + "Mixins: " + typeInfo.getMixins() ); stack.addAll(typeInfo.getMixins()); // fields for (Field field : type.getDeclaredFields()) { // Property or CollectionProperty if (Property.class.isAssignableFrom(field.getType()) || CollectionProperty.class.isAssignableFrom(field.getType())) { PropertyInfoImpl propInfo = new PropertyInfoImpl(field); Class<?> binding = propInfo.getType(); // attribute if (binding.isPrimitive() || binding.equals(String.class) || Number.class.isAssignableFrom(binding) || Boolean.class.isAssignableFrom(binding) || Date.class.isAssignableFrom(binding) || binding.isEnum()) { if (binding.isEnum()) { binding = String.class; } AttributeType propType = buildAttributeType(field, binding); AttributeDescriptor desc = factory.createAttributeDescriptor(propType, propType.getName(), 0, propInfo.getMaxOccurs(), propInfo.isNullable(), propInfo.getDefaultValue()); properties.add(desc); log.debug(indent + " " + "Attribute: " + desc); } // geometry else if (Geometry.class.isAssignableFrom(binding)) { AttributeType propType = buildAttributeType(field, binding); GeometryType geomType = factory.createGeometryType(propType.getName(), propType.getBinding(), crs, propType.isIdentified(), propType.isAbstract(), propType.getRestrictions(), propType.getSuper(), propType.getDescription()); GeometryDescriptor desc = factory.createGeometryDescriptor(geomType, geomType.getName(), 0, 1, propInfo.isNullable(), propInfo.getDefaultValue()); properties.add(desc); log.debug(indent + " " + "Geometry: " + desc); } // complex else if (Composite.class.isAssignableFrom(binding)) { ComplexType propType = buildComplexType((Class<? extends Composite>) binding, indent + " "); AttributeDescriptor desc = factory.createAttributeDescriptor(propType, nameInStore(field), 0, propInfo.getMaxOccurs(), propInfo.isNullable(), propInfo.getDefaultValue()); properties.add(desc); log.debug(indent + " " + "Complex Property: " + desc); } else { throw new RuntimeException("Property value type is not supported: " + binding); } } } } NameInStore nameInStore = compositeClass.getAnnotation(NameInStore.class); Name name = buildName(nameInStore != null ? nameInStore.value() : compositeClass.getSimpleName()); boolean isIdentified = false; boolean isAbstract = false; List<Filter> restrictions = null; AttributeType superType = null; Description annotation = compositeClass.getAnnotation(Description.class); InternationalString description = annotation != null ? SimpleInternationalString.wrap(annotation.value()) : null; return factory.createComplexType(name, properties, isIdentified, isAbstract, restrictions, superType, description); }
From source file:eu.stratosphere.nephele.jobmanager.scheduler.RecoveryLogic.java
private static void findVerticesToRestart(final ExecutionVertex failedVertex, final Set<ExecutionVertex> verticesToBeCanceled) { final Queue<ExecutionVertex> verticesToTest = new ArrayDeque<ExecutionVertex>(); final Set<ExecutionVertex> visited = new HashSet<ExecutionVertex>(); verticesToTest.add(failedVertex);// w w w . j av a 2 s.co m while (!verticesToTest.isEmpty()) { final ExecutionVertex vertex = verticesToTest.poll(); // Predecessors must be either checkpoints or need to be restarted, too for (int j = 0; j < vertex.getNumberOfPredecessors(); j++) { final ExecutionVertex predecessor = vertex.getPredecessor(j); if (hasInstanceAssigned(predecessor)) { verticesToBeCanceled.add(predecessor); } if (!visited.contains(predecessor)) { verticesToTest.add(predecessor); } } visited.add(vertex); } }
From source file:org.apache.metron.common.stellar.StellarCompiler.java
public StellarCompiler(final ArithmeticEvaluator arithmeticEvaluator, final NumberLiteralEvaluator numberLiteralEvaluator, final ComparisonExpressionWithOperatorEvaluator comparisonExpressionWithOperatorEvaluator) { this(new Expression(new ArrayDeque<>()), arithmeticEvaluator, numberLiteralEvaluator, comparisonExpressionWithOperatorEvaluator); }
From source file:io.inkstand.jcr.util.JCRContentHandler.java
/** * Creates a new content handler using the specified session for performing the input * * @param session/*from w w w.j a v a2s . c o m*/ * the JCR session bound to a user with sufficient privileges to perform the content loader operation */ public JCRContentHandler(final Session session) { this.session = session; nodeStack = new ArrayDeque<>(); textStack = new ArrayDeque<>(); propertyStack = new ArrayDeque<>(); }
From source file:com.github.beardlybread.orgestrator.io.GoogleDriveApi.java
@Override public void onCreate(Bundle b) { super.onCreate(b); this.requestHistory = new ArrayDeque<>(); this.initialize(); }
From source file:org.xwiki.xdomviz.Main.java
/** * <p>/*from w w w. ja va 2s . c o m*/ * This method creates an isomorphic tree using node structures instead of blocks. This is necessary because a * single XDOM's block can be a child of multiple parents but the getParent() method is able to return only a single * parent. Using this alternative representation, full parent information is correctly stored in each node. * </p> * <p> * The node tree representation allows also the manipulation of the tree structure because all the attributes of a * node are mutable. * </p> * * @param xdom * @return The root node of the new tree. */ private static Node createNodeTree(XDOM xdom) { // The list of the nodes created from the visited XDOM's blocks. List<Node> nodes = new ArrayList<Node>(); // Breadth first visit of the XDOM. Queue<Block> blocksQueue = new ArrayDeque<Block>(); blocksQueue.add(xdom.getRoot()); while (!blocksQueue.isEmpty()) { Block block = blocksQueue.poll(); // If there isn't a node corresponding to this block, create it! Node parentNode = findNode(nodes, block); if (parentNode == null) { parentNode = new Node(block); nodes.add(parentNode); } for (Block child : block.getChildren()) { blocksQueue.add(child); // If there isn't a node corresponding to this child-block, create it! Node childNode = findNode(nodes, child); if (childNode == null) { childNode = new Node(child); nodes.add(childNode); } // Link parent and child child. parentNode.getChildren().add(childNode); childNode.getParents().add(parentNode); } } return findNode(nodes, xdom.getRoot()); }
From source file:org.talend.dataprep.transformation.actions.text.Split.java
@Override public void compile(ActionContext context) { super.compile(context); if (context.getActionStatus() == ActionContext.ActionStatus.OK) { if (StringUtils.isEmpty(getSeparator(context))) { LOGGER.warn("Cannot split on an empty separator"); context.setActionStatus(ActionContext.ActionStatus.CANCELED); }/*from ww w . j a va 2 s . c o m*/ // Create split columns final RowMetadata rowMetadata = context.getRowMetadata(); final String columnId = context.getColumnId(); final ColumnMetadata column = rowMetadata.getById(columnId); final Deque<String> lastColumnId = new ArrayDeque<>(); final Map<String, String> parameters = context.getParameters(); int limit = Integer.parseInt(parameters.get(LIMIT)); final List<String> newColumns = new ArrayList<>(); lastColumnId.push(columnId); for (int i = 0; i < limit; i++) { final int newColumnIndex = i + 1; newColumns.add(context.column(column.getName() + SPLIT_APPENDIX + i, r -> { final ColumnMetadata c = ColumnMetadata.Builder // .column() // .type(Type.STRING) // .computedId(StringUtils.EMPTY) // .name(column.getName() + SPLIT_APPENDIX + newColumnIndex) // .build(); lastColumnId.push(rowMetadata.insertAfter(lastColumnId.pop(), c)); return c; })); } context.get(NEW_COLUMNS_CONTEXT, p -> newColumns); // Save new column names for apply } }
From source file:au.com.cybersearch2.classyfy.ClassyfyLogic.java
public NodeDetailsBean getNodeDetails(Node data) { NodeDetailsBean nodeDetailsBean = new NodeDetailsBean(); // Collect children, distinguishing between folders and categories for (Node child : data.getChildren()) { String title = child.getTitle(); long id = (long) child.getId(); ListItem item = new ListItem("Title", title, id); if (RecordModel.getModel(child.getModel()) == RecordModel.recordFolder) nodeDetailsBean.getFolderTitles().add(item); else// ww w. j av a 2 s . c om nodeDetailsBean.getCategoryTitles().add(item); } // Collect node hierarchy up to root node Node node = data.getParent(); Deque<Node> nodeDeque = new ArrayDeque<Node>(); // Walk up to top node while (node.getModel() != NodeType.ROOT)// Top of tree { nodeDeque.add(node); node = node.getParent(); } Iterator<Node> nodeIterator = nodeDeque.descendingIterator(); while (nodeIterator.hasNext()) { node = nodeIterator.next(); String title = node.getTitle(); long id = (long) node.getId(); ListItem item = new ListItem("Title", title, id); nodeDetailsBean.getHierarchy().add(item); } // Build heading from Title and record type StringBuilder builder = new StringBuilder(); builder.append(RecordModel.getNameByNode(data)).append(": "); if ((data.getTitle() != null) && (data.getTitle().length() > 0)) builder.append(data.getTitle()); else builder.append('?'); // This is an error. Handle gracefully. nodeDetailsBean.setHeading(builder.toString()); // Collect details in FieldDescripter order Map<String, Object> valueMap = data.getProperties(); Set<FieldDescriptor> fieldSet = FieldDescriptorSetFactory.instance(data); for (FieldDescriptor descriptor : fieldSet) { Object value = valueMap.get(descriptor.getName()); if (value == null) continue; nodeDetailsBean.getFieldList().add(new ListItem(descriptor.getTitle(), value.toString())); } return nodeDetailsBean; }