Examples of PdLanguage


Examples of org.foray.fotree.fo.prop.PdLanguage

            throws PropertyException {
        final PropertyCollection collection = new PropertyCollection();
        final PropertyValue pv = checkKeywords(this.getValidKeywords(), value);
        if (pv != null) {
            collection.addItem(new PdCountry(pv));
            collection.addItem(new PdLanguage(pv));
            return collection;
        }
        // There are 2 properties which can be explicitly set
        final byte maxTokens = 2;
        // Tokenize the input & put the tokens into an ArrayList
        final StringTokenizer st = new StringTokenizer(value);
        final List<String> tokenList = new ArrayList<String>(st.countTokens());
        while (st.hasMoreTokens()) {
            tokenList.add(st.nextToken());
        }
        if (tokenList.size() < 1 || tokenList.size() > maxTokens) {
            throw unexpectedValue(value, fobj);
        }
        // Create an array indicating which property is in each position
        final FoProperty[] positionArray = new FoProperty[tokenList.size()];
        for (int i = 0; i < tokenList.size(); i++) {
            final FoProperty contentType = getContentType(tokenList.get(i));
            if (contentType == null) {
                throw unexpectedValue(value, fobj);
            }
            positionArray[i] = contentType;
        }
        boolean countryFound = false;
        boolean languageFound = false;
        for (int i = 0; i < positionArray.length; i++) {
            switch (positionArray[i]) {
            case COUNTRY: {
                if (countryFound) {
                    throw unexpectedValue(value, fobj);
                }
                collection.addItem(new PdCountry(fobj, propertyFullName,
                        tokenList.get(i)));
                countryFound = true;
                break;
            }
            case LANGUAGE: {
                if (languageFound) {
                    throw unexpectedValue(value, fobj);
                }
                collection.addItem(new PdLanguage(fobj, propertyFullName,
                        tokenList.get(i)));
                languageFound = true;
                break;
            }
            }
View Full Code Here

Examples of org.foray.fotree.fo.prop.PdLanguage

        case KEEP_WITH_PREVIOUS: {
            return new PdKeepWithPrevious(fobj, propertyFullName,
                    attributeValue);
        }
        case LANGUAGE: {
            return new PdLanguage(fobj, propertyFullName, attributeValue);
        }
        case LAST_LINE_END_INDENT: {
            return new PdLastLineEndIndent(fobj, propertyFullName,
                    attributeValue);
        }
View Full Code Here

Examples of org.foray.fotree.fo.prop.PdLanguage

     * @param context An object that knows how to resolve FO Tree context
     * issues.
     * @return The language property.
     */
    public String getLanguage(final FObj fobj, final FoContext context) {
        PdLanguage property = (PdLanguage) getProperty(FoProperty.LANGUAGE);
        if (property != null) {
            return property.getValue(context, fobj);
        }
        final Lang langProperty = (Lang) getProperty(XmlProperty.LANG);
        if (langProperty != null) {
            property = langProperty.getLanguage();
            if (property != null) {
                return property.getValue(context, fobj);
            }
        }
        return PdLanguage.getValueNoInstance(context, fobj);
    }
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.