001    /*
002     * The MIT License
003     * Copyright (c) 2012 Microsoft Corporation
004     *
005     * Permission is hereby granted, free of charge, to any person obtaining a copy
006     * of this software and associated documentation files (the "Software"), to deal
007     * in the Software without restriction, including without limitation the rights
008     * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
009     * copies of the Software, and to permit persons to whom the Software is
010     * furnished to do so, subject to the following conditions:
011     *
012     * The above copyright notice and this permission notice shall be included in
013     * all copies or substantial portions of the Software.
014     *
015     * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
016     * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
017     * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
018     * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
019     * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
020     * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
021     * THE SOFTWARE.
022     */
023    
024    package microsoft.exchange.webservices.data.security;
025    
026    import microsoft.exchange.webservices.data.core.exception.misc.ArgumentNullException;
027    import microsoft.exchange.webservices.data.core.exception.misc.ArgumentOutOfRangeException;
028    
029    /**
030     * Table of atomized String objects.
031     */
032    public abstract class XmlNameTable {
033    
034      /**
035       * Initializes a new instance of the XmlNameTable class.
036       */
037      protected XmlNameTable() {
038      }
039    
040      /**
041       * When overridden in a derived class, atomizes the specified String and
042       * adds it to the XmlNameTable.
043       *
044       * @param array : The name to add.
045       * @return The new atomized String or the existing one if it already exists.
046       * @throws ArgumentNullException array is null.
047       */
048      public abstract String Add(String array);
049    
050      /**
051       * Reads an XML Schema from the supplied stream.
052       *
053       * @param array  The character array containing the name to add.
054       * @param offset Zero-based index into the array specifying the first character
055       *               of the name.
056       * @param length The number of characters in the name.
057       * @return The new atomized String or the existing one if it already exists.
058       * If length is zero, String.Empty is returned
059       * @throws ArgumentOutOfRangeException 0 > offset -or- offset >= array.Length -or- length >
060       *                                     array.Length The above conditions do not cause an exception
061       *                                     to be thrown if length =0.
062       * @throws ArgumentOutOfRangeException length < 0.
063       */
064      public abstract String Add(char[] array, int offset, int length);
065    
066      /**
067       * When overridden in a derived class, gets the atomized String containing
068       * the same value as the specified String.
069       *
070       * @param array The name to look up.
071       * @return The atomized String or null if the String has not already been
072       * atomized.
073       * @throws ArgumentNullException : array is null.
074       */
075      public abstract String Get(String array);
076    
077      /**
078       * When overridden in a derived class, gets the atomized String containing
079       * the same characters as the specified range of characters in the given
080       * array.
081       *
082       * @param array  The character array containing the name to add.
083       * @param offset Zero-based index into the array specifying the first character
084       *               of the name.
085       * @param length The number of characters in the name.
086       * @return The atomized String or null if the String has not already been
087       * atomized. If length is zero, String.Empty is returned
088       * @throws ArgumentOutOfRangeException 0 > offset -or- offset >= array.Length -or- length >
089       *                                     array.Length The above conditions do not cause an exception
090       *                                     to be thrown if length =0.
091       * @throws ArgumentOutOfRangeException length < 0.
092       */
093      public abstract String Get(char[] array, int offset, int length);
094    
095    }