Package ariba.util.core

Examples of ariba.util.core.GrowOnlyHashtable


     * including all non-preferred timezones.
     * @return map of offset key to timezone
     */
    public static Map<String,TimeZone> createTimeZoneByOffSetMap (List preferredTimezones, boolean sparse)
    {
        Map<String,TimeZone> timezoneByOffsetKeys = new GrowOnlyHashtable();

        /*
            Changed the STD_YEAR to use the current year instead of hardcoding
            2002.  If you pass a  previous year to get the offset, java
            will return timezone as of that year, any changes to timezones the
            occured since then are not included.
            This change will work correctly for most cases execpt for changes
            to day light time saving changes that occur in countries in the
            southern hemisphere where the day light time saving period
            spans 2 calendar years.  The logic that assume the day light time zone
            between Feb 1 and Aug 1, might not be correct for those countries.
         */
        STD_YEAR = Calendar.getInstance().get(Calendar.YEAR);
        DST_YEAR = STD_YEAR;
        String[] timezones = TimeZone.getAvailableIDs();

        for (int i = 0; i < timezones.length; ++i) {
            // iterate through the list of timezones returned by the JVM and
            // construct "key" for the given timezone
            TimeZone timezone = TimeZone.getTimeZone(timezones[i]);
            int febOffset = timezone.getOffset(1, STD_YEAR, STD_MONTH, STD_DATE, 7, 0);
            int augOffset = timezone.getOffset(1, DST_YEAR, DST_MONTH, DST_DATE, 6, 0);
            String newKey = Fmt.S("%s:%s", Constants.getInteger(febOffset), Constants.getInteger(augOffset));
            // now insert key/timezone into the timezone map. If the key has already
            // been inserted (ie, a different timezone name has already been inserted
            // for the same timezone, GMT-8 is US/SanFrancisco or US/LosAngeles), then
            // check if the current value (ie timezone id) is a preferred value.  If not
            // then overwrite, if so, then keep the preferred value.
            // The "last entry" wins mechanism needs to be maintained for backward
            // compatibility, but we've added the extra "preferred timezone" concept.

            // Note that this caches the value at the system level and we'll need to
            // add a per-realm override and possibly a per-user override in the future.

            if (timezoneByOffsetKeys.containsKey(newKey)) {
                String currId = timezoneByOffsetKeys.get(newKey).getID();
                if (preferredTimezones == null || !preferredTimezones.contains(currId)) {
                    Log.aribaweb.debug("Overwriting existing timezone key: %s value: %s with new value: %s",
                            newKey, currId, timezones[i]);
                    timezoneByOffsetKeys.put(newKey, timezone);
                }
                else {
                    Log.aribaweb.debug("Preferred timezone not overwritten: %s", currId);
                }
            }
            else if (sparse) {
                if (preferredTimezones != null && preferredTimezones.contains(timezone.getID())) {
                    // for sparse maps, only insert preferred timezones
                    timezoneByOffsetKeys.put(newKey, timezone);
                }
            }
            else {
                // not sparse so create full map by inserting non-preferred timezones
                // last timezone from TimeZone.getAvailableIDs() will win for any given offset key
                timezoneByOffsetKeys.put(newKey, timezone);
            }
        }
        return timezoneByOffsetKeys;
    }
View Full Code Here


    {
        super();
        _multiLocaleResourceManager = multiLocaleResourceManager;
        _locale = locale;
        _characterEncoding = lookupCharacterEncoding(_locale);
        _resources = new GrowOnlyHashtable();
        _urlsForResource = new GrowOnlyHashtable();
        synchronized (this.getClass()) {
            _index = NextIndex;
            NextIndex++;
        }
    }
View Full Code Here

    }

    protected void clearCache ()
    {
        synchronized (_resources) {
            _resources = new GrowOnlyHashtable();
        }
    }
View Full Code Here

    }

    private static AWContentType registerContentType (String contentTypeName)
    {
        if (ContentTypesByName == null) {
            ContentTypesByName = new GrowOnlyHashtable();
            ContentTypesByIndex = new AWContentType[SupportedContentTypeCount];
        }
        AWContentType contentType = new AWContentType(contentTypeName);
        ContentTypesByName.put(contentType.name, contentType);
        if (contentType.index >= ContentTypesByIndex.length) {
View Full Code Here

    }

    protected GrowOnlyHashtable childrenByName ()
    {
        if (_childrenByName == null) {
            _childrenByName = new GrowOnlyHashtable();
        }
        return _childrenByName;
    }
View Full Code Here

        return null;
    }

    public AWXmlNode[] childrenWithName (String nodeNameWithWildcard)
    {
        GrowOnlyHashtable childrenByName = childrenByName();
        AWXmlNode[] childrenArray = (AWXmlNode[])childrenByName.get(nodeNameWithWildcard);
        if (childrenArray == null) {
            synchronized (childrenByName) {
                childrenArray = (AWXmlNode[])childrenByName.get(nodeNameWithWildcard);
                if (childrenArray == null) {
                    List childrenVector = ListUtil.list();
                    int nodeCount = _xmlNodeChildren.length;
                    boolean getAllChildren = nodeNameWithWildcard.equals("*");
                    for (int index = 0; index < nodeCount; index++) {
                        AWXmlNode currentChild = _xmlNodeChildren[index];
                        String currentNodeTagName = currentChild.tagName();
                        // This assumes a wildcard char "*" is appended to nodeName.
                        if (getAllChildren || nodeNameWithWildcard.startsWith(currentNodeTagName)) {
                            childrenVector.add(currentChild);
                        }
                    }
                    childrenArray = (AWXmlNode[])AWUtil.getArray(childrenVector, AWConcreteXmlNode.class);
                    childrenByName.put(nodeNameWithWildcard, childrenArray);
                }
            }
        }
        return childrenArray;
    }
View Full Code Here

    GrowOnlyHashtable _labelsForIdentifier;

    public AWVIdentifierFormatter(Locale locale)
    {
        _locale = locale;
        _labelsForIdentifier = new GrowOnlyHashtable();
        Assert.that(_locale != null, "locale must not be null");
    }
View Full Code Here

        _Activation getChildActivation (String contextKey, Object value, boolean chaining)
        {
            if (value == null) value = Meta.NullMarker;
            Map<String, GrowOnlyHashtable> byKey = (chaining) ? _valueNodeMapByContextKeyChaining : _valueNodeMapByContextKey;
            if (byKey == null) return null;
            GrowOnlyHashtable byVal = byKey.get(contextKey);
            return (byVal == null) ? null : (_Activation)byVal.get(value);
        }
View Full Code Here

            if (value == null) value = Meta.NullMarker;
            GrowOnlyHashtable<String, GrowOnlyHashtable> byKey;
            // Thread safety:  Okay to lose an activation?  (e.g. write it to an lost map)
            if (chaining) {
                if ((byKey = _valueNodeMapByContextKeyChaining) == null)
                    byKey = _valueNodeMapByContextKeyChaining = new GrowOnlyHashtable();
            } else {
                if ((byKey = _valueNodeMapByContextKey) == null)
                    byKey = _valueNodeMapByContextKey = new GrowOnlyHashtable();
            }

            GrowOnlyHashtable byVal = byKey.get(contextKey);
            if (byVal == null) {
                byVal = new GrowOnlyHashtable();
                byKey.put(contextKey, byVal);
            }
            byVal.put(value, activation);
        }
View Full Code Here

    /*
        Suppresses default constructor for noninstantiability
    */
    private SafeJavaRepository (boolean initialized)
    {
        _name2Specification = new GrowOnlyHashtable();
        if (initialized) {
            fullInitialize();
        }
    }
View Full Code Here

TOP

Related Classes of ariba.util.core.GrowOnlyHashtable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.