Source Code Cross Referenced for PhysicalAction.java in  » Net » Terracotta » com » tc » object » dna » api » 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 » Net » Terracotta » com.tc.object.dna.api 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice.  All rights reserved.
003:         */
004:        package com.tc.object.dna.api;
005:
006:        /**
007:         * A physical object change action
008:         */
009:        public class PhysicalAction {
010:            private final String field;
011:            private final Object value;
012:            private final int index;
013:            private final boolean isReference;
014:            private final int type;
015:
016:            private static final int TRUE_PHYSICAL = 1;
017:            private static final int ARRAY_ELEMENT = 2;
018:            private static final int ENTIRE_ARRAY = 3;
019:            private static final int SUB_ARRAY = 4;
020:
021:            // TODO: These 3 constructors would probably be easier to use if they were static factory methods instead
022:
023:            /**
024:             * Construct a physical action representing a new value for an entire array
025:             * @param value The new array
026:             */
027:            public PhysicalAction(Object value) {
028:                this (null, -1, value, false, ENTIRE_ARRAY);
029:            }
030:
031:            /**
032:             * Construct a physical action representing a new subarray
033:             * @param value The new subarray
034:             * @param startPos The starting position for the new subarray
035:             */
036:            public PhysicalAction(Object value, int startPos) {
037:                this (null, startPos, value, false, SUB_ARRAY);
038:            }
039:
040:            /**
041:             * Construct a physical action representing a single array element
042:             * change.
043:             * @param index The index in the array parent
044:             * @param value The new value for the array element
045:             * @param isReference Whether the new value is a reference 
046:             */
047:            public PhysicalAction(int index, Object value, boolean isReference) {
048:                this (null, index, value, isReference, ARRAY_ELEMENT);
049:            }
050:
051:            /**
052:             * Construct a physical action that consists of a field, a new value, and 
053:             * whether the new value is a reference.
054:             */
055:            public PhysicalAction(String field, Object value,
056:                    boolean isReference) {
057:                this (field, -1, value, isReference, TRUE_PHYSICAL);
058:            }
059:
060:            /**
061:             * Main internal constructor with all parameters.
062:             * @param field Field name, will be null for all but true physical
063:             * @param index Array index or -1 if not an array index
064:             * @param value Value
065:             * @param isReference True if reference
066:             * @param type Internal type flag, not publicly exposed
067:             */
068:            private PhysicalAction(String field, int index, Object value,
069:                    boolean isReference, int type) {
070:                this .field = field;
071:                this .index = index;
072:                this .value = value;
073:                this .isReference = isReference;
074:                this .type = type;
075:            }
076:
077:            /**
078:             * Get field name, only valid if this physical action is a true physical field change.
079:             * @return Field name, never null
080:             * @throws IllegalStateException If called on an action that returns false for {@link #isTruePhysical()}
081:             */
082:            public String getFieldName() {
083:                if (type != TRUE_PHYSICAL) {
084:                    throw new IllegalStateException(String.valueOf(type));
085:                }
086:
087:                return this .field;
088:            }
089:
090:            /**
091:             * Get object value
092:             * @return Object value
093:             */
094:            public Object getObject() {
095:                return this .value;
096:            }
097:
098:            /**
099:             * Is the object a reference?
100:             * @return True if reference
101:             */
102:            public boolean isReference() {
103:                return isReference;
104:            }
105:
106:            /**
107:             * If this is an array element, the index of the element.  If this is a subarray,
108:             * the starting position of the new subarray.  Otherwise, an error.
109:             * @return The array index
110:             * @throws IllegalStateException If not an array element or subarray
111:             */
112:            public int getArrayIndex() {
113:                if (!((type == ARRAY_ELEMENT) || (type == SUB_ARRAY))) {
114:                    throw new IllegalStateException(String.valueOf(type));
115:                }
116:                return this .index;
117:            }
118:
119:            /**
120:             * @return True if this is a true physical field change
121:             */
122:            public boolean isTruePhysical() {
123:                return type == TRUE_PHYSICAL;
124:            }
125:
126:            /**
127:             * @return True if this is an array element change
128:             */
129:            public boolean isArrayElement() {
130:                return type == ARRAY_ELEMENT;
131:            }
132:
133:            /**
134:             * @return True if this is an entire array change
135:             */
136:            public boolean isEntireArray() {
137:                return type == ENTIRE_ARRAY;
138:            }
139:
140:            /**
141:             * @return True if this is a subarray change
142:             */
143:            public boolean isSubArray() {
144:                return type == SUB_ARRAY;
145:            }
146:
147:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.