Source Code Cross Referenced for Attribute.java in  » Web-Server » Jigsaw » org » w3c » tools » resources » upgrade » 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 » Web Server » Jigsaw » org.w3c.tools.resources.upgrade 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // Attribute.java
002:        // $Id: Attribute.java,v 1.4 2000/08/16 21:37:55 ylafon Exp $
003:        // (c) COPYRIGHT MIT and INRIA, 1996.
004:        // Please first read the full copyright statement in file COPYRIGHT.html
005:
006:        package org.w3c.tools.resources.upgrade;
007:
008:        import java.io.DataInputStream;
009:        import java.io.DataOutputStream;
010:        import java.io.IOException;
011:        import java.io.Serializable;
012:
013:        /**
014:         * Instances of this class describe an attribute of a resource.
015:         */
016:
017:        abstract public class Attribute implements  Serializable {
018:            /**
019:             * Flags value - This attribute is computed from the resource state.
020:             */
021:            public static final int COMPUTED = (1 << 0);
022:            /**
023:             * Flag value - This attribute is editable.
024:             */
025:            public static final int EDITABLE = (1 << 1);
026:            /**
027:             * Flag value - This attribute is mandatory.
028:             */
029:            public static final int MANDATORY = (1 << 2);
030:            /**
031:             * Flag value - This attribute shouldn't be saved.
032:             */
033:            public static final int DONTSAVE = (1 << 3);
034:            /**
035:             * The attribute name.
036:             */
037:            protected String name = null;
038:            /**
039:             * The attribute's value type, as the name of its class.
040:             */
041:            protected String type = null;
042:            /**
043:             * The attribute's default value.
044:             */
045:            private transient Object defvalue = null;
046:            /**
047:             * The associated flags (see the predefined flags).
048:             */
049:            protected int flags = 0;
050:
051:            /**
052:             * Get this attribute name.
053:             * @return A String giving the attribute name.
054:             */
055:
056:            public String getName() {
057:                return name;
058:            }
059:
060:            /**
061:             * Get this attribute type.
062:             */
063:
064:            public String getType() {
065:                return type;
066:            }
067:
068:            /**
069:             * Check some flag on this attribute description.
070:             */
071:
072:            public boolean checkFlag(int tst) {
073:                return (flags & tst) == tst;
074:            }
075:
076:            /**
077:             * Get this attribute default value.
078:             * @return A default value for this attribute (may be
079:             *    <strong>null</strong>).
080:             */
081:
082:            public Object getDefault() {
083:                return defvalue;
084:            }
085:
086:            /**
087:             * Stringify a value of this kind.
088:             * @param obj The value to stringify.
089:             */
090:
091:            public String stringify(Object value) {
092:                return value.toString();
093:            }
094:
095:            /**
096:             * Is the provided object a suitable value for this attribute ?
097:             * If so, store it into the given store.
098:             * @param value The value to check.
099:             * @param store The array to store the value to if succeed.
100:             * @param idx The location in the above array.
101:             * @return A boolean <strong>true</strong> if this object can be used
102:             *    as a value for this attribute.
103:             * @exception IllegalAttributeAccess If the provided value doesn't match
104:             *    the expected type.
105:             */
106:
107:            abstract public boolean checkValue(Object value);
108:
109:            /**
110:             * Get number of bytes needed to pickle that attribute.
111:             * This method is always called before pickling an attribute, to
112:             * get the length of that attribute value, and record it before saving
113:             * the actual bytes. This allows, for example, to skip attribute whose
114:             * definition was removed from a class. 
115:             * <p>In an ASCII format, this plays a role similar to emitting
116:             * a newline.
117:             * @param value The value that is about to be pickled.
118:             * @return The number of bytes needed to pickle that value.
119:             */
120:
121:            abstract public int getPickleLength(Object value);
122:
123:            /**
124:             * Pickle an attribute of this type to the given stream.
125:             * This method is used to make attribute values persistent, the pickle
126:             * method should dump the provided value in whatever format, provided
127:             * its unpickle method is able to restore it.
128:             * @param out The DataOutputStream to dump the object to.
129:             * @param obj The object to pickle.
130:             * @exception IOException If some IO error occured while dump the
131:             *    attribute.
132:             */
133:
134:            abstract public void pickle(DataOutputStream out, Object obj)
135:                    throws IOException;
136:
137:            /**
138:             * Unpickle an attribute of this type from the given stream.
139:             * This method is used to restore a pickled attribute value from the given
140:             * stream. It should read in the format it used at pickle time, and
141:             * consume the same number of bytes from the stream.
142:             * @param in The DataInputStream to read from.
143:             * @return The object value.
144:             * @exception IOException If some IOError occured while reading the stream.
145:             */
146:
147:            abstract public Object unpickle(DataInputStream in)
148:                    throws IOException;
149:
150:            /**
151:             * Private constructore to create a new resource attribute description.
152:             * @param name The name of the attribute.
153:             * @param type Its type (as a Java class).
154:             * @param def Its default value.
155:             * @param flags Its associated flags.
156:             */
157:
158:            public Attribute(String name, Object def, Integer flags) {
159:                this.name = name;
160:                this.defvalue = def;
161:                this.flags = flags.intValue();
162:            }
163:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.