/// <summary> method to catch Velocity log messages. When we /// see the introspector dump message, then set the flag /// </summary> public virtual void logVelocityMessage(int level, System.String message) { if (message.equals(Introspector.CACHEDUMP_MSG)) { sawCacheDump = true; } }
/// <summary> /// Locate, open, and parse a library configuration file. /// </summary> /// public ConfigFile() { this.config_ = new Hashtable<String, String>(); path_ = findConfigFile(); if (!path_.equals("")) parse(); }
/** * Returns the {@code Currency} instance for this currency code. * <p> * * @param currencyCode * the currency code. * @return the {@code Currency} instance for this currency code. * * @throws IllegalArgumentException * if the currency code is not a supported ISO 4217 currency * code. */ public static Currency getInstance(String currencyCode) { foreach (Locale l in Locale.getAvailableLocales()) { RegionInfo rc = new RegionInfo(l.getCountry()); if (currencyCode.equals(rc.ISOCurrencySymbol)) { return new Currency(rc); } } throw new java.lang.IllegalArgumentException("currency code is not a supported ISO 4217 currency code"); }
/** * Construct a new {@code FileHandler}. The given name pattern is used as * output filename, the maximum file size is set to {@code limit}, the file * count is initialized to {@code count} and the append mode is set to * {@code append}. The remaining configuration is done using * {@code LogManager} properties. This handler is configured to write to a * rotating set of count files, when the limit of bytes has been written to * one output file, another file will be opened instead. * * @param pattern * the name pattern for the output file. * @param limit * the data amount limit in bytes of one output file, can not be * negative. * @param count * the maximum number of files to use, can not be less than one. * @param append * the append mode. * @throws IOException * if any I/O error occurs. * @throws SecurityException * if a security manager exists and it determines that the * caller does not have the required permissions to control this * handler; required permissions include * {@code LogPermission("control")}, * {@code FilePermission("write")} etc. * @throws IllegalArgumentException * if {@code pattern} is empty, {@code limit < 0} or * {@code count < 1}. * @throws NullPointerException * if {@code pattern} is {@code null}. */ public FileHandler(String pattern, int limit, int count, bool append) { // throws IOException { if (pattern.equals("")) { //$NON-NLS-1$ throw new java.lang.IllegalArgumentException("Pattern cannot be empty"); //$NON-NLS-1$ } if (limit < 0 || count < 1) { // logging.1B=The limit and count property must be larger than 0 and // 1, respectively throw new java.lang.IllegalArgumentException("The limit and count property must be larger than 0 and 1, respectively"); //$NON-NLS-1$ } init(pattern, java.lang.Boolean.valueOf(append), java.lang.Integer.valueOf(limit), java.lang.Integer .valueOf(count)); }
/** * Construct a new {@code FileHandler}. The given name pattern is used as * output filename, the file limit is set to zero (no limit), the file count * is initialized to one and the value of {@code append} becomes the new * instance's append mode. The remaining configuration is done using * {@code LogManager} properties. This handler writes to only one file * with no size limit. * * @param pattern * the name pattern for the output file. * @param append * the append mode. * @throws IOException * if any I/O error occurs. * @throws SecurityException * if a security manager exists and it determines that the * caller does not have the required permissions to control this * handler; required permissions include * {@code LogPermission("control")}, * {@code FilePermission("write")} etc. * @throws IllegalArgumentException * if {@code pattern} is empty. * @throws NullPointerException * if {@code pattern} is {@code null}. */ public FileHandler(String pattern, bool append) { //throws IOException { if (pattern.equals("")) { //$NON-NLS-1$ throw new java.lang.IllegalArgumentException("Pattern cannot be empty"); //$NON-NLS-1$ } init(pattern, java.lang.Boolean.valueOf(append), java.lang.Integer.valueOf(DEFAULT_LIMIT), java.lang.Integer.valueOf(DEFAULT_COUNT)); }
/** * Constructs a new {@code FileHandler}. The given name pattern is used as * output filename, the file limit is set to zero (no limit), the file count * is set to one; the remaining configuration is done using * {@code LogManager} properties or their default values. This handler * writes to only one file with no size limit. * * @param pattern * the name pattern for the output file. * @throws IOException * if any I/O error occurs. * @throws SecurityException * if a security manager exists and it determines that the * caller does not have the required permissions to control this * handler; required permissions include * {@code LogPermission("control")}, * {@code FilePermission("write")} etc. * @throws IllegalArgumentException * if the pattern is empty. * @throws NullPointerException * if the pattern is {@code null}. */ public FileHandler(String pattern) { // throws IOException { if (pattern.equals("")) { //$NON-NLS-1$ // logging.19=Pattern cannot be empty throw new java.lang.IllegalArgumentException("Pattern cannot be empty"); //$NON-NLS-1$ } init(pattern, null, java.lang.Integer.valueOf(DEFAULT_LIMIT), java.lang.Integer .valueOf(DEFAULT_COUNT)); }
/** * Parses a level name into a {@code Level} object. * * @param name * the name of the desired {@code level}, which cannot be * {@code null}. * @return the level with the specified name. * @throws NullPointerException * if {@code name} is {@code null}. * @throws IllegalArgumentException * if {@code name} is not valid. */ public static Level parse(String name) { //throws IllegalArgumentException { if (name == null) { // logging.1C=The 'name' parameter is null. throw new java.lang.NullPointerException("The 'name' parameter is null."); //$NON-NLS-1$ } bool isNameAnInt; int nameAsInt; try { nameAsInt = java.lang.Integer.parseInt(name); isNameAnInt = true; } catch (java.lang.NumberFormatException e) { nameAsInt = 0; isNameAnInt = false; } lock (levels) { foreach (Level level in levels) { if (name.equals(level.getName())) { return level; } } if (isNameAnInt) { /* * Loop through levels a second time, so that the returned * instance will be passed on the order of construction. */ foreach (Level level in levels) { if (nameAsInt == level.intValue()) { return level; } } } } if (!isNameAnInt) { // logging.1D=Cannot parse this name: {0} throw new java.lang.IllegalArgumentException("Cannot parse this name: "+ name); //$NON-NLS-1$ } return new Level(name, nameAsInt); }
private void init(String path, String pathActions) { if (pathActions == null || pathActions.equals("")) { //$NON-NLS-1$ throw new java.lang.IllegalArgumentException("actions invalid"); //$NON-NLS-1$ } this.actions = toCanonicalActionString(pathActions); if (path == null) { throw new java.lang.NullPointerException("path is null"); //$NON-NLS-1$ } if (path.equals("<<ALL FILES>>")) { //$NON-NLS-1$ includeAll = true; } else { /*canonPath = AccessController .doPrivileged(new PrivilegedAction<String>() { public String run() {*/ try { canonPath = new File(path).getCanonicalPath(); } catch (IOException e) { canonPath = path; }/* } });*/ if (path.equals("*") || path.endsWith(File.separator + "*")) { //$NON-NLS-1$ //$NON-NLS-2$ allDir = true; } if (path.equals("-") || path.endsWith(File.separator + "-")) { //$NON-NLS-1$ //$NON-NLS-2$ allSubdir = true; } } }
/** * Returns the service with the specified {@code type} implementing the * specified {@code algorithm}, or {@code null} if no such implementation * exists. * <p/> * If two services match the requested type and algorithm, the one added * with the {@link #putService(Service)} is returned (as opposed to the one * added via {@link #put(Object, Object)}. * * @param type * the type of the service (for example {@code KeyPairGenerator}) * @param algorithm * the algorithm name (case insensitive) * @return the requested service, or {@code null} if no such implementation * exists */ public Provider.Service getService(String type, String algorithm) { lock (this) { if (type == null || algorithm == null) { throw new java.lang.NullPointerException(); } if (type.equals(lastServiceName) && algorithm.equalsIgnoreCase(lastAlgorithm)) { return returnedService; } String alg = algorithm.toUpperCase(); Object o = null; if (serviceTable != null) { o = serviceTable.get(type, alg); } if (o == null && aliasTable != null) { o = aliasTable.get(type, alg); } if (o == null) { updatePropertyServiceTable(); } if (o == null && propertyServiceTable != null) { o = propertyServiceTable.get(type, alg); } if (o == null && propertyAliasTable != null) { o = propertyAliasTable.get(type, alg); } if (o != null) { lastServiceName = type; lastAlgorithm = algorithm; returnedService = (Provider.Service)o; return returnedService; } return null; } }
//throws SAXNotRecognizedException, SAXNotSupportedException /** * Set a feature flag for the parser. * * <p>The only features recognized are namespaces and * namespace-prefixes.</p> * * @param name The feature name, as a complete URI. * @param value The requested feature value. * @exception SAXNotRecognizedException If the feature * can't be assigned or retrieved. * @exception SAXNotSupportedException If the feature * can't be assigned that value. * @see org.xml.sax.XMLReader#setFeature */ public void setFeature(String name, bool value) { if (name.equals(NAMESPACES)) { checkNotParsing("feature", name); namespaces = value; if (!namespaces && !prefixes) { prefixes = true; } } else if (name.equals(NAMESPACE_PREFIXES)) { checkNotParsing("feature", name); prefixes = value; if (!prefixes && !namespaces) { namespaces = true; } } else if (name.equals(XMLNS_URIs)) { checkNotParsing("feature", name); uris = value; } else { throw new SAXNotRecognizedException("Feature: " + name); } }
public void setAssociatedList(String input) { if (input == null) validComponent = false; else if (input.equals("NULL")) associatedList = null; else associatedList = new File(input); }
/** * Return anjava.util.Enumeration<Object> of all prefixes for a given URI whose * declarations are active in the current context. * This includes declarations from parent contexts that have * not been overridden. * * <p/>This method returns prefixes mapped to a specific Namespace * URI. The xml: prefix will be included. If you want only one * prefix that's mapped to the Namespace URI, and you don't care * which one you get, use the {@link #getPrefix getPrefix} * method instead. * * <p/><strong>Note:</strong> the empty (default) prefix is <em>never</em> included * in thisjava.util.Enumeration<Object>; to check for the presence of a default * Namespace, use the {@link #getURI getURI} method with an * argument of "". * * @param uri The Namespace URI. * @return Anjava.util.Enumeration<Object> of prefixes (never empty). * @see #getPrefix * @see #getDeclaredPrefixes * @see #getURI */ public java.util.Enumeration<Object> getPrefixes(String uri) { java.util.Vector<Object> prefixes = new java.util.Vector<Object>(); java.util.Enumeration<Object> allPrefixes = getPrefixes(); while (allPrefixes.hasMoreElements()) { String prefix = (String)allPrefixes.nextElement(); if (uri.equals(getURI(prefix))) { prefixes.addElement(prefix); } } return prefixes.elements(); }
//////////////////////////////////////////////////////////////////// // Operations within a context. //////////////////////////////////////////////////////////////////// /** * Declare a Namespace prefix. All prefixes must be declared * before they are referenced. For example, a SAX driver (parser) * would scan an element's attributes * in two passes: first for namespace declarations, * then a second pass using {@link #processName processName()} to * interpret prefixes against (potentially redefined) prefixes. * * <p/>This method declares a prefix in the current Namespace * context; the prefix will remain in force until this context * is popped, unless it is shadowed in a descendant context. * * <p/>To declare the default element Namespace, use the empty string as * the prefix. * * <p/>Note that you must <em>not</em> declare a prefix after * you've pushed and popped another Namespace context, or * treated the declarations phase as complete by processing * a prefixed name. * * <p/>Note that there is an asymmetry in this library: {@link * #getPrefix getPrefix} will not return the "" prefix, * even if you have declared a default element namespace. * To check for a default namespace, * you have to look it up explicitly using {@link #getURI getURI}. * This asymmetry exists to make it easier to look up prefixes * for attribute names, where the default prefix is not allowed. * * @param prefix The prefix to declare, or the empty string to * indicate the default element namespace. This may never have * the value "xml" or "xmlns". * @param uri The Namespace URI to associate with the prefix. * @return true if the prefix was legal, false otherwise * * @see #processName * @see #getURI * @see #getPrefix */ public bool declarePrefix(String prefix, String uri) { if (prefix.equals("xml") || prefix.equals("xmlns")) { return false; } else { currentContext.declarePrefix(prefix, uri); return true; } }
/// <summary> /// Create a new ConfigPolicyManager which will act on the rules specified in /// the configuration and download unknown certificates when necessary. /// </summary> /// /// <param name="configFileName">separately call load().</param> /// <param name="certificateCache">CertificateCache.</param> /// <param name="searchDepth"></param> /// <param name="graceInterval">public key and the validation time. If omitted, use a default value.</param> /// <param name="keyTimestampTtl">value.</param> /// <param name="maxTrackedKeys"></param> public ConfigPolicyManager(String configFileName, CertificateCache certificateCache, int searchDepth, double graceInterval, double keyTimestampTtl, int maxTrackedKeys) { this.certificateCache_ = new CertificateCache(); this.maxDepth_ = 5; this.keyGraceInterval_ = 3000; this.keyTimestampTtl_ = 3600000; this.maxTrackedKeys_ = 1000; this.fixedCertificateCache_ = new Hashtable(); this.keyTimestamps_ = new Hashtable(); this.config_ = new BoostInfoParser(); this.requiresVerification_ = true; this.refreshManager_ = new ConfigPolicyManager.TrustAnchorRefreshManager (); certificateCache_ = certificateCache; maxDepth_ = searchDepth; keyGraceInterval_ = graceInterval; keyTimestampTtl_ = keyTimestampTtl; maxTrackedKeys_ = maxTrackedKeys; if (configFileName != null && !configFileName.equals("")) load(configFileName); }
/// <summary> /// Determines if a name satisfies the relation to another name, based on /// matchRelation. /// </summary> /// /// <param name="name"></param> /// <param name="matchName"></param> /// <param name="matchRelation">name as a prefix "is-strict-prefix-of" - passes if the name has the other name as a prefix, and is not equal "equal" - passes if the two names are equal</param> /// <returns>True if matches.</returns> private static bool matchesRelation(Name name, Name matchName, String matchRelation) { bool passed = false; if (matchRelation.equals("is-strict-prefix-of")) { if (matchName.size() == name.size()) passed = false; else if (matchName.match(name)) passed = true; } else if (matchRelation.equals("is-prefix-of")) { if (matchName.match(name)) passed = true; } else if (matchRelation.equals("equal")) { if (matchName.equals(name)) passed = true; } return passed; }
protected internal virtual String convertPattern(String template, String fromChars, String toChars, bool check) { if (!check && fromChars.equals(toChars)) { return template; } bool quote = false; StringBuilder output = new StringBuilder(); int length = template.length(); for (int i = 0; i < length; i++) { int index; char next = template.charAt(i); if (next == '\'') { quote = !quote; } if (!quote && (index = fromChars.indexOf(next)) != -1) { output.append(toChars.charAt(index)); } else if (check && !quote && ((next >= 'a' && next <= 'z') || (next >= 'A' && next <= 'Z'))) { // text.05=Invalid pattern char {0} in {1} throw new java.lang.IllegalArgumentException("Invalid pattern char "+next+" in "+ template); //$NON-NLS-1$ } else { output.append(next); } } if (quote) { // text.04=Unterminated quote throw new java.lang.IllegalArgumentException("Unterminated quote"); //$NON-NLS-1$ } return output.toString(); }
//throws SAXNotRecognizedException, SAXNotSupportedException /** * Check a parser feature flag. * * <p>The only features recognized are namespaces and * namespace-prefixes.</p> * * @param name The feature name, as a complete URI. * @return The current feature value. * @exception SAXNotRecognizedException If the feature * value can't be assigned or retrieved. * @exception SAXNotSupportedException If the * feature is not currently readable. * @see org.xml.sax.XMLReader#setFeature */ public bool getFeature(String name) { if (name.equals(NAMESPACES)) { return namespaces; } else if (name.equals(NAMESPACE_PREFIXES)) { return prefixes; } else if (name.equals(XMLNS_URIs)) { return uris; } else { throw new SAXNotRecognizedException("Feature: " + name); } }
//throws NoSuchAlgorithmException private static java.security.Provider getProvider(String engine, String alg, String mech) { java.util.Map<String, String> map = new java.util.HashMap<String, String>(); map.put(engine + "." + alg, ""); map.put(engine + "." + alg + " " + "MechanismType", mech); java.security.Provider[] providers = java.security.Security.getProviders(map); if (providers == null) { if (mech.equals("DOM")) { // look for providers without MechanismType specified map.clear(); map.put(engine + "." + alg, ""); providers = java.security.Security.getProviders(map); if (providers != null) { return providers[0]; } } throw new java.security.NoSuchAlgorithmException("Algorithm type " + alg + " not available"); } return providers[0]; }
/** * Sets the properties of this URL using the provided arguments. Only a * {@code URLStreamHandler} can use this method to set fields of the * existing URL instance. A URL is generally constant. * * @param protocol * the protocol to be set. * @param host * the host name to be set. * @param port * the port number to be set. * @param authority * the authority to be set. * @param userInfo * the user-info to be set. * @param path * the path to be set. * @param query * the query to be set. * @param ref * the reference to be set. */ protected internal void set(String protocol, String host, int port, String authority, String userInfo, String file, String query, String refJ) { String filePart = path; if (query != null && !query.equals("")) { //$NON-NLS-1$ if (filePart != null) { filePart = filePart + "?" + query; //$NON-NLS-1$ } else { filePart = "?" + query; //$NON-NLS-1$ } } this.set(protocol, host, port, filePart, refJ); this.authority = authority; this.userInfo = userInfo; this.path = path; this.query = query; }
void setWriteMethod(java.lang.Class beanClass, String setterName) { //throws IntrospectionException { java.lang.reflect.Method writeMethod = null; try { if (getter != null) { writeMethod = beanClass.getMethod(setterName, new java.lang.Class[] { getter.getReturnType() }); } else { java.lang.Class clazz = beanClass; java.lang.reflect.Method[] methods = null; while (clazz != null && writeMethod == null) { methods = clazz.getDeclaredMethods(); foreach (java.lang.reflect.Method method in methods) { if (setterName.equals(method.getName())) { if (method.getParameterTypes().Length == 1) { writeMethod = method; break; } } } clazz = clazz.getSuperclass(); } } } catch (java.lang.Exception e) { throw new IntrospectionException(e.getLocalizedMessage()); } catch (System.Exception e) { throw new IntrospectionException(e.Message); } if (writeMethod == null) { throw new IntrospectionException("Method not found: " + setterName); //$NON-NLS-1$ } setWriteMethod(writeMethod); }
/** * Get the service of the specified type * */ internal Provider.Service getService(String type) { lock (this) { updatePropertyServiceTable(); if (lastServicesByType != null && type.equals(lastType)) { return lastServicesByType; } Provider.Service service; for (java.util.Iterator<Service> it = getServices().iterator(); it.hasNext(); ) { service = it.next(); if (type.equals(service.type)) { lastType = type; lastServicesByType = service; return service; } } return null; } }
public org.xml.sax.InputSource resolveEntity(String publicId, String systemId) { // throws SAXException, IOException { if (systemId.equals (PREFS_DTD_NAME)) { org.xml.sax.InputSource result = new org.xml.sax.InputSource (new java.io.StringReader ( PREFS_DTD)); result.setSystemId (PREFS_DTD_NAME); return result; } // prefs.1=Invalid DOCTYPE declaration: {0} throw new org.xml.sax.SAXException ("Invalid DOCTYPE declaration: " + systemId); //$NON-NLS-1$ }