本文整理汇总了Java中gov.nih.nci.cagrid.common.Utils.fileToStringBuffer方法的典型用法代码示例。如果您正苦于以下问题:Java Utils.fileToStringBuffer方法的具体用法?Java Utils.fileToStringBuffer怎么用?Java Utils.fileToStringBuffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gov.nih.nci.cagrid.common.Utils
的用法示例。
在下文中一共展示了Utils.fileToStringBuffer方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getStyleCopyLibs
import gov.nih.nci.cagrid.common.Utils; //导入方法依赖的package包/类
public File[] getStyleCopyLibs() throws IOException {
File styleLib = new File(styleDir, "lib");
if (styleLib.exists() && styleLib.isDirectory()) {
final Set<String> nocopy = new HashSet<String>();
File nocopyFile = new File(styleDir, NOCOPY_LIBS_FILE);
if (nocopyFile.exists()) {
StringBuffer nocopyContents = Utils.fileToStringBuffer(nocopyFile);
StringTokenizer nocopyTok = new StringTokenizer(nocopyContents.toString(), ",");
while (nocopyTok.hasMoreTokens()) {
nocopy.add(nocopyTok.nextToken());
}
}
File[] jars = styleLib.listFiles(new FileFilters.JarFileFilter() {
public boolean accept(File path) {
boolean ok = super.accept(path);
return !nocopy.contains(path.getName()) && ok;
}
});
return jars;
}
return null;
}
示例2: fixDevBuildDeploy
import gov.nih.nci.cagrid.common.Utils; //导入方法依赖的package包/类
protected void fixDevBuildDeploy() throws Exception {
// if this service was upgraded from 1.1 to 1.2 the dev build deploy
// will have a bug
// preventing the undeployTomcat target to work
StringBuffer devsb = Utils.fileToStringBuffer(new File(getServicePath() + File.separator
+ "dev-build-deploy.xml"));
String newFileString = devsb.toString();
newFileString = newFileString.replace("postUndeployyTomcat", "postUndeployTomcat");
FileWriter fw = new FileWriter(new File(getServicePath() + File.separator + "dev-build-deploy.xml"));
fw.write(newFileString);
fw.close();
getStatus().addDescriptionLine(
"fixed typo error created during upgrade from 1.1 to 1.2 with target undeployTomcat");
}
示例3: cleanXmi
import gov.nih.nci.cagrid.common.Utils; //导入方法依赖的package包/类
private static File cleanXmi(File originalXmi) throws IOException {
LOG.debug("Clean XMI");
File cleanedFile = new File(originalXmi.getParentFile(), "cleaned_" + originalXmi.getName());
StringBuffer xmiContents = Utils.fileToStringBuffer(originalXmi);
XmiCleaner.cleanXmi(xmiContents);
Utils.stringBufferToFile(xmiContents, cleanedFile.getAbsolutePath());
return cleanedFile;
}
示例4: addClientImpl
import gov.nih.nci.cagrid.common.Utils; //导入方法依赖的package包/类
public void addClientImpl(MethodType method) throws SynchronizationException {
StringBuffer fileContent = null;
try {
fileContent = Utils.fileToStringBuffer(new File(serviceClient));
} catch (IOException e) {
throw new SynchronizationException("Error loading service client: " + e.getMessage(), e);
}
// insert the new client method
int endOfClass = fileContent.lastIndexOf("}");
addClientImpl(method, endOfClass);
}
示例5: removeClientImpl
import gov.nih.nci.cagrid.common.Utils; //导入方法依赖的package包/类
public void removeClientImpl(JavaMethod method) throws SynchronizationException {
StringBuffer fileContent = null;
try {
fileContent = Utils.fileToStringBuffer(new File(serviceClient));
} catch (IOException e) {
throw new SynchronizationException("Error loading service client: " + e.getMessage(), e);
}
// remove the method
String clientMethod = SyncHelper.createClientUnBoxedSignatureStringFromMethod(method);
int startOfMethod = SyncHelper.startOfSignature(fileContent, clientMethod);
int endOfMethod = SyncHelper.bracketMatch(fileContent, startOfMethod);
if ((startOfMethod == -1) || (endOfMethod == -1)) {
System.err.println("WARNING: Unable to locate method in clientImpl : " + method.getName());
return;
}
fileContent.delete(startOfMethod, endOfMethod);
try {
FileWriter fw = new FileWriter(new File(serviceClient));
fw.write(SyncHelper.removeMultiNewLines(fileContent.toString()));
fw.close();
} catch (IOException e1) {
throw new SynchronizationException("Error writing service client: " + e1.getMessage(), e1);
}
}
示例6: removeImpl
import gov.nih.nci.cagrid.common.Utils; //导入方法依赖的package包/类
public void removeImpl(JavaMethod method) throws SynchronizationException {
StringBuffer fileContent = null;
try {
fileContent = Utils.fileToStringBuffer(new File(serviceImpl));
} catch (IOException e) {
throw new SynchronizationException("Error loading service impl: " + e.getMessage(), e);
}
// remove the method
String clientMethod = SyncHelper.createUnBoxedSignatureStringFromMethod(method, serviceInfo);
int startOfMethod = SyncHelper.startOfSignature(fileContent, clientMethod);
int endOfMethod = SyncHelper.bracketMatch(fileContent, startOfMethod);
if ((startOfMethod == -1) || (endOfMethod == -1)) {
System.err.println("WARNING: Unable to locate method in Impl : " + method.getName());
return;
}
fileContent.delete(startOfMethod, endOfMethod);
try {
FileWriter fw = new FileWriter(new File(serviceImpl));
fw.write(SyncHelper.removeMultiNewLines(fileContent.toString()));
fw.close();
} catch (IOException e1) {
throw new SynchronizationException("Error saving service impl: " + e1.getMessage(), e1);
}
}
示例7: getConfiguration
import gov.nih.nci.cagrid.common.Utils; //导入方法依赖的package包/类
private StringBuffer getConfiguration() throws IOException {
return Utils.fileToStringBuffer(getLogConfigFile());
}
示例8: main
import gov.nih.nci.cagrid.common.Utils; //导入方法依赖的package包/类
public static void main(String[] args) {
Options options = getCommandOptions();
// parse the command line
CommandLine cmd = null;
try {
cmd = new BasicParser().parse(options, args);
} catch (ParseException e) {
log.debug("Error parsing arguments: " + e.getMessage());
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp(XmiCleaner.class.getSimpleName(), options);
System.exit(-1);
return;
}
String inputFilename = cmd.getOptionValue("inputXmi");
File inputXmiFile = new File(inputFilename);
if (!inputXmiFile.isFile()) {
String message = inputFilename + " does not appear to be a file";
log.error(message);
System.err.println(message);
System.exit(1);
}
String outputFilename = cmd.getOptionValue("outputXmi");
File outputXmiFile = null;
if (outputFilename == null || outputFilename.length() == 0) {
File xmiDir = inputXmiFile.getParentFile();
outputXmiFile = new File(xmiDir, "cleaned_" + inputXmiFile.getName());
} else {
outputXmiFile = new File(outputFilename);
}
StringBuffer xmiContents = null;
try {
log.debug("Loading xmi from " + inputXmiFile.getAbsolutePath());
xmiContents = Utils.fileToStringBuffer(inputXmiFile);
log.debug("Cleaning xmi");
cleanXmi(xmiContents);
log.debug("Writing xmi to " + outputXmiFile.getAbsolutePath());
Utils.stringBufferToFile(xmiContents, outputXmiFile.getAbsolutePath());
} catch (Exception ex) {
ex.printStackTrace();
System.exit(1);
}
}
示例9: addMethods
import gov.nih.nci.cagrid.common.Utils; //导入方法依赖的package包/类
public void addMethods(List additions) throws SynchronizationException {
for (int i = 0; i < additions.size(); i++) {
// add it to the interface
MethodType method = (MethodType) additions.get(i);
if (!method.getName().equals(IntroduceConstants.SERVICE_SECURITY_METADATA_METHOD)) {
StringBuffer fileContent = null;
try {
fileContent = Utils.fileToStringBuffer(new File(serviceInterface));
} catch (IOException e) {
throw new SynchronizationException("Error loading service interface file: " + e.getMessage(), e);
}
// insert the new client method
int endOfClass = fileContent.lastIndexOf("}");
StringBuffer clientMethod = new StringBuffer();
if (method.isIsImported() && (method.getImportInformation().getFromIntroduce() != null)
&& !method.getImportInformation().getFromIntroduce().booleanValue()) {
clientMethod.append(SyncHelper.createJavaDoc(method)).append("\n").append(TAB).append(
SyncHelper.createBoxedSignatureStringFromMethod(method)).append(" ").append(
SyncHelper.createClientExceptions(method, serviceInfo));
} else {
clientMethod.append(SyncHelper.createJavaDoc(method)).append("\n").append(TAB).append(
SyncHelper.createClientUnBoxedSignatureStringFromMethod(method, serviceInfo)).append(" ")
.append(SyncHelper.createClientExceptions(method, serviceInfo));
}
clientMethod.append(";\n\n");
fileContent.insert(endOfClass, clientMethod);
try {
FileWriter fw = new FileWriter(new File(serviceInterface));
fw.write(SyncHelper.removeMultiNewLines(fileContent.toString()));
fw.close();
} catch (IOException e1) {
throw new SynchronizationException("Error writing service interface: " + e1.getMessage(), e1);
}
if (!method.isIsProvided()) {
// populate the impl method
addImpl(method);
// populate the provider impl method
addProviderImpl(method);
// populate the client method
}
addClientImpl(method);
}
}
}
示例10: modifyMethods
import gov.nih.nci.cagrid.common.Utils; //导入方法依赖的package包/类
public void modifyMethods(List modifiedMethods) throws SynchronizationException {
for (int i = 0; i < modifiedMethods.size(); i++) {
// add it to the interface
Modification mod = (Modification) modifiedMethods.get(i);
MethodType method = mod.getMethodType();
if (!method.getName().equals(IntroduceConstants.SERVICE_SECURITY_METADATA_METHOD)) {
StringBuffer fileContent = null;
try {
fileContent = Utils.fileToStringBuffer(new File(serviceInterface));
} catch (IOException e) {
throw new SynchronizationException("Error loading service interface file: " + e.getMessage(), e);
}
// remove the old interface method
String clientMethod = null;
if (method.isIsImported() && (method.getImportInformation().getFromIntroduce() != null)
&& !method.getImportInformation().getFromIntroduce().booleanValue()) {
clientMethod = SyncHelper.createBoxedSignatureStringFromMethod(mod.getIMethod());
} else {
clientMethod = SyncHelper.createClientUnBoxedSignatureStringFromMethod(mod.getIMethod());
}
int startOfMethod = SyncHelper.startOfSignature(fileContent, clientMethod);
String restOfFile = fileContent.substring(startOfMethod);
int endOfMethod = startOfMethod + restOfFile.indexOf(";") + 1;
startOfMethod = SyncHelper.startOfJavaDoc(fileContent, startOfMethod);
if ((startOfMethod == -1) || (endOfMethod == -1)) {
System.err.println("WARNING: Unable to locate method in I : "
+ CommonTools.lowerCaseFirstCharacter(method.getName()));
return;
}
fileContent.delete(startOfMethod, endOfMethod);
// insert the new interface method
int endOfClass = fileContent.lastIndexOf("}");
if (method.isIsImported() && (method.getImportInformation().getFromIntroduce() != null)
&& !method.getImportInformation().getFromIntroduce().booleanValue()) {
clientMethod = SyncHelper.createJavaDoc(method) + "\n" + TAB
+ SyncHelper.createBoxedSignatureStringFromMethod(method) + " "
+ SyncHelper.createClientExceptions(method, serviceInfo);
} else {
clientMethod = SyncHelper.createJavaDoc(method) + "\n" + TAB
+ SyncHelper.createClientUnBoxedSignatureStringFromMethod(method, serviceInfo) + " "
+ SyncHelper.createClientExceptions(method, serviceInfo);
}
clientMethod += ";\n\n";
fileContent.insert(endOfClass, clientMethod);
try {
FileWriter fw = new FileWriter(new File(serviceInterface));
fw.write(SyncHelper.removeMultiNewLines(fileContent.toString()));
fw.close();
} catch (IOException e1) {
throw new SynchronizationException("Error saving service interface: " + e1.getMessage(), e1);
}
}
// if the method was not provided
if (!method.isIsProvided()) {
// just clean up the modified impl
modifyImpl(mod);
// redo the provider impl method
removeProviderImpl(mod.getIMethod());
addProviderImpl(method);
}
// redo the client method
removeClientImpl(mod.getIMethod());
addClientImpl(method);
}
}
示例11: addImpl
import gov.nih.nci.cagrid.common.Utils; //导入方法依赖的package包/类
public void addImpl(MethodType method) throws SynchronizationException {
StringBuffer fileContent = null;
try {
fileContent = Utils.fileToStringBuffer(new File(serviceImpl));
} catch (IOException e) {
throw new SynchronizationException("Error loading service impl: " + e.getMessage(), e);
}
String clientMethod = null;
// insert the new client method
int endOfClass = fileContent.lastIndexOf("}");
if (method.isIsImported() && (method.getImportInformation().getFromIntroduce() != null)
&& !method.getImportInformation().getFromIntroduce().booleanValue()) {
clientMethod = TAB + SyncHelper.createBoxedSignatureStringFromMethod(method) + " "
+ SyncHelper.createClientExceptions(method, serviceInfo);
} else {
clientMethod = TAB + SyncHelper.createUnBoxedSignatureStringFromMethod(method, serviceInfo) + " "
+ SyncHelper.createExceptions(method, serviceInfo);
}
clientMethod += "{\n";
// if this method is returning a new client handle and is creating a
// resource to do so
if (method.getOutput() != null
&& method.getOutput().getIsClientHandle() != null
&& method.getOutput().getIsClientHandle().booleanValue()
&& method.getOutput().getIsCreatingResourceForClientHandle() != null
&& method.getOutput().getIsCreatingResourceForClientHandle().booleanValue()
&& !(method.getOutput().isIsArray())
&& !(CommonTools.getService(serviceInfo.getServices(),
method.getOutput().getResourceClientIntroduceServiceName()).getResourceFrameworkOptions().getSingleton()!=null || CommonTools.getService(serviceInfo.getServices(),
method.getOutput().getResourceClientIntroduceServiceName()).getResourceFrameworkOptions().getCustom()!=null)) {
SpecificMethodInformation smi = new SpecificMethodInformation(serviceInfo, service, method);
ResourceCreatorTemplate resourceCreatorTemplate = new ResourceCreatorTemplate();
String createResourceCode = resourceCreatorTemplate.generate(smi);
clientMethod += createResourceCode;
} else {
clientMethod += DOUBLE_TAB + "//TODO: Implement this autogenerated method\n";
clientMethod += DOUBLE_TAB + "throw new RemoteException(\"Not yet implemented\");\n";
}
clientMethod += TAB + "}\n\n";
fileContent.insert(endOfClass, clientMethod);
try {
String fileContentString = fileContent.toString();
FileWriter fw = new FileWriter(new File(serviceImpl));
fw.write(SyncHelper.removeMultiNewLines(fileContentString));
fw.close();
} catch (IOException e1) {
throw new SynchronizationException("Error saving service impl: " + e1.getMessage(), e1);
}
}
示例12: modifyImpl
import gov.nih.nci.cagrid.common.Utils; //导入方法依赖的package包/类
public void modifyImpl(Modification mod) throws SynchronizationException {
MethodType method = mod.getMethodType();
JavaMethod oldMethod = mod.getImplMethod();
StringBuffer fileContent = null;
try {
fileContent = Utils.fileToStringBuffer(new File(serviceImpl));
} catch (IOException e) {
throw new SynchronizationException("Error loading service impl: " + e.getMessage(), e);
}
// remove the old method signature
String clientMethod = "";
if (method.isIsImported() && (method.getImportInformation().getFromIntroduce() != null)
&& !method.getImportInformation().getFromIntroduce().booleanValue()) {
clientMethod = SyncHelper.createBoxedSignatureStringFromMethod(oldMethod);
} else {
clientMethod = SyncHelper.createClientUnBoxedSignatureStringFromMethod(oldMethod);
}
int startOfMethod = SyncHelper.startOfSignature(fileContent, clientMethod);
int endOfSignature = SyncHelper.endOfSignature(fileContent, startOfMethod);
if ((startOfMethod == -1) || (endOfSignature == -1)) {
System.err.println("WARNING: Unable to locate method in Impl : " + oldMethod.getName());
return;
}
fileContent.delete(startOfMethod, endOfSignature);
// add in the new modified signature
if (method.isIsImported() && (method.getImportInformation().getFromIntroduce() != null)
&& !method.getImportInformation().getFromIntroduce().booleanValue()) {
clientMethod = TAB + SyncHelper.createBoxedSignatureStringFromMethod(method) + " "
+ SyncHelper.createClientExceptions(method, serviceInfo);
} else {
clientMethod = TAB + SyncHelper.createUnBoxedSignatureStringFromMethod(method, serviceInfo) + " "
+ SyncHelper.createExceptions(method, serviceInfo);
}
clientMethod += "{";
fileContent.insert(startOfMethod, clientMethod);
try {
FileWriter fw = new FileWriter(new File(serviceImpl));
fw.write(SyncHelper.removeMultiNewLines(fileContent.toString()));
fw.close();
} catch (IOException e1) {
throw new SynchronizationException("Error saving service impl: " + e1.getMessage(), e1);
}
}
示例13: sync
import gov.nih.nci.cagrid.common.Utils; //导入方法依赖的package包/类
public void sync() throws SynchronizationException {
// sync each sub service
if ((getServiceInformation().getServices() != null)
&& (getServiceInformation().getServices().getService() != null)) {
for (ServiceType service : getServiceInformation().getServices().getService()) {
try {
SpecificServiceInformation ssi = new SpecificServiceInformation(getServiceInformation(), service);
// regenerate the services client layer "ClientBase"
ServiceClientBaseTemplate clientBaseT = new ServiceClientBaseTemplate();
String clientBaseS = clientBaseT.generate(new SpecificServiceInformation(getServiceInformation(), service));
File clientBaseF = new File(getBaseDirectory() + File.separator + "src" + File.separator + CommonTools.getPackageDir(service)
+ File.separator + "client" + File.separator + service.getName() + "ClientBase.java");
FileWriter clientBaseFW = new FileWriter(clientBaseF);
clientBaseFW.write(clientBaseS);
clientBaseFW.close();
// regenerate the services globus layer "ImplBase"
ServiceImplBaseTemplate implBaseT = new ServiceImplBaseTemplate();
String implBaseS = implBaseT.generate(new SpecificServiceInformation(getServiceInformation(), ssi
.getService()));
File implBaseF = new File(getBaseDirectory() + File.separator + "src" + File.separator
+ CommonTools.getPackageDir(ssi.getService()) + File.separator + "service" + File.separator
+ ssi.getService().getName() + "ImplBase.java");
FileWriter implBaseFW = new FileWriter(implBaseF);
implBaseFW.write(implBaseS);
implBaseFW.close();
// execute the source synchronization to make any necessary
// changes to source
// code for new/modified/removed methods
SyncMethods methodSync = new SyncMethods(getBaseDirectory(), getServiceInformation(), service);
methodSync.sync();
SyncResource resourceSync = new SyncResource(getBaseDirectory(), getServiceInformation(), service);
resourceSync.sync();
// resync the security configuration files and authorization
// callbacks
SyncSecurity securitySync = new SyncSecurity(getBaseDirectory(), getServiceInformation(), service);
securitySync.sync();
// if there is a description on the service then add it to
// the interfaces javadoc
if ((ssi.getService().getDescription() != null) && (ssi.getService().getDescription().length() > 0)) {
StringBuffer fileContent = null;
String serviceInf = null;
serviceInf = getBaseDirectory().getAbsolutePath() + File.separator + "src" + File.separator
+ CommonTools.getPackageDir(ssi.getService()) + File.separator + "common" + File.separator
+ ssi.getService().getName() + "I.java";
fileContent = Utils.fileToStringBuffer(new File(serviceInf));
BufferedReader reader = new BufferedReader(new StringReader(ssi.getService().getDescription()));
String line = reader.readLine();
String descriptionString = "\n";
while (line != null) {
descriptionString += " * " + line + "\n";
line = reader.readLine();
}
descriptionString += " *\n * ";
int startofjavadoc = fileContent.indexOf("/**");
int startofoldfirstline = fileContent.indexOf("This class is autogenerated, DO NOT EDIT.");
if (startofoldfirstline >= 0) {
fileContent.replace(startofjavadoc + 3, startofoldfirstline, descriptionString);
String fileContentString = fileContent.toString();
FileWriter fw = new FileWriter(new File(serviceInf));
fw.write(fileContentString);
fw.close();
}
}
} catch (Exception e) {
logger.error(e.getMessage(),e);
throw new SynchronizationException(e.getMessage(), e);
}
}
}
}