Example usage for java.util Stack pop

List of usage examples for java.util Stack pop

Introduction

In this page you can find the example usage for java.util Stack pop.

Prototype

public synchronized E pop() 

Source Link

Document

Removes the object at the top of this stack and returns that object as the value of this function.

Usage

From source file:com.projity.pm.graphic.model.transform.NodeCacheTransformer.java

public void transfrom(List list) {
    model.clear();//from  w  ww .  ja  v a  2  s.  co  m

    if (list == null)
        return;

    boolean preserveHierarchy = transformer.isPreserveHierarchy();

    if (!transformer.isShowSummary()) {
        preserveHierarchy = false;
        removeSummaries(list);
    }
    Map<GraphicNode, List<GraphicNode>> assignmentsMap = null;
    if (!transformer.isShowAssignments())
        removeAssignments(list);
    if (!transformer.isShowEmptyLines())
        removeVoids(list);
    if (transformer.isShowEmptyLines() && !transformer.isShowEndEmptyLines())
        removeEndVoids(list);

    NodeTransformer composition = transformer.getTransformer();

    NodeFilter hiddenFilter = transformer.getHiddenFilter();
    if (hiddenFilter instanceof BaseFilter && !((BaseFilter) hiddenFilter).isActive())
        hiddenFilter = null; //to avoid useless filtering in case of BaseFilter
    NodeFilter userFilter = (transformer.isNoneFilter()) ? null : transformer.getUserFilter();
    boolean filtering = hiddenFilter != null || userFilter != null;

    NodeSorter sorter1 = transformer.getHiddenSorter();
    NodeSorter sorter2 = transformer.getUserSorter();
    boolean sorting = !(sorter1 == null && transformer.isNoneSorter());

    NodeGrouper grouper = transformer.getUserGrouper();
    boolean grouping = !transformer.isNoneGrouper();

    if (!filtering && !sorting && !grouping)
        return;

    if (transformer.isShowAssignments() && preserveHierarchy && !transformer.isTreatAssignmentsAsTasks())
        assignmentsMap = extractAssignments(list);

    List localList = null;
    Stack parents = null;
    boolean alreadyExcluded;
    if (preserveHierarchy) {
        localList = new ArrayList();
        parents = new Stack();
    } else
        localList = list;

    GraphicNode gnode, previous = null;
    Object current;
    for (Iterator i = list.iterator(); i.hasNext();) {
        gnode = (GraphicNode) i.next();
        gnode.setFiltered(false);
        if (!gnode.isVoid()) {
            current = (composition == null) ? gnode.getNode() : composition.evaluate(gnode.getNode());
            alreadyExcluded = false;
            if (hiddenFilter != null) {
                if (!hiddenFilter.evaluate(current)) {
                    if (!gnode.isSummary() || !preserveHierarchy) {
                        i.remove();
                        continue;
                    }
                    if (gnode.isSummary() && preserveHierarchy)
                        gnode.setFiltered(true);
                    alreadyExcluded = true;
                }
            }
            if (userFilter != null && !alreadyExcluded) {
                if (!userFilter.evaluate(current)) {
                    if (!gnode.isSummary() || !preserveHierarchy) {
                        i.remove();
                        continue;
                    }
                    if (gnode.isSummary() && preserveHierarchy)
                        gnode.setFiltered(true);
                }
            }
        }
        if (preserveHierarchy) {
            //contruct a temporary tree for sorting and grouping
            //                if (parents==null||previous==null){
            //                   System.out.println("null");
            //                }
            if (gnode.getLevel() == 1) {
                localList.add(gnode);
                parents.clear();
            } else {
                if (previous.getLevel() < gnode.getLevel()) {
                    parents.push(previous);
                } else if (previous.getLevel() >= gnode.getLevel()) {
                    while (parents.size() >= gnode.getLevel())
                        parents.pop();
                }
                ((GraphicNode) parents.peek()).getChildren().add(gnode);
            }
            previous = gnode;
        }
    }

    //remove parents without children
    if (preserveHierarchy) {
        list.clear();
        if (transformer.isShowEmptySummaries()) {
            if ("TaskUsage".equals(viewName))
                filterBadBranches(localList);
        } else
            filterEmptySummaries(localList, false);
    }

    if (sorting) {
        if (sorter1 != null)
            sorter1.sortList(localList, new GraphicNodeComparator(sorter1, composition), preserveHierarchy);
        if (!transformer.isNoneSorter())
            sorter2.sortList(localList, new GraphicNodeComparator(sorter2, composition), preserveHierarchy);
    }

    if (grouping) {
        List groups = grouper.getGroups();
        levelOffset = groups.size();
        List groupedList = new LinkedList();
        groupList(localList, groupedList, groups.listIterator(), null, composition, preserveHierarchy);
        localList.clear();
        localList.addAll(groupedList);
    }

    if (preserveHierarchy) { //converts tmp tree to list
        treeToList(localList, list);
    }

    if (assignmentsMap != null)
        recoverAssignments(list, assignmentsMap);

    //        if (transformer.isShowEmptyLines())
    //           placeVoidNodes(list);

}

