/// <summary> Attempts to return the specified Item (from a select or 1select) text. /// Will check for text in the following order:<br/> /// Localized Text (long form) -> Localized Text (no special form) <br /> /// If no textID is available, method will return this item's labelInnerText. /// </summary> /// <param name="sel">the selection (item), if <code>null</code> will throw a IllegalArgumentException /// </param> /// <returns> Question Text. <code>null</code> if no text for this element exists (after all fallbacks). /// </returns> /// <throws> RunTimeException if this method is called on an element that is NOT a QuestionDef </throws> /// <throws> IllegalArgumentException if Selection is <code>null</code> </throws> public virtual System.String getSelectItemText(Selection sel) { //throw tantrum if this method is called when it shouldn't be or sel==null if (!(FormElement is QuestionDef)) { throw new System.SystemException("Can't retrieve question text for non-QuestionDef form elements!"); } if (sel == null) { throw new System.ArgumentException("Cannot use null as an argument!"); } //Just in case the selection hasn't had a chance to be initialized yet. if (sel.index == -1) { sel.attachChoice(this.Question); } //check for the null id case and return labelInnerText if it is so. System.String tid = sel.choice.TextID; if (tid == null || (System.Object)tid == (System.Object) "") { return(substituteStringArgs(sel.choice.getLabelInnerText())); } //otherwise check for 'long' form of the textID, then for the default form and return System.String returnText; returnText = getIText(tid, "long"); if (returnText == null) { returnText = getIText(tid, null); } return(substituteStringArgs(returnText)); }
private void InitBlock() { Value = vs; List< Selection > output = new List< Selection >(); //validate type for (int i = 0; i < input.size(); i++) { Selection s = (Selection) input.elementAt(i); output.addElement(s); } return output; }
private static Selection getSelection(System.String choiceValue, QuestionDef q) { Selection s; if (q == null || q.DynamicChoices != null) { s = new Selection(choiceValue); } else { SelectChoice choice = q.getChoiceForValue(choiceValue); s = (choice != null?choice.selection():null); } return(s); }
private static System.Collections.ArrayList getSelections(System.String text, QuestionDef q) { System.Collections.ArrayList v = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10)); System.Collections.ArrayList choices = DateUtils.split(text, XFormAnswerDataSerializer.DELIMITER, true); for (int i = 0; i < choices.Count; i++) { Selection s = getSelection((System.String)choices[i], q); if (s != null) { v.Add(s); } } return(v); }
/// <summary> extract the value out of a Selection according to the current CHOICE_MODE</summary> /// <param name="s"> /// </param> /// <returns> Integer or String /// </returns> private System.Object extractSelection(Selection s) { switch (CHOICE_MODE) { case CHOICE_VALUE: return(s.Value); case CHOICE_INDEX: if (s.index == -1) { throw new System.SystemException("trying to serialize in choice-index mode but selections do not have indexes set!"); } return((System.Int32)s.index); default: throw new System.ArgumentException(); } }
/// <param name="data">The AnswerDataObject to be serialized /// </param> /// <returns> A string containing the xforms compliant format /// for a <select> tag, a string containing a list of answers /// separated by space characters. /// </returns> public virtual System.Object serializeAnswerData(SelectMultiData data) { System.Collections.ArrayList selections = (System.Collections.ArrayList)data.Value; System.Collections.IEnumerator en = selections.GetEnumerator(); StringBuilder selectString = new StringBuilder(); //UPGRADE_TODO: Method 'java.util.Enumeration.hasMoreElements' was converted to 'System.Collections.IEnumerator.MoveNext' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilEnumerationhasMoreElements'" while (en.MoveNext()) { //UPGRADE_TODO: Method 'java.util.Enumeration.nextElement' was converted to 'System.Collections.IEnumerator.Current' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilEnumerationnextElement'" Selection selection = (Selection)en.Current; if (selectString.length() > 0) { selectString.append(DELIMITER); } selectString.append(selection.Value); } //As Crazy, and stupid, as it sounds, this is the XForms specification //for storing multiple selections. return(selectString.toString()); }
/// <summary> This method is generally used to retrieve special forms for a /// (select or 1select) item, e.g. "audio", "video", etc. /// /// </summary> /// <param name="sel">- The Item whose text you're trying to retrieve. /// </param> /// <param name="form">- Special text form of Item you're trying to retrieve. /// </param> /// <returns> Special Form Text. <code>null</code> if no text for this element exists (with the specified special form). /// </returns> /// <throws> RunTimeException if this method is called on an element that is NOT a QuestionDef </throws> /// <throws> IllegalArgumentException if <code>sel == null</code> </throws> public virtual System.String getSpecialFormSelectItemText(Selection sel, System.String form) { if (sel == null) { throw new System.ArgumentException("Cannot use null as an argument for Selection!"); } //Just in case the selection hasn't had a chance to be initialized yet. if (sel.index == -1) { sel.attachChoice(this.Question); } System.String textID = sel.choice.TextID; if (textID == null || textID.Equals("")) { return(null); } System.String returnText = getIText(textID, form); return(substituteStringArgs(returnText)); }
//UPGRADE_TODO: Class 'java.io.DataInputStream' was converted to 'System.IO.BinaryReader' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioDataInputStream'" public virtual void readExternal(System.IO.BinaryReader in_Renamed, PrototypeFactory pf) { s = (Selection)ExtUtil.read(in_Renamed, typeof(Selection), pf); }
public SelectOneData(Selection s) { Value = s; }
/// <summary> reduce a SelectOneData to an integer (index mode) or string (value mode)</summary> /// <param name="data"> /// </param> /// <returns> Integer or String /// </returns> private System.Object compactSelectOne(SelectOneData data) { Selection val = (Selection)data.Value; return(extractSelection(val)); }