001 /* 002 * CDDL HEADER START 003 * 004 * The contents of this file are subject to the terms of the 005 * Common Development and Distribution License, Version 1.0 only 006 * (the "License"). You may not use this file except in compliance 007 * with the License. 008 * 009 * You can obtain a copy of the license at 010 * trunk/opends/resource/legal-notices/OpenDS.LICENSE 011 * or https://OpenDS.dev.java.net/OpenDS.LICENSE. 012 * See the License for the specific language governing permissions 013 * and limitations under the License. 014 * 015 * When distributing Covered Code, include this CDDL HEADER in each 016 * file and include the License file at 017 * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable, 018 * add the following below this CDDL HEADER, with the fields enclosed 019 * by brackets "[]" replaced with your own identifying information: 020 * Portions Copyright [yyyy] [name of copyright owner] 021 * 022 * CDDL HEADER END 023 * 024 * 025 * Copyright 2008 Sun Microsystems, Inc. 026 */ 027 package org.opends.server.api; 028 029 030 031 import java.util.Map; 032 033 import org.opends.server.types.Attribute; 034 import org.opends.server.types.DirectoryException; 035 import org.opends.server.types.ObjectClass; 036 037 038 039 /** 040 * This class provides a utility for interacting with compressed 041 * representations of schema elements. 042 */ 043 @org.opends.server.types.PublicAPI( 044 stability=org.opends.server.types.StabilityLevel.UNCOMMITTED, 045 mayInstantiate=false, 046 mayExtend=true, 047 mayInvoke=false) 048 public abstract class CompressedSchema 049 { 050 /** 051 * Encodes the provided set of object classes to a byte array. If 052 * the same set had been previously encoded, then the cached value 053 * will be used. Otherwise, a new value will be created. 054 * 055 * @param objectClasses The set of object classes for which to 056 * retrieve the corresponding byte array 057 * token. 058 * 059 * @return A byte array containing the identifier assigned to the 060 * object class set. 061 * 062 * @throws DirectoryException If a problem occurs while attempting 063 * to determine the appropriate 064 * identifier. 065 */ 066 public abstract byte[] 067 encodeObjectClasses(Map<ObjectClass,String> objectClasses) 068 throws DirectoryException; 069 070 071 072 /** 073 * Decodes an object class set from the provided byte array. 074 * 075 * @param encodedObjectClasses The byte array containing the 076 * object class set identifier. 077 * 078 * @return The decoded object class set. 079 * 080 * @throws DirectoryException If the provided byte array cannot be 081 * decoded as an object class set. 082 */ 083 public abstract Map<ObjectClass,String> 084 decodeObjectClasses(byte[] encodedObjectClasses) 085 throws DirectoryException; 086 087 088 089 /** 090 * Encodes the information in the provided attribute to a byte 091 * array. 092 * 093 * @param attribute The attribute to be encoded. 094 * 095 * @return An encoded representation of the provided attribute. 096 * 097 * @throws DirectoryException If a problem occurs while attempting 098 * to determine the appropriate 099 * identifier. 100 */ 101 public abstract byte[] encodeAttribute(Attribute attribute) 102 throws DirectoryException; 103 104 105 106 /** 107 * Decodes the contents of the provided array as an attribute. 108 * 109 * @param encodedEntry The byte array containing the encoded 110 * entry. 111 * @param startPos The position within the array of the first 112 * byte for the attribute to decode. 113 * @param length The number of bytes contained in the 114 * encoded attribute. 115 * 116 * @return The decoded attribute. 117 * 118 * @throws DirectoryException If the attribute could not be 119 * decoded properly for some reason. 120 */ 121 public abstract Attribute decodeAttribute(byte[] encodedEntry, 122 int startPos, int length) 123 throws DirectoryException; 124 } 125