From source file:org.apache.tajo.engine.planner.LogicalPlanner.java

@Override
public LogicalNode visitJoin(PlanContext context, Stack<Expr> stack, Join join) throws PlanningException {
    // Phase 1: Init
    LogicalPlan plan = context.plan;/*  w  w w .j a  va  2 s .  c  o  m*/
    QueryBlock block = context.queryBlock;

    if (join.hasQual()) {
        ExprNormalizedResult normalizedResult = normalizer.normalize(context, join.getQual(), true);
        block.namedExprsMgr.addExpr(normalizedResult.baseExpr);
        if (normalizedResult.aggExprs.size() > 0 || normalizedResult.scalarExprs.size() > 0) {
            throw new VerifyException("Filter condition cannot include aggregation function");
        }
    }

    ////////////////////////////////////////////////////////
    // Visit and Build Child Plan
    ////////////////////////////////////////////////////////
    stack.push(join);
    LogicalNode left = visit(context, stack, join.getLeft());
    LogicalNode right = visit(context, stack, join.getRight());
    stack.pop();
    ////////////////////////////////////////////////////////

    JoinNode joinNode = context.queryBlock.getNodeFromExpr(join);
    joinNode.setJoinType(join.getJoinType());
    joinNode.setLeftChild(left);
    joinNode.setRightChild(right);

    // Set A merged input schema
    Schema merged;
    if (join.isNatural()) {
        merged = getNaturalJoinSchema(left, right);
    } else {
        merged = SchemaUtil.merge(left.getOutSchema(), right.getOutSchema());
    }
    joinNode.setInSchema(merged);

    // Create EvalNode for a search condition.
    EvalNode joinCondition = null;
    if (join.hasQual()) {
        EvalNode evalNode = exprAnnotator.createEvalNode(context, join.getQual(), NameResolvingMode.LEGACY);
        joinCondition = context.evalOptimizer.optimize(context, evalNode);
    }

    List<String> newlyEvaluatedExprs = getNewlyEvaluatedExprsForJoin(context, joinNode, stack);
    List<Target> targets = TUtil.newList(PlannerUtil.schemaToTargets(merged));

    for (String newAddedExpr : newlyEvaluatedExprs) {
        targets.add(block.namedExprsMgr.getTarget(newAddedExpr, true));
    }
    joinNode.setTargets(targets.toArray(new Target[targets.size()]));

    // Determine join conditions
    if (join.isNatural()) { // if natural join, it should have the equi-join conditions by common column names
        EvalNode njCond = getNaturalJoinCondition(joinNode);
        joinNode.setJoinQual(njCond);
    } else if (join.hasQual()) { // otherwise, the given join conditions are set
        joinNode.setJoinQual(joinCondition);
    }

    return joinNode;
}

From source file:gdt.data.store.Entigrator.java

/**
 * List components of the entity and its components
 * recursively. // ww w. j  a  v  a 2  s . c  om
 *  @param entity the entity.
 * @return the array of keys of components.
 */
public String[] ent_listComponentsCascade(Sack entity) {
    if (entity == null)
        return null;

    Stack<String> s = new Stack<String>();
    ent_listComponentsCascade(entity, s);
    int cnt = s.size();
    if (cnt < 1)
        return null;
    String[] sa = new String[cnt];
    for (int i = 0; i < cnt; i++)
        sa[i] = (String) s.pop();
    return sa;
}

From source file:org.apache.rya.rdftriplestore.inference.InferenceEngine.java

