List of usage examples for java.util Stack peek
public synchronized E peek()
From source file:org.sakaiproject.signup.restful.SignupEvent.java
public Element toXml(Document doc, Stack stack) { Element event = doc.createElement("signupEvent"); if (stack.isEmpty()) { doc.appendChild(event);/*from ww w. jav a 2 s.c om*/ } else { ((Element) stack.peek()).appendChild(event); } stack.push(event); event.setAttribute("id", getId()); event.setAttribute("eventid", getEventId().toString()); event.setAttribute("title", getTitle()); event.setAttribute("organizer", this.getOrganizerName()); event.setAttribute("location", this.getLocation()); event.setAttribute("event-type", this.getMeetingType()); event.setAttribute("event-recurrenceId", this.getRecurrenceId().toString()); if (description != null) event.setAttribute("description", description); event.setAttribute("start-time", this.getStartTime().toString()); event.setAttribute("end-time", this.getEndTime().toString()); event.setAttribute("signup-begin", this.getSignupBegins().toString()); event.setAttribute("signup-deadline", this.getSignupDeadline().toString()); // event.setAttribute("repeat-event", // Boolean.valueOf(isRecurredMeeting()).toString()); // properties // getProperties().toXml(doc, stack); // apppend the options as chidren stack.pop(); return event; }
From source file:org.wso2.carbon.repository.core.jdbc.dataaccess.JDBCDatabaseTransaction.java
private static TransactionEntry getStackedTransactionalEntry() { Stack<TransactionEntry> transactionalEntryStack = tStackedTransactionalEntryStack.get(); if (transactionalEntryStack == null) { tStackedTransactionalEntryStack.remove(); transactionalEntryStack = tStackedTransactionalEntryStack.get(); }//from ww w . j ava2 s. co m return transactionalEntryStack.peek(); }
From source file:padl.creator.cppfile.eclipse.plugin.internal.GeneratorHelper.java
void convertDeclaration(final Accumulator anAccumulator, final ICPPASTNamespaceDefinition aDeclaration, final Stack<IContainer> someContainers) { IContainer container = someContainers.peek(); // If the current container is the default package, // I add the new package (if one must be created) // into the code-level model. if (container.equals(this.codeLevelModel.getConstituentFromID(Constants.DEFAULT_PACKAGE_ID))) { container = this.codeLevelModel; }/* w ww. j ava2 s .c om*/ final IBinding binding = ((ICPPASTNamespaceDefinition) aDeclaration).getName().resolveBinding(); final String namespaceName = binding.getName(); final char[] id; if (StringUtils.EMPTY.equals(namespaceName)) { id = Utils.createAnonymousName(GeneratorHelper.UniqueID++); } else { id = namespaceName.toCharArray(); } // In C++, it is legitimate to have the same space // declared in multiple files, a way to share its // content and its declarations... So, yes, if it // already exists, do nothing, just reuse the one // created the first time. if (container.doesContainConstituentWithID(id)) { final IContainer existingPackage = (IContainer) container.getConstituentFromID(id); someContainers.push(existingPackage); return; } final IPackage newPackage = ((ICPPFactoryEclipse) CPPFactoryEclipse.getInstance()).createPackage(id); container.addConstituent(newPackage); someContainers.push(newPackage); }
From source file:org.apache.hadoop.hbase.filter.ParseFilter.java
/** * This function is called while parsing the filterString and an operator is parsed * <p>// w ww. j a v a 2 s. com * @param operatorStack the stack containing the operators and parenthesis * @param filterStack the stack containing the filters * @param operator the operator found while parsing the filterString */ public void reduce(Stack<ByteBuffer> operatorStack, Stack<Filter> filterStack, ByteBuffer operator) { while (!operatorStack.empty() && !(ParseConstants.LPAREN_BUFFER.equals(operatorStack.peek())) && hasHigherPriority(operatorStack.peek(), operator)) { filterStack.push(popArguments(operatorStack, filterStack)); } }
From source file:padl.creator.cppfile.eclipse.plugin.internal.GeneratorHelper.java
private void addVariableToModelOrFieldToClass(final ICPPVariable aCPPVariable, final Stack<IContainer> someContainers) { final IContainer container = someContainers.peek(); final String[] qualifiedNameRow; try {//ww w .j a va 2 s . c o m qualifiedNameRow = aCPPVariable.getQualifiedName(); } catch (final DOMException e) { e.printStackTrace(ProxyConsole.getInstance().errorOutput()); throw new RuntimeException(e); } final String fieldTypeName = Utils.getInterestingTypeName(aCPPVariable.getType()); final String fieldName = qualifiedNameRow[qualifiedNameRow.length - 1]; final String id = fieldTypeName + '.' + fieldName; final IEntity fieldTypeEntity = SearchHelper.getExistingContainerOrCreateGhost(this.codeLevelModel, someContainers, fieldTypeName, false); if (Arrays.equals(((IConstituent) container).getName(), fieldName.toCharArray())) { // It is possible but really I don't understand why: // see Chrome/browser/render_widget_host_hwnd.h:class RenderWidgetHostHWND return; } final int cardinality = Utils.getCardinality(aCPPVariable); IField field = null; if (aCPPVariable instanceof ICPPField && !(container instanceof IPackage)) { field = ((ICPPFactoryEclipse) CPPFactoryEclipse.getInstance()).createField(id.toCharArray(), fieldName.toCharArray(), fieldTypeEntity.getName(), cardinality); Utils.setVisibility(field, (ICPPMember) aCPPVariable); } else if (aCPPVariable instanceof ICPPVariable || container instanceof IPackage) { field = ((ICPPFactoryEclipse) CPPFactoryEclipse.getInstance()).createGlobalField(id.toCharArray(), fieldName.toCharArray(), fieldTypeEntity.getName(), cardinality); } Utils.setConst(field, aCPPVariable); container.addConstituent(field); }
From source file:padl.creator.cppfile.eclipse.plugin.internal.GeneratorHelper.java
private void addEnumerationToModel(final ICPPEnumeration aCPPEnumeration, final Stack<IContainer> someContainers) throws DOMException { final IContainer container = someContainers.peek(); char[] id = Utils.getQualifiedName(aCPPEnumeration.getQualifiedNameCharArray()); // It is possible for the name to be empty, // for enumeration for example if (id.length == 0) { id = Utils.createAnonymousName(GeneratorHelper.UniqueID++); }//from w w w .j a v a 2 s. c om if (!container.doesContainConstituentWithID(id)) { final IEnum enumeration = ((ICPPFactoryEclipse) CPPFactoryEclipse.getInstance()).createEnum(id); for (final IEnumerator enumerator : aCPPEnumeration.getEnumerators()) { final IEnumValue anEnumValue = ((ICPPFactoryEclipse) CPPFactoryEclipse.getInstance()) .createEnumValue(enumerator.getName().toCharArray()); enumeration.addConstituent(anEnumValue); } container.addConstituent(enumeration); } }
From source file:org.apache.tajo.engine.planner.rewrite.FilterPushDownRule.java
@Override public LogicalNode visitGroupBy(FilterPushDownContext context, LogicalPlan plan, LogicalPlan.QueryBlock block, GroupbyNode groupbyNode, Stack<LogicalNode> stack) throws PlanningException { LogicalNode parentNode = stack.peek(); List<EvalNode> aggrEvals; if (parentNode.getType() == NodeType.HAVING) { aggrEvals = addHavingNode(context, plan, block, null, (HavingNode) parentNode, groupbyNode); } else {// w w w . j av a2 s .c o m aggrEvals = addHavingNode(context, plan, block, (UnaryNode) parentNode, null, groupbyNode); } if (aggrEvals != null) { // remove aggregation eval from conext context.pushingDownFilters.removeAll(aggrEvals); } List<EvalNode> notMatched = new ArrayList<EvalNode>(); // transform Map<EvalNode, EvalNode> tranformed = findCanPushdownAndTransform(context, block, groupbyNode, groupbyNode.getChild(), notMatched, null, false, 0); context.setFiltersTobePushed(tranformed.keySet()); LogicalNode current = super.visitGroupBy(context, plan, block, groupbyNode, stack); context.setToOrigin(tranformed); context.addFiltersTobePushed(notMatched); return current; }
From source file:org.apache.pdfbox.contentstream.PDFStreamEngine.java
/** * Saves the entire graphics stack./* w ww . j a v a2 s . c o m*/ */ protected final Stack<PDGraphicsState> saveGraphicsStack() { Stack<PDGraphicsState> savedStack = graphicsStack; graphicsStack = new Stack<PDGraphicsState>(); graphicsStack.add(savedStack.peek().clone()); return savedStack; }
From source file:org.sakaiproject.util.BaseResourceProperties.java
/** * Serialize the resource into XML, adding an element to the doc under the top of the stack element. * /* w w w. j av a 2 s .c om*/ * @param doc * The DOM doc to contain the XML (or null for a string return). * @param stack * The DOM elements, the top of which is the containing element of the new "resource" element. * @return The newly added element. */ public Element toXml(Document doc, Stack stack) { Element properties = doc.createElement("properties"); ((Element) stack.peek()).appendChild(properties); Enumeration props = m_props.keys(); while (props.hasMoreElements()) { String name = (String) props.nextElement(); Object value = m_props.get(name); if (value instanceof String) { Element propElement = doc.createElement("property"); properties.appendChild(propElement); propElement.setAttribute("name", name); // encode to allow special characters in the value Xml.encodeAttribute(propElement, "value", (String) value); propElement.setAttribute("enc", "BASE64"); } else if (value instanceof List) { for (Iterator iValues = ((List) value).iterator(); iValues.hasNext();) { Object val = iValues.next(); if (val instanceof String) { Element propElement = doc.createElement("property"); properties.appendChild(propElement); propElement.setAttribute("name", name); Xml.encodeAttribute(propElement, "value", (String) val); propElement.setAttribute("enc", "BASE64"); propElement.setAttribute("list", "list"); } else { M_log.warn(".toXml: in list not string: " + name); } } } else { M_log.warn(".toXml: not a string, not a value: " + name); } } return properties; }
From source file:padl.creator.cppfile.eclipse.plugin.internal.GeneratorHelper.java
private void addEntityToModelOrMemberToClass(final Accumulator anAccumulator, final ICPPClassType aCPPEntity, final Stack<IContainer> someContainers) { final IContainer container = someContainers.peek(); char[] id;//from ww w . j a v a 2 s . c om try { id = Utils.getQualifiedName(aCPPEntity.getQualifiedNameCharArray()); } catch (final DOMException e) { e.printStackTrace(ProxyConsole.getInstance().errorOutput()); throw new RuntimeException(e); } char[] name = aCPPEntity.getNameCharArray(); // It is possible for the name to be empty, // for enumeration for example if (id.length == 0 || name.length == 0) { // id.length could be 1 in case of union... id = Utils.createAnonymousName(GeneratorHelper.UniqueID++); name = id; } // Yann 2013/09/28: Name vs. ID! // Member entities have for name the simple name of the entity // but for ID the ID of their container and "$" and their ID. char[] memberID = ((IConstituent) container).getID(); memberID = ArrayUtils.add(memberID, IConstants.MEMBER_ENTITY_SYMBOL); memberID = ArrayUtils.addAll(memberID, name); // It is possible that the entity already exists in the case of // In one file: // class DebuggerWrapper; // In another file: // class DebuggerWrapper { // ... if (container.doesContainConstituentWithID(id) || container.doesContainConstituentWithID(memberID)) { return; } final IFirstClassEntity entity; final int type = aCPPEntity.getKey(); if (type == ICPPASTCompositeTypeSpecifier.k_class) { if (container instanceof IFirstClassEntity) { if (Utils.isInterface(aCPPEntity)) { entity = ((ICPPFactoryEclipse) CPPFactoryEclipse.getInstance()).createMemberInterface(memberID, name); } else { entity = ((ICPPFactoryEclipse) CPPFactoryEclipse.getInstance()).createMemberClass(memberID, name); entity.setAbstract(Utils.isAbstract(aCPPEntity)); } } else { if (Utils.isInterface(aCPPEntity)) { entity = ((ICPPFactoryEclipse) CPPFactoryEclipse.getInstance()).createInterface(id, name); } else { entity = ((ICPPFactoryEclipse) CPPFactoryEclipse.getInstance()).createClass(id, name); entity.setAbstract(Utils.isAbstract(aCPPEntity)); entity.equals(entity); } } } else if (type == IASTCompositeTypeSpecifier.k_struct) { if (container instanceof IFirstClassEntity) { entity = ((ICPPFactoryEclipse) CPPFactoryEclipse.getInstance()).createMemberStructure(memberID); } else { entity = ((ICPPFactoryEclipse) CPPFactoryEclipse.getInstance()).createStructure(id); } } else if (type == IASTCompositeTypeSpecifier.k_union) { entity = ((ICPPFactoryEclipse) CPPFactoryEclipse.getInstance()).createUnion(id); } else { entity = null; // Should never happen! Would fail fast! } container.addConstituent(entity); anAccumulator.addClassTypes(aCPPEntity, entity); }