/** * Record a violation of the property access restrictions. */ private void addViolation(String key, Object[] args, boolean fatal) { if (_violations == null) _violations = new HashSet(); _violations.add(_loc.get(key, args)); _fail |= fatal; }
/** * Return a Localizer instance that will access the properties file * in the package of the given class using the system default locale. * * @see #forPackage(Class,Locale) */ public static Localizer forPackage(Class cls) { return forPackage(cls, null); }
/** * Return the localized string matching the given key. */ public Message getFatal(String key) { return getFatal(key, null); }
public static BooleanRepresentation valueOf(String booleanRepresentationKey, ClassLoader cl) { // 1st step, try to lookup the BooleanRepresentation from the default ones BooleanRepresentation booleanRepresentation = BUILTIN_BOOLEAN_REPRESENTATIONS.get(booleanRepresentationKey); if (booleanRepresentation == null && booleanRepresentationKey.contains("/")) { // if the key contains a '/' then the first value is the key for 'true', the 2nd value is for 'false' String[] vals = booleanRepresentationKey.split("/"); if (vals.length == 2) { booleanRepresentation = new StringBooleanRepresentation(vals[0], vals[1]); } } else { // or do a class lookup for a custom BooleanRepresentation try { Class<? extends BooleanRepresentation> booleanRepresentationClass = (Class<? extends BooleanRepresentation>) cl.loadClass(booleanRepresentationKey); booleanRepresentation = booleanRepresentationClass.newInstance(); } catch (Exception e) { // nothing to do } } if (booleanRepresentation == null) { Localizer _loc = Localizer.forPackage(BooleanRepresentation.class); throw new UserException(_loc.get("unknown-booleanRepresentation", new Object[]{booleanRepresentationKey, Arrays.toString(BUILTIN_BOOLEAN_REPRESENTATIONS.keySet().toArray(new String[]{}))} )); } return booleanRepresentation; }
/** * Find the given localized string, or return null if not found. */ private String findLocalized(String key, boolean fatal, Class scope) { // find the localizer package that contains this key Localizer loc = null; // check the package that the value claims to be defined in, if // available, before we start guessing. if (scope != null) { loc = Localizer.forPackage(scope); try { return loc.getFatal(key).getMessage(); } catch (MissingResourceException mse) { } } for (Class cls = getClass(); cls != Object.class; cls = cls.getSuperclass()) { loc = Localizer.forPackage(cls); try { return loc.getFatal(key).getMessage(); } catch (MissingResourceException mse) { } } if (fatal) throw new MissingResourceException(key, getClass().getName(), key); return null; }
/** * Return the localized string matching the given key. The given * <code>subs</code> objects will be substituted * into the found string according to the rules of the * {@link MessageFormat} class. * * @see #get(String) */ public Message get(String key, Object[] subs) { return new Message(_pkg, getBundle(), key, subs, false); }
return loc; else { loc = new Localizer(pkg, file, locale, cls == null ? null:(ClassLoader) AccessController.doPrivileged( J2DoPrivHelper.getClassLoaderAction(cls)));
public static BooleanRepresentation valueOf(String booleanRepresentationKey, ClassLoader cl) { // 1st step, try to lookup the BooleanRepresentation from the default ones BooleanRepresentation booleanRepresentation = BUILTIN_BOOLEAN_REPRESENTATIONS.get(booleanRepresentationKey); if (booleanRepresentation == null && booleanRepresentationKey.contains("/")) { // if the key contains a '/' then the first value is the key for 'true', the 2nd value is for 'false' String[] vals = booleanRepresentationKey.split("/"); if (vals.length == 2) { booleanRepresentation = new StringBooleanRepresentation(vals[0], vals[1]); } } else { // or do a class lookup for a custom BooleanRepresentation try { Class<? extends BooleanRepresentation> booleanRepresentationClass = (Class<? extends BooleanRepresentation>) cl.loadClass(booleanRepresentationKey); booleanRepresentation = booleanRepresentationClass.newInstance(); } catch (Exception e) { // nothing to do } } if (booleanRepresentation == null) { Localizer _loc = Localizer.forPackage(BooleanRepresentation.class); throw new UserException(_loc.get("unknown-booleanRepresentation", new Object[]{booleanRepresentationKey, Arrays.toString(BUILTIN_BOOLEAN_REPRESENTATIONS.keySet().toArray(new String[]{}))} )); } return booleanRepresentation; }
/** * Find the given localized string, or return null if not found. */ @SuppressWarnings("unchecked") private String findLocalized(String key, boolean fatal, Class<?> scope) { // find the localizer package that contains this key Localizer loc = null; // check the package that the value claims to be defined in, if // available, before we start guessing. if (scope != null) { loc = Localizer.forPackage(scope); try { return loc.getFatal(key).getMessage(); } catch (MissingResourceException mse) { } } for (Class cls = getClass(); cls != Object.class; cls = cls.getSuperclass()) { loc = Localizer.forPackage(cls); try { return loc.getFatal(key).getMessage(); } catch (MissingResourceException mse) { } } if (fatal) throw new MissingResourceException(key, getClass().getName(), key); return null; }
/** * Return the localized string matching the given key. The given * <code>subs</code> objects will be substituted * into the found string according to the rules of the * {@link MessageFormat} class. * * @see #getFatal(String) */ public Message getFatal(String key, Object[] subs) { return new Message(_pkg, getBundle(), key, subs, true); }
return loc; else { loc = new Localizer(pkg, file, locale, cls == null ? null:AccessController.doPrivileged( J2DoPrivHelper.getClassLoaderAction(cls)));
public int compare(Object o1, Object o2) { if (_idx != -1) { o1 = ((Object[]) o1)[_idx]; o2 = ((Object[]) o2)[_idx]; } else { o1 = _val.evaluate(o1, o1, _ctx, _params); o2 = _val.evaluate(o2, o2, _ctx, _params); } if (o1 == null && o2 == null) return 0; if (o1 == null) return (_asc) ? 1 : -1; if (o2 == null) return (_asc) ? -1 : 1; if (o1 instanceof Boolean && o2 instanceof Boolean) { int i1 = ((Boolean) o1).booleanValue() ? 1 : 0; int i2 = ((Boolean) o2).booleanValue() ? 1 : 0; return i1 - i2; } try { if (_asc) return ((Comparable) o1).compareTo(o2); return ((Comparable) o2).compareTo(o1); } catch (ClassCastException cce) { Localizer loc = Localizer.forPackage (InMemoryExpressionFactory.class); throw new UserException(loc.get("not-comp", o1, o2)); } } }
/** * When the event type is not PAYLOAD_EXTENTS, return the set of * object IDs for updated objects. When the event type is * PAYLOAD_LOCAL_STALE_DETECTION, items in this list may actually have * been deleted from the database. */ public Collection getUpdatedObjectIds() { if (_payload == PAYLOAD_EXTENTS) throw new UserException(s_loc.get("extent-only-event")); return (_updates == null) ? Collections.EMPTY_LIST : _updates; }
/** * Return a Localizer instance that will access the properties file * in the package of the given class using the system default locale. * * @see #forPackage(Class,Locale) */ public static Localizer forPackage(Class<?> cls) { return forPackage(cls, null); }
/** * Find the given localized string, or return null if not found. */ @SuppressWarnings("unchecked") private String findLocalized(String key, boolean fatal, Class<?> scope) { // find the localizer package that contains this key Localizer loc = null; // check the package that the value claims to be defined in, if // available, before we start guessing. if (scope != null) { loc = Localizer.forPackage(scope); try { return loc.getFatal(key).getMessage(); } catch (MissingResourceException mse) { } } for (Class cls = getClass(); cls != Object.class; cls = cls.getSuperclass()) { loc = Localizer.forPackage(cls); try { return loc.getFatal(key).getMessage(); } catch (MissingResourceException mse) { } } if (fatal) throw new MissingResourceException(key, getClass().getName(), key); return null; }
/** * Return the localized string matching the given key. */ public Message getFatal(String key) { return getFatal(key, null); }
/** * Return the localized string matching the given key. The given * <code>subs</code> objects will be substituted * into the found string according to the rules of the * {@link MessageFormat} class. * * @see #get(String) */ public Message get(String key, Object[] subs) { return new Message(_pkg, getBundle(), key, subs, false); }
return loc; else { loc = new Localizer(pkg, file, locale, cls == null ? null:AccessController.doPrivileged( J2DoPrivHelper.getClassLoaderAction(cls)));
public int compare(Object o1, Object o2) { if (_idx != -1) { o1 = ((Object[]) o1)[_idx]; o2 = ((Object[]) o2)[_idx]; } else { o1 = _val.evaluate(o1, o1, _ctx, _params); o2 = _val.evaluate(o2, o2, _ctx, _params); } if (o1 == null && o2 == null) return 0; if (o1 == null) return (_asc) ? 1 : -1; if (o2 == null) return (_asc) ? -1 : 1; if (o1 instanceof Boolean && o2 instanceof Boolean) { int i1 = ((Boolean) o1).booleanValue() ? 1 : 0; int i2 = ((Boolean) o2).booleanValue() ? 1 : 0; return i1 - i2; } try { if (_asc) return ((Comparable) o1).compareTo(o2); return ((Comparable) o2).compareTo(o1); } catch (ClassCastException cce) { Localizer loc = Localizer.forPackage (InMemoryExpressionFactory.class); throw new UserException(loc.get("not-comp", o1, o2)); } } }
protected Object eval(Object candidate, Object orig, StoreContext ctx, Object[] params) { throw new UnsupportedException(_loc.get("in-mem-subquery")); } }