/**
 * Queries domain and range information, then populates the inference engine with direct
 * domain/range relations and any that can be inferred from the subclass graph, subproperty
 * graph, and inverse property map. Should be called after that class and property information
 * has been refreshed./*  w w  w  . j  a v a  2 s.c o m*/
 *
 * Computes indirect domain/range:
 *  - If p1 has domain c, and p2 is a subproperty of p1, then p2 also has domain c.
 *  - If p1 has range c, and p2 is a subproperty of p1, then p2 also has range c.
 *  - If p1 has domain c, and p2 is the inverse of p1, then p2 has range c.
 *  - If p1 has range c, and p2 is the inverse of p1, then p2 has domain c.
 *  - If p has domain c1, and c1 is a subclass of c2, then p also has domain c2.
 *  - If p has range c1, and c1 is a subclass of c2, then p also has range c2.
 * @throws QueryEvaluationException
 */
private void refreshDomainRange() throws QueryEvaluationException {
    final Map<URI, Set<URI>> domainByTypePartial = new ConcurrentHashMap<>();
    final Map<URI, Set<URI>> rangeByTypePartial = new ConcurrentHashMap<>();
    // First, populate domain and range based on direct domain/range triples.
    CloseableIteration<Statement, QueryEvaluationException> iter = RyaDAOHelper.query(ryaDAO, null, RDFS.DOMAIN,
            null, conf);
    try {
        while (iter.hasNext()) {
            final Statement st = iter.next();
            final Resource property = st.getSubject();
            final Value domainType = st.getObject();
            if (domainType instanceof URI && property instanceof URI) {
                if (!domainByTypePartial.containsKey(domainType)) {
                    domainByTypePartial.put((URI) domainType, new HashSet<>());
                }
                domainByTypePartial.get(domainType).add((URI) property);
            }
        }
    } finally {
        if (iter != null) {
            iter.close();
        }
    }
    iter = RyaDAOHelper.query(ryaDAO, null, RDFS.RANGE, null, conf);
    try {
        while (iter.hasNext()) {
            final Statement st = iter.next();
            final Resource property = st.getSubject();
            final Value rangeType = st.getObject();
            if (rangeType instanceof URI && property instanceof URI) {
                if (!rangeByTypePartial.containsKey(rangeType)) {
                    rangeByTypePartial.put((URI) rangeType, new HashSet<>());
                }
                rangeByTypePartial.get(rangeType).add((URI) property);
            }
        }
    } finally {
        if (iter != null) {
            iter.close();
        }
    }
    // Then combine with the subclass/subproperty graphs and the inverse property map to compute
    // the closure of domain and range per class.
    final Set<URI> domainRangeTypeSet = new HashSet<>(domainByTypePartial.keySet());
    domainRangeTypeSet.addAll(rangeByTypePartial.keySet());
    // Extend to subproperties: make sure that using a more specific form of a property
    // still triggers its domain/range inferences.
    // Mirror for inverse properties: make sure that using the inverse form of a property
    // triggers the inverse domain/range inferences.
    // These two rules can recursively trigger one another.
    for (final URI domainRangeType : domainRangeTypeSet) {
        final Set<URI> propertiesWithDomain = domainByTypePartial.getOrDefault(domainRangeType,
                new HashSet<>());
        final Set<URI> propertiesWithRange = rangeByTypePartial.getOrDefault(domainRangeType, new HashSet<>());
        // Since findParents will traverse the subproperty graph and find all indirect
        // subproperties, the subproperty rule does not need to trigger itself directly.
        // And since no more than one inverseOf relationship is stored for any property, the
        // inverse property rule does not need to trigger itself directly. However, each rule
        // can trigger the other, so keep track of how the inferred domains/ranges were
        // discovered so we can apply only those rules that might yield new information.
        final Stack<URI> domainViaSuperProperty = new Stack<>();
        final Stack<URI> rangeViaSuperProperty = new Stack<>();
        final Stack<URI> domainViaInverseProperty = new Stack<>();
        final Stack<URI> rangeViaInverseProperty = new Stack<>();
        // Start with the direct domain/range assertions, which can trigger any rule.
        domainViaSuperProperty.addAll(propertiesWithDomain);
        domainViaInverseProperty.addAll(propertiesWithDomain);
        rangeViaSuperProperty.addAll(propertiesWithRange);
        rangeViaInverseProperty.addAll(propertiesWithRange);
        // Repeatedly infer domain/range from subproperties/inverse properties until no new
        // information can be generated.
        while (!(domainViaSuperProperty.isEmpty() && rangeViaSuperProperty.isEmpty()
                && domainViaInverseProperty.isEmpty() && rangeViaInverseProperty.isEmpty())) {
            // For a type c and property p, if c is a domain of p, then c is the range of any
            // inverse of p. Would be redundant for properties discovered via inverseOf.
            while (!domainViaSuperProperty.isEmpty()) {
                final URI property = domainViaSuperProperty.pop();
                final URI inverseProperty = findInverseOf(property);
                if (inverseProperty != null && propertiesWithRange.add(inverseProperty)) {
                    rangeViaInverseProperty.push(inverseProperty);
                }
            }
            // For a type c and property p, if c is a range of p, then c is the domain of any
            // inverse of p. Would be redundant for properties discovered via inverseOf.
            while (!rangeViaSuperProperty.isEmpty()) {
                final URI property = rangeViaSuperProperty.pop();
                final URI inverseProperty = findInverseOf(property);
                if (inverseProperty != null && propertiesWithDomain.add(inverseProperty)) {
                    domainViaInverseProperty.push(inverseProperty);
                }
            }
            // For a type c and property p, if c is a domain of p, then c is also a domain of
            // p's subproperties. Would be redundant for properties discovered via this rule.
            while (!domainViaInverseProperty.isEmpty()) {
                final URI property = domainViaInverseProperty.pop();
                final Set<URI> subProperties = getSubProperties(property);
                subProperties.removeAll(propertiesWithDomain);
                propertiesWithDomain.addAll(subProperties);
                domainViaSuperProperty.addAll(subProperties);
            }
            // For a type c and property p, if c is a range of p, then c is also a range of
            // p's subproperties. Would be redundant for properties discovered via this rule.
            while (!rangeViaInverseProperty.isEmpty()) {
                final URI property = rangeViaInverseProperty.pop();
                final Set<URI> subProperties = getSubProperties(property);
                subProperties.removeAll(propertiesWithRange);
                propertiesWithRange.addAll(subProperties);
                rangeViaSuperProperty.addAll(subProperties);
            }
        }
        if (!propertiesWithDomain.isEmpty()) {
            domainByTypePartial.put(domainRangeType, propertiesWithDomain);
        }
        if (!propertiesWithRange.isEmpty()) {
            rangeByTypePartial.put(domainRangeType, propertiesWithRange);
        }
    }
    // Once all properties have been found for each domain/range class, extend to superclasses:
    // make sure that the consequent of a domain/range inference goes on to apply any more
    // general classes as well.
    for (final URI subtype : domainRangeTypeSet) {
        final Set<URI> supertypes = getSuperClasses(subtype);
        final Set<URI> propertiesWithDomain = domainByTypePartial.getOrDefault(subtype, new HashSet<>());
        final Set<URI> propertiesWithRange = rangeByTypePartial.getOrDefault(subtype, new HashSet<>());
        for (final URI supertype : supertypes) {
            // For a property p and its domain c: all of c's superclasses are also domains of p.
            if (!propertiesWithDomain.isEmpty() && !domainByTypePartial.containsKey(supertype)) {
                domainByTypePartial.put(supertype, new HashSet<>());
            }
            for (final URI property : propertiesWithDomain) {
                domainByTypePartial.get(supertype).add(property);
            }
            // For a property p and its range c: all of c's superclasses are also ranges of p.
            if (!propertiesWithRange.isEmpty() && !rangeByTypePartial.containsKey(supertype)) {
                rangeByTypePartial.put(supertype, new HashSet<>());
            }
            for (final URI property : propertiesWithRange) {
                rangeByTypePartial.get(supertype).add(property);
            }
        }
    }
    domainByType = domainByTypePartial;
    rangeByType = rangeByTypePartial;
}

