Debian Codegraph @

net/sf/saxon/om/NodeInfo.java

raw symbols SCIP
1 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2 // Copyright (c) 2018 Saxonica Limited.
3 // This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
4 // If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 // This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0.
6 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
7
8 package net.sf.saxon.om;
9
10 import net.sf.saxon.Configuration;
11 import net.sf.saxon.event.Receiver;
12 import net.sf.saxon.expr.parser.Location;
13 import net.sf.saxon.pattern.AnyNodeTest;
14 import net.sf.saxon.pattern.NodeTest;
15 import net.sf.saxon.trans.Err;
16 import net.sf.saxon.trans.XPathException;
17 import net.sf.saxon.tree.iter.AxisIterator;
18 import net.sf.saxon.tree.util.FastStringBuffer;
19 import net.sf.saxon.tree.util.Navigator;
20 import net.sf.saxon.type.BuiltInAtomicType;
21 import net.sf.saxon.type.SchemaType;
22 import net.sf.saxon.type.Type;
23 import net.sf.saxon.type.Untyped;
24 import org.xml.sax.Locator;
25
26 import javax.xml.transform.Source;
27 import javax.xml.transform.SourceLocator;
28
29 /**
30 * The NodeInfo interface represents a node in Saxon's implementation of the XPath 2.0 data model.
31 * <p>Note that several NodeInfo objects may represent the same node. To test node identity, the
32 * method {@link #equals(Object)} should be used. An exception to this rule applies for
33 * document nodes, where the correspondence between document nodes and DocumentInfo objects is one to
34 * one. NodeInfo objects are never reused: a given NodeInfo object represents the same node for its entire
35 * lifetime.</p>
36 * <p>This is the primary interface for accessing trees in Saxon, and it forms part of the public
37 * Saxon API. Methods that form part of the public API are (since Saxon 8.4)
38 * labelled with a JavaDoc "since" tag: classes and methods that have no such label should not be
39 * regarded as stable interfaces.</p>
40 * <p>The interface represented by this class is at a slightly higher level than the abstraction described
41 * in the W3C data model specification, in that it includes support for the XPath axes, rather than exposing
42 * the lower-level properties (such as "parent" and "children") directly. All navigation within trees,
43 * except for a few convenience methods, is done by following the axes using the {@link #iterateAxis} method.
44 * This allows different implementations of the XPath tree model to implement axis navigation in different ways.
45 * Some implementations may choose to use the helper methods provided in class {@link net.sf.saxon.tree.util.Navigator}.</p>
46 * <p>Note that the stability of this interface applies to classes that use the interface,
47 * not to classes that implement it. The interface may be extended in future to add new methods.</p>
48 * <p>New implementations of NodeInfo are advised also to implement the methods in interface
49 * ExtendedNodeInfo, which will be moved into this interface at some time in the future.</p>
50 *
51 * @since 8.4. Extended with three extra methods, previously in ExtendedNodeInfo, in 9.1.
52 * In 9.7, DocumentInfo is no longer defined as a sub-interface; it is replaced with TreeInfo,
53 * which contains information about any XML node tree, whether or not it is rooted at a document node.
54 * In 9.8, default implementations are provided for some of the methods, making it easier to create
55 * a new implementation of this interface.
56 */
57
58 public interface NodeInfo extends Source, Item<NodeInfo>, Location {
59
60 /**
61 * Get information about the tree to which this NodeInfo belongs
62 * @return the TreeInfo
63 * @since 9.7
64 */
65
66 TreeInfo getTreeInfo();
67
68 /**
69 * Convenience method to get the Configuration. Always returns the same result as {@code getTreeInfo().getConfiguration()}
70 * @return the Configuration to which the tree belongs. The default implementation invokes
71 * {@code getTreeInfo().getConfiguration()}.
72 * @since 8.4
73 */
74
75 default Configuration getConfiguration() {
76 return getTreeInfo().getConfiguration();
77 }
78
79 /**
80 * Get the kind of node. This will be a value such as {@link net.sf.saxon.type.Type#ELEMENT}
81 * or {@link net.sf.saxon.type.Type#ATTRIBUTE}. There are seven kinds of node: documents, elements, attributes,
82 * text, comments, processing-instructions, and namespaces.
83 *
84 * @return an integer identifying the kind of node. These integer values are the
85 * same as those used in the DOM
86 * @see net.sf.saxon.type.Type
87 * @since 8.4
88 */
89
90 int getNodeKind();
91
92 /**
93 * Determine whether this is the same node as another node.
94 * <p>Note that two different NodeInfo instances can represent the same conceptual node.
95 * Therefore the "==" operator should not be used to test node identity. The equals()
96 * method should give the same result as isSameNodeInfo(), but since this rule was introduced
97 * late it might not apply to all implementations.</p>
98 * <p>Note: a.isSameNodeInfo(b) if and only if generateId(a)==generateId(b).</p>
99 * <p>This method has the same semantics as isSameNode() in DOM Level 3, but
100 * works on Saxon NodeInfo objects rather than DOM Node objects.</p>
101 * <p>From Saxon 9.9 this method has a default implementation that invokes {@code equals()},
102 * and all Saxon implementations of {@code NodeInfo} rely on this default implementation.
103 * The method is retained for backwards compatibility, but applications are advised to
104 * use the {@code equals()} method in preference, and user-defined implementations of
105 * {@code NodeInfo} are advised to rely on the default implementation. In particular,
106 * implementations of {@code equals()} should not invoke {@code isSameNodeInfo}.</p>
107 *
108 * @param other the node to be compared with this node
109 * @return true if this NodeInfo object and the supplied NodeInfo object represent
110 * the same node in the tree. The default implementation returns
111 * {@code equals(other)}
112 */
113
114 default boolean isSameNodeInfo(NodeInfo other) {
115 return equals(other);
116 }
117
118 /**
119 * The equals() method compares nodes for identity. It is defined to give the same result
120 * as isSameNodeInfo().
121 *
122 * @param other the node to be compared with this node
123 * @return true if this NodeInfo object and the supplied NodeInfo object represent
124 * the same node in the tree.
125 * @since 8.7 Previously, the effect of the equals() method was not defined. Callers
126 * should therefore be aware that third party implementations of the NodeInfo interface may
127 * not implement the correct semantics. It is safer to use isSameNodeInfo() for this reason.
128 * The equals() method has been defined because it is useful in contexts such as a Java Set or HashMap.
129 */
130
131 boolean equals(Object other);
132
133 /**
134 * The hashCode() method obeys the contract for hashCode(): that is, if two objects are equal
135 * (represent the same node) then they must have the same hashCode()
136 *
137 * @since 8.7 Previously, the effect of the equals() and hashCode() methods was not defined. Callers
138 * should therefore be aware that third party implementations of the NodeInfo interface may
139 * not implement the correct semantics.
140 */
141
142 int hashCode();
143
144 /**
145 * Get the System ID for the node. Note this is not the
146 * same as the base URI: the base URI can be modified by xml:base, but
147 * the system ID cannot. The base URI is used primarily for resolving
148 * relative URIs within the content of the document. The system ID is
149 * used primarily in conjunction with a line number, for identifying the
150 * location of elements within the source XML, in particular when errors
151 * are found. For a document node, the System ID represents the value of
152 * the document-uri property as defined in the XDM data model.
153 *
154 * @return the System Identifier of the entity in the source document
155 * containing the node, or null if not known or not applicable.
156 * @since 8.4
157 */
158
159 /*@Nullable*/
160 String getSystemId();
161
162 /**
163 * Get the Public ID of the entity containing the node. This method
164 * is provided largely so that NodeInfo can act as a {@link Locator}
165 * or {@link SourceLocator}, and many implementations return null.
166 * @return the Public Identifier of the entity in the source document
167 * containing the node, or null if not known or not applicable.
168 * The default implementation returns null.
169 * @since 9.7
170 */
171
172 default String getPublicId() {
173 return null;
174 }
175
176 /**
177 * Get the Base URI for the node, that is, the URI used for resolving a relative URI contained
178 * in the node. This will be the same as the System ID unless xml:base has been used. Where the
179 * node does not have a base URI of its own, the base URI of its parent node is returned.
180 *
181 * @return the base URI of the node. This may be null if the base URI is unknown, including the case
182 * where the node has no parent.
183 * @since 8.4
184 */
185
186 String getBaseURI();
187
188 /**
189 * Get line number. Line numbers are not maintained by default, except for
190 * stylesheets and schema documents. Line numbering can be requested using the
191 * -l option on the command line, or by setting options on the TransformerFactory
192 * or the Configuration before the source document is built.
193 * <p>The granularity of line numbering is normally the element level: for other nodes
194 * such as text nodes and attributes, the line number of the parent element will normally be returned.</p>
195 * <p>In the case of a tree constructed by taking input from a SAX parser, the line number will reflect the
196 * SAX rules: that is, the line number of an element is the line number where the start tag ends. This
197 * may be a little confusing where elements have many attributes spread over multiple lines, or where
198 * single attributes (as can easily happen with XSLT 2.0 stylesheets) occupy several lines.</p>
199 * <p>In the case of a tree constructed by a stylesheet or query, the line number may reflect the line in
200 * the stylesheet or query that caused the node to be constructed.</p>
201 * <p>The line number can be read from within an XPath expression using the Saxon extension function
202 * saxon:line-number()</p>
203 *
204 * @return the line number of the node in its original source document; or
205 * -1 if not available. The default implementation returns -1.
206 * @since 8.4
207 */
208
209 default int getLineNumber() {
210 return -1;
211 }
212
213 /**
214 * Get column number. Column numbers are not maintained by default. Column numbering
215 * can be requested in the same way as line numbering; but a tree implementation can ignore
216 * the request.
217 * <p>The granularity of column numbering is normally the element level: for other nodes
218 * such as text nodes and attributes, the line number of the parent element will normally be returned.</p>
219 * <p>In the case of a tree constructed by taking input from a SAX parser, the column number will reflect the
220 * SAX rules: that is, the column number of an element is the column number where the start tag ends. This
221 * may be a little confusing where elements have many attributes spread over multiple lines, or where
222 * single attributes (as can easily happen with XSLT 2.0 stylesheets) occupy several lines.</p>
223 * <p>In the case of a tree constructed by a stylesheet or query, the column number may reflect the line in
224 * the stylesheet or query that caused the node to be constructed.</p>
225 * <p>The column number can be read from within an XPath expression using the Saxon extension function
226 * saxon:column-number()</p>
227 *
228 * @return the column number of the node in its original source document; or
229 * -1 if not available. The default implementation returns -1.
230 * @since 9.1
231 */
232
233 default int getColumnNumber() {
234 return -1;
235 }
236
237 /**
238 * Determine the relative position of this node and another node, in document order.
239 * <p>The other node must always be in the same tree; the effect of calling this method
240 * when the two nodes are in different trees is undefined. To obtain a global ordering
241 * of nodes, the application should first compare the result of getDocumentNumber(),
242 * and only if the document number is the same should compareOrder() be called.</p>
243 *
244 * @param other The other node, whose position is to be compared with this
245 * node
246 * @return -1 if this node precedes the other node, +1 if it follows the
247 * other node, or 0 if they are the same node. (In this case,
248 * isSameNode() will always return true, and the two nodes will
249 * produce the same result for generateId())
250 * @since 8.4
251 */
252
253 int compareOrder(NodeInfo other);
254
255 /**
256 * Return the string value of the node as defined in the XPath data model.
257 * <p>The interpretation of this depends on the type
258 * of node. For an element it is the accumulated character content of the element,
259 * including descendant elements.</p>
260 * <p>This method returns the string value as if the node were untyped. Unlike the string value
261 * accessor in the XPath 2.0 data model, it does not report an error if the element has a complex
262 * type, instead it returns the concatenation of the descendant text nodes as it would if the element
263 * were untyped.</p>
264 *
265 * @return the string value of the node
266 * @since 8.4
267 */
268
269 String getStringValue();
270
271 /**
272 * Ask whether this NodeInfo implementation holds a fingerprint identifying the name of the
273 * node in the NamePool. If the answer is true, then the {@link #getFingerprint} method must
274 * return the fingerprint of the node. If the answer is false, then the {@link #getFingerprint}
275 * method should throw an {@code UnsupportedOperationException}. In the case of unnamed nodes
276 * such as text nodes, the result can be either true (in which case getFingerprint() should
277 * return -1) or false (in which case getFingerprint may throw an exception).
278 * @return true if the implementation of this node provides fingerprints.
279 * @since 9.8; previously Saxon relied on using <code>FingerprintedNode</code> as a marker interface.
280 */
281
282 boolean hasFingerprint();
283
284 /**
285 * Get fingerprint. The fingerprint is a coded form of the expanded name
286 * of the node: two nodes
287 * with the same name code have the same namespace URI and the same local name.
288 * The fingerprint contains no information about the namespace prefix. For a name
289 * in the null namespace, the fingerprint is the same as the name code.
290 *
291 * @return an integer fingerprint; two nodes with the same fingerprint have
292 * the same expanded QName. For unnamed nodes (text nodes, comments, document nodes,
293 * and namespace nodes for the default namespace), returns -1.
294 * @throws UnsupportedOperationException if this kind of node does not hold
295 * namepool fingerprints (specifically, if {@link #hasFingerprint()} returns false).
296 * @since 8.4 (moved into FingerprintedNode at 9.7; then back into NodeInfo at 9.8).
297 */
298
299 int getFingerprint();
300
301 /**
302 * Get the local part of the name of this node. This is the name after the ":" if any.
303 *
304 * @return the local part of the name. For an unnamed node, returns "". Unlike the DOM
305 * interface, this returns the full name in the case of a non-namespaced name.
306 * @since 8.4
307 */
308
309 String getLocalPart();
310
311 /**
312 * Get the URI part of the name of this node. This is the URI corresponding to the
313 * prefix, or the URI of the default namespace if appropriate.
314 *
315 * @return The URI of the namespace of this node. For an unnamed node,
316 * or for an element or attribute that is not in a namespace, or for a processing
317 * instruction, returns an empty string.
318 * @since 8.4
319 */
320
321 String getURI();
322
323 /**
324 * Get the display name of this node, in the form of a lexical QName.
325 * For elements and attributes this is [prefix:]localname.
326 * For unnamed nodes, it is an empty string.
327 *
328 * @return The display name of this node. For a node with no name, returns
329 * an empty string.
330 * @since 8.4
331 */
332
333 String getDisplayName();
334
335 /**
336 * Get the prefix of the name of the node. This is defined only for elements and attributes.
337 * If the node has no prefix, or for other kinds of node, returns a zero-length string.
338 *
339 * @return The prefix of the name of the node.
340 * @since 8.4
341 */
342
343 String getPrefix();
344
345 /**
346 * Get the type annotation of this node, if any. The type annotation is represented as
347 * SchemaType object.
348 * <p>Types derived from a DTD are not reflected in the result of this method.</p>
349 *
350 * @return For element and attribute nodes: the type annotation derived from schema
351 * validation (defaulting to xs:untyped and xs:untypedAtomic in the absence of schema
352 * validation). For comments, text nodes, processing instructions, and namespaces: null.
353 * For document nodes, either xs:untyped if the document has not been validated, or
354 * xs:anyType if it has.
355 * <p>The default implementation returns {@link BuiltInAtomicType#UNTYPED_ATOMIC} for attribute
356 * nodes, {@link Untyped#getInstance} for element and document nodes, and null otherwise</p>
357 * @since 9.4
358 */
359
360 default SchemaType getSchemaType() {
361 switch (getNodeKind()) {
362 case Type.ATTRIBUTE:
363 return BuiltInAtomicType.UNTYPED_ATOMIC;
364 case Type.DOCUMENT:
365 case Type.ELEMENT:
366 return Untyped.getInstance();
367 default:
368 return null;
369 }
370 }
371
372 /**
373 * Bit setting in the returned type annotation indicating a DTD_derived type on an attribute node
374 */
375
376 int IS_DTD_TYPE = 1 << 30;
377
378 /**
379 * Bit setting for use alongside a type annotation indicating that the is-nilled property is set
380 */
381
382 int IS_NILLED = 1 << 29;
383
384
385 /**
386 * Get the typed value. This will either be a single AtomicValue or a value whose items are
387 * atomic values.
388 * @return the typed value of the node
389 * @throws XPathException if the node has no typed value, for example if
390 * it is an element node with element-only content
391 * @since 8.5. Changed in 9.5 to return the new type AtomicSequence.
392 */
393
394 AtomicSequence atomize() throws XPathException;
395
396 /**
397 * Get the NodeInfo object representing the parent of this node
398 *
399 * @return the parent of this node; null if this node has no parent
400 * @since 8.4
401 */
402
403 /*@Nullable*/
404 NodeInfo getParent();
405
406 /**
407 * Return an iteration over all the nodes reached by the given axis from this node
408 *
409 * @param axisNumber an integer identifying the axis; one of the constants
410 * defined in class {@link AxisInfo}
411 * @return an AxisIterator that delivers the nodes reached by the axis in
412 * turn. The nodes are returned in axis order (document order for a forwards
413 * axis, reverse document order for a reverse axis). The default implementation
414 * returns {@code iterateAxis(axisNumber, AnyNodeTest.getInstance()}.
415 * @throws UnsupportedOperationException if the namespace axis is
416 * requested and this axis is not supported for this implementation.
417 * @see AxisInfo
418 * @since 8.4
419 */
420
421 default AxisIterator iterateAxis(byte axisNumber) {
422 return iterateAxis(axisNumber, AnyNodeTest.getInstance());
423 }
424
425
426 /**
427 * Return an iteration over all the nodes reached by the given axis from this node
428 * that match a given NodeTest
429 *
430 * @param axisNumber an integer identifying the axis; one of the constants
431 * defined in class {@link AxisInfo}
432 * @param nodeTest A condition to be satisfied by the returned nodes; nodes
433 * that do not satisfy this condition are not included in the result
434 * @return an AxisIterator that delivers the nodes reached by the axis in
435 * turn. The nodes are returned in axis order (document order for a forwards
436 * axis, reverse document order for a reverse axis).
437 * @throws UnsupportedOperationException if the namespace axis is
438 * requested and this axis is not supported for this implementation.
439 * @see AxisInfo
440 * @since 8.4
441 */
442
443 AxisIterator iterateAxis(byte axisNumber, NodeTest nodeTest);
444
445 /**
446 * Get the string value of a given attribute of this node
447 *
448 * @param uri the namespace URI of the attribute name. Supply the empty string for an attribute
449 * that is in no namespace
450 * @param local the local part of the attribute name.
451 * @return the attribute value if it exists, or null if it does not exist. Always returns null
452 * if this node is not an element.
453 * @since 9.4
454 */
455
456 /*@Nullable*/
457 String getAttributeValue(/*@NotNull*/ String uri, /*@NotNull*/ String local);
458
459 /**
460 * Get the root node of the tree containing this node
461 *
462 * @return the NodeInfo representing the top-level ancestor of this node.
463 * This will not necessarily be a document node. If this node has no parent,
464 * then the method returns this node.
465 * @since 8.4
466 */
467
468 NodeInfo getRoot();
469
470 /**
471 * Determine whether the node has any children.
472 * <p>Note: the result is equivalent to
473 * <code>iterateAxis(Axis.CHILD).next() != null</code></p>
474 *
475 * @return True if the node has one or more children
476 * @since 8.4
477 */
478
479 boolean hasChildNodes();
480
481 /**
482 * Construct a character string that uniquely identifies this node.
483 * Note: a.isSameNode(b) if and only if generateId(a)==generateId(b)
484 *
485 * @param buffer a buffer which will be updated to hold a string
486 * that uniquely identifies this node, across all documents.
487 * @since 8.7
488 * <p>Changed in Saxon 8.7 to generate the ID value in a client-supplied buffer</p>
489 */
490
491 void generateId(FastStringBuffer buffer);
492
493 /**
494 * Copy this node to a given Receiver.
495 * <p>This method is primarily for internal use. It should not be considered a stable
496 * part of the Saxon API.</p>
497 * <p>The default implementation invokes {@code Navigator.copy(this, out, copyOptions, locationId);} which
498 * is always adequate.</p>
499 *
500 * @param out the Receiver to which the node should be copied. It is the caller's
501 * responsibility to ensure that this Receiver is open before the method is called
502 * (or that it is self-opening), and that it is closed after use.
503 * @param copyOptions a selection of the options defined in {@link CopyOptions}
504 * @param locationId If non-null, identifies the location of the instruction
505 * that requested this copy. If zero, indicates that the location information
506 * is not available
507 * @throws XPathException if any downstream error occurs
508 */
509
510 default void copy(Receiver out, int copyOptions, Location locationId) throws XPathException {
511 Navigator.copy(this, out, copyOptions, locationId);
512 }
513
514
515 /**
516 * Get all namespace declarations and undeclarations defined on this element.
517 * <p>This method is intended primarily for internal use. User applications needing
518 * information about the namespace context of a node should use <code>iterateAxis(Axis.NAMESPACE)</code>.
519 * (However, not all implementations support the namespace axis, whereas all implementations are
520 * required to support this method.)</p>
521 *
522 * @param buffer If this is non-null, and the result array fits in this buffer, then the result
523 * may overwrite the contents of this array, to avoid the cost of allocating a new array on the heap.
524 * @return An array of namespace binding objects representing the namespace declarations and undeclarations present on
525 * this element. For a node other than an element, return null.
526 * If the uri part is "", then this is a namespace undeclaration rather than a declaration.
527 * The XML namespace is never included in the list. If the supplied array is larger than required,
528 * then the first unused entry will be set to null.
529 * <p>
530 * For a node other than an element, the method returns null.</p>
531 */
532
533 NamespaceBinding[] getDeclaredNamespaces(/*@Nullable*/ NamespaceBinding[] buffer);
534
535 /**
536 * Ask whether this node has the is-id property
537 *
538 * @return true if the node is an ID. The default
539 * implementation returns false.
540 */
541
542 default boolean isId() {
543 return false;
544 }
545
546 /**
547 * Ask whether this node has the is-idref property
548 *
549 * @return true if the node is an IDREF or IDREFS element or attribute. The default
550 * implementation returns false.
551 */
552
553 default boolean isIdref() {
554 return false;
555 }
556
557 /**
558 * Ask whether the node has the is-nilled property
559 *
560 * @return true if the node has the is-nilled property. The default
561 * implementation returns false.
562 */
563
564 default boolean isNilled() {
565 return false;
566 }
567
568 /**
569 * Ask whether this is a node in a streamed document
570 * @return true if the node is in a document being processed using streaming.
571 * The default implementation returns false.
572 */
573
574 default boolean isStreamed() {
575 return false;
576 }
577
578 /**
579 * Provide a short string showing the contents of the item, suitable
580 * for use in error messages
581 *
582 * @return a depiction of the item suitable for use in error messages.
583 * The default implementation returns:
584 * <ul>
585 * <li><code>document-node()</code> for a document node</li>
586 * <li><code>&lt;p:local/&gt;</code> for an element node</li>
587 * <li><code>@p:local</code> for an attribute node</li>
588 * <li><code>text("In a hole...")</code> for a text node</li>
589 * <li><code>&lt;--You are old, ...--&gt;</code> for a comment node</li>
590 * <li><code>&lt;?pi?&gt;</code> for a processing instruction node</li>
591 * <li><code>xmlns:p=uri</code> for a namespace node</li>
592 * </ul>
593 */
594
595 @Override
596 default String toShortString() {
597 switch (getNodeKind()) {
598 case Type.DOCUMENT:
599 return "document-node()";
600 case Type.ELEMENT:
601 return "<" + getDisplayName() + "/>";
602 case Type.ATTRIBUTE:
603 return "@" + getDisplayName();
604 case Type.TEXT:
605 return "text(\"" + Err.truncate30(getStringValue()) + "\")";
606 case Type.COMMENT:
607 return "<!--" + Err.truncate30(getStringValue()) + "-->";
608 case Type.PROCESSING_INSTRUCTION:
609 return "<?" + getDisplayName() + "?>";
610 case Type.NAMESPACE:
611 String prefix = getLocalPart();
612 return "xmlns" + (prefix.equals("") ? "" : ":" + prefix) + "=\"" + getStringValue() + '"';
613 default:
614 return "";
615 }
616 }
617
618 /**
619 * Get the genre of this item
620 *
621 * @return the genre: specifically, {@link Genre#NODE}. The default implementation (which should not
622 * be overridden) returns {@link Genre#NODE}.
623 */
624 @Override
625 default Genre getGenre() {
626 return Genre.NODE;
627 }
628
629
630 }
631