View Javadoc

1   /**
2    * Copyright (c) 2008-2012, http://www.snakeyaml.org
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.yaml.snakeyaml.constructor;
17  
18  import org.yaml.snakeyaml.nodes.Node;
19  
20  /**
21   * Provide a way to construct a Java instance out of the composed Node. Support
22   * recursive objects if it is required. (create Native Data Structure out of
23   * Node Graph)
24   * 
25   * @see <a href="http://yaml.org/spec/1.1/#id859109">Chapter 3. Processing YAML
26   *      Information</a>
27   */
28  public interface Construct {
29      /**
30       * Construct a Java instance with all the properties injected when it is
31       * possible.
32       * 
33       * @param node
34       *            composed Node
35       * @return a complete Java instance
36       */
37      public Object construct(Node node);
38  
39      /**
40       * Apply the second step when constructing recursive structures. Because the
41       * instance is already created it can assign a reference to itself.
42       * 
43       * @param node
44       *            composed Node
45       * @param object
46       *            the instance constructed earlier by
47       *            <code>construct(Node node)</code> for the provided Node
48       */
49      public void construct2ndStep(Node node, Object object);
50  }