001    /*
002     * Copyright (c) OSGi Alliance (2001, 2008). All Rights Reserved.
003     *
004     * Licensed under the Apache License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     *      http://www.apache.org/licenses/LICENSE-2.0
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    package org.osgi.service.metatype;
017    
018    import java.io.IOException;
019    import java.io.InputStream;
020    
021    /**
022     * Description for the data type information of an objectclass.
023     * 
024     * @version $Revision: 5673 $
025     */
026    public interface ObjectClassDefinition {
027            /**
028             * Argument for <code>getAttributeDefinitions(int)</code>.
029             * <p>
030             * <code>REQUIRED</code> indicates that only the required definitions are
031             * returned. The value is 1.
032             */
033            public static final int REQUIRED        = 1;
034            /**
035             * Argument for <code>getAttributeDefinitions(int)</code>.
036             * <p>
037             * <code>OPTIONAL</code> indicates that only the optional definitions are
038             * returned. The value is 2.
039             */
040            public static final int OPTIONAL        = 2;
041            /**
042             * Argument for <code>getAttributeDefinitions(int)</code>.
043             * <p>
044             * <code>ALL</code> indicates that all the definitions are returned. The value
045             * is -1.
046             */
047            public static final int ALL                     = 0xFFFFFFFF;
048    
049            /**
050             * Return the name of this object class.
051             * 
052             * The name may be localized.
053             * 
054             * @return The name of this object class.
055             */
056            public String getName();
057    
058            /**
059             * Return the id of this object class.
060             * 
061             * <p>
062             * <code>ObjectDefintion</code> objects share a global namespace in the
063             * registry. They share this aspect with LDAP/X.500 attributes. In these
064             * standards the OSI Object Identifier (OID) is used to uniquely identify
065             * object classes. If such an OID exists, (which can be requested at several
066             * standard organisations and many companies already have a node in the
067             * tree) it can be returned here. Otherwise, a unique id should be returned
068             * which can be a java class name (reverse domain name) or generated with a
069             * GUID algorithm. Note that all LDAP defined object classes already have an
070             * OID associated. It is strongly advised to define the object classes from
071             * existing LDAP schemes which will give the OID for free. Many such schemes
072             * exist ranging from postal addresses to DHCP parameters.
073             * 
074             * @return The id of this object class.
075             */
076            public String getID();
077    
078            /**
079             * Return a description of this object class.
080             * 
081             * The description may be localized.
082             * 
083             * @return The description of this object class.
084             */
085            public String getDescription();
086    
087            /**
088             * Return the attribute definitions for this object class.
089             * 
090             * <p>
091             * Return a set of attributes. The filter parameter can distinguish between
092             * <code>ALL</code>,<code>REQUIRED</code> or the <code>OPTIONAL</code>
093             * attributes.
094             * 
095             * @param filter <code>ALL</code>,<code>REQUIRED</code>,<code>OPTIONAL</code>
096             * @return An array of attribute definitions or <code>null</code> if no
097             *         attributes are selected
098             */
099            public AttributeDefinition[] getAttributeDefinitions(int filter);
100    
101            /**
102             * Return an <code>InputStream</code> object that can be used to create an
103             * icon from.
104             * 
105             * <p>
106             * Indicate the size and return an <code>InputStream</code> object containing
107             * an icon. The returned icon maybe larger or smaller than the indicated
108             * size.
109             * 
110             * <p>
111             * The icon may depend on the localization.
112             * 
113             * @param size Requested size of an icon, e.g. a 16x16 pixels icon then size =
114             *        16
115             * @return An InputStream representing an icon or <code>null</code>
116             * @throws IOException If the <code>InputStream</code> cannot be returned.
117             */
118            public InputStream getIcon(int size) throws IOException;
119    }