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
024package microsoft.exchange.webservices.data.security;
025
026import microsoft.exchange.webservices.data.core.exception.misc.ArgumentNullException;
027import microsoft.exchange.webservices.data.core.exception.misc.ArgumentOutOfRangeException;
028
029/**
030 * Table of atomized String objects.
031 */
032public 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   */
060  public abstract String Add(char[] array, int offset, int length);
061
062  /**
063   * When overridden in a derived class, gets the atomized String containing
064   * the same value as the specified String.
065   *
066   * @param array The name to look up.
067   * @return The atomized String or null if the String has not already been
068   * atomized.
069   * @throws ArgumentNullException : array is null.
070   */
071  public abstract String Get(String array);
072
073  /**
074   * When overridden in a derived class, gets the atomized String containing
075   * the same characters as the specified range of characters in the given
076   * array.
077   *
078   * @param array  The character array containing the name to add.
079   * @param offset Zero-based index into the array specifying the first character
080   *               of the name.
081   * @param length The number of characters in the name.
082   * @return The atomized String or null if the String has not already been
083   * atomized. If length is zero, String.Empty is returned
084   */
085  public abstract String Get(char[] array, int offset, int length);
086
087}