Source Code Cross Referenced for TinyAttributeCollection.java in  » XML » saxonb » net » sf » saxon » tinytree » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » XML » saxonb » net.sf.saxon.tinytree 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.sf.saxon.tinytree;
002:
003:        import net.sf.saxon.om.AttributeCollection;
004:        import net.sf.saxon.om.NamePool;
005:        import net.sf.saxon.event.LocationProvider;
006:        import net.sf.saxon.style.StandardNames;
007:
008:        /**
009:         * An implementation of the AttributeCollection interface based directly on the
010:         * TinyTree data structure.
011:         */
012:
013:        public class TinyAttributeCollection implements  AttributeCollection {
014:
015:            int element;
016:            TinyTree tree;
017:            int firstAttribute;
018:
019:            public TinyAttributeCollection(TinyTree tree, int element) {
020:                this .tree = tree;
021:                this .element = element;
022:                this .firstAttribute = tree.alpha[element];
023:            }
024:
025:            /**
026:             * Set the location provider. This must be set if the methods getSystemId() and getLineNumber()
027:             * are to be used to get location information for an attribute.
028:             */
029:
030:            public void setLocationProvider(LocationProvider provider) {
031:                //
032:            }
033:
034:            /**
035:             * Return the number of attributes in the list.
036:             *
037:             * @return The number of attributes in the list.
038:             */
039:
040:            public int getLength() {
041:                int i = firstAttribute;
042:                while (i < tree.numberOfAttributes
043:                        && tree.attParent[i] == element) {
044:                    i++;
045:                }
046:                return i - firstAttribute;
047:            }
048:
049:            /**
050:             * Get the namecode of an attribute (by position).
051:             *
052:             * @param index The position of the attribute in the list.
053:             * @return The display name of the attribute as a string, or null if there
054:             *         is no attribute at that position.
055:             */
056:
057:            public int getNameCode(int index) {
058:                return tree.attCode[firstAttribute + index];
059:            }
060:
061:            /**
062:             * Get the type annotation of an attribute (by position).
063:             *
064:             * @param index The position of the attribute in the list.
065:             * @return The type annotation of the attribute as the fingerprint of the type name.
066:             * The bit {@link net.sf.saxon.om.NodeInfo.IS_DTD_TYPE} represents a DTD-derived type.
067:             */
068:
069:            public int getTypeAnnotation(int index) {
070:                if (tree.attTypeCode == null) {
071:                    return StandardNames.XDT_UNTYPED_ATOMIC;
072:                }
073:                ;
074:                return tree.attTypeCode[firstAttribute + index];
075:            }
076:
077:            /**
078:             * Get the locationID of an attribute (by position)
079:             *
080:             * @param index The position of the attribute in the list.
081:             * @return The location identifier of the attribute. This can be supplied
082:             *         to a {@link net.sf.saxon.event.LocationProvider} in order to obtain the
083:             *         actual system identifier and line number of the relevant location
084:             */
085:
086:            public int getLocationId(int index) {
087:                return 0;
088:            }
089:
090:            /**
091:             * Get the systemId part of the location of an attribute, at a given index.
092:             * <p/>
093:             * <p>Attribute location information is not available from a SAX parser, so this method
094:             * is not useful for getting the location of an attribute in a source document. However,
095:             * in a Saxon result document, the location information represents the location in the
096:             * stylesheet of the instruction used to generate this attribute, which is useful for
097:             * debugging.</p>
098:             *
099:             * @param index the required attribute
100:             * @return the systemId of the location of the attribute
101:             */
102:
103:            public String getSystemId(int index) {
104:                return tree.getSystemId(element);
105:            }
106:
107:            /**
108:             * Get the line number part of the location of an attribute, at a given index.
109:             * <p/>
110:             * <p>Attribute location information is not available from a SAX parser, so this method
111:             * is not useful for getting the location of an attribute in a source document. However,
112:             * in a Saxon result document, the location information represents the location in the
113:             * stylesheet of the instruction used to generate this attribute, which is useful for
114:             * debugging.</p>
115:             *
116:             * @param index the required attribute
117:             * @return the line number of the location of the attribute
118:             */
119:
120:            public int getLineNumber(int index) {
121:                return -1;
122:            }
123:
124:            /**
125:             * Get the properties of an attribute (by position)
126:             *
127:             * @param index The position of the attribute in the list.
128:             * @return The properties of the attribute. This is a set
129:             *         of bit-settings defined in class {@link net.sf.saxon.event.ReceiverOptions}. The
130:             *         most interesting of these is {{@link net.sf.saxon.event.ReceiverOptions#DEFAULTED_ATTRIBUTE},
131:             *         which indicates an attribute that was added to an element as a result of schema validation.
132:             */
133:
134:            public int getProperties(int index) {
135:                return 0;
136:            }
137:
138:            /**
139:             * Get the prefix of the name of an attribute (by position).
140:             *
141:             * @param index The position of the attribute in the list.
142:             * @return The prefix of the attribute name as a string, or null if there
143:             *         is no attribute at that position. Returns "" for an attribute that
144:             *         has no prefix.
145:             */
146:
147:            public String getPrefix(int index) {
148:                return tree.getNamePool().getPrefix(getNameCode(index));
149:            }
150:
151:            /**
152:             * Get the lexical QName of an attribute (by position).
153:             *
154:             * @param index The position of the attribute in the list.
155:             * @return The lexical QName of the attribute as a string, or null if there
156:             *         is no attribute at that position.
157:             */
158:
159:            public String getQName(int index) {
160:                return tree.getNamePool().getDisplayName(getNameCode(index));
161:            }
162:
163:            /**
164:             * Get the local name of an attribute (by position).
165:             *
166:             * @param index The position of the attribute in the list.
167:             * @return The local name of the attribute as a string, or null if there
168:             *         is no attribute at that position.
169:             */
170:
171:            public String getLocalName(int index) {
172:                return tree.getNamePool().getLocalName(getNameCode(index));
173:            }
174:
175:            /**
176:             * Get the namespace URI of an attribute (by position).
177:             *
178:             * @param index The position of the attribute in the list.
179:             * @return The local name of the attribute as a string, or null if there
180:             *         is no attribute at that position.
181:             */
182:
183:            public String getURI(int index) {
184:                return tree.getNamePool().getURI(getNameCode(index));
185:            }
186:
187:            /**
188:             * Get the index of an attribute (by name).
189:             *
190:             * @param uri       The namespace uri of the attribute.
191:             * @param localname The local name of the attribute.
192:             * @return The index position of the attribute
193:             */
194:
195:            public int getIndex(String uri, String localname) {
196:                int fingerprint = tree.getNamePool().getFingerprint(uri,
197:                        localname);
198:                return getIndexByFingerprint(fingerprint);
199:            }
200:
201:            /**
202:             * Get the index, given the fingerprint
203:             */
204:
205:            public int getIndexByFingerprint(int fingerprint) {
206:                int i = firstAttribute;
207:                while (tree.attParent[i] == element) {
208:                    if ((tree.attCode[i] & NamePool.FP_MASK) == fingerprint) {
209:                        return i - firstAttribute;
210:                    }
211:                    i++;
212:                }
213:                return -1;
214:            }
215:
216:            /**
217:             * Get the attribute value using its fingerprint
218:             */
219:
220:            public String getValueByFingerprint(int fingerprint) {
221:                return getValue(getIndexByFingerprint(fingerprint));
222:            }
223:
224:            /**
225:             * Get the value of an attribute (by name).
226:             *
227:             * @param uri       The namespace uri of the attribute.
228:             * @param localname The local name of the attribute.
229:             * @return The index position of the attribute
230:             */
231:
232:            public String getValue(String uri, String localname) {
233:                return getValue(getIndex(uri, localname));
234:            }
235:
236:            /**
237:             * Get the value of an attribute (by position).
238:             *
239:             * @param index The position of the attribute in the list.
240:             * @return The attribute value as a string, or null if
241:             *         there is no attribute at that position.
242:             */
243:
244:            public String getValue(int index) {
245:                return tree.attValue[firstAttribute + index].toString();
246:            }
247:
248:            /**
249:             * Determine whether a given attribute has the is-ID property set
250:             */
251:
252:            public boolean isId(int index) {
253:                return ((getTypeAnnotation(index) & NamePool.FP_MASK) == StandardNames.XS_ID)
254:                        || ((getNameCode(index) & NamePool.FP_MASK) == StandardNames.XML_ID);
255:            }
256:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.