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   *   http://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  package org.apache.myfaces.orchestra.dynaForm.metadata;
20  
21  import java.util.Iterator;
22  import java.util.Set;
23  
24  /**
25   * A writable implementation of the MetaData interface that is initialised
26   * by Extractor objects, and then read by other objects that need information
27   * about the available properties.
28   * <p>
29   * An instance of this class is created and then passed to a list of one or
30   * more Extractor objects, together with a source object to be introspected.
31   * The extractor instances deduce information about fields of the source
32   * object and then add or update MetaField objects held by the MetaDataImpl.
33   * <p>
34   * An instance of MetaDataImpl is then typically cast to the read-only
35   * MetaData interface type and passed to objects that make use of the 
36   * gathered metadata, such as dynaform "gui builders". 
37   */
38  public interface MetaDataWritable extends MetaData
39  {
40      /**
41       * Indicate whether the field with the specified name should be
42       * used or ignored.
43       *
44       * @see #setLockFields(boolean)
45       */
46      public boolean isWantedField(String name);
47  
48      /**
49              // we processed this field due to the fact that it was the parent of a requestedField
50       * should this field be processed.
51       *
52       * @return true if the given name is the parent of one of the requestedFields
53       * @see #processField(String)
54       * @see #setLockFields(boolean)
55       */
56      public boolean isParentOfWantedField(String name);
57  
58      /**
59       * request to add this field if we reach it. eg. used to trigger traversing the object graph for
60       * linked entities
61       * <p>
62       * Name may be of form "foo.bar.baz"
63       */
64      public void requestField(String name);
65  
66      public Set<String> getRequestedFields();
67  
68      /**
69       * add a new field to the metadata or return one if one already exists for
70       * the given name
71       */
72      public MetaFieldWritable getOrCreateField(String name);
73  
74      public int getFieldCount();
75  
76      public Iterator<String> iterFieldNames();
77  
78      public MetaField getField(String name);
79  
80      public String[] getFieldNames();
81  
82      /**
83       * Prevent the adding of any new MetaField objects to this instance (but
84       * enhancing existing fields is permitted).
85       * <p>
86       * When set to true, any call to isProcessableField will return false for names
87       * that are not already known, and getOrCreateField will throw an exception if
88       * the field does not exist.
89       */
90      public boolean setLockFields(boolean lockFields);
91  }