mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-05 21:45:37 +00:00
ICU-3501 Fix some code formatting
X-SVN-Rev: 15999
This commit is contained in:
parent
47695b8314
commit
5b508cd44f
1 changed files with 33 additions and 44 deletions
|
@ -1,14 +1,8 @@
|
|||
/*
|
||||
*****************************************************************************
|
||||
* Copyright (C) 2000-2002, International Business Machines Corporation and *
|
||||
* Copyright (C) 2000-2004, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*****************************************************************************
|
||||
*
|
||||
* $Source: /xsrl/Nsvn/icu/unicodetools/com/ibm/rbm/BundleGroup.java,v $
|
||||
* $Date: 2004/07/11 02:00:30 $
|
||||
* $Revision: 1.3 $
|
||||
*
|
||||
*****************************************************************************
|
||||
*/
|
||||
package com.ibm.rbm;
|
||||
|
||||
|
@ -20,19 +14,19 @@ import java.util.*;
|
|||
/**
|
||||
* A class representing a group of BundleItems and the meta data associated with that group
|
||||
*
|
||||
* @author Jared Jackson - Email: <a href="mailto:jjared@almaden.ibm.com">jjared@almaden.ibm.com</a>
|
||||
* @author Jared Jackson
|
||||
* @see com.ibm.rbm.RBManager
|
||||
*/
|
||||
public class BundleGroup {
|
||||
private String name; // The name of the group
|
||||
private String comment; // A comment describing this group
|
||||
private TreeSet items; // The NLS items contained in this group
|
||||
private Bundle bundle; // The parent Bundle object of this group
|
||||
private String name; // The name of the group
|
||||
private String comment; // A comment describing this group
|
||||
private TreeSet items; // The NLS items contained in this group
|
||||
private Bundle bundle; // The parent Bundle object of this group
|
||||
|
||||
/**
|
||||
* Basic data constructor. Creates a BundleGroup with a parent bundle and a given name.
|
||||
* Basic data constructor.
|
||||
* Creates a BundleGroup with a parent bundle and a given name.
|
||||
*/
|
||||
|
||||
public BundleGroup(Bundle parent, String name) {
|
||||
bundle = parent;
|
||||
this.name = name;
|
||||
|
@ -40,7 +34,8 @@ public class BundleGroup {
|
|||
items = new TreeSet(new Comparator(){
|
||||
public boolean equals(Object o) { return false; }
|
||||
public int compare(Object o1, Object o2) {
|
||||
if (!(o1 instanceof BundleItem) || !(o2 instanceof BundleItem)) return 0;
|
||||
if (!(o1 instanceof BundleItem) || !(o2 instanceof BundleItem))
|
||||
return 0;
|
||||
BundleItem i1 = (BundleItem)o1;
|
||||
BundleItem i2 = (BundleItem)o2;
|
||||
return i1.getKey().compareTo(i2.getKey());
|
||||
|
@ -51,10 +46,8 @@ public class BundleGroup {
|
|||
/**
|
||||
* Two bundle groups are considered equal iff their names are the same.
|
||||
*/
|
||||
|
||||
public boolean equals(Object o) {
|
||||
if (o instanceof BundleGroup && ((BundleGroup)o).getName().equals(name)) return true;
|
||||
return false;
|
||||
return (o instanceof BundleGroup && ((BundleGroup)o).getName().equals(name));
|
||||
}
|
||||
|
||||
// This should be changed anywhere it is used
|
||||
|
@ -69,11 +62,10 @@ public class BundleGroup {
|
|||
}
|
||||
|
||||
/**
|
||||
* Adds a BundleItem to the group as long as that item is not currently in the group. If the
|
||||
* item.group is not equal to this group, then it is changed to be this group. <BR/>
|
||||
* Adds a BundleItem to the group as long as that item is not currently in the group.
|
||||
* If the item.group is not equal to this group, then it is changed to be this group.
|
||||
* This method should, in most cases, only be called from the Bundle class.
|
||||
*/
|
||||
|
||||
public void addBundleItem(BundleItem item) {
|
||||
if (items.contains(item)) {
|
||||
items.remove(item);
|
||||
|
@ -85,7 +77,6 @@ public class BundleGroup {
|
|||
/**
|
||||
* Remove an item of the given name from the group
|
||||
*/
|
||||
|
||||
public void removeBundleItem(String itemName) {
|
||||
Iterator iter = items.iterator();
|
||||
while(iter.hasNext()) {
|
||||
|
@ -100,27 +91,27 @@ public class BundleGroup {
|
|||
/**
|
||||
* Returns the number of items stored in the group
|
||||
*/
|
||||
|
||||
public int getItemCount() {
|
||||
return items.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a BundleItem from the set of items at a particular index point. If the index is greater than or equal
|
||||
* to the number of items in the set, null is returned.
|
||||
* Returns a BundleItem from the set of items at a particular index point.
|
||||
* If the index is greater than or equal to the number of items in the set,
|
||||
* null is returned.
|
||||
*/
|
||||
|
||||
public BundleItem getBundleItem(int index) {
|
||||
if (index >= items.size()) return null;
|
||||
if (index >= items.size())
|
||||
return null;
|
||||
Iterator iter = items.iterator();
|
||||
for (int i=0; i < index; i++) iter.next();
|
||||
for (int i=0; i < index; i++)
|
||||
iter.next();
|
||||
return (BundleItem)iter.next();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the bundle to which this group belongs
|
||||
*/
|
||||
|
||||
public Bundle getParentBundle() {
|
||||
return bundle;
|
||||
}
|
||||
|
@ -128,7 +119,6 @@ public class BundleGroup {
|
|||
/**
|
||||
* Returns the comment associated with this bundle
|
||||
*/
|
||||
|
||||
public String getComment() {
|
||||
return comment;
|
||||
}
|
||||
|
@ -136,7 +126,6 @@ public class BundleGroup {
|
|||
/**
|
||||
* Returns the name of the bundle
|
||||
*/
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
@ -156,28 +145,28 @@ public class BundleGroup {
|
|||
/**
|
||||
* The translation to a string returns the name of the group
|
||||
*/
|
||||
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the output for a group heading. This will be found in comment lines above the group items
|
||||
* Returns the output for a group heading.
|
||||
* This will be found in comment lines above the group items
|
||||
*/
|
||||
|
||||
public String toOutputString() {
|
||||
public String toOutputString() {
|
||||
String retStr = "\n#\n# @group " + name + "\n#\n";
|
||||
if (comment != null) retStr += "# @groupComment " + comment + "\n";
|
||||
if (comment != null)
|
||||
retStr += "# @groupComment " + comment + "\n";
|
||||
return retStr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the output contents to a particular PrintStream. The output will be suitable for a properly
|
||||
* formatted .properties file.
|
||||
* Writes the output contents to a particular PrintStream.
|
||||
* The output will be suitable for a properly formatted .properties file.
|
||||
*/
|
||||
|
||||
public void writeContents(PrintStream ps) {
|
||||
if (!name.equals("Ungrouped Items")) ps.println(this.toOutputString());
|
||||
if (!name.equals("Ungrouped Items"))
|
||||
ps.println(this.toOutputString());
|
||||
Iterator iter = items.iterator();
|
||||
while (iter.hasNext()) {
|
||||
((BundleItem) iter.next()).writeContents(ps);
|
||||
|
@ -185,12 +174,12 @@ public class BundleGroup {
|
|||
}
|
||||
|
||||
/**
|
||||
* Writes the output contents to a particular Writer. The output will be suitable for a properly
|
||||
* formatted .properties file.
|
||||
* Writes the output contents to a particular Writer.
|
||||
* The output will be suitable for a properly formatted .properties file.
|
||||
*/
|
||||
|
||||
public void writeContents(Writer w) throws IOException {
|
||||
if (!name.equals("Ungrouped Items")) w.write(this.toOutputString() + "\n");
|
||||
if (!name.equals("Ungrouped Items"))
|
||||
w.write(this.toOutputString() + "\n");
|
||||
Iterator iter = items.iterator();
|
||||
while (iter.hasNext()) {
|
||||
((BundleItem) iter.next()).writeContents(w);
|
||||
|
|
Loading…
Add table
Reference in a new issue