ICU-3501 Bundle changes

X-SVN-Rev: 15974
This commit is contained in:
George Rhoten 2004-07-03 04:21:20 +00:00
parent caa45d1968
commit 47ea0761b1
2 changed files with 31 additions and 17 deletions

View File

@ -124,21 +124,15 @@ public class RBImporter extends JDialog {
BundleGroup group = null;
BundleGroup backup_group = null;
if (group_name == null) group_name = getDefaultGroup();
if (encoding == null) return;
if (group_name == null)
group_name = getDefaultGroup();
if (encoding == null)
return;
// Get the bundle to which we will be adding this resource
if (rbm.hasResource(encoding)) {
Vector bv = rbm.getBundles();
for (int i = 0; i < bv.size(); i++) {
Bundle tempb = (Bundle)bv.elementAt(i);
if (tempb.encoding.equals(encoding)) {
bundle = tempb;
break;
}
}
}
bundle = rbm.getBundle(encoding);
// Skip this import if the bundle is non-existent (Should have been resolved if wanted)
if (bundle == null) return;
if (bundle == null)
return;
// Find the group in the bundle, Ungrouped if non-existent
Vector gv = bundle.getGroupsAsVector();
for (int i=0; i < gv.size(); i++) {

View File

@ -557,18 +557,20 @@ public class RBManager {
* @param groupComment An optional comment to be added to the group, can be <CODE>null</CODE>
* @return An error response. If the creation was successful <CODE>true</CODE> is returned, if there was an error <CODE>false</CODE> is returned.
*/
public boolean createGroup(String groupName, String groupComment) {
if (groupName == null || groupName.equals("")) return false;
if (groupName == null || groupName.equals(""))
return false;
// Check to see if the group exists
Bundle mainBundle = (Bundle)bundles.firstElement();
if (mainBundle.hasGroup(groupName)) return false;
if (mainBundle.hasGroup(groupName))
return false;
// Create the group
for (int i=0; i < bundles.size(); i++) {
Bundle bundle = (Bundle)bundles.elementAt(i);
BundleGroup bg = new BundleGroup(bundle, groupName);
if (groupComment != null) bg.setComment(groupComment);
if (groupComment != null)
bg.setComment(groupComment);
bundle.addBundleGroup(bg);
}
return true;
@ -849,6 +851,24 @@ public class RBManager {
return bundles;
}
/**
* Return a bundle from a locale
* @return The requested resource bundle
*/
public Bundle getBundle(String locale) {
Bundle bundle = null;
if (hasResource(locale)) {
for (int i = 0; i < bundles.size(); i++) {
Bundle tempb = (Bundle)bundles.elementAt(i);
if (tempb.encoding.equals(locale)) {
bundle = tempb;
break;
}
}
}
return bundle;
}
/**
* Returns the name of the file that is the base class file for the resource bundle.
*/