From source file:com.unboundid.scim2.common.utils.SchemaUtils.java

/**
 * Gets SCIM schema attributes for a class.
 *
 * @param classesProcessed a stack containing the classes processed prior
 *                         to this class.  This is used for cycle detection.
 * @param cls the class to get the attributes for.
 * @return a collection of SCIM schema attributes for the class.
 * @throws IntrospectionException thrown if an error occurs during
 *    Introspection./*from   w ww  . ja  va 2s .  co  m*/
 */
private static Collection<AttributeDefinition> getAttributes(final Stack<String> classesProcessed,
        final Class<?> cls) throws IntrospectionException {
    String className = cls.getCanonicalName();
    if (!cls.isAssignableFrom(AttributeDefinition.class) && classesProcessed.contains(className)) {
        throw new RuntimeException("Cycles detected in Schema");
    }

    Collection<PropertyDescriptor> propertyDescriptors = getPropertyDescriptors(cls);
    Collection<AttributeDefinition> attributes = new ArrayList<AttributeDefinition>();

    for (PropertyDescriptor propertyDescriptor : propertyDescriptors) {
        if (propertyDescriptor.getName().equals("subAttributes")
                && cls.isAssignableFrom(AttributeDefinition.class) && classesProcessed.contains(className)) {
            // Skip second nesting of subAttributes the second time around
            // since there is no subAttributes of subAttributes in SCIM.
            continue;
        }
        AttributeDefinition.Builder attributeBuilder = new AttributeDefinition.Builder();

        Field field = findField(cls, propertyDescriptor.getName());

        if (field == null) {
            continue;
        }
        Attribute schemaProperty = null;
        JsonProperty jsonProperty = null;
        if (field.isAnnotationPresent(Attribute.class)) {
            schemaProperty = field.getAnnotation(Attribute.class);
        }
        if (field.isAnnotationPresent(JsonProperty.class)) {
            jsonProperty = field.getAnnotation(JsonProperty.class);
        }

        // Only generate schema for annotated fields.
        if (schemaProperty == null) {
            continue;
        }

        addName(attributeBuilder, propertyDescriptor, jsonProperty);
        addDescription(attributeBuilder, schemaProperty);
        addCaseExact(attributeBuilder, schemaProperty);
        addRequired(attributeBuilder, schemaProperty);
        addReturned(attributeBuilder, schemaProperty);
        addUniqueness(attributeBuilder, schemaProperty);
        addReferenceTypes(attributeBuilder, schemaProperty);
        addMutability(attributeBuilder, schemaProperty);
        addMultiValued(attributeBuilder, propertyDescriptor, schemaProperty);
        addCanonicalValues(attributeBuilder, schemaProperty);

        Class propertyCls = propertyDescriptor.getPropertyType();

        // if this is a multivalued attribute the real sub attribute class is the
        // the one specified in the annotation, not the list, set, array, etc.
        if ((schemaProperty.multiValueClass() != NullType.class)) {
            propertyCls = schemaProperty.multiValueClass();
        }

        AttributeDefinition.Type type = getAttributeType(propertyCls);
        attributeBuilder.setType(type);

        if (type == AttributeDefinition.Type.COMPLEX) {
            // Add this class to the list to allow cycle detection
            classesProcessed.push(cls.getCanonicalName());
            Collection<AttributeDefinition> subAttributes = getAttributes(classesProcessed, propertyCls);
            attributeBuilder
                    .addSubAttributes(subAttributes.toArray(new AttributeDefinition[subAttributes.size()]));
            classesProcessed.pop();
        }

        attributes.add(attributeBuilder.build());
    }

    return attributes;
}

