Changeset 26253 for main/trunk


Ignore:
Timestamp:
2012-09-26T12:44:23+12:00 (12 years ago)
Author:
sjm84
Message:

Reformatting this file

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/XSLTUtil.java

    r26248 r26253  
    122122    }
    123123
    124 
    125124    public static String replace(String orig, String match, String replacement)
    126125    {
     
    169168    }
    170169
    171 
    172170    public static String getInterfaceText(String interface_name, String lang, String key)
    173171    {
     
    283281    }
    284282
    285   public static String getCollectionText(String collection, String site_name, String lang, String key) {
    286     return getCollectionTextWithDOMMulti(collection, site_name, lang, key);
    287   }
    288   // xslt didn't like calling the function with Node varargs, so have this hack for now
    289   public static String getCollectionTextWithDOM(String collection, String site_name, String lang, String key, Node n1) {
    290     return getCollectionTextWithDOMMulti(collection, site_name, lang, key, n1);
    291   }
    292    public static String getCollectionTextWithDOM(String collection, String site_name, String lang, String key, Node n1, Node n2) {
    293     return getCollectionTextWithDOMMulti(collection, site_name, lang, key, n1, n2);
    294   }
    295   public static String getCollectionTextWithDOM(String collection, String site_name, String lang, String key, Node n1, Node n2, Node n3) {
    296     return getCollectionTextWithDOMMulti(collection, site_name, lang, key, n1, n2, n3);
    297   }
    298   public static String getCollectionTextWithDOM(String collection, String site_name, String lang, String key, Node n1, Node n2, Node n3, Node n4) {
    299     return getCollectionTextWithDOMMulti(collection, site_name, lang, key, n1, n2, n3, n4);
    300   }
    301   public static String getCollectionTextWithDOMMulti(String collection, String site_name, String lang, String key, Node ... nodes) {
    302 
    303     int num_nodes = nodes.length;
    304     String [] args = null;
    305     if (num_nodes != 0) {
    306       args = new String[num_nodes];
    307 
    308       for (int i=0; i<num_nodes; i++) {
    309      
    310     String node_str = XMLConverter.getString(nodes[i]);
    311     args[i] = node_str;
    312       }
    313     }
    314     CollectionClassLoader class_loader = new CollectionClassLoader(XSLTUtil.class.getClassLoader(), GSFile.siteHome(GlobalProperties.getGSDL3Home(), site_name), collection);
    315     Dictionary dict = new Dictionary(collection, lang, class_loader);
    316     String result = dict.get(key, args);
    317     if (result != null) {
    318       return result;
    319     }
    320     return "text:"+collection+":"+key;
    321    
    322   }
    323 
     283    public static String getCollectionText(String collection, String site_name, String lang, String key)
     284    {
     285        return getCollectionTextWithDOMMulti(collection, site_name, lang, key);
     286    }
     287
     288    // xslt didn't like calling the function with Node varargs, so have this hack for now
     289    public static String getCollectionTextWithDOM(String collection, String site_name, String lang, String key, Node n1)
     290    {
     291        return getCollectionTextWithDOMMulti(collection, site_name, lang, key, n1);
     292    }
     293
     294    public static String getCollectionTextWithDOM(String collection, String site_name, String lang, String key, Node n1, Node n2)
     295    {
     296        return getCollectionTextWithDOMMulti(collection, site_name, lang, key, n1, n2);
     297    }
     298
     299    public static String getCollectionTextWithDOM(String collection, String site_name, String lang, String key, Node n1, Node n2, Node n3)
     300    {
     301        return getCollectionTextWithDOMMulti(collection, site_name, lang, key, n1, n2, n3);
     302    }
     303
     304    public static String getCollectionTextWithDOM(String collection, String site_name, String lang, String key, Node n1, Node n2, Node n3, Node n4)
     305    {
     306        return getCollectionTextWithDOMMulti(collection, site_name, lang, key, n1, n2, n3, n4);
     307    }
     308
     309    public static String getCollectionTextWithDOMMulti(String collection, String site_name, String lang, String key, Node... nodes)
     310    {
     311        int num_nodes = nodes.length;
     312        String[] args = null;
     313        if (num_nodes != 0)
     314        {
     315            args = new String[num_nodes];
     316
     317            for (int i = 0; i < num_nodes; i++)
     318            {
     319
     320                String node_str = XMLConverter.getString(nodes[i]);
     321                args[i] = node_str;
     322            }
     323        }
     324
     325        CollectionClassLoader class_loader = new CollectionClassLoader(XSLTUtil.class.getClassLoader(), GSFile.siteHome(GlobalProperties.getGSDL3Home(), site_name), collection);
     326        Dictionary dict = new Dictionary(collection, lang, class_loader);
     327        String result = dict.get(key, args);
     328        if (result != null)
     329        {
     330            return result;
     331        }
     332        return "text:" + collection + ":" + key;
     333
     334    }
    324335
    325336    public static boolean isImage(String mimetype)
     
    332343    }
    333344
    334   // formatting /preprocessing functions
    335   // some require a language, so we'll have a language param for all
    336   public static String toLower(String orig, String lang)
     345    // formatting /preprocessing functions
     346    // some require a language, so we'll have a language param for all
     347    public static String toLower(String orig, String lang)
    337348    {
    338349        return orig.toLowerCase();
     
    344355    }
    345356
    346         public static String tidyWhitespace(String original, String lang)
     357    public static String tidyWhitespace(String original, String lang)
    347358    {
    348359
     
    355366    }
    356367
    357         public static String stripWhitespace(String original, String lang)
     368    public static String stripWhitespace(String original, String lang)
    358369    {
    359370
Note: See TracChangeset for help on using the changeset viewer.