KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > saxon > value > NotationValue


1 package net.sf.saxon.value;
2
3 import net.sf.saxon.expr.XPathContext;
4 import net.sf.saxon.trans.XPathException;
5 import net.sf.saxon.type.BuiltInAtomicType;
6 import net.sf.saxon.type.ItemType;
7 import net.sf.saxon.type.Type;
8 import net.sf.saxon.type.ValidationException;
9 import net.sf.saxon.ConversionContext;
10
11
12 /**
13  * An xs:NOTATION value.
14  */

15
16 public final class NotationValue extends QNameValue {
17
18    /**
19      * Constructor
20      * @param prefix The prefix part of the QName (not used in comparisons). Use null or "" to represent the
21      * default prefix.
22      * @param uri The namespace part of the QName. Use null or "" to represent the null namespace.
23      * @param localName The local part of the QName
24      */

25
26     public NotationValue(String JavaDoc prefix, String JavaDoc uri, String JavaDoc localName) throws XPathException {
27         super(prefix, uri, localName);
28     }
29
30     /**
31      * Convert to target data type
32      * @param requiredType an integer identifying the required atomic type
33      * @param conversion
34      * @return an AtomicValue, a value of the required type; or an ErrorValue
35      */

36
37     public AtomicValue convertPrimitive(BuiltInAtomicType requiredType, boolean validate, ConversionContext conversion) {
38         switch (requiredType.getPrimitiveType()) {
39             case Type.ATOMIC:
40             case Type.ITEM:
41             case Type.QNAME:
42             case Type.STRING:
43             case Type.UNTYPED_ATOMIC:
44                 return super.convertPrimitive(requiredType, validate, conversion);
45             default:
46                 ValidationException err = new ValidationException("Cannot convert NOTATION to " +
47                         requiredType.getDisplayName());
48                 //err.setXPathContext(context);
49
err.setErrorCode("FORG0001");
50                 return new ValidationErrorValue(err);
51         }
52     }
53
54     /**
55      * Return the type of the expression
56      * @return Type.NOTATION (always)
57      */

58
59     public ItemType getItemType() {
60         return Type.NOTATION_TYPE;
61     }
62
63
64      /**
65      * The toString() method returns the name in the form QName("uri", "local")
66      * @return the name in Clark notation: {uri}local
67      */

68
69     public String JavaDoc toString() {
70         return "NOTATION(" + getClarkName() + ')';
71     }
72
73 }
74
75 //
76
// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
77
// you may not use this file except in compliance with the License. You may obtain a copy of the
78
// License at http://www.mozilla.org/MPL/
79
//
80
// Software distributed under the License is distributed on an "AS IS" basis,
81
// WITHOUT WARRANTY OF ANY KIND, either express or implied.
82
// See the License for the specific language governing rights and limitations under the License.
83
//
84
// The Original Code is: all this file.
85
//
86
// The Initial Developer of the Original Code is Michael H. Kay
87
//
88
// Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
89
//
90
// Contributor(s): none.
91
//
92

93
Popular Tags