From source file:com.amalto.core.storage.StorageMetadataUtils.java

private static void _path(ComplexTypeMetadata type, FieldMetadata target, Stack<FieldMetadata> path,
        Set<ComplexTypeMetadata> processedTypes, boolean includeReferences) {
    // Various optimizations for very simple cases
    if (type == null) {
        throw new IllegalArgumentException("Origin can not be null");
    }// w  ww . j a v a  2  s  .c  o  m
    if (target == null) {
        throw new IllegalArgumentException("Target field can not be null");
    }
    if (Storage.PROJECTION_TYPE.equals(type.getName()) && type.hasField(target.getName())) {
        path.push(type.getField(target.getName()));
    }
    if (target.getContainingType() instanceof ContainedComplexTypeMetadata) {
        String targetPath = target.getPath();
        if (type.hasField(targetPath)) {
            StringTokenizer tokenizer = new StringTokenizer(targetPath, "/"); //$NON-NLS-1$
            StringBuilder currentPath = new StringBuilder();
            while (tokenizer.hasMoreTokens()) {
                currentPath.append(tokenizer.nextToken()).append('/');
                path.add(type.getField(currentPath.toString()));
            }
            return;
        }
    }
    //
    if (processedTypes.contains(type)) {
        return;
    }
    processedTypes.add(type);
    Collection<FieldMetadata> fields = type.getFields();
    for (FieldMetadata current : fields) {
        path.push(current);
        if (current.equals(target)) {
            return;
        }
        if (current instanceof ContainedTypeFieldMetadata) {
            ComplexTypeMetadata containedType = ((ContainedTypeFieldMetadata) current).getContainedType();
            _path(containedType, target, path, processedTypes, includeReferences);
            if (path.peek().equals(target)) {
                return;
            }
            for (ComplexTypeMetadata subType : containedType.getSubTypes()) {
                for (FieldMetadata field : subType.getFields()) {
                    if (field.getDeclaringType() == subType) {
                        _path(subType, target, path, processedTypes, includeReferences);
                        if (path.peek().equals(target)) {
                            return;
                        }
                    }
                }
            }
        } else if (current instanceof ReferenceFieldMetadata) {
            if (includeReferences) {
                ComplexTypeMetadata referencedType = ((ReferenceFieldMetadata) current).getReferencedType();
                _path(referencedType, target, path, processedTypes, true);
                if (path.peek().equals(target)) {
                    return;
                }
                for (ComplexTypeMetadata subType : referencedType.getSubTypes()) {
                    for (FieldMetadata field : subType.getFields()) {
                        if (field.getDeclaringType() == subType) {
                            _path(subType, target, path, processedTypes, true);
                            if (path.peek().equals(target)) {
                                return;
                            }
                        }
                    }
                }
            }
        }
        path.pop();
    }
}

