Source Code Cross Referenced for DocumentSummary.java in  » XML » tclib » com » sosnoski » xmlbench » 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 » tclib » com.sosnoski.xmlbench 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 2000-2001 Sosnoski Software Solutions, Inc.
003:         *
004:         * Permission is hereby granted, free of charge, to any person obtaining a copy
005:         * of this software and associated documentation files (the "Software"), to deal
006:         * in the Software without restriction, including without limitation the rights
007:         * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008:         * copies of the Software, and to permit persons to whom the Software is
009:         * furnished to do so, subject to the following conditions:
010:         *
011:         * The above copyright notice and this permission notice shall be included in
012:         * all copies or substantial portions of the Software.
013:         *
014:         * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015:         * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016:         * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017:         * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018:         * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
019:         * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
020:         * IN THE SOFTWARE.
021:         */
022:
023:        package com.sosnoski.xmlbench;
024:
025:        /**
026:         * Document summary information. This includes several count values
027:         * characteristic of a document, allowing simple consistency checks across
028:         * different representations of the document.
029:         *
030:         * @author Dennis M. Sosnoski
031:         * @version 1.2
032:         */
033:
034:        public class DocumentSummary {
035:            /** Number of elements. */
036:            private int m_elementCount;
037:
038:            /** Number of content text segments. */
039:            private int m_contentCount;
040:
041:            /** Number of attributes. */
042:            private int m_attributeCount;
043:
044:            /** Number of characters of content text. */
045:            private int m_textCharCount;
046:
047:            /** Number of characters of attribute data. */
048:            private int m_attrCharCount;
049:
050:            /**
051:             * Reset count values.
052:             */
053:
054:            public void reset() {
055:                m_elementCount = 0;
056:                m_contentCount = 0;
057:                m_attributeCount = 0;
058:                m_textCharCount = 0;
059:                m_attrCharCount = 0;
060:            }
061:
062:            /**
063:             * Get element count.
064:             *
065:             * @return number of elements
066:             */
067:
068:            public int getElementCount() {
069:                return m_elementCount;
070:            }
071:
072:            /**
073:             * Get content segment count.
074:             *
075:             * @return number of content segments
076:             */
077:
078:            public int getContentCount() {
079:                return m_contentCount;
080:            }
081:
082:            /**
083:             * Get attribute count.
084:             *
085:             * @return number of attributes
086:             */
087:
088:            public int getAttributeCount() {
089:                return m_attributeCount;
090:            }
091:
092:            /**
093:             * Get text content character count.
094:             *
095:             * @return number of text characters
096:             */
097:
098:            public int getTextCharCount() {
099:                return m_textCharCount;
100:            }
101:
102:            /**
103:             * Get attribute value character count.
104:             *
105:             * @return number of attribute value characters
106:             */
107:
108:            public int getAttrCharCount() {
109:                return m_attrCharCount;
110:            }
111:
112:            /**
113:             * Add to element count.
114:             *
115:             * @param count value to be added to element count
116:             */
117:
118:            public void addElements(int count) {
119:                m_elementCount += count;
120:            }
121:
122:            /**
123:             * Count attribute. Increments the attribute count by one and adds the
124:             * supplied character count to the attribute data length.
125:             *
126:             * @param length attribute value text length
127:             */
128:
129:            public void addAttribute(int length) {
130:                m_attributeCount++;
131:                m_attrCharCount += length;
132:            }
133:
134:            /**
135:             * Count content text segment. Increments the content segment count by one
136:             * and adds the supplied character count to the content text length.
137:             *
138:             * @param length attribute value text length
139:             */
140:
141:            public void addContent(int length) {
142:                m_contentCount++;
143:                m_textCharCount += length;
144:            }
145:
146:            /**
147:             * Check if object is equal to this one.
148:             *
149:             * @param obj object to be compared
150:             * @return <code>true</code> if the values match, <code>false</code>
151:             * if not
152:             */
153:
154:            public boolean equals(Object obj) {
155:                if (obj instanceof  DocumentSummary) {
156:                    DocumentSummary comp = (DocumentSummary) obj;
157:                    return m_elementCount == comp.m_elementCount
158:                            && m_contentCount == comp.m_contentCount
159:                            && m_attributeCount == comp.m_attributeCount
160:                            && m_textCharCount == comp.m_textCharCount
161:                            && m_attrCharCount == comp.m_attrCharCount;
162:                } else {
163:                    return false;
164:                }
165:            }
166:
167:            /**
168:             * Check if object structure is equal to this one. This comparison ignores
169:             * the text content segment count and total character length, since that
170:             * can be changed by output formatting.
171:             *
172:             * @param obj object to be compared
173:             * @return <code>true</code> if the values match, <code>false</code>
174:             * if not
175:             */
176:
177:            public boolean structureEquals(Object obj) {
178:                if (obj instanceof  DocumentSummary) {
179:                    DocumentSummary comp = (DocumentSummary) obj;
180:                    return m_elementCount == comp.m_elementCount
181:                            && m_attributeCount == comp.m_attributeCount
182:                            && m_attrCharCount == comp.m_attrCharCount;
183:                } else {
184:                    return false;
185:                }
186:            }
187:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.