當前位置: 首頁>>代碼示例>>Java>>正文


Java DetailField.Builder方法代碼示例

本文整理匯總了Java中org.commcare.suite.model.DetailField.Builder方法的典型用法代碼示例。如果您正苦於以下問題:Java DetailField.Builder方法的具體用法?Java DetailField.Builder怎麽用?Java DetailField.Builder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.commcare.suite.model.DetailField的用法示例。


在下文中一共展示了DetailField.Builder方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: parseStyle

import org.commcare.suite.model.DetailField; //導入方法依賴的package包/類
private void parseStyle(DetailField.Builder builder) throws InvalidStructureException, IOException, XmlPullParserException {
    //style
    if (parser.getName().toLowerCase().equals("style")) {
        StyleParser styleParser = new StyleParser(builder, parser);
        styleParser.parse();
        //Header
        GridParser gridParser = new GridParser(builder, parser);
        gridParser.parse();

        //exit style block
        parser.nextTag();
        parser.nextTag();
    }
}
 
開發者ID:dimagi,項目名稱:commcare-j2me,代碼行數:15,代碼來源:DetailFieldParser.java

示例2: parseTemplate

import org.commcare.suite.model.DetailField; //導入方法依賴的package包/類
private void parseTemplate(DetailField.Builder builder) throws InvalidStructureException, IOException, XmlPullParserException {
    //Template
    checkNode("template");

    builder.setTemplateWidthHint(parser.getAttributeValue(null, "width"));

    String form = parser.getAttributeValue(null, "form");
    if (form == null) {
        form = "";
    }
    builder.setTemplateForm(form);

    parser.nextTag();
    DetailTemplate template;
    if (form.equals("graph")) {
        template = graphParser.parse();
    } else if (form.equals("callout")) {
        template = new CalloutParser(parser).parse();
    } else {
        checkNode("text");
        try {
            template = new TextParser(parser).parse();
        } catch (InvalidStructureException ise) {
            throw new InvalidStructureException("Error in suite detail with id " + id + " : " + ise.getMessage(), parser);
        }
    }
    builder.setTemplate(template);
}
 
開發者ID:dimagi,項目名稱:commcare-j2me,代碼行數:29,代碼來源:DetailFieldParser.java

示例3: parseBlanksPreference

import org.commcare.suite.model.DetailField; //導入方法依賴的package包/類
private void parseBlanksPreference(DetailField.Builder builder, String direction) {
    String blanksPreference = parser.getAttributeValue(null, "blanks");
    if ("last".equals(blanksPreference)) {
        builder.setShowBlanksLast(true);
    } else if ("first".equals(blanksPreference)) {
        builder.setShowBlanksLast(false);
    } else {
        // If HQ hasn't specified "first" or "last", default to the behavior from before the
        // "blanks" attribute existed
        builder.setShowBlanksLast(!"ascending".equals(direction));
    }
}
 
開發者ID:dimagi,項目名稱:commcare-core,代碼行數:13,代碼來源:DetailFieldParser.java

示例4: parse

import org.commcare.suite.model.DetailField; //導入方法依賴的package包/類
public DetailField parse() throws InvalidStructureException, IOException, XmlPullParserException {
    checkNode("field");

    DetailField.Builder builder = new DetailField.Builder();

    //Get the fields
    String sortDefault = parser.getAttributeValue(null, "sort");
    if (sortDefault != null && sortDefault.equals("default")) {
        builder.setSortOrder(1);
    }
    String relevancy = parser.getAttributeValue(null, "relevant");
    if (relevancy != null) {
        try {
            XPathParseTool.parseXPath(relevancy);
            builder.setRelevancy(relevancy);
        } catch (XPathSyntaxException e) {
            e.printStackTrace();
            throw new InvalidStructureException("Bad XPath Expression {" + relevancy + "}", parser);
        }
    }
    if (nextTagInBlock("field")) {
        parseStyle(builder);
        checkNode("header");

        builder.setHeaderWidthHint(parser.getAttributeValue(null, "width"));

        String form = parser.getAttributeValue(null, "form");
        builder.setHeaderForm(form == null ? "" : form);

        parser.nextTag();
        checkNode("text");
        Text header = new TextParser(parser).parse();
        builder.setHeader(header);

    } else {
        throw new InvalidStructureException("Not enough field entries", parser);
    }
    if (nextTagInBlock("field")) {
        parseTemplate(builder);
    } else {
        throw new InvalidStructureException("detail <field> with no <template>!", parser);
    }
    if (nextTagInBlock("field")) {
        //sort details
        checkNode(new String[]{"sort", "background"});

        String name = parser.getName().toLowerCase();

        if (name.equals("sort")) {
            parseSort(builder);
        } else if (name.equals("background")) {
            // background tag in fields is deprecated
            skipBlock("background");
        }
    }
    return builder.build();
}
 
開發者ID:dimagi,項目名稱:commcare-j2me,代碼行數:58,代碼來源:DetailFieldParser.java

示例5: parseSort

import org.commcare.suite.model.DetailField; //導入方法依賴的package包/類
private void parseSort(DetailField.Builder builder) throws InvalidStructureException, IOException, XmlPullParserException {
    //So in the past we've been fairly flexible about inputs to attributes and such
    //in case we want to expand their function in the future. These are limited sets,
    //and it'd be nice to limit their inputs and fail fast, but that also means
    //we have to be careful about not changing their input values in-major release
    //version, so we'll be flexible for now.

    String order = parser.getAttributeValue(null, "order");
    if (order != null && !"".equals(order)) {
        try {
            builder.setSortOrder(Integer.parseInt(order));
        } catch (NumberFormatException nfe) {
            //see above comment
        }
    }
    String direction = parser.getAttributeValue(null, "direction");
    if ("ascending".equals(direction)) {
        builder.setSortDirection(DetailField.DIRECTION_ASCENDING);
    } else if ("descending".equals(direction)) {
        builder.setSortDirection(DetailField.DIRECTION_DESCENDING);
    } else {
        //see above comment. Also note that this catches the null case,
        //which will need to be caught specially otherwise
    }

    //See if there's a sort type
    String type = parser.getAttributeValue(null, "type");
    if ("int".equals(type)) {
        builder.setSortType(Constants.DATATYPE_INTEGER);
    } else if ("double".equals(type)) {
        builder.setSortType(Constants.DATATYPE_DECIMAL);
    } else if ("string".equals(type)) {
        builder.setSortType(Constants.DATATYPE_TEXT);
    } else {
        //see above comment
    }

    //See if this has a text value for the sort
    if (nextTagInBlock("sort")) {
        //Make sure the internal element _is_ a text
        checkNode("text");

        //Get it if so
        Text sort = new TextParser(parser).parse();
        builder.setSort(sort);
    }
}
 
開發者ID:dimagi,項目名稱:commcare-j2me,代碼行數:48,代碼來源:DetailFieldParser.java

示例6: parse

import org.commcare.suite.model.DetailField; //導入方法依賴的package包/類
@Override
public DetailField parse() throws InvalidStructureException, IOException, XmlPullParserException {
    checkNode("field");

    DetailField.Builder builder = new DetailField.Builder();

    String sortDefault = parser.getAttributeValue(null, "sort");
    if (sortDefault != null && sortDefault.equals("default")) {
        builder.setSortOrder(1);
    }
    String relevancy = parser.getAttributeValue(null, "relevant");
    if (relevancy != null) {
        try {
            XPathParseTool.parseXPath(relevancy);
            builder.setRelevancy(relevancy);
        } catch (XPathSyntaxException e) {
            e.printStackTrace();
            throw new InvalidStructureException("Bad XPath Expression {" + relevancy + "}", parser);
        }
    }
    String printId = parser.getAttributeValue(null, "print-id");
    if (printId != null) {
        builder.setPrintIdentifier(printId);
    }

    if (nextTagInBlock("field")) {
        parseStyle(builder);
        checkNode("header");

        builder.setHeaderWidthHint(parser.getAttributeValue(null, "width"));

        String form = parser.getAttributeValue(null, "form");
        builder.setHeaderForm(form == null ? "" : form);

        parser.nextTag();
        checkNode("text");
        Text header = new TextParser(parser).parse();
        builder.setHeader(header);

    } else {
        throw new InvalidStructureException("Not enough field entries", parser);
    }
    if (nextTagInBlock("field")) {
        parseTemplate(builder);
    } else {
        throw new InvalidStructureException("detail <field> with no <template>!", parser);
    }
    if (nextTagInBlock("field")) {
        //sort details
        checkNode(new String[]{"sort", "background"});

        String name = parser.getName().toLowerCase();

        if (name.equals("sort")) {
            parseSort(builder);
        } else if (name.equals("background")) {
            // background tag in fields is deprecated
            skipBlock("background");
        }
    }
    return builder.build();
}
 
開發者ID:dimagi,項目名稱:commcare-core,代碼行數:63,代碼來源:DetailFieldParser.java

示例7: parseSort

import org.commcare.suite.model.DetailField; //導入方法依賴的package包/類
private void parseSort(DetailField.Builder builder) throws InvalidStructureException, IOException, XmlPullParserException {
    //So in the past we've been fairly flexible about inputs to attributes and such
    //in case we want to expand their function in the future. These are limited sets,
    //and it'd be nice to limit their inputs and fail fast, but that also means
    //we have to be careful about not changing their input values in-major release
    //version, so we'll be flexible for now.

    String order = parser.getAttributeValue(null, "order");
    if (order != null && !"".equals(order)) {
        try {
            builder.setSortOrder(Integer.parseInt(order));
        } catch (NumberFormatException nfe) {
            //see above comment
        }
    }
    String direction = parser.getAttributeValue(null, "direction");
    if ("ascending".equals(direction)) {
        builder.setSortDirection(DetailField.DIRECTION_ASCENDING);
    } else if ("descending".equals(direction)) {
        builder.setSortDirection(DetailField.DIRECTION_DESCENDING);
    } else {
        //see above comment. Also note that this catches the null case,
        //which will need to be caught specially otherwise
    }

    //See if there's a sort type
    String type = parser.getAttributeValue(null, "type");
    if ("int".equals(type)) {
        builder.setSortType(Constants.DATATYPE_INTEGER);
    } else if ("double".equals(type)) {
        builder.setSortType(Constants.DATATYPE_DECIMAL);
    } else if ("string".equals(type)) {
        builder.setSortType(Constants.DATATYPE_TEXT);
    } else {
        //see above comment
    }

    parseBlanksPreference(builder, direction);

    //See if this has a text value for the sort
    if (nextTagInBlock("sort")) {
        //Make sure the internal element _is_ a text
        checkNode("text");

        //Get it if so
        Text sort = new TextParser(parser).parse();
        builder.setSort(sort);
    }
}
 
開發者ID:dimagi,項目名稱:commcare-core,代碼行數:50,代碼來源:DetailFieldParser.java


注:本文中的org.commcare.suite.model.DetailField.Builder方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。