/// <summary> /// Evaluate arguments. /// </summary> /// <param name="args"> /// argument expressions. </param> /// <exception cref="DynamicError"> /// Dynamic error. </exception> /// <returns> Result of evaluation. </returns> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public org.eclipse.wst.xml.xpath2.api.ResultSequence evaluate(java.util.Collection args, org.eclipse.wst.xml.xpath2.api.EvaluationContext ec) throws org.eclipse.wst.xml.xpath2.processor.DynamicError public override ResultSequence evaluate(ICollection args, EvaluationContext ec) { Debug.Assert(args.Count >= min_arity() && args.Count <= max_arity()); ResultSequence argument = null; if (args.Count == 0) { argument = getResultSetForArityZero(ec); } else { var i = args.GetEnumerator(); i.MoveNext(); argument = (ResultSequence)i.Current; } return(fn_number(argument, ec)); }
/// <summary> /// Creates a new ResultSequence consisting of the base64Binary value /// </summary> /// <param name="arg"> /// The ResultSequence from which to construct base64Binary value </param> /// <returns> New ResultSequence representing base64Binary value </returns> /// <exception cref="DynamicError"> </exception> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public org.eclipse.wst.xml.xpath2.api.ResultSequence constructor(org.eclipse.wst.xml.xpath2.api.ResultSequence arg) throws org.eclipse.wst.xml.xpath2.processor.DynamicError public override ResultSequence constructor(ResultSequence arg) { return(null); //if (arg.empty()) //{ // return ResultBuffer.EMPTY; //} //AnyAtomicType aat = (AnyAtomicType) arg.first(); //if (aat is NumericType || aat is XSDuration || aat is CalendarType || aat is XSBoolean || aat is XSAnyURI) //{ // throw DynamicError.invalidType(); //} //if (!isCastable(aat)) //{ // throw DynamicError.cant_cast(null); //} //string str_value = aat.StringValue; //sbyte[] decodedValue = Base64.decode(str_value); //if (aat is XSHexBinary) //{ // decodedValue = HexBin.decode(str_value); // decodedValue = Base64.encode(decodedValue).Bytes; //} //else //{ // decodedValue = str_value.GetBytes(); //} //if (decodedValue != null) //{ // return new XSBase64Binary(StringHelperClass.NewString(decodedValue)); //} //else //{ // // invalid base64 string // throw DynamicError.throw_type_error(); //} }
/// <summary> /// Year-from-Date operation. /// </summary> /// <param name="args"> /// Result from the expressions evaluation. </param> /// <exception cref="DynamicError"> /// Dynamic error. </exception> /// <returns> Result of fn:year-from-date operation. </returns> public static ResultSequence year_from_date(ICollection args) { ICollection cargs = Function.convert_arguments(args, expected_args()); var i = cargs.GetEnumerator(); i.MoveNext(); ResultSequence arg1 = (ResultSequence)i.Current; if (arg1 == null || arg1.empty()) { return(ResultBuffer.EMPTY); } XSDate dt = (XSDate)arg1.first(); int res = dt.year(); return(new XSInteger(new System.Numerics.BigInteger(res))); }
/// <summary> /// Creates a new ResultSequence consisting of the extractable String in the /// supplied ResultSequence /// </summary> /// <param name="arg"> /// The ResultSequence from which to extract the String </param> /// <returns> New ResultSequence consisting of the supplied String </returns> /// <exception cref="DynamicError"> </exception> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public org.eclipse.wst.xml.xpath2.api.ResultSequence constructor(org.eclipse.wst.xml.xpath2.api.ResultSequence arg) throws org.eclipse.wst.xml.xpath2.processor.DynamicError public override ResultSequence constructor(ResultSequence arg) { if (arg.empty()) { return(ResultBuffer.EMPTY); } Item aat = arg.first(); string srcString = aat.StringValue; if (!isSatisfiesConstraints(srcString)) { // invalid input DynamicError.throw_type_error(); } return(new XSNormalizedString(srcString)); }
/// <summary> /// Base-Uri operation. /// </summary> /// <param name="args"> /// Result from the expressions evaluation. </param> /// <exception cref="DynamicError"> /// Dynamic error. </exception> /// <returns> Result of fn:base-uri operation. </returns> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public static org.eclipse.wst.xml.xpath2.api.ResultSequence seconds_from_time(java.util.Collection args) throws org.eclipse.wst.xml.xpath2.processor.DynamicError public static ResultSequence seconds_from_time(ICollection args) { ICollection cargs = Function.convert_arguments(args, expected_args()); var i = cargs.GetEnumerator(); i.MoveNext(); ResultSequence arg1 = (ResultSequence)i.Current; if (arg1.empty()) { return(ResultBuffer.EMPTY); } XSTime dt = (XSTime)arg1.first(); double res = dt.second(); return(new XSDecimal(new decimal(res))); }
/// <summary> /// Name operation. /// </summary> /// <param name="args"> /// Result from the expressions evaluation. </param> /// <param name="context"> /// Dynamic context. </param> /// <exception cref="DynamicError"> /// Dynamic error. </exception> /// <returns> Result of fn:name operation. </returns> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public static org.eclipse.wst.xml.xpath2.api.ResultSequence name(java.util.Collection args, org.eclipse.wst.xml.xpath2.api.EvaluationContext ec) throws org.eclipse.wst.xml.xpath2.processor.DynamicError public static ResultSequence name(ICollection args, EvaluationContext ec) { ICollection cargs = Function.convert_arguments(args, expected_args()); // get arg ResultSequence arg1 = null; if (cargs.Count == 0) { if (ec.ContextItem == null) { throw DynamicError.contextUndefined(); } else { arg1 = ResultBuffer.wrap(ec.ContextItem); } } else { var i = cargs.GetEnumerator(); i.MoveNext(); arg1 = (ResultSequence)i.Current; } if (arg1.empty()) { return(new XSString("")); } NodeType an = (NodeType)arg1.first(); QName name = an.node_name(); string sname = ""; if (name != null) { sname = name.StringValue; } return(new XSString(sname)); }
/// <summary> /// Matches operation. /// </summary> /// <param name="args"> /// Result from the expressions evaluation. </param> /// <exception cref="DynamicError"> /// Dynamic error. </exception> /// <returns> Result of fn:matches operation. </returns> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public static org.eclipse.wst.xml.xpath2.api.ResultSequence matches(java.util.Collection args) throws org.eclipse.wst.xml.xpath2.processor.DynamicError public static ResultSequence matches(ICollection args) { ICollection cargs = Function.convert_arguments(args, expected_args()); // get args IEnumerator argiter = cargs.GetEnumerator(); argiter.MoveNext(); ResultSequence arg1 = (ResultSequence)argiter.Current; string str1 = ""; if (!arg1.empty()) { str1 = ((XSString)arg1.first()).value(); } argiter.MoveNext(); ResultSequence arg2 = (ResultSequence)argiter.Current; string pattern = ((XSString)arg2.first()).value(); string flags = null; if (argiter.MoveNext()) { ResultSequence flagRS = null; flagRS = (ResultSequence)argiter.Current; flags = flagRS.first().StringValue; if (validflags.IndexOf(flags, StringComparison.Ordinal) == -1 && flags.Length > 0) { throw DynamicError.regex_flags_error(null); } } try { bool result = false; result = matches(pattern, flags, str1); return(XSBoolean.valueOf(result)); } catch (Exception pex) { throw DynamicError.regex_error(pex.Message); } }
/// <summary> /// Local-Name-from-QName operation. /// </summary> /// <param name="args"> /// Result from the expressions evaluation. </param> /// <exception cref="DynamicError"> /// Dynamic error. </exception> /// <returns> Result of fn:local-name-from-QName operation. </returns> public static ResultSequence local_name(ICollection args) { ICollection cargs = Function.convert_arguments(args, expected_args()); // get arg var i = cargs.GetEnumerator(); i.MoveNext(); ResultSequence arg1 = (ResultSequence)i.Current; if (arg1.empty()) { return(ResultBuffer.EMPTY); } QName qname = (QName)arg1.first(); return(new XSNCName(qname.local())); }
/// <summary> /// Language operation. /// </summary> /// <param name="args"> /// Result from the expressions evaluation. </param> /// <exception cref="DynamicError"> /// Dynamic error. </exception> /// <returns> Result of fn:lang operation. </returns> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public static org.eclipse.wst.xml.xpath2.api.ResultSequence lang(java.util.Collection args, org.eclipse.wst.xml.xpath2.api.EvaluationContext ec) throws org.eclipse.wst.xml.xpath2.processor.DynamicError public static ResultSequence lang(ICollection args, EvaluationContext ec) { ICollection cargs = Function.convert_arguments(args, expected_args()); // get arg IEnumerator citer = cargs.GetEnumerator(); citer.MoveNext(); ResultSequence arg1 = (ResultSequence)citer.Current; ResultSequence arg2 = null; if (cargs.Count == 1) { if (ec.ContextItem == null) { throw DynamicError.contextUndefined(); } arg2 = (AnyType)ec.ContextItem; } else { citer.MoveNext(); arg2 = (ResultSequence)citer.Current; } string lang = ""; if (!(arg1 == null || arg1.empty())) { lang = ((XSString)arg1.first()).value(); } if (!(arg2.first() is NodeType)) { throw DynamicError.invalidType(); } NodeType an = (NodeType)arg2.first(); return(new XSBoolean(test_lang(an.node_value(), lang))); }
/// <summary> /// Codepoints to string operation. /// </summary> /// <param name="args"> /// Result from the expressions evaluation. </param> /// <exception cref="DynamicError"> /// Dynamic error. </exception> /// <returns> Result of fn:codepoints-to-string operation. </returns> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public static org.eclipse.wst.xml.xpath2.api.ResultSequence codepoints_to_string(java.util.Collection args) throws org.eclipse.wst.xml.xpath2.processor.DynamicError public static ResultSequence codepoints_to_string(ICollection args) { ICollection cargs = Function.convert_arguments(args, expected_args()); var j = cargs.GetEnumerator(); j.MoveNext(); ResultSequence arg1 = (ResultSequence)j.Current; if (arg1 == null || arg1.empty()) { return(new XSString("")); } int[] codePointArray = new int[arg1.size()]; int codePointIndex = 0; for (var i = arg1.iterator(); i.MoveNext();) { XSInteger code = (XSInteger)i.Current; int codepoint = (int)code.int_value(); if (codepoint < MIN_LEGAL_CODEPOINT || codepoint > MAX_LEGAL_CODEPOINT) { throw DynamicError.unsupported_codepoint("U+" + Convert.ToString(codepoint, 16).ToUpper()); } codePointArray[codePointIndex] = codepoint; codePointIndex++; } try { var c = codePointArray.Select(x => (char)x).ToArray(); string str = new string(c); return(new XSString(str)); } catch (System.ArgumentException iae) { // This should be duoble checked above, but rather safe than sorry throw DynamicError.unsupported_codepoint(iae.Message); } }
/// <summary> /// Op-Intersect operation. /// </summary> /// <param name="args"> /// Result from the expressions evaluation. </param> /// <exception cref="DynamicError"> /// Dynamic error. </exception> /// <returns> Result of operation. </returns> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public static org.eclipse.wst.xml.xpath2.api.ResultSequence op_intersect(java.util.Collection args) throws org.eclipse.wst.xml.xpath2.processor.DynamicError public static ResultSequence op_intersect(ICollection args) { ResultBuffer rs = new ResultBuffer(); // convert arguments ICollection cargs = Function.convert_arguments(args, expected_args()); // get arguments IEnumerator iter = cargs.GetEnumerator(); iter.MoveNext(); ResultSequence one = (ResultSequence)iter.Current; iter.MoveNext(); ResultSequence two = (ResultSequence)iter.Current; // XXX lame for (var i = one.iterator(); i.MoveNext();) { NodeType node = (NodeType)i.Current; bool found = false; // death for (var j = two.iterator(); j.MoveNext();) { NodeType node2 = (NodeType)j.Current; if (node.node_value() == node2.node_value()) { found = true; break; } } if (found) { rs.add(node); } } rs = NodeType.linarize(rs); return(rs.Sequence); }
/// <summary> /// Apply the URI escaping rules to the arguments. /// </summary> /// <param name="args"> /// have the URI escaping rules applied to them. </param> /// <param name="escape_space"> TODO </param> /// <exception cref="DynamicError"> /// Dynamic error. </exception> /// <returns> The result of applying the URI escaping rules to the arguments. </returns> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public static org.eclipse.wst.xml.xpath2.api.ResultSequence escape_uri(java.util.Collection args, boolean escape_delimiters, boolean escape_space) throws org.eclipse.wst.xml.xpath2.processor.DynamicError public static ResultSequence escape_uri(ICollection args, bool escape_delimiters, bool escape_space) { ICollection cargs = Function.convert_arguments(args, expected_args()); IEnumerator argi = cargs.GetEnumerator(); //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: argi.MoveNext(); ResultSequence arg1 = (ResultSequence)argi.Current; if (arg1.empty()) { return(new XSString("")); } AnyType aat = (AnyType)arg1.item(0); string str = aat.StringValue; var encoding = Encoding.UTF8; byte[] bytes = new byte[0]; Array.Resize(ref bytes, encoding.GetByteCount(str)); encoding.GetBytes(str, 0, str.Length, bytes, 0); StringBuilder sb = new StringBuilder(); for (int i = 0; i < bytes.Length; i++) { byte x = bytes[i]; if (needs_escape((sbyte)x, escape_delimiters, escape_space)) { sb.Append("%"); sb.Append((x & 0xFF).ToString("x").ToUpper()); } else { sb.Append((char)x); } } return(new XSString(sb.ToString())); }
/// <summary> /// Concatenate the arguments. /// </summary> /// <param name="args"> /// are concatenated. </param> /// <exception cref="DynamicError"> /// Dynamic error. </exception> /// <returns> The result of the concatenation of the arguments. </returns> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public static org.eclipse.wst.xml.xpath2.api.ResultSequence concat(java.util.Collection args) throws org.eclipse.wst.xml.xpath2.processor.DynamicError public static ResultSequence concat(ICollection args) { // sanity check if (args.Count < 2) { DynamicError.throw_type_error(); } ResultBuffer rs = new ResultBuffer(); string result = ""; // go through args StringBuilder buf = new StringBuilder(); for (IEnumerator argi = args.GetEnumerator(); argi.MoveNext();) { ResultSequence arg = (ResultSequence)argi.Current; int size = arg.size(); // sanity check if (size > 1) { DynamicError.throw_type_error(); } if (size == 0) { continue; } Item at = arg.first(); buf.Append(at.StringValue); } result = buf.ToString(); rs.add(new XSString(result)); return(rs.Sequence); }
/// <summary> /// Substring-Before operation. /// </summary> /// <param name="args"> /// Result from the expressions evaluation. </param> /// <exception cref="DynamicError"> /// Dynamic error. </exception> /// <returns> Result of fn:substring-before operation. </returns> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public static org.eclipse.wst.xml.xpath2.api.ResultSequence substring_before(java.util.Collection args) throws org.eclipse.wst.xml.xpath2.processor.DynamicError public static ResultSequence substring_before(ICollection args) { ICollection cargs = Function.convert_arguments(args, expected_args()); // get args IEnumerator argiter = cargs.GetEnumerator(); argiter.MoveNext(); ResultSequence arg1 = (ResultSequence)argiter.Current; string str1 = ""; string str2 = ""; if (!(arg1 == null || arg1.empty())) { str1 = ((XSString)arg1.first()).value(); } argiter.MoveNext(); ResultSequence arg2 = (ResultSequence)argiter.Current; if (!(arg2 == null || arg2.empty())) { str2 = ((XSString)arg2.first()).value(); } int str2len = str2.Length; if (str2len == 0) { return(new XSString("")); } int index = str1.IndexOf(str2, StringComparison.Ordinal); if (index == -1) { return(new XSString("")); } return(new XSString(str1.Substring(0, index))); }
/// <summary> /// Mathematical addition between this time stored and the supplied time /// duration. /// </summary> /// <param name="arg"> /// A XDTDayTimeDuration representation of the duration of time to /// add </param> /// <returns> A XSTime representing the result of this addition. </returns> /// <exception cref="DynamicError"> </exception> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public org.eclipse.wst.xml.xpath2.api.ResultSequence plus(org.eclipse.wst.xml.xpath2.api.ResultSequence arg) throws org.eclipse.wst.xml.xpath2.processor.DynamicError public virtual ResultSequence plus(ResultSequence arg) { XSDuration val = (XSDuration)NumericType.get_single_type(arg, typeof(XSDayTimeDuration)); try { double ms = val.time_value() * 1000.0; XSTime res = (XSTime)clone(); res.calendar().add(Calendar.MILLISECOND, (int)ms); return(ResultSequenceFactory.create_new(res)); } catch { Debug.Assert(false); return(null); } }
/// <summary> /// Trace operation. /// </summary> /// <param name="args"> /// Result from the expressions evaluation. </param> /// <exception cref="DynamicError"> /// Dynamic error. </exception> /// <returns> Result of fn:trace operation. </returns> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public static org.eclipse.wst.xml.xpath2.api.ResultSequence trace(java.util.Collection args) throws org.eclipse.wst.xml.xpath2.processor.DynamicError public static ResultSequence trace(ICollection args) { // sanity check args if (args.Count != 2) { DynamicError.throw_type_error(); } IEnumerator argsi = args.GetEnumerator(); argsi.MoveNext(); ResultSequence arg1 = (ResultSequence)argsi.Current; argsi.MoveNext(); ResultSequence arg2 = (ResultSequence)argsi.Current; if (arg2 == null || arg2.size() != 1) { DynamicError.throw_type_error(); } Item at = arg2.first(); if (!(at is XSString)) { DynamicError.throw_type_error(); } XSString label = (XSString)at; int index = 1; for (var i = arg1.iterator(); i.MoveNext(); index++) { at = (AnyType)i.Current; Console.WriteLine(label.value() + " [" + index + "] " + ((AnyType)at).string_type() + ":" + at.StringValue); } return(arg1); }
/// <summary> /// Evaluate arguments. /// </summary> /// <param name="args"> /// argument expressions. </param> /// <exception cref="DynamicError"> /// Dynamic error. </exception> /// <returns> Result of evaluation. </returns> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public org.eclipse.wst.xml.xpath2.api.ResultSequence evaluate(java.util.Collection args, org.eclipse.wst.xml.xpath2.api.EvaluationContext ec) throws org.eclipse.wst.xml.xpath2.processor.DynamicError public override ResultSequence evaluate(ICollection args, org.eclipse.wst.xml.xpath2.api.EvaluationContext ec) { // Differentiate depending on whether there is one (required) argument or whatever. ICollection cargs = Function.convert_arguments(args, args.Count == 1 ? expected_args1() : expected_args()); QName code = null; ResultSequence items = null; string description = null; // Iterate over the args IEnumerator it = cargs.GetEnumerator(); if (it.MoveNext()) { ResultSequence rsQName = (ResultSequence)it.Current; // for arity 2 and 3, the code is not mandatory, as in fn:code((), "description). Handle this: if (!rsQName.empty()) { code = (QName)rsQName.first(); } } // Next arg (if present) is the description if (it.MoveNext()) { ResultSequence rsDescription = (ResultSequence)it.Current; description = ((XSString)rsDescription.first()).value(); } // Final arg (if present) is the list of items if (it.MoveNext()) { items = (ResultSequence)it.Current; } // Handle the code if missing if (code == null) { code = new QName("err", "FOER0000", "http://www.w3.org/2005/xqt-errors"); } return(error(code, description, items)); }
/// <summary> /// Timezone-from-Date operation. /// </summary> /// <param name="args"> /// Result from the expressions evaluation. </param> /// <exception cref="DynamicError"> /// Dynamic error. </exception> /// <returns> Result of fn:timezone-from-date operation. </returns> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public static org.eclipse.wst.xml.xpath2.api.ResultSequence timezone_from_date(java.util.Collection args) throws org.eclipse.wst.xml.xpath2.processor.DynamicError public static ResultSequence timezone_from_date(ICollection args) { ICollection cargs = Function.convert_arguments(args, expected_args()); var i = cargs.GetEnumerator(); i.MoveNext(); ResultSequence arg1 = (ResultSequence)i.Current; if (arg1 == null || arg1.empty()) { return(ResultBuffer.EMPTY); } XSDate dt = (XSDate)arg1.first(); if (dt.timezoned()) { return(dt.tz()); } return(ResultBuffer.EMPTY); }
/// <summary> /// Namespace-Uri operation. /// </summary> /// <param name="args"> /// Result from the expressions evaluation. </param> /// <exception cref="DynamicError"> /// Dynamic error. </exception> /// <returns> Result of fn:namespace-uri operation. </returns> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public static org.eclipse.wst.xml.xpath2.api.ResultSequence namespace_uri(java.util.Collection args, org.eclipse.wst.xml.xpath2.api.EvaluationContext context) throws org.eclipse.wst.xml.xpath2.processor.DynamicError public static ResultSequence namespace_uri(ICollection args, EvaluationContext context) { ICollection cargs = Function.convert_arguments(args, expected_args()); ResultSequence arg1 = null; if (cargs.Count == 0) { if (context.ContextItem == null) { throw DynamicError.contextUndefined(); } arg1 = (AnyType)context.ContextItem; } else { // get arg var i = cargs.GetEnumerator(); i.MoveNext(); arg1 = (ResultSequence)i.Current; } if (arg1.empty()) { return(new XSAnyURI("")); } NodeType an = (NodeType)arg1.first(); QName name = an.node_name(); string sname = ""; if (name != null) { sname = name.@namespace(); } return(new XSAnyURI(sname)); }
/// <summary> /// Contains operation. /// </summary> /// <param name="args"> /// Result from the expressions evaluation. </param> /// <exception cref="DynamicError"> /// Dynamic error. </exception> /// <returns> Result of fn:contains operation. </returns> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public static org.eclipse.wst.xml.xpath2.api.ResultSequence contains(java.util.Collection args) throws org.eclipse.wst.xml.xpath2.processor.DynamicError public static ResultSequence contains(ICollection args) { ICollection cargs = Function.convert_arguments(args, expected_args()); // get args IEnumerator argiter = cargs.GetEnumerator(); argiter.MoveNext(); ResultSequence arg1 = (ResultSequence)argiter.Current; string str1 = ""; string str2 = ""; if (!(arg1 == null || arg1.empty())) { str1 = ((XSString)arg1.first()).value(); } argiter.MoveNext(); ResultSequence arg2 = (ResultSequence)argiter.Current; if (!(arg2 == null || arg2.empty())) { str2 = ((XSString)arg2.first()).value(); } int str1len = str1.Length; int str2len = str2.Length; if (str2len == 0) { return(XSBoolean.TRUE); } if (str1len == 0) { return(XSBoolean.FALSE); } return(XSBoolean.valueOf(str1.IndexOf(str2, StringComparison.Ordinal) != -1)); }
/// <summary> /// Creates a new result sequence consisting of the retrievable decimal /// number in the supplied result sequence /// </summary> /// <param name="arg"> /// The result sequence from which to extract the decimal number. </param> /// <exception cref="DynamicError"> </exception> /// <returns> A new result sequence consisting of the decimal number supplied. </returns> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public org.eclipse.wst.xml.xpath2.api.ResultSequence constructor(org.eclipse.wst.xml.xpath2.api.ResultSequence arg) throws org.eclipse.wst.xml.xpath2.processor.DynamicError public override ResultSequence constructor(ResultSequence arg) { if (arg.empty()) { return(ResultBuffer.EMPTY); } Item aat = arg.first(); if (aat is XSDuration || aat is CalendarType || aat is XSBase64Binary || aat is XSHexBinary || aat is XSAnyURI) { throw DynamicError.invalidType(); } if (aat.StringValue.IndexOf("-INF", StringComparison.Ordinal) != -1) { throw DynamicError.cant_cast(null); } if (!isLexicalValue(aat.StringValue)) { throw DynamicError.invalidLexicalValue(); } if (!isCastable(aat)) { throw DynamicError.cant_cast(null); } try { // XPath doesn't allow for converting Exponents to Decimal values. return(castDecimal(aat)); } catch (System.FormatException) { throw DynamicError.cant_cast(null); } }
/// <summary> /// Absolute value operation. /// </summary> /// <param name="arg"> /// Result from the expressions evaluation. </param> /// <exception cref="DynamicError"> /// Dynamic error. </exception> /// <returns> Result of fn:abs operation. </returns> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public static org.eclipse.wst.xml.xpath2.api.ResultSequence fn_abs(org.eclipse.wst.xml.xpath2.api.ResultSequence arg) throws org.eclipse.wst.xml.xpath2.processor.DynamicError public static ResultSequence fn_abs(ResultSequence arg) { // sanity chex NumericType nt = get_single_numeric_arg(arg); // empty arg if (nt == null) { return(ResultBuffer.EMPTY); } if (nt is XSDouble) { XSDouble dat = (XSDouble)nt; if (dat.zero() || dat.negativeZero()) { return(new XSDouble("0")); } if (dat.infinite()) { return(new XSDouble(double.PositiveInfinity)); } } if (nt is XSFloat) { XSFloat dat = (XSFloat)nt; if (dat.zero() || dat.negativeZero()) { return(new XSFloat((float)0)); } if (dat.infinite()) { return(new XSFloat(float.PositiveInfinity)); } } return(nt.abs()); }
/// <summary> /// Resolve-URI operation. /// </summary> /// <param name="args"> /// Result from the expressions evaluation. </param> /// <param name="d_context"> /// Dynamic context </param> /// <exception cref="DynamicError"> /// Dynamic error. </exception> /// <returns> Result of fn:resolve-uri operation. </returns> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public static org.eclipse.wst.xml.xpath2.api.ResultSequence resolveURI(java.util.Collection args, org.eclipse.wst.xml.xpath2.api.EvaluationContext ec) throws org.eclipse.wst.xml.xpath2.processor.DynamicError public static ResultSequence resolveURI(ICollection args, EvaluationContext ec) { if (ec.StaticContext.BaseUri == null) { throw DynamicError.noBaseURI(); } ICollection cargs = args; IEnumerator argit = cargs.GetEnumerator(); argit.MoveNext(); ResultSequence relativeRS = (ResultSequence)argit.Current; ResultSequence baseUriRS = null; if (argit.MoveNext()) { baseUriRS = (ResultSequence)argit.Current; } if (relativeRS.empty()) { return(ResultBuffer.EMPTY); } Item relativeURI = relativeRS.first(); string resolvedURI = null; if (baseUriRS == null) { resolvedURI = resolveURI(ec.StaticContext.BaseUri.ToString(), relativeURI.StringValue); } else { Item baseURI = baseUriRS.first(); resolvedURI = resolveURI(baseURI.StringValue, relativeURI.StringValue); } return(new XSAnyURI(resolvedURI)); }
/// <summary> /// String operation. /// </summary> /// <param name="args"> /// Result from the expressions evaluation. </param> /// <exception cref="DynamicError"> /// Dynamic error. </exception> /// <returns> Result of fn:string operation. </returns> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public static org.eclipse.wst.xml.xpath2.api.ResultSequence string(java.util.Collection args, org.eclipse.wst.xml.xpath2.api.EvaluationContext ec) throws org.eclipse.wst.xml.xpath2.processor.DynamicError public static ResultSequence @string(ICollection args, EvaluationContext ec) { Debug.Assert(args.Count == 0 || args.Count == 1); ResultSequence arg1 = null; if (args.Count == 0) { // support for arity = 0 return(getResultSetForArityZero(ec)); } else { var i = args.GetEnumerator(); i.MoveNext(); arg1 = (ResultSequence)i.Current; } // sanity check args if (arg1.size() > 1) { throw new DynamicError(TypeError.invalid_type(null)); } ResultBuffer rs = new ResultBuffer(); if (arg1.empty()) { rs.add(new XSString("")); } else { Item at = arg1.first(); rs.add(new XSString(at.StringValue)); } return(rs.Sequence); }
/// <summary> /// Op-To operation. /// </summary> /// <param name="args"> /// Result from the expressions evaluation. </param> /// <exception cref="DynamicError"> /// Dynamic error. </exception> /// <returns> Result of operation. </returns> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public static org.eclipse.wst.xml.xpath2.api.ResultSequence op_to(java.util.Collection args) throws org.eclipse.wst.xml.xpath2.processor.DynamicError public static ResultSequence op_to(ICollection args) { // convert arguments ICollection cargs = Function.convert_arguments(args, expected_args()); // get arguments IEnumerator iter = cargs.GetEnumerator(); iter.MoveNext(); ResultSequence r = (ResultSequence)iter.Current; int one = (int)((XSInteger)r.first()).int_value(); iter.MoveNext(); r = (ResultSequence)iter.Current; if (r == null || r.first() == null) { return(ResultBuffer.EMPTY); } int two = (int)((XSInteger)r.first()).int_value(); if (one > two) { return(ResultBuffer.EMPTY); } // inclusive first and last if (one == two) { return(new XSInteger(new System.Numerics.BigInteger(one))); } /* * for(one++; one <= two; one++) { rs.add(new XSInteger(one)); } * * return rs; */ return(new RangeResultSequence(one, two)); }
/// <summary> /// Sum operation. /// </summary> /// <param name="args"> /// Result from the expressions evaluation. </param> /// <exception cref="DynamicError"> /// Dynamic error. </exception> /// <returns> Result of fn:sum operation. </returns> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public static org.eclipse.wst.xml.xpath2.api.ResultSequence sum(org.eclipse.wst.xml.xpath2.api.ResultSequence arg, org.eclipse.wst.xml.xpath2.processor.internal.types.AnyAtomicType zero) throws org.eclipse.wst.xml.xpath2.processor.DynamicError public static ResultSequence sum(ResultSequence arg, AnyAtomicType zero) { if (arg.empty()) { return(ResultSequenceFactory.create_new(zero)); } MathPlus total = null; TypePromoter tp = new ScalarTypePromoter(); tp.considerSequence(arg); for (var i = arg.iterator(); i.MoveNext();) { AnyAtomicType conv = tp.promote((AnyType)i.Current); if (conv == null) { conv = zero; } if (conv is XSDouble && ((XSDouble)conv).nan() || conv is XSFloat && ((XSFloat)conv).nan()) { return(ResultSequenceFactory.create_new(tp.promote(new XSFloat(float.NaN)))); } if (total == null) { total = (MathPlus)conv; } else { total = (MathPlus)total.plus(ResultSequenceFactory.create_new(conv)).first(); } } return(ResultSequenceFactory.create_new((AnyType)total)); }
/// <summary> /// Base-Uri operation. /// </summary> /// <param name="args"> /// Result from the expressions evaluation. </param> /// <param name="d_context"> /// Dynamic context </param> /// <exception cref="DynamicError"> /// Dynamic error. </exception> /// <returns> Result of fn:base-uri operation. </returns> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public static org.eclipse.wst.xml.xpath2.api.ResultSequence base_uri(java.util.Collection args, org.eclipse.wst.xml.xpath2.api.EvaluationContext ec) throws org.eclipse.wst.xml.xpath2.processor.DynamicError public static ResultSequence base_uri(ICollection args, EvaluationContext ec) { ICollection cargs = Function.convert_arguments(args, expected_args()); ResultSequence rs = null; if (cargs.Count == 0) { // support for arity 0 // get base-uri from the context item. Item contextItem = ec.ContextItem; if (contextItem != null) { rs = getBaseUri(contextItem); } else { throw DynamicError.contextUndefined(); } } else if (cargs.Count == 1) { // support for arity 1 var i = cargs.GetEnumerator(); i.MoveNext(); ResultSequence arg1 = (ResultSequence)i.Current; Item att = arg1 == null || arg1.empty() ? null : arg1.first(); rs = getBaseUri(att); } else { // arity other than 0 or 1 is not allowed throw DynamicError.throw_type_error(); } return(rs); }
public virtual String InvokeToSingleString(String moduleUri, String separator, String inputSearchDetails) { ResultSequence resultSequence = null; string strResponse = ""; try { resultSequence = Invoke(moduleUri, inputSearchDetails); if (resultSequence != null) { strResponse = resultSequence.AsString(separator); } if (resultSequence != null) { resultSequence.Close(); } } catch (Exception ex) { throw ex; } return(strResponse); }
/// <summary> /// Equality comparison between this number and the supplied representation. </summary> /// <param name="aa"> /// Representation to be compared with (must currently be of type /// XSDouble) /// </param> /// <returns> True if the 2 representations represent the same number. False /// otherwise /// @since 1.1 </returns> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public boolean eq(AnyType aa, org.eclipse.wst.xml.xpath2.api.DynamicContext dynamicContext) throws org.eclipse.wst.xml.xpath2.processor.DynamicError public override bool eq(AnyType aa, DynamicContext dynamicContext) { ResultSequence rs = ResultSequenceFactory.create_new(aa); ResultSequence crs = constructor(rs); if (crs.empty()) { throw DynamicError.throw_type_error(); } Item cat = crs.first(); XSDouble d = (XSDouble)cat; if (d.nan() && nan()) { return(false); } double?thatvalue = new double?(d.double_value()); double?thisvalue = new double?(double_value()); return(thisvalue.Equals(thatvalue)); }
/// <summary> /// Op-Union operation. /// </summary> /// <param name="args"> /// Result from the expressions evaluation. </param> /// <exception cref="DynamicError"> /// Dynamic error. </exception> /// <returns> Result of operation. </returns> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public static org.eclipse.wst.xml.xpath2.api.ResultSequence op_union(java.util.Collection args) throws org.eclipse.wst.xml.xpath2.processor.DynamicError public static ResultSequence op_union(ICollection args) { ResultBuffer rs = new ResultBuffer(); // convert arguments ICollection cargs = Function.convert_arguments(args, expected_args()); // get arguments IEnumerator iter = cargs.GetEnumerator(); iter.MoveNext(); ResultSequence one = (ResultSequence)iter.Current; iter.MoveNext(); ResultSequence two = (ResultSequence)iter.Current; // XXX i don't fink u've ever seen anything lamer than this rs.concat(one); rs.concat(two); rs = NodeType.linarize(rs); return(rs.Sequence); }