org.andromda.core.common
Class ResourceWriter

java.lang.Object
  extended by org.andromda.core.common.ResourceWriter

public class ResourceWriter
extends java.lang.Object

Used for writing resources for the framework. Also keeps histories of previous resources generated so that we can avoid regenerating if the generated resources are current.

Author:
Chad Brandon

Constructor Summary
ResourceWriter()
           
 
Method Summary
 long getWrittenCount()
          Gets the number of currently written resources over the course of this instance's history.
static ResourceWriter instance()
          Gets the shared ResourceWriter instance.
 boolean isHistoryBefore(long time)
          Checks to see if the history is before the given time.
 void resetHistory(java.lang.String modelUri)
          Resets the a history file, to write the history writeHistory() must be called.
 void setEncoding(java.lang.String encoding)
          Sets the encoding to which all output written from this class will be written.
 void writeHistory()
          Writes the output history to disk.
 void writeStringToFile(java.lang.String string, java.io.File file)
          Writes the string to the file specified by the fileLocation argument.
 void writeStringToFile(java.lang.String string, java.io.File file, java.lang.String namespace)
          Writes the string to the file specified by the fileLocation argument.
 void writeStringToFile(java.lang.String string, java.lang.String fileLocation)
          Writes the string to the file specified by the fileLocation argument.
 void writeStringToFile(java.lang.String string, java.lang.String fileLocation, java.lang.String namespace)
          Writes the string to the file specified by the fileLocation argument.
 void writeUrlToFile(java.net.URL url, java.lang.String fileLocation)
          Writes the URL contents to a file specified by the fileLocation argument.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourceWriter

public ResourceWriter()
Method Detail

instance

public static ResourceWriter instance()
Gets the shared ResourceWriter instance. Normally you'll want to retrieve the instance through this method.

Returns:
the shared instance.

writeStringToFile

public void writeStringToFile(java.lang.String string,
                              java.io.File file,
                              java.lang.String namespace)
                       throws java.io.IOException
Writes the string to the file specified by the fileLocation argument.

Parameters:
string - the string to write to the file
file - the file to which to write.
namespace - the current namespace for which this resource is being written.
Throws:
java.io.IOException

writeStringToFile

public void writeStringToFile(java.lang.String string,
                              java.lang.String fileLocation)
                       throws java.io.IOException
Writes the string to the file specified by the fileLocation argument.

Parameters:
string - the string to write to the file
fileLocation - the location of the file which to write.
Throws:
java.io.IOException

writeStringToFile

public void writeStringToFile(java.lang.String string,
                              java.io.File file)
                       throws java.io.IOException
Writes the string to the file specified by the fileLocation argument.

Parameters:
string - the string to write to the file
file - the file which to write.
Throws:
java.io.IOException

writeStringToFile

public void writeStringToFile(java.lang.String string,
                              java.lang.String fileLocation,
                              java.lang.String namespace)
                       throws java.io.IOException
Writes the string to the file specified by the fileLocation argument.

Parameters:
string - the string to write to the file
fileLocation - the location of the file which to write.
namespace - the current namespace for which this resource is being written.
Throws:
java.io.IOException

writeUrlToFile

public void writeUrlToFile(java.net.URL url,
                           java.lang.String fileLocation)
                    throws java.io.IOException
Writes the URL contents to a file specified by the fileLocation argument.

Parameters:
url - the URL to read
fileLocation - the location which to write.
Throws:
java.io.IOException

setEncoding

public void setEncoding(java.lang.String encoding)
Sets the encoding to which all output written from this class will be written.

Parameters:
encoding - the encoding type (UTF-8, ISO-8859-1, etc).

resetHistory

public void resetHistory(java.lang.String modelUri)
Resets the a history file, to write the history writeHistory() must be called.

Parameters:
modelUri - used to construct the file name from the modelUri where the history is stored

getWrittenCount

public long getWrittenCount()
Gets the number of currently written resources over the course of this instance's history.

Returns:
the number of written resources.

writeHistory

public void writeHistory()
                  throws java.io.IOException
Writes the output history to disk.

Throws:
java.io.IOException

isHistoryBefore

public boolean isHistoryBefore(long time)
Checks to see if the history is before the given time.

Parameters:
time - the time in milliseconds to check against.
Returns:
true/false


Copyright © 2003-2008 AndroMDA.org. All Rights Reserved.