本文整理汇总了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();
}
}
示例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);
}
示例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));
}
}
示例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();
}
示例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);
}
}
示例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();
}
示例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);
}
}