KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > xsl > StringSource


1 /*
2  * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Resin Open Source is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17  * of NON-INFRINGEMENT. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Resin Open Source; if not, write to the
22  * Free SoftwareFoundation, Inc.
23  * 59 Temple Place, Suite 330
24  * Boston, MA 02111-1307 USA
25  *
26  * @author Scott Ferguson
27  */

28
29 package com.caucho.xsl;
30
31 import javax.xml.transform.Source JavaDoc;
32 import java.io.File JavaDoc;
33
34 /**
35  * Source for an input string.
36  */

37 public class StringSource implements Source JavaDoc {
38   /**
39    * The feature name to tell if the transformer can handle stream input.
40    */

41   public static final String JavaDoc FEATURE = "stringsource";
42
43   /**
44    * Underlying string.
45    */

46   private String JavaDoc string;
47
48   /**
49    * System identifier (URL).
50    */

51   private String JavaDoc systemId;
52
53   /**
54    * Public identifier.
55    */

56   private String JavaDoc publicId;
57
58   /**
59    * Zero-arg constructor.
60    */

61   public StringSource()
62   {
63   }
64
65   /**
66    * Create a StringSource with a given string.
67    *
68    * @param source the source string.
69    */

70   public StringSource(String JavaDoc source)
71   {
72     this.string = source;
73   }
74
75   /**
76    * Create a StringSource with a given string and systemId.
77    *
78    * @param source the source string.
79    * @param systemId the URL representing the string location.
80    */

81   public StringSource(String JavaDoc source, String JavaDoc systemId)
82   {
83     this.string = source;
84     this.systemId = systemId;
85   }
86
87   /**
88    * Returns the source string.
89    */

90   public String JavaDoc getString()
91   {
92     return string;
93   }
94
95   /**
96    * Sets the source string stream.
97    */

98   public void setString(String JavaDoc is)
99   {
100     this.string = is;
101   }
102
103   /**
104    * Returns the system identifier (URL).
105    */

106   public String JavaDoc getSystemId()
107   {
108     return systemId;
109   }
110
111   /**
112    * Sets the system identifier (URL).
113    */

114   public void setSystemId(String JavaDoc systemId)
115   {
116     this.systemId = systemId;
117   }
118
119   /**
120    * Sets the system identifier (URL) from a File.
121    */

122   public void setSystemId(File JavaDoc file)
123   {
124     this.systemId = file.toString();
125   }
126
127   /**
128    * Returns the public identifier (URL).
129    */

130   public String JavaDoc getPublicId()
131   {
132     return publicId;
133   }
134
135   /**
136    * Sets the public identifier (URL).
137    */

138   public void setPublicId(String JavaDoc publicId)
139   {
140     this.publicId = publicId;
141   }
142 }
143
Popular Tags