1 package net.sf.saxon.om; 2 import net.sf.saxon.trans.XPathException; 3 4 /** 5 * An Item is an object that can occur as a member of a sequence. 6 * It corresponds directly to the concept of an item in the XPath 2.0 data model. 7 * There are two kinds of Item: atomic values, and nodes. 8 * <p> 9 * This interface is part of the public Saxon API. As such (starting from Saxon 8.4), 10 * methods that form part of the stable API are labelled with a JavaDoc "since" tag 11 * to identify the Saxon release at which they were introduced. 12 * 13 * @author Michael H. Kay 14 * @since 8.4 15 */ 16 17 public interface Item extends ValueRepresentation { 18 19 /** 20 * Get the value of the item as a string. For nodes, this is the string value of the 21 * node as defined in the XPath 2.0 data model, except that all nodes are treated as being 22 * untyped: it is not an error to get the string value of a node with a complex type. 23 * For atomic values, the method returns the result of casting the atomic value to a string. 24 * <p> 25 * If the calling code can handle any CharSequence, the method {@link #getStringValueCS} should 26 * be used. If the caller requires a string, this method is preferred. 27 * 28 * @return the string value of the item 29 * @see #getStringValueCS 30 * @since 8.4 31 */ 32 33 public String getStringValue(); 34 35 /** 36 * Get the string value of the item as a CharSequence. This is in some cases more efficient than 37 * the version of the method that returns a String. The method satisfies the rule that 38 * <code>X.getStringValueCS().toString()</code> returns a string that is equal to 39 * <code>X.getStringValue()</code>. 40 * <p> 41 * Note that two CharSequence values of different types should not be compared using equals(), and 42 * for the same reason they should not be used as a key in a hash table. 43 * <p> 44 * If the calling code can handle any CharSequence, this method should 45 * be used. If the caller requires a string, the {@link #getStringValue} method is preferred. 46 * 47 * @return the string value of the item 48 * @see #getStringValue 49 * @since 8.4 50 */ 51 52 public CharSequence getStringValueCS(); 53 54 /** 55 * Get the typed value of the item. 56 * <p> 57 * For a node, this is the typed value as defined in the XPath 2.0 data model. Since a node 58 * may have a list-valued data type, the typed value is in general a sequence, and it is returned 59 * in the form of a SequenceIterator. 60 * <p> 61 * If the node has not been validated against a schema, the typed value 62 * will be the same as the string value, either as an instance of xs:string or as an instance 63 * of xdt:untypedAtomic, depending on the node kind. 64 * <p> 65 * For an atomic value, this method returns an iterator over a singleton sequence containing 66 * the atomic value itself. 67 * 68 * @return an iterator over the items in the typed value of the node or atomic value. The 69 * items returned by this iterator will always be atomic values. 70 * @throws XPathException where no typed value is available, for example in the case of 71 * an element with complex content 72 * @since 8.4 73 */ 74 75 public SequenceIterator getTypedValue() throws XPathException; 76 77 78 } 79 80 81 82 // 83 // The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License"); 84 // you may not use this file except in compliance with the License. You may obtain a copy of the 85 // License at http://www.mozilla.org/MPL/ 86 // 87 // Software distributed under the License is distributed on an "AS IS" basis, 88 // WITHOUT WARRANTY OF ANY KIND, either express or implied. 89 // See the License for the specific language governing rights and limitations under the License. 90 // 91 // The Original Code is: all this file. 92 // 93 // The Initial Developer of the Original Code is Michael H. Kay. 94 // 95 // Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved. 96 // 97 // Contributor(s): none. 98 // 99