1 /*** 2 * The contents of this file are subject to the Mozilla Public 3 * License Version 1.1 (the "License"); you may not use this file 4 * except in compliance with the License. You may obtain a copy of 5 * the License at http://www.mozilla.org/MPL/ 6 * 7 * Software distributed under the License is distributed on an "AS 8 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 9 * implied. See the License for the specific language governing 10 * rights and limitations under the License. 11 * 12 * The Original Code is pow2toolkit library. 13 * 14 * The Initial Owner of the Original Code is 15 * Power Of Two S.R.L. (www.pow2.com) 16 * 17 * Portions created by Power Of Two S.R.L. are 18 * Copyright (C) Power Of Two S.R.L. 19 * All Rights Reserved. 20 * 21 * Contributor(s): 22 */ 23 24 package com.pow2.texen.ant; 25 26 27 import com.pow2.util.*; 28 29 30 /*** 31 * FileBean class 32 * 33 * @author Luca Fossato 34 * @created 25 ottobre 2002 35 */ 36 public class FileBean 37 { 38 private String fileDirectory; 39 private String fileName; 40 private String fileContent; 41 42 43 /*** 44 * Default Constructor 45 */ 46 public FileBean() 47 { 48 } 49 50 51 /*** 52 * Sets the textDirectory attribute of the FileBean object 53 * 54 * @param fileDirectory The new fileDirectory value 55 */ 56 public void setFileDirectory(String fileDirectory) 57 { 58 this.fileDirectory = fileDirectory; 59 } 60 61 62 /*** 63 * Gets the textDirectory attribute of the FileBean object 64 * 65 * @return The textDirectory value 66 */ 67 public String getFileDirectory() 68 { 69 return fileDirectory; 70 } 71 72 73 /*** 74 * Gets the fileName attribute of the FileBean object 75 * 76 * @return The fileName value 77 */ 78 public String getFileName() 79 { 80 return fileName; 81 } 82 83 84 /*** 85 * Sets the fileName attribute of the FileBean object 86 * 87 * @param fileName The new fileName value 88 */ 89 public void setFileName(String fileName) 90 { 91 this.fileName = fileName; 92 } 93 94 95 /*** 96 * Sets the fileContent attribute of the FileBean object 97 * 98 * @param fileContent The new fileContent value 99 */ 100 public void setFileContent(String fileContent) 101 { 102 this.fileContent = fileContent; 103 } 104 105 106 /*** 107 * Gets the fileContent attribute of the FileBean object 108 * 109 * @return The fileContent value 110 */ 111 public String getFileContent() 112 { 113 return getFileContent(fileName); 114 } 115 116 117 /*** 118 * Gets the fileContent attribute of the FileBean object 119 * 120 * @param fileName the name of the file to read 121 * @return the fileContent value, or the exception message string 122 * if any error occurs 123 */ 124 public String getFileContent(String fileName) 125 { 126 StringBuffer sb = null; 127 String filePath = ""; 128 129 if (!Util.isNull(fileDirectory)) 130 filePath += (fileDirectory + "/"); 131 132 filePath += fileName; 133 134 try 135 { 136 fileContent = FileUtil.read(filePath).toString(); 137 } 138 catch(Exception e) 139 { 140 fileContent = e.getMessage(); 141 } 142 143 return fileContent; 144 } 145 }