Examples of PairValueContainer


Examples of com.volantis.mcs.build.themes.definitions.values.impl.PairValueContainer

                container.addValue(value);
            } catch (NumberFormatException nfe) {
                System.out.println("Invalid time: '" + valStr + "'");
            }
        } else if (name.equals("pairValue")) {
            PairValueContainer pair = new PairValueContainer();

            pushObject(pair);
            processThemePropertyChildren(element);
            popObject();

            PairValue value = definitionsFactory.createPairValue();
            value.setFirst(pair.getFirst());
            value.setSecond(pair.getSecond());

            ValueContainer container =
                    (ValueContainer) findObject(ValueContainer.class);
            container.addValue(value);
        } else if (name.equals("listValue")) {
            ListValueContainer pair = new ListValueContainer();

            pushObject(pair);
            processThemePropertyChildren(element);
            popObject();

            ListValue value = definitionsFactory.createListValue();
            Value next = null;
            while((next = pair.getNext())!=null){
                value.setNext(next);
            }
           
            ValueContainer container =
                    (ValueContainer) findObject(ValueContainer.class);
            container.addValue(value);
        } else if (name.equals("frequencyValue")) {
            String valStr = element.getText();

            try {
                double doubleVal = Double.parseDouble(valStr);
                String units = element.getAttributeValue("units");
                ValueContainer container =
                        (ValueContainer) findObject(ValueContainer.class);
                FrequencyValue value = definitionsFactory.createFrequencyValue();
                value.setNumber(doubleVal);
                value.setUnits(units);
                container.addValue(value);
            } catch (NumberFormatException nfe) {
                System.out.println("Invalid frequency: '" + valStr + "'");
            }
        } else if (name.equals("fractionValue")) {
            PairValueContainer pair = new PairValueContainer();

            pushObject(pair);
            processThemePropertyChildren(element);
            popObject();

            FractionValue value = definitionsFactory.createFractionValue();
            value.setNumerator(pair.getFirst());
            value.setDenominator(pair.getSecond());

            ValueContainer container =
                    (ValueContainer) findObject(ValueContainer.class);
            container.addValue(value);
        } else if (name.equals("keywordRef")) {

            // Resolve the keyword reference to the keyword (must come before)
            // and then create a representation.
            ValueContainer container =
                    (ValueContainer) findObject(ValueContainer.class);
            String keywordName = element.getText();

            // Get the keyword from the property's type.
            Property property = (Property) findObject(Property.class);
            Type type = property.getType();
            if (type != null) {
                KeywordSearchContainer keywordCont =
                        new KeywordSearchContainer();
                keywordCont.setKeywordName(keywordName);
                TypeVisitor keywordFinder = new AbstractTypeVisitor() {
                    public void visitKeywords(Keywords visitee, Object obj) {
                        KeywordSearchContainer ksc =
                                (KeywordSearchContainer) obj;
                        Keyword keyword =
                                visitee.getKeyword(ksc.getKeywordName());
                        if (keyword != null) {
                            ksc.setKeyword(keyword);
                        }
                    }

                    public void visitTypeRef(TypeRef visitee, Object obj) {
                        TypeDefinition td = getTypeDef(visitee.getReference());
                        if (td != null) {
                            Type t = td.getType();
                            if (t != null) {
                                t.accept(this, obj);
                            }
                        }
                    }
                };
                type.accept(keywordFinder, keywordCont);
                if (keywordCont.getKeyword() == null) {
                    System.out.println("Keyword " + keywordName
                                       + " not found in property "
                                       + property.getName());
                } else {
                    KeywordReference reference
                            = definitionsFactory.createKeywordReference();
                    reference.setKeyword(keywordCont.getKeyword());
                    container.addValue(reference);
                }
            } else {
                System.out.println(
                        "Property has no type: could not find keywords");
            }
        } else if (name.equals("themeDefinition")) {
            // Process all the children.
            processThemePropertyChildren(element);
        } else if (name.equals("choiceType")) {
            ChoiceType choiceType = definitionsFactory.createChoiceType();
            TypeList typeList = new TypeList();

            pushObject(choiceType);
            pushObject(typeList);
            processThemePropertyChildren(element);
            popObject();
            popObject();

            Iterator it = typeList.getList().iterator();
            while (it.hasNext()) {
                choiceType.addType((Type) it.next());
            }
            storeType(choiceType);
        } else if (name.equals("pairType")) {
            PairType pairType = definitionsFactory.createPairType();

            pushObject(pairType);
            processThemePropertyChildren(element);
            popObject();

            storeType(pairType);
        } else if (name.equals("fractionType")) {
            FractionType fractionType = definitionsFactory.createFractionType();

            pushObject(fractionType);
            processThemePropertyChildren(element);
            popObject();
            storeType(fractionType);
        } else if (name.equals("first")) {
            TypeList typeList = new TypeList();
            NameHolder nameHolder = new NameHolder();

            pushObject(typeList);
            pushObject(nameHolder);
            processThemePropertyChildren(element);
            popObject();
            popObject();

            if (!typeList.getList().isEmpty()) {
                PairType pair = (PairType) findObject(PairType.class);
                pair.setFirst((Type) typeList.getList().get(0));
            }
        } else if (name.equals("second")) {
            TypeList typeList = new TypeList();
            NameHolder nameHolder = new NameHolder();

            pushObject(typeList);
            pushObject(nameHolder);
            processThemePropertyChildren(element);
            popObject();
            popObject();

            if (!typeList.getList().isEmpty()) {
                PairType pair = (PairType) findObject(PairType.class);
                pair.setSecond((Type) typeList.getList().get(0));
            }
        } else if (name.equals("numerator")) {
            TypeList typeList = new TypeList();
            NameHolder nameHolder = new NameHolder();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.