本文整理汇总了Java中org.javarosa.core.model.instance.InvalidReferenceException.getMessage方法的典型用法代码示例。如果您正苦于以下问题:Java InvalidReferenceException.getMessage方法的具体用法?Java InvalidReferenceException.getMessage怎么用?Java InvalidReferenceException.getMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.javarosa.core.model.instance.InvalidReferenceException
的用法示例。
在下文中一共展示了InvalidReferenceException.getMessage方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createModelIfBelowMaxCount
import org.javarosa.core.model.instance.InvalidReferenceException; //导入方法依赖的package包/类
private static void createModelIfBelowMaxCount(FormIndex index, FormDef form, int fullcount) {
TreeReference ref = form.getChildInstanceRef(index);
TreeElement element = form.getMainInstance().resolveReference(ref);
if (element == null) {
int instanceIndexOfDeepestRepeat = index.getLastRepeatInstanceIndex();
if (instanceIndexOfDeepestRepeat == -1) {
throw new RuntimeException("Attempting to expand a repeat for a form index where no repeats were present: " + index);
}
if (instanceIndexOfDeepestRepeat < fullcount) {
try {
form.createNewRepeat(index);
} catch (InvalidReferenceException ire) {
ire.printStackTrace();
throw new RuntimeException("Invalid Reference while creating new repeat!" + ire.getMessage());
}
}
}
}
示例2: answerQuestion
import org.javarosa.core.model.instance.InvalidReferenceException; //导入方法依赖的package包/类
/**
* Attempts to save the answer at the specified FormIndex into the
* datamodel.
*
* @param index
* @param data
* @return OK if save was successful, error if a constraint was violated.
*/
public int answerQuestion(FormIndex index, IAnswerData data, boolean midSurvey) {
QuestionDef q = model.getQuestionPrompt(index).getQuestion();
if (model.getEvent(index) != FormEntryController.EVENT_QUESTION) {
throw new RuntimeException("Non-Question object at the form index.");
}
TreeElement element = model.getTreeElement(index);
boolean complexQuestion = q.isComplex();
boolean hasConstraints = false;
if (element.isRequired() && data == null) {
return ANSWER_REQUIRED_BUT_EMPTY;
} else if (!complexQuestion && !model.getForm().evaluateConstraint(index.getReference(), data)) {
return ANSWER_CONSTRAINT_VIOLATED;
} else if (!complexQuestion) {
commitAnswer(element, index, data, midSurvey);
return ANSWER_OK;
} else if (complexQuestion && hasConstraints) {
//TODO: itemsets: don't currently evaluate constraints for itemset/copy -- haven't figured out how handle it yet
throw new RuntimeException("Itemsets do not currently evaluate constraints. Your constraint will not work, please remove it before proceeding.");
} else {
try {
model.getForm().copyItemsetAnswer(q, element, data, midSurvey);
} catch (InvalidReferenceException ire) {
ire.printStackTrace();
throw new RuntimeException("Invalid reference while copying itemset answer: " + ire.getMessage());
}
return ANSWER_OK;
}
}
示例3: newRepeat
import org.javarosa.core.model.instance.InvalidReferenceException; //导入方法依赖的package包/类
/**
* Creates a new repeated instance of the group referenced by the specified
* FormIndex.
*
* @param questionIndex
*/
public void newRepeat(FormIndex questionIndex) {
try{
model.getForm().createNewRepeat(questionIndex);
} catch(InvalidReferenceException ire) {
throw new RuntimeException("Invalid reference while copying itemset answer: " + ire.getMessage());
}
}
示例4: createModelIfNecessary
import org.javarosa.core.model.instance.InvalidReferenceException; //导入方法依赖的package包/类
/**
* For the current index: Checks whether the index represents a node which
* should exist given a non-interactive repeat, along with a count for that
* repeat which is beneath the dynamic level specified.
*
* If this index does represent such a node, the new model for the repeat is
* created behind the scenes and the index for the initial question is
* returned.
*
* Note: This method will not prevent the addition of new repeat elements in
* the interface, it will merely use the xforms repeat hint to create new
* nodes that are assumed to exist
*
* @param index The index to be evaluated as to whether the underlying model is
* hinted to exist
*/
private void createModelIfNecessary(FormIndex index) {
if (index.isInForm()) {
IFormElement e = getForm().getChild(index);
if (e instanceof GroupDef) {
GroupDef g = (GroupDef) e;
if (g.getRepeat() && g.getCountReference() != null) {
// Lu Gram: repeat count XPath needs to be contextualized for nested repeat groups
TreeReference countRef = FormInstance.unpackReference(g.getCountReference());
TreeReference contextualized = countRef.contextualize(index.getReference());
IAnswerData count = getForm().getMainInstance().resolveReference(contextualized).getValue();
if (count != null) {
long fullcount = ((Integer) count.getValue()).intValue();
TreeReference ref = getForm().getChildInstanceRef(index);
TreeElement element = getForm().getMainInstance().resolveReference(ref);
if (element == null) {
if (index.getTerminal().getInstanceIndex() < fullcount) {
try {
getForm().createNewRepeat(index);
} catch (InvalidReferenceException ire) {
ire.printStackTrace();
throw new RuntimeException("Invalid Reference while creting new repeat!" + ire.getMessage());
}
}
}
}
}
}
}
}
示例5: newRepeat
import org.javarosa.core.model.instance.InvalidReferenceException; //导入方法依赖的package包/类
/**
* Creates a new repeated instance of the group referenced by the specified
* FormIndex.
*/
public void newRepeat(FormIndex questionIndex) {
try {
model.getForm().createNewRepeat(questionIndex);
formEntrySession.addNewRepeat(questionIndex);
} catch (InvalidReferenceException ire) {
throw new RuntimeException("Invalid reference while copying itemset answer: " + ire.getMessage());
}
}
示例6: createModelIfNecessary
import org.javarosa.core.model.instance.InvalidReferenceException; //导入方法依赖的package包/类
/**
* For the current index: Checks whether the index represents a node which
* should exist given a non-interactive repeat, along with a count for that
* repeat which is beneath the dynamic level specified.
*
* If this index does represent such a node, the new model for the repeat is
* created behind the scenes and the index for the initial question is
* returned.
*
* Note: This method will not prevent the addition of new repeat elements in
* the interface, it will merely use the xforms repeat hint to create new
* nodes that are assumed to exist
*
* @param index To be evaluated as to whether the underlying model is
* hinted to exist
*/
public void createModelIfNecessary(FormIndex index) {
if (index.isInForm()) {
IFormElement e = getForm().getChild(index);
if (e instanceof GroupDef) {
GroupDef g = (GroupDef)e;
if (g.getRepeat() && g.getCountReference() != null) {
IAnswerData count = getForm().getMainInstance().resolveReference(g.getConextualizedCountReference(index.getReference())).getValue();
if (count != null) {
int fullcount = -1;
try {
fullcount = ((Integer)new IntegerData().cast(count.uncast()).getValue()).intValue();
} catch (IllegalArgumentException iae) {
throw new RuntimeException("The repeat count value \"" + count.uncast().getString() + "\" at " + g.getConextualizedCountReference(index.getReference()).toString() + " must be a number!");
}
TreeReference ref = getForm().getChildInstanceRef(index);
TreeElement element = getForm().getMainInstance().resolveReference(ref);
if (element == null) {
if (index.getInstanceIndex() < fullcount) {
try {
getForm().createNewRepeat(index);
} catch (InvalidReferenceException ire) {
ire.printStackTrace();
throw new RuntimeException("Invalid Reference while creating new repeat!" + ire.getMessage());
}
}
}
}
}
}
}
}
示例7: answerQuestion
import org.javarosa.core.model.instance.InvalidReferenceException; //导入方法依赖的package包/类
/**
* Attempts to save the answer at the specified FormIndex into the
* datamodel.
*
* @return OK if save was successful, error if a constraint was violated.
*/
public int answerQuestion(FormIndex index, IAnswerData data) {
QuestionDef q = model.getQuestionPrompt(index).getQuestion();
if (model.getEvent(index) != FormEntryController.EVENT_QUESTION) {
throw new RuntimeException("Non-Question object at the form index.");
}
TreeElement element = model.getTreeElement(index);
// A question is complex when it has a copy tag that needs to be
// evaluated by copying in the correct xml subtree. XXX: The code to
// answer complex questions is incomplete, but luckily this feature is
// rarely used.
boolean complexQuestion = q.isComplex();
boolean hasConstraints = false;
if (element.isRequired() && data == null) {
return ANSWER_REQUIRED_BUT_EMPTY;
}
if (complexQuestion) {
if (hasConstraints) {
//TODO: itemsets: don't currently evaluate constraints for
//itemset/copy -- haven't figured out how handle it yet
throw new RuntimeException("Itemsets do not currently evaluate constraints. Your constraint will not work, please remove it before proceeding.");
} else {
try {
model.getForm().copyItemsetAnswer(q, element, data);
} catch (InvalidReferenceException ire) {
ire.printStackTrace();
throw new RuntimeException("Invalid reference while copying itemset answer: " + ire.getMessage());
}
q.getActionController().triggerActionsFromEvent(Action.EVENT_QUESTION_VALUE_CHANGED, model.getForm());
return ANSWER_OK;
}
} else {
if (!model.getForm().evaluateConstraint(index.getReference(), data)) {
// constraint checking failed
return ANSWER_CONSTRAINT_VIOLATED;
}
commitAnswer(element, index, data);
q.getActionController().triggerActionsFromEvent(Action.EVENT_QUESTION_VALUE_CHANGED, model.getForm());
return ANSWER_OK;
}
}