View Javadoc
1   /*
2    *  Licensed to the Apache Software Foundation (ASF) under one
3    *  or more contributor license agreements.  See the NOTICE file
4    *  distributed with this work for additional information
5    *  regarding copyright ownership.  The ASF licenses this file
6    *  to you under the Apache License, Version 2.0 (the
7    *  "License"); you may not use this file except in compliance
8    *  with the License.  You may obtain a copy of the License at
9    *  
10   *    https://www.apache.org/licenses/LICENSE-2.0
11   *  
12   *  Unless required by applicable law or agreed to in writing,
13   *  software distributed under the License is distributed on an
14   *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   *  KIND, either express or implied.  See the License for the
16   *  specific language governing permissions and limitations
17   *  under the License. 
18   *  
19   */
20  package org.apache.directory.api.ldap.schema.converter;
21  
22  
23  import java.io.InputStream;
24  import java.io.Writer;
25  
26  
27  /**
28   * A bean used to hold a schema. We keep its name and we associate with this
29   * object an inputStream mapped on the OpenLdap schema to read, and a writer
30   * in which the ldif file will be dumped.
31   *
32   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
33   */
34  public class Schema
35  {
36      /** The schema name */
37      private String name;
38  
39      /** The inputStream mapped on the file to read */
40      private InputStream in;
41  
42      /** The writer where we dump the ldif lines */
43      private Writer out;
44  
45  
46      /**
47       * Set the schema name to parse. This name is the prefix of the
48       * schema file, which postfix is '.schema'.
49       * 
50       * For instance, 'test.schema' being the file to parse, its name 
51       * will be 'test'
52       * @param name The schema name
53       */
54      public void setName( String name )
55      {
56          this.name = name;
57      }
58  
59  
60      /**
61       * @return The schema name.
62       */
63      public String getName()
64      {
65          return name;
66      }
67  
68  
69      /**
70       * Set the inputStream mapped on the schema file
71       * @param in The InputStream mapped on the schema file
72       */
73      public void setInput( InputStream in )
74      {
75          this.in = in;
76      }
77  
78  
79      /**
80       * @return The InputStream mapped on the schema file
81       */
82      public InputStream getInput()
83      {
84          return in;
85      }
86  
87  
88      /**
89       * @return The writer in which the ldif lines will be dumped
90       */
91      public Writer getOutput()
92      {
93          return out;
94      }
95  
96  
97      /**
98       * Set a writer to dump the ldif files
99       * @param out The writer 
100      */
101     public void setOutput( Writer out )
102     {
103         this.out = out;
104     }
105     
106     
107     /**
108      * @see Object#toString()
109      */
110     @Override
111     public String toString()
112     {
113         return "Schema " + name + ".schema";
114     }
115 }