ICU-2055 factor some code
X-SVN-Rev: 16726
This commit is contained in:
parent
aedf7a85a6
commit
2644cf5c59
@ -41,6 +41,9 @@ import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Text;
|
||||
|
||||
import com.ibm.icu.dev.tool.UOption;
|
||||
|
||||
|
||||
public class CachingEntityResolver implements EntityResolver {
|
||||
static final String CLDR_DTD_CACHE = "CLDR_DTD_CACHE";
|
||||
private static String gCacheDir = null;
|
||||
|
@ -170,7 +170,7 @@ public class LDML2ICUConverter {
|
||||
if(writeSupplemental==true){
|
||||
int lastIndex = args[0].lastIndexOf(File.separator, args[0].length()) + 1 /* add 1 to skip past the separator */;
|
||||
fileName = args[0].substring(lastIndex, args[0].length());
|
||||
String xmlfileName = getFullPath(false,args[0]);
|
||||
String xmlfileName = LDMLUtilities.getFullPath(false,args[0],sourceDir, destDir);
|
||||
try {
|
||||
|
||||
printInfo("Parsing document "+xmlfileName);
|
||||
@ -196,7 +196,7 @@ public class LDML2ICUConverter {
|
||||
long start = System.currentTimeMillis();
|
||||
int lastIndex = args[i].lastIndexOf(File.separator, args[i].length()) + 1 /* add 1 to skip past the separator */;
|
||||
fileName = args[i].substring(lastIndex, args[i].length());
|
||||
String xmlfileName = getFullPath(false,args[i]);
|
||||
String xmlfileName = LDMLUtilities.getFullPath(false,args[i],sourceDir, destDir);
|
||||
/*
|
||||
* debugging code
|
||||
*
|
||||
@ -256,41 +256,6 @@ public class LDML2ICUConverter {
|
||||
}
|
||||
}
|
||||
}
|
||||
private String getFullPath(boolean fileType, String fName){
|
||||
String str;
|
||||
int lastIndex1 = fName.lastIndexOf(File.separator, fName.length()) + 1/* add 1 to skip past the separator */;
|
||||
int lastIndex2 = fName.lastIndexOf('.', fName.length());
|
||||
if (fileType == true) {
|
||||
if(lastIndex2 == -1){
|
||||
fName = fName.trim() + ".txt";
|
||||
}else{
|
||||
if(!fName.substring(lastIndex2).equalsIgnoreCase(".txt")){
|
||||
fName = fName.substring(lastIndex1,lastIndex2) + ".txt";
|
||||
}
|
||||
}
|
||||
if (destDir != null && fName != null) {
|
||||
str = destDir + "/" + fName.trim();
|
||||
} else {
|
||||
str = System.getProperty("user.dir") + "/" + fName.trim();
|
||||
}
|
||||
} else {
|
||||
if(lastIndex2 == -1){
|
||||
fName = fName.trim() + ".xml";
|
||||
}else{
|
||||
if(!fName.substring(lastIndex2).equalsIgnoreCase(".xml") && fName.substring(lastIndex2).equalsIgnoreCase(".xlf")){
|
||||
fName = fName.substring(lastIndex1,lastIndex2) + ".xml";
|
||||
}
|
||||
}
|
||||
if(sourceDir != null && fName != null) {
|
||||
str = sourceDir + "/" + fName;
|
||||
} else if (lastIndex1 > 0) {
|
||||
str = fName;
|
||||
} else {
|
||||
str = System.getProperty("user.dir") + "/" + fName;
|
||||
}
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
private void createResourceBundle(String xmlfileName) {
|
||||
try {
|
||||
|
@ -145,7 +145,7 @@ public class LDMLComparator {
|
||||
private Hashtable requested = new Hashtable();
|
||||
private Hashtable deprecatedLanguageCodes = new Hashtable();
|
||||
private Hashtable deprecatedCountryCodes = new Hashtable();
|
||||
|
||||
private TreeSet vettingSet = new TreeSet();
|
||||
private String encoding = "UTF-8"; // default encoding
|
||||
|
||||
//PN added
|
||||
@ -292,6 +292,7 @@ public class LDMLComparator {
|
||||
indexwriter.println("</tr>");
|
||||
is.close();
|
||||
}
|
||||
// TODO: handle vettingSet;
|
||||
}
|
||||
}
|
||||
}catch(Exception e)
|
||||
@ -393,6 +394,10 @@ public class LDMLComparator {
|
||||
{
|
||||
result |= OPT_UNKNOWN;
|
||||
}
|
||||
} else {
|
||||
if(m_Vetting == true) {
|
||||
vettingSet.add(option);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1400,4 +1400,41 @@ System.err.println(filename2 + ":" + e.getLineNumber() + (col>=0?":" + col:"")
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
static public String getFullPath(boolean fileType, String fName, String sourceDir, String destDir){
|
||||
String str;
|
||||
int lastIndex1 = fName.lastIndexOf(File.separator, fName.length()) + 1/* add 1 to skip past the separator */;
|
||||
int lastIndex2 = fName.lastIndexOf('.', fName.length());
|
||||
if (fileType == true) {
|
||||
if(lastIndex2 == -1){
|
||||
fName = fName.trim() + ".txt";
|
||||
}else{
|
||||
if(!fName.substring(lastIndex2).equalsIgnoreCase(".txt")){
|
||||
fName = fName.substring(lastIndex1,lastIndex2) + ".txt";
|
||||
}
|
||||
}
|
||||
if (destDir != null && fName != null) {
|
||||
str = destDir + "/" + fName.trim();
|
||||
} else {
|
||||
str = System.getProperty("user.dir") + "/" + fName.trim();
|
||||
}
|
||||
} else {
|
||||
if(lastIndex2 == -1){
|
||||
fName = fName.trim() + ".xml";
|
||||
}else{
|
||||
if(!fName.substring(lastIndex2).equalsIgnoreCase(".xml") && fName.substring(lastIndex2).equalsIgnoreCase(".xlf")){
|
||||
fName = fName.substring(lastIndex1,lastIndex2) + ".xml";
|
||||
}
|
||||
}
|
||||
if(sourceDir != null && fName != null) {
|
||||
str = sourceDir + "/" + fName;
|
||||
} else if (lastIndex1 > 0) {
|
||||
str = fName;
|
||||
} else {
|
||||
str = System.getProperty("user.dir") + "/" + fName;
|
||||
}
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user