Changeset 3362


Ignore:
Timestamp:
2002-08-20T10:34:52+12:00 (22 years ago)
Author:
kjdon
Message:

more utils

Location:
trunk/gsdl3/src/java/org/greenstone/gsdl3/util
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/util/GSFile.java

    r3341 r3362  
    136136    }
    137137    */
     138
     139   
    138140    static public String stylesheetPath(ConfigVars config, String filename) {
    139141    // try site one first
     
    204206    }
    205207
     208    // this assumes that lang stuff is in its own directory -
     209    //interfaces_home/translate
     210    public static String getLangPath(ConfigVars config, String lang) {
     211   
     212    return config.interfaces_home_+File.separatorChar+
     213        "translate"+File.separatorChar+lang+".xml";
     214    }   
     215
     216    public static File getLangFile(ConfigVars config, String lang) {
     217   
     218    return new File(config.interfaces_home_+File.separatorChar+
     219        "translate"+File.separatorChar+lang+".xml");
     220    }
    206221}
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/util/GSXML.java

    r3341 r3362  
    1212public class GSXML {
    1313
     14    public static final String PARAM_TYPE_INTEGER = "integer";
     15    public static final String PARAM_TYPE_BOOLEAN = "boolean";
     16    public static final String PARAM_TYPE_ENUM = "enum";
    1417  // takes a node with a resource elements inside it and extracts all the
    1518  // HASh oids - name att for resource
     
    8588    }
    8689
     90    public static String getValue(Element e) {
     91    String val = e.getAttribute("value");
     92    if (val ==null || val.equals("")) {
     93        // have to get it out of the text
     94        val=getNodeText(e);
     95
     96    }
     97    return val;
     98    }
    8799    /** extracts the text out of a node */
    88100    public static String getNodeText(Element param) {
     
    224236    return null; //not found
    225237    }
     238
     239    /** takes an xpath type expression of the form name/name/...
     240    and returns the first node that matches, or null if not found */
     241    public static Node getNodeByPath(Node n, String path) {
     242   
     243    String link = GSPath.getFirstLink(path);
     244    path = GSPath.removeFirstLink(path);
     245    while (!link.equals("")) {
     246        n = getChildByTagName(n, link);
     247        if (n==null) {
     248        return null;
     249        }
     250        link = GSPath.getFirstLink(path);
     251        path = GSPath.removeFirstLink(path);
     252    }
     253    return n;
     254    }
    226255    public static HashMap getChildrenMap(Node n) {
    227256   
     
    245274    }
    246275
     276
     277    public static Element createParameter(Document owner, String param_name,
     278                      String type, String default_value,
     279                      String []values) {
     280
     281
     282    Element p = owner.createElement("param");
     283    p.setAttribute("name", param_name);
     284    p.setAttribute("type", type);
     285    p.setAttribute("default", default_value);
     286   
     287    if (type.equals(PARAM_TYPE_ENUM)) {
     288        for (int i=0; i<values.length; i++) {
     289        Element e = owner.createElement("element");
     290        e.setAttribute("name", values[i]);
     291        p.appendChild(e);
     292        }
     293    }
     294    return p;
     295    }
    247296}
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/util/XMLTransformer.java

    r3341 r3362  
    5656   */
    5757    public XMLTransformer() {
     58
     59    //System.out.println("system property="+System.getProperty("javax.xml.transform.TransformerFactory"));
     60
     61    System.setProperty("javax.xml.transform.TransformerFactory", "org.apache.xalan.processor.TransformerFactoryImpl");
    5862    try {
    59         t_factory_ = TransformerFactory.newInstance();
     63        t_factory_ = org.apache.xalan.processor.TransformerFactoryImpl.newInstance();
    6064
    6165    } catch (Exception e) {
    6266        System.out.println("XMLTransformer() exception "+e.getMessage());
    6367    }
     68   
     69    //System.out.println("system property="+System.getProperty("javax.xml.transform.TransformerFactory"));
    6470    }
    6571
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/util/XSLTUtil.java

    r3341 r3362  
    66public class XSLTUtil {
    77
    8     public static String toLower(String orig) {
     8       public static String toLower(String orig) {
    99    return orig.toLowerCase();
    1010    }
    1111
     12    public static byte[] toUTF8(String orig) {
     13   
     14    try {
     15        byte[] utf8 = orig.getBytes("UTF-8");
     16        return utf8;
     17    }
     18    catch (Exception e){
     19        System.out.println("unsupported encoding");
     20        return orig.getBytes();
     21    }
     22    }
     23
     24    public static int getInt(String orig) {
     25    return 20;
     26    }
     27   
     28    public static String getString(String orig) {
     29    return orig;
     30    }
    1231}
Note: See TracChangeset for help on using the changeset viewer.