Source Code Cross Referenced for BundleGroup.java in  » Internationalization-Localization » RBManager » com » ibm » rbm » 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 » Internationalization Localization » RBManager » com.ibm.rbm 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *****************************************************************************
003:         * Copyright (C) 2000-2004, International Business Machines Corporation and  *
004:         * others. All Rights Reserved.                                              *
005:         *****************************************************************************
006:         */
007:        package com.ibm.rbm;
008:
009:        import java.io.IOException;
010:        import java.io.PrintStream;
011:        import java.io.Writer;
012:        import java.util.*;
013:
014:        /**
015:         * A class representing a group of BundleItems and the meta data associated with that group
016:         * 
017:         * @author Jared Jackson
018:         * @see com.ibm.rbm.RBManager
019:         */
020:        public class BundleGroup {
021:            private String name; // The name of the group
022:            private String comment; // A comment describing this group
023:            private TreeSet items; // The NLS items contained in this group
024:            private Bundle bundle; // The parent Bundle object of this group
025:
026:            /**
027:             * Basic data constructor.
028:             * Creates a BundleGroup with a parent bundle and a given name.
029:             */
030:            public BundleGroup(Bundle parent, String name) {
031:                bundle = parent;
032:                this .name = name;
033:                comment = null;
034:                items = new TreeSet(new Comparator() {
035:                    public boolean equals(Object o) {
036:                        return false;
037:                    }
038:
039:                    public int compare(Object o1, Object o2) {
040:                        if (!(o1 instanceof  BundleItem)
041:                                || !(o2 instanceof  BundleItem))
042:                            return 0;
043:                        BundleItem i1 = (BundleItem) o1;
044:                        BundleItem i2 = (BundleItem) o2;
045:                        return i1.getKey().compareTo(i2.getKey());
046:                    }
047:                });
048:            }
049:
050:            /**
051:             * Two bundle groups are considered equal iff their names are the same.
052:             */
053:            public boolean equals(Object o) {
054:                return (o instanceof  BundleGroup && ((BundleGroup) o).getName()
055:                        .equals(name));
056:            }
057:
058:            // This should be changed anywhere it is used
059:
060:            public Vector getItemsAsVector() {
061:                Vector v = new Vector();
062:                Iterator iter = items.iterator();
063:                while (iter.hasNext()) {
064:                    v.addElement(iter.next());
065:                }
066:                return v;
067:            }
068:
069:            /**
070:             * Adds a BundleItem to the group as long as that item is not currently in the group.
071:             * If the item.group is not equal to this group, then it is changed to be this group.
072:             * This method should, in most cases, only be called from the Bundle class.
073:             */
074:            public void addBundleItem(BundleItem item) {
075:                if (items.contains(item)) {
076:                    items.remove(item);
077:                }
078:                item.setParentGroup(this );
079:                items.add(item);
080:            }
081:
082:            /**
083:             * Remove an item of the given name from the group
084:             */
085:            public void removeBundleItem(String itemName) {
086:                Iterator iter = items.iterator();
087:                while (iter.hasNext()) {
088:                    BundleItem item = (BundleItem) iter.next();
089:                    if (item.getKey().equals(itemName)) {
090:                        items.remove(item);
091:                        break;
092:                    }
093:                }
094:            }
095:
096:            /**
097:             * Returns the number of items stored in the group
098:             */
099:            public int getItemCount() {
100:                return items.size();
101:            }
102:
103:            /**
104:             * Returns a BundleItem from the set of items at a particular index point.
105:             * If the index is greater than or equal to the number of items in the set,
106:             * null is returned.
107:             */
108:            public BundleItem getBundleItem(int index) {
109:                if (index >= items.size())
110:                    return null;
111:                Iterator iter = items.iterator();
112:                for (int i = 0; i < index; i++)
113:                    iter.next();
114:                return (BundleItem) iter.next();
115:            }
116:
117:            /**
118:             * Returns the bundle to which this group belongs
119:             */
120:            public Bundle getParentBundle() {
121:                return bundle;
122:            }
123:
124:            /**
125:             * Returns the comment associated with this bundle
126:             */
127:            public String getComment() {
128:                return comment;
129:            }
130:
131:            /**
132:             * Returns the name of the bundle
133:             */
134:            public String getName() {
135:                return name;
136:            }
137:
138:            protected void setParentBundle(Bundle bundle) {
139:                this .bundle = bundle;
140:            }
141:
142:            public void setComment(String comment) {
143:                this .comment = comment;
144:            }
145:
146:            public void setName(String name) {
147:                this .name = name;
148:            }
149:
150:            /**
151:             * The translation to a string returns the name of the group
152:             */
153:            public String toString() {
154:                return name;
155:            }
156:
157:            /**
158:             * Returns the output for a group heading.
159:             * This will be found in comment lines above the group items
160:             */
161:            public String toOutputString() {
162:                String retStr = "\n#\n# @group " + name + "\n#\n";
163:                if (comment != null)
164:                    retStr += "# @groupComment " + comment + "\n";
165:                return retStr;
166:            }
167:
168:            /**
169:             * Writes the output contents to a particular PrintStream.
170:             * The output will be suitable for a properly formatted .properties file.
171:             */
172:            public void writeContents(PrintStream ps) {
173:                if (!name.equals("Ungrouped Items"))
174:                    ps.println(this .toOutputString());
175:                Iterator iter = items.iterator();
176:                while (iter.hasNext()) {
177:                    ((BundleItem) iter.next()).writeContents(ps);
178:                }
179:            }
180:
181:            /**
182:             * Writes the output contents to a particular Writer.
183:             * The output will be suitable for a properly formatted .properties file.
184:             */
185:            public void writeContents(Writer w) throws IOException {
186:                if (!name.equals("Ungrouped Items"))
187:                    w.write(this .toOutputString() + "\n");
188:                Iterator iter = items.iterator();
189:                while (iter.hasNext()) {
190:                    ((BundleItem) iter.next()).writeContents(w);
191:                }
192:            }
193:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.