From source file:com.sqewd.open.dal.core.persistence.db.EntityHelper.java

@SuppressWarnings({ "rawtypes", "unchecked" })
public static Object getColumnValue(final ResultSet rs, final StructAttributeReflect attr,
        final AbstractEntity entity, final AbstractJoinGraph gr, final Stack<KeyValuePair<Class<?>>> path)
        throws Exception {

    Object value = null;/* www. ja v  a2  s  .  co  m*/

    KeyValuePair<String> alias = gr.getAliasFor(path, attr.Column, 0);
    String tabprefix = alias.getKey();

    if (EnumPrimitives.isPrimitiveType(attr.Field.getType())) {
        EnumPrimitives prim = EnumPrimitives.type(attr.Field.getType());
        switch (prim) {
        case ECharacter:
            String sv = rs.getString(tabprefix + "." + attr.Column);
            if (!rs.wasNull()) {
                PropertyUtils.setSimpleProperty(entity, attr.Field.getName(), sv.charAt(0));
            }
            break;
        case EShort:
            short shv = rs.getShort(tabprefix + "." + attr.Column);
            if (!rs.wasNull()) {
                PropertyUtils.setSimpleProperty(entity, attr.Field.getName(), shv);
            }
            break;
        case EInteger:
            int iv = rs.getInt(tabprefix + "." + attr.Column);
            if (!rs.wasNull()) {
                PropertyUtils.setSimpleProperty(entity, attr.Field.getName(), iv);
            }
            break;
        case ELong:
            long lv = rs.getLong(tabprefix + "." + attr.Column);
            if (!rs.wasNull()) {
                PropertyUtils.setSimpleProperty(entity, attr.Field.getName(), lv);
            }
            break;
        case EFloat:
            float fv = rs.getFloat(tabprefix + "." + attr.Column);
            if (!rs.wasNull()) {
                PropertyUtils.setSimpleProperty(entity, attr.Field.getName(), fv);
            }
            break;
        case EDouble:
            double dv = rs.getDouble(tabprefix + "." + attr.Column);
            if (!rs.wasNull()) {
                PropertyUtils.setSimpleProperty(entity, attr.Field.getName(), dv);
            }
            break;
        default:
            throw new Exception("Unsupported Data type [" + prim.name() + "]");
        }
    } else if (attr.Convertor != null) {
        // TODO : Not supported at this time.
        value = rs.getString(tabprefix + "." + attr.Column);

    } else if (attr.Field.getType().equals(String.class)) {
        value = rs.getString(tabprefix + "." + attr.Column);
        if (rs.wasNull()) {
            value = null;
        }
    } else if (attr.Field.getType().equals(Date.class)) {
        long lvalue = rs.getLong(tabprefix + "." + attr.Column);
        if (!rs.wasNull()) {
            Date dt = new Date(lvalue);
            value = dt;
        }
    } else if (attr.Field.getType().isEnum()) {
        String svalue = rs.getString(tabprefix + "." + attr.Column);
        if (!rs.wasNull()) {
            Class ecls = attr.Field.getType();
            value = Enum.valueOf(ecls, svalue);
        }
    } else if (attr.Reference != null) {
        Class<?> rt = Class.forName(attr.Reference.Class);
        Object obj = rt.newInstance();
        if (!(obj instanceof AbstractEntity))
            throw new Exception("Unsupported Entity type [" + rt.getCanonicalName() + "]");
        AbstractEntity rentity = (AbstractEntity) obj;
        if (path.size() > 0) {
            path.peek().setKey(attr.Column);
        }

        KeyValuePair<Class<?>> cls = new KeyValuePair<Class<?>>();
        cls.setValue(rentity.getClass());
        path.push(cls);
        setEntity(rentity, rs, gr, path);
        value = rentity;
        path.pop();
    }
    return value;
}

From source file:com.android.launcher3.CellLayout.java

private void recycleTempRects(Stack<Rect> used) {
    while (!used.isEmpty()) {
        mTempRectStack.push(used.pop());
    }
}

From source file:gdt.data.store.Entigrator.java

/**
 * List components of the entity /*w  w w .  j av a2 s  . co m*/
 *  @param entity the entity.
 * @return the array of keys of components.
 */
public String[] ent_listComponents(Sack entity) {
    try {
        if (entity == null)
            return null;
        Core[] ca = entity.elementGet("component");
        if (ca == null)
            return null;
        Stack<String> s = new Stack<String>();
        for (Core aCa : ca) {
            if (entity.getKey().equals(aCa.value))
                continue;
            s.push(aCa.value);
        }
        int cnt = s.size();
        if (cnt < 1)
            return null;
        String[] sa = new String[cnt];
        for (int i = 0; i < cnt; i++)
            sa[i] = s.pop();
        return sa;
    } catch (Exception e) {
        Logger.getLogger(getClass().getName()).severe(e.toString());
        return null;
    }
}

From source file:com.taobao.tdhs.jdbc.sqlparser.ParseSQL.java

private boolean checkSpecialStr(String sqlstring, String searchStr) {

    //????searchStr
    Stack<String> stack = new Stack<String>();
    boolean exist_danyinhao = false;
    for (int i = 0; i < sqlstring.length(); i++) {
        ///* ww w .  j ava2s . c o  m*/
        if (sqlstring.substring(i, i + 1).equals("'") == false) {
            stack.push(sqlstring.substring(i, i + 1));
        }

        //'
        if (sqlstring.substring(i, i + 1).equals("'")) {
            //?\,?,\,,??
            int count = 0;
            int k = i;
            boolean real_danyinhao;
            while (k - 1 >= 0 && sqlstring.substring(k - 1, k).equals("\\") == true) {
                k--;
                count++;
            }
            //System.out.println("\\:"+count);
            if (count % 2 == 0) {
                //??
                real_danyinhao = true;
            } else {
                //???,value
                real_danyinhao = false;
                stack.push(sqlstring.substring(i, i + 1));
            }
            if (real_danyinhao == true) {
                if (exist_danyinhao == false) {
                    exist_danyinhao = true;
                    stack.push(sqlstring.substring(i, i + 1));
                } else {
                    boolean find_real_danyinhao = false;
                    while (find_real_danyinhao == false) {
                        while (!stack.pop().equals("'")) {
                            ;
                        }
                        //???,??\
                        if (stack.isEmpty() == false && stack.peek().equals("\\")) {
                            //?,???
                            count = 0;
                            while (stack.peek().equals("\\")) {
                                stack.pop();
                                count++;
                            }
                            if (count % 2 == 0) {
                                //?
                                find_real_danyinhao = true;
                            } else {
                                //?
                                find_real_danyinhao = false;
                            }
                        } else {
                            //
                            find_real_danyinhao = true;
                        }

                    }

                    exist_danyinhao = false;
                }
            }

        }
    } //end for

    logger.debug(stack.toString());

    if (stack.isEmpty() == false && stack.search(searchStr) > -1) {
        stack.clear();
        return true;
    } else {
        return false;
    }
}