01: /*
02: * The contents of this file are subject to the terms of the Common Development
03: * and Distribution License (the License). You may not use this file except in
04: * compliance with the License.
05: *
06: * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
07: * or http://www.netbeans.org/cddl.txt.
08: *
09: * When distributing Covered Code, include this CDDL Header Notice in each file
10: * and include the License file at http://www.netbeans.org/cddl.txt.
11: * If applicable, add the following below the CDDL Header, with the fields
12: * enclosed by brackets [] replaced by your own identifying information:
13: * "Portions Copyrighted [year] [name of copyright owner]"
14: *
15: * The Original Software is NetBeans. The Initial Developer of the Original
16: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
17: * Microsystems, Inc. All Rights Reserved.
18: */
19:
20: /*
21: * Util.java
22: *
23: * Created on January 18, 2007, 3:52 PM
24: *
25: * To change this template, choose Tools | Template Manager
26: * and open the template in the editor.
27: */
28:
29: package org.netbeans.modules.wsdlextensions.ftp.validator;
30:
31: import java.text.MessageFormat;
32: import java.util.ResourceBundle;
33: import java.util.regex.Matcher;
34: import java.util.regex.Pattern;
35:
36: /**
37: *
38: * @author jfu
39: */
40: public class Util {
41: private static final String ENV_VAR_REGEX = "\\$\\{([a-zA-Z0-9\\.\\-\\_^\\{\\}]+)\\}";
42: private static final Pattern ENV_VAR_REF_PATT = Pattern
43: .compile(ENV_VAR_REGEX);
44: private static final ResourceBundle mMessages = ResourceBundle
45: .getBundle("org.netbeans.modules.wsdlextensions.ftp.validator.Bundle");
46:
47: public static String getMessage(String key) {
48: return mMessages.getString(key);
49: }
50:
51: public static String getMessage(String key, String param) {
52: return getMessage(key, new Object[] { param });
53: }
54:
55: public static String getMessage(String key, Object[] params) {
56: String fmt = mMessages.getString(key);
57: if (params != null) {
58: return MessageFormat.format(fmt, params);
59: } else {
60: return fmt;
61: }
62: }
63:
64: public static boolean hasMigrationEnvVar(String attrVal) {
65: return attrVal != null ? ENV_VAR_REF_PATT.matcher(attrVal)
66: .find() : false;
67: }
68: }
|