001/*
002 * Copyright 2009-2017 UnboundID Corp.
003 * All Rights Reserved.
004 */
005/*
006 * Copyright (C) 2009-2017 UnboundID Corp.
007 *
008 * This program is free software; you can redistribute it and/or modify
009 * it under the terms of the GNU General Public License (GPLv2 only)
010 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only)
011 * as published by the Free Software Foundation.
012 *
013 * This program is distributed in the hope that it will be useful,
014 * but WITHOUT ANY WARRANTY; without even the implied warranty of
015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
016 * GNU General Public License for more details.
017 *
018 * You should have received a copy of the GNU General Public License
019 * along with this program; if not, see <http://www.gnu.org/licenses>.
020 */
021package com.unboundid.ldap.sdk.persist;
022
023
024
025import com.unboundid.util.NotMutable;
026import com.unboundid.util.StaticUtils;
027import com.unboundid.util.ThreadSafety;
028import com.unboundid.util.ThreadSafetyLevel;
029
030
031
032/**
033 * This class provides an OID allocator implementation that will generate OIDs
034 * which are equal to the lowercase name of the associated attribute type or
035 * object class followed by "-oid".  This will not result in an OID that is
036 * technically valid, but is accepted by several directory servers.
037 */
038@NotMutable()
039@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
040public final class DefaultOIDAllocator
041       extends OIDAllocator
042{
043  /**
044   * The singleton instance of this OID allocator.
045   */
046  private static final DefaultOIDAllocator INSTANCE = new DefaultOIDAllocator();
047
048
049
050  /**
051   * The serial version UID for this serializable class.
052   */
053  private static final long serialVersionUID = 4815405566303309719L;
054
055
056
057  /**
058   * Creates a new instance of this OID allocator.
059   */
060  private DefaultOIDAllocator()
061  {
062    // No implementation required.
063  }
064
065
066
067  /**
068   * Retrieves the singleton instance of this OID allocator.
069   *
070   * @return  The singleton instance of this OID allocator.
071   */
072  public static DefaultOIDAllocator getInstance()
073  {
074    return INSTANCE;
075  }
076
077
078
079  /**
080   * {@inheritDoc}
081   */
082  @Override()
083  public String allocateAttributeTypeOID(final String name)
084  {
085    return StaticUtils.toLowerCase(name) + "-oid";
086  }
087
088
089
090  /**
091   * {@inheritDoc}
092   */
093  @Override()
094  public String allocateObjectClassOID(final String name)
095  {
096    return StaticUtils.toLowerCase(name) + "-oid";
097  }
098}