当前位置: 首页>>代码示例>>Java>>正文


Java XFormUtils类代码示例

本文整理汇总了Java中org.javarosa.xform.util.XFormUtils的典型用法代码示例。如果您正苦于以下问题:Java XFormUtils类的具体用法?Java XFormUtils怎么用?Java XFormUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


XFormUtils类属于org.javarosa.xform.util包,在下文中一共展示了XFormUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parseBind

import org.javarosa.xform.util.XFormUtils; //导入依赖的package包/类
protected void parseBind(Element e) {
  // remember raw bindings in case we want to compare parsed XForms later
  parser.bindElements.add(copyBindingElement(e));
  List<String> usedAtts = new ArrayList<String>();

  DataBinding binding = processStandardBindAttributes(usedAtts, e);

  String value = e.getAttributeValue(ParserConsts.NAMESPACE_ODK, "length");
  if (value != null) {
    e.setAttribute(ParserConsts.NAMESPACE_ODK, "length", null);
  }

  log.info("Calling handle found value " + ((value == null) ? "null" : value));

  if (value != null) {
    Integer iValue = Integer.valueOf(value);
    parser.setNodesetStringLength(e.getAttributeValue(null, "nodeset"), iValue);
  }

  // print unused attribute warning message for parent element
  if (XFormUtils.showUnusedAttributeWarning(e, usedAtts)) {
    System.out.println(XFormUtils.unusedAttWarning(e, usedAtts));
  }

  addBinding(binding);
}
 
开发者ID:opendatakit,项目名称:aggregate,代码行数:27,代码来源:BaseFormParserForJavaRosa.java

示例2: main

import org.javarosa.xform.util.XFormUtils; //导入依赖的package包/类
/**
 * @param args
 */
public static void main(String[] args) {
	// Very simple class that takes in an xform as an argument then outputs the debug
	// info from the XForm parser
	
	if( args.length != 1 ) {
		System.err.println("Usage: validator <xform>\n\tNOTE: the <xform> must be the full path to the file.");
		return;
	}
	
	String xf_name = args[0];
	FileInputStream is;
	try {
		is = new FileInputStream(xf_name);
	} catch (FileNotFoundException e) {
		System.err.println("Error: the file '" + xf_name + "' could not be found!");
		return;
	}
	
	XFormUtils.getFormFromInputStream(is);
}
 
开发者ID:medic,项目名称:javarosa,代码行数:24,代码来源:MainClass.java

示例3: summarize

import org.javarosa.xform.util.XFormUtils; //导入依赖的package包/类
private void summarize() {
	addToTextArea("\n\n==================================\nForm Summary\n==================================\n");
	updateStatus("Creating Summary");
	
	FileInputStream in;
	try {
		in = new FileInputStream(newForm);
		FormDef f = XFormUtils.getFormFromInputStream(in);
		addToTextArea(FormOverview.overview(f, this.languages.getSelectedItem()));
		addToTextArea("\n\n==================================\nForm Summary Complete\n==================================\n");
		updateStatus("Summary Completed");
	} catch (FileNotFoundException e) {
		addToTextArea("ERROR! File Not Found Exception when attempting to load form " + newForm);
		e.printStackTrace();
		updateStatus("Error while loading form");
	}
	 
	
}
 
开发者ID:medic,项目名称:javarosa,代码行数:20,代码来源:XFormValidatorGUI.java

示例4: updateLang

import org.javarosa.xform.util.XFormUtils; //导入依赖的package包/类
private void updateLang() {
	try {
		languages.removeAll();
		FileInputStream in = new FileInputStream(newForm);
		FormDef f = XFormUtils.getFormFromInputStream(in);
		if (f.getLocalizer() != null) {
			String[] locales = f.getLocalizer().getAvailableLocales();
			for (int i = 0; i < locales.length; ++i) {
				languages.add(locales[i]);
			}
			languages.select(f.getLocalizer().getDefaultLocale());
			languages.setVisible(true);
		} else {
			languages.setVisible(false);
		}
	} catch (Exception e) {
		//All failures here should just get swallowed, this is tertiary functionality
		e.printStackTrace();
		languages.setVisible(false);
	}
}
 
开发者ID:medic,项目名称:javarosa,代码行数:22,代码来源:XFormValidatorGUI.java

示例5: FormInstanceValidator

import org.javarosa.xform.util.XFormUtils; //导入依赖的package包/类
public FormInstanceValidator(InputStream formInput, InputStream instanceInput) throws Exception {
		theForm = XFormUtils.getFormFromInputStream(formInput);
		
		savedModel = XFormParser.restoreDataModel(instanceInput, null);
        TreeElement templateRoot = theForm.getInstance().getRoot().deepCopy(true);

        //sanity check instance names before loading
        if (!savedModel.getRoot().getName().equals(templateRoot.getName()) || savedModel.getRoot().getMult() != 0) {
			System.out.println("Instance model name does not match xform instance name.");
			System.out.println("Instance: " + savedModel.getName() + " Xform: " + templateRoot.getName());
			System.exit(1);
        }
        
        model = new FormEntryModel(theForm);
        controller = new FormEntryController(model);

        
        //Populate XForm Model 
//        TreeReference tr = TreeReference.rootRef();
//        tr.add(templateRoot.getName(), TreeReference.INDEX_UNBOUND);
//        templateRoot.populate(savedRoot, f);
//
//        f.getInstance().setRoot(templateRoot);
	}
 
开发者ID:medic,项目名称:javarosa,代码行数:25,代码来源:FormInstanceValidator.java

示例6: parseTitle

import org.javarosa.xform.util.XFormUtils; //导入依赖的package包/类
private void parseTitle (Element e) {
     List<String> usedAtts = new ArrayList<String>(); //no attributes parsed in title.
	String title = getXMLText(e, true);
	System.out.println("Title: \"" + title + "\"");
	_f.setTitle(title);
	if(_f.getName() == null) {
		//Jan 9, 2009 - ctsims
		//We don't really want to allow for forms without
		//some unique ID, so if a title is available, use
		//that.
		_f.setName(title);
	}


	if(XFormUtils.showUnusedAttributeWarning(e, usedAtts)){
		reporter.warning(XFormParserReporter.TYPE_UNKNOWN_MARKUP, XFormUtils.unusedAttWarning(e, usedAtts), getVagueLocation(e));
	}
}
 
开发者ID:medic,项目名称:javarosa,代码行数:19,代码来源:XFormParser.java

示例7: parseMeta

import org.javarosa.xform.util.XFormUtils; //导入依赖的package包/类
private void parseMeta (Element e) {
     List<String> usedAtts = new ArrayList<String>();
	int attributes = e.getAttributeCount();
	for(int i = 0 ; i < attributes ; ++i) {
		String name = e.getAttributeName(i);
		String value = e.getAttributeValue(i);
		if("name".equals(name)) {
			_f.setName(value);
		}
	}


	usedAtts.add("name");
	if(XFormUtils.showUnusedAttributeWarning(e, usedAtts)){
		reporter.warning(XFormParserReporter.TYPE_UNKNOWN_MARKUP, XFormUtils.unusedAttWarning(e, usedAtts), getVagueLocation(e));
	}
}
 
开发者ID:medic,项目名称:javarosa,代码行数:18,代码来源:XFormParser.java

示例8: parseQuestionLabel

import org.javarosa.xform.util.XFormUtils; //导入依赖的package包/类
private void parseQuestionLabel (QuestionDef q, Element e) {
	String label = getLabel(e);
	String ref = e.getAttributeValue("", REF_ATTR);

     List<String> usedAtts = new ArrayList<String>();
	usedAtts.add(REF_ATTR);

	if (ref != null) {
		if (ref.startsWith(ITEXT_OPEN) && ref.endsWith(ITEXT_CLOSE)) {
			String textRef = ref.substring(ITEXT_OPEN.length(), ref.indexOf(ITEXT_CLOSE));

			verifyTextMappings(textRef, "Question <label>", true);
			q.setTextID(textRef);
		} else {
			throw new RuntimeException("malformed ref [" + ref + "] for <label>");
		}
	} else {
		q.setLabelInnerText(label);
	}


	if(XFormUtils.showUnusedAttributeWarning(e, usedAtts)){
		reporter.warning(XFormParserReporter.TYPE_UNKNOWN_MARKUP, XFormUtils.unusedAttWarning(e, usedAtts), getVagueLocation(e));
	}
}
 
开发者ID:medic,项目名称:javarosa,代码行数:26,代码来源:XFormParser.java

示例9: recurseForOutput

import org.javarosa.xform.util.XFormUtils; //导入依赖的package包/类
private void recurseForOutput(Element e){
	if(e.getChildCount() == 0) return;

	for(int i=0;i<e.getChildCount();i++){
		int kidType = e.getType(i);
		if(kidType == Node.TEXT) { continue; }
		if(e.getChild(i) instanceof String) { continue; }
		Element kid = (Element)e.getChild(i);

			//is just text
		if(kidType == Node.ELEMENT && XFormUtils.isOutput(kid)){
			String s = "${"+parseOutput(kid)+"}";
			e.removeChild(i);
			e.addChild(i, Node.TEXT, s);

			//has kids? Recurse through them and swap output tag for parsed version
		}else if(kid.getChildCount() !=0){
			recurseForOutput(kid);
			//is something else
		}else{
			continue;
		}
	}
}
 
开发者ID:medic,项目名称:javarosa,代码行数:25,代码来源:XFormParser.java

示例10: parseHint

import org.javarosa.xform.util.XFormUtils; //导入依赖的package包/类
private void parseHint (QuestionDef q, Element e) {
     List<String> usedAtts = new ArrayList<String>();
	usedAtts.add(REF_ATTR);
	String hint = getXMLText(e, true);
	String hintInnerText = getLabel(e);
	String ref = e.getAttributeValue("", REF_ATTR);

	if (ref != null) {
		if (ref.startsWith(ITEXT_OPEN) && ref.endsWith(ITEXT_CLOSE)) {
			String textRef = ref.substring(ITEXT_OPEN.length(), ref.indexOf(ITEXT_CLOSE));

			verifyTextMappings(textRef, "<hint>", false);
			q.setHelpTextID(textRef);
		} else {
			throw new RuntimeException("malformed ref [" + ref + "] for <hint>");
		}
	} else {
	    q.setHelpInnerText(hintInnerText);
		q.setHelpText(hint);
	}

	if(XFormUtils.showUnusedAttributeWarning(e, usedAtts)){
		reporter.warning(XFormParserReporter.TYPE_UNKNOWN_MARKUP, XFormUtils.unusedAttWarning(e, usedAtts), getVagueLocation(e));
	}
}
 
开发者ID:medic,项目名称:javarosa,代码行数:26,代码来源:XFormParser.java

示例11: parseIText

import org.javarosa.xform.util.XFormUtils; //导入依赖的package包/类
private void parseIText (Element itext) {
	Localizer l = new Localizer(true, true);
	_f.setLocalizer(l);
	l.registerLocalizable(_f);

     ArrayList<String> usedAtts = new ArrayList<String>(); //used for warning message

	for (int i = 0; i < itext.getChildCount(); i++) {
		Element trans = itext.getElement(i);
		if (trans == null || !trans.getName().equals("translation"))
			continue;

		parseTranslation(l, trans);
	}

	if (l.getAvailableLocales().length == 0)
		throw new XFormParseException("no <translation>s defined",itext);

	if (l.getDefaultLocale() == null)
		l.setDefaultLocale(l.getAvailableLocales()[0]);

	//print unused attribute warning message for parent element
	if(XFormUtils.showUnusedAttributeWarning(itext, usedAtts)){
		reporter.warning(XFormParserReporter.TYPE_UNKNOWN_MARKUP, XFormUtils.unusedAttWarning(itext, usedAtts), getVagueLocation(itext));
	}
}
 
开发者ID:medic,项目名称:javarosa,代码行数:27,代码来源:XFormParser.java

示例12: testGeoShapeSupportForEnclosedArea

import org.javarosa.xform.util.XFormUtils; //导入依赖的package包/类
public void testGeoShapeSupportForEnclosedArea() throws Exception {
   // Read the form definition
String FORM_NAME = (new File(PathConst.getTestResourcePath(), "area.xml")).getAbsolutePath();
InputStream is = null;
FormDef formDef = null;
is = new FileInputStream(new File(FORM_NAME));
   formDef = XFormUtils.getFormFromInputStream(is);

   // trigger all calculations
   formDef.initialize(true, new InstanceInitializationFactory());

   // get the calculated area
   IAnswerData areaResult = formDef.getMainInstance().getRoot().getChildAt(1).getValue();

   assertTrue((int) Math.rint((Double) areaResult.getValue()) == 151452);
 }
 
开发者ID:medic,项目名称:javarosa,代码行数:17,代码来源:GeoShapeAreaTest.java

示例13: init

import org.javarosa.xform.util.XFormUtils; //导入依赖的package包/类
public void init(){
	String xf_name = FORM_NAME; 			
	FileInputStream is;
	try {
		is = new FileInputStream(xf_name);
	} catch (FileNotFoundException e) {
		System.err.println("Error: the file '" + xf_name
				+ "' could not be found!");
		throw new RuntimeException("Error: the file '" + xf_name
				+ "' could not be found!");
	}
	
	// Parse the form
	xform = XFormUtils.getFormFromInputStream(is);
	
	femodel = new FormEntryModel(xform);
	fec = new FormEntryController(femodel);
	
	if( xform == null ) {
		System.out.println("\n\n==================================\nERROR: XForm has failed validation!!");
	} else {
	}
}
 
开发者ID:medic,项目名称:javarosa,代码行数:24,代码来源:FormParseInit.java

示例14: main

import org.javarosa.xform.util.XFormUtils; //导入依赖的package包/类
/**
 * @param args
 */
public static void main(String[] args) {
    // Very simple class that takes in an xform as an argument then outputs the debug
    // info from the XForm parser

    if( args.length != 1 ) {
        System.err.println("Usage: validator <xform>\n\tNOTE: the <xform> must be the full path to the file.");
        return;
    }

    String xf_name = args[0];
    FileInputStream is;
    try {
        is = new FileInputStream(xf_name);
    } catch (FileNotFoundException e) {
        System.err.println("Error: the file '" + xf_name + "' could not be found!");
        return;
    }

    XFormUtils.getFormFromInputStream(is);
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:24,代码来源:MainClass.java

示例15: summarize

import org.javarosa.xform.util.XFormUtils; //导入依赖的package包/类
private void summarize() {
    addToTextArea("\n\n==================================\nForm Summary\n==================================\n");
    updateStatus("Creating Summary");

    FileInputStream in;
    try {
        in = new FileInputStream(newForm);
        FormDef f = XFormUtils.getFormFromInputStream(in);
        addToTextArea(FormOverview.overview(f, this.languages.getSelectedItem()));
        addToTextArea("\n\n==================================\nForm Summary Complete\n==================================\n");
        updateStatus("Summary Completed");
    } catch (FileNotFoundException e) {
        addToTextArea("ERROR! File Not Found Exception when attempting to load form " + newForm);
        e.printStackTrace();
        updateStatus("Error while loading form");
    }


}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:20,代码来源:XFormValidatorGUI.java


注:本文中的org.javarosa.xform.util.XFormUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。