diff options
Diffstat (limited to 'src/com/sun/org/apache/xml/internal/resolver/CatalogEntry.java')
-rw-r--r-- | src/com/sun/org/apache/xml/internal/resolver/CatalogEntry.java | 47 |
1 files changed, 23 insertions, 24 deletions
diff --git a/src/com/sun/org/apache/xml/internal/resolver/CatalogEntry.java b/src/com/sun/org/apache/xml/internal/resolver/CatalogEntry.java index 076e2f5..44b2af9 100644 --- a/src/com/sun/org/apache/xml/internal/resolver/CatalogEntry.java +++ b/src/com/sun/org/apache/xml/internal/resolver/CatalogEntry.java @@ -1,18 +1,15 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! + * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. */ -// CatalogEntry.java - Represents Catalog entries - /* - * Copyright 2001-2004 The Apache Software Foundation or its licensors, - * as applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -20,11 +17,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +// CatalogEntry.java - Represents Catalog entries package com.sun.org.apache.xml.internal.resolver; -import java.util.Hashtable; +import java.util.Map; import java.util.Vector; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.atomic.AtomicInteger; /** * Represents a Catalog entry. @@ -53,14 +52,14 @@ import java.util.Vector; */ public class CatalogEntry { /** The nextEntry is the ordinal number of the next entry type. */ - protected static int nextEntry = 0; + protected static AtomicInteger nextEntry = new AtomicInteger(0); /** * The entryTypes vector maps catalog entry names * (e.g., 'BASE' or 'SYSTEM') to their type (1, 2, etc.). * Names are case sensitive. */ - protected static Hashtable entryTypes = new Hashtable(); + protected static final Map<String, Integer> entryTypes = new ConcurrentHashMap<>(); /** The entryTypes vector maps catalog entry types to the number of arguments they're required to have. */ @@ -77,12 +76,12 @@ public class CatalogEntry { * of arguments. * @return The type for the new entry. */ - public static int addEntryType(String name, int numArgs) { - entryTypes.put(name, new Integer(nextEntry)); - entryArgs.add(nextEntry, new Integer(numArgs)); - nextEntry++; + static int addEntryType(String name, int numArgs) { + final int index = nextEntry.getAndIncrement(); + entryTypes.put(name, index); + entryArgs.add(index, numArgs); - return nextEntry-1; + return index; } /** @@ -99,13 +98,13 @@ public class CatalogEntry { throw new CatalogException(CatalogException.INVALID_ENTRY_TYPE); } - Integer iType = (Integer) entryTypes.get(name); + Integer iType = entryTypes.get(name); if (iType == null) { throw new CatalogException(CatalogException.INVALID_ENTRY_TYPE); } - return iType.intValue(); + return iType; } /** @@ -161,13 +160,13 @@ public class CatalogEntry { */ public CatalogEntry(String name, Vector args) throws CatalogException { - Integer iType = (Integer) entryTypes.get(name); + Integer iType = entryTypes.get(name); if (iType == null) { throw new CatalogException(CatalogException.INVALID_ENTRY_TYPE); } - int type = iType.intValue(); + int type = iType; try { Integer iArgs = (Integer) entryArgs.get(type); |