KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > xam > ModelSource


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.xml.xam;
21
22
23 import org.openide.util.Lookup;
24 /**
25  * This is the class that encapsulates the physical file for each model.
26  * @author girix
27  */

28 public class ModelSource implements Lookup.Provider {
29     
30     private Lookup lookup;
31     private boolean editable;
32     
33     /**
34      * Create a model source object given the lookup context. If editable is false
35      * the model cannot be mutated. Note that editable is static attribute of the
36      * model source, and does not reflect the access attribute of the associated file.
37      *
38      * @param lookup Lookup object associated with this ModelSource. Lookup minimally
39      * contains a File path of the backing file of the model and a javax.swing.text.Document object.
40      * @param editable whether the model is supposed to be mutated.
41      */

42     public ModelSource(Lookup lookup, boolean editable){
43         this.editable = editable;
44         this.lookup = lookup;
45     }
46     
47     /**
48      * Returns the lookup object associated with this ModelSource. Lookup minimally
49      * contains a File absolute path or FileObject of the backing file of the model
50      * and javax.swing.text.Document object. If model is DOM, the lookup should
51      * also contains javax.xml.transform.Source object for use in cases of relative
52      * resolution of resource such as validation.
53      */

54     public Lookup getLookup(){
55         return lookup;
56     }
57     
58     /**
59      * States if the backing file can be edited.
60      * @return true if the model source file is writable.
61      */

62     public boolean isEditable(){
63         return editable;
64     }
65 }
66
Popular Tags