KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > javabb > infra > Parser


1 package org.javabb.infra;
2
3 /*
4  * Copyright 2004 JavaFree.org
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18
19 /**
20  * $Id: Parser.java,v 1.5.10.2 2006/04/17 17:47:18 daltoncamargo Exp $
21  * @author Dalton Camargo - <a HREF="mailto:dalton@javabb.org">dalton@javabb.org </a> <br>
22  */

23 public class Parser {
24     /**
25      * um HQL é passado e nele é substituido {vo} pelo caminho do VO na aplicação
26      * @param hql a ser parseado
27      * @return HQL parseado
28      */

29     public static String JavaDoc replaceHQL(String JavaDoc hql) {
30         return hql.replaceAll("\\{vo\\}", "org.javabb.vo.");
31     }
32
33     /**
34      * Cofirm if a parameter are an integer
35      * @param param
36      * @return true for yes, and false to not
37      */

38     public static boolean isInt(String JavaDoc param) {
39         try {
40             new Integer JavaDoc(param);
41
42             return true;
43         } catch (Exception JavaDoc e) {
44             return false;
45         }
46     }
47
48     /**
49      * Return lang of locale field
50      * @param locale - ex: en_US
51      * @return en
52      */

53     public static String JavaDoc getLang(String JavaDoc locale) {
54         if (locale == null) {
55             // Case the param is null, return default configuration
56
return "en";
57         }
58
59         String JavaDoc[] lc = locale.split("_");
60
61         return lc[0];
62     }
63
64     /**
65      * Return Country of locale field
66      * @param locale - ex: en_US
67      * @return US
68      */

69     public static String JavaDoc getCountry(String JavaDoc locale) {
70         if (locale == null) {
71             // Case the param is null, return default configuration
72
return "US";
73         }
74
75         String JavaDoc[] lc = locale.split("_");
76
77         return lc[1];
78     }
79 }
80
Popular Tags