Class FileArtifact
- java.lang.Object
-
- net.ssehub.easy.instantiation.core.model.artifactModel.CompositeArtifact
-
- net.ssehub.easy.instantiation.core.model.artifactModel.FileArtifact
-
- All Implemented Interfaces:
IArtifact,IArtifactChangedListener,IFileSystemArtifact,IActualValueProvider,IStringValueProvider,IVilType
- Direct Known Subclasses:
ClassFileArtifact,JavaFileArtifact,VtlFileArtifact,XmlFileArtifact
public class FileArtifact extends CompositeArtifact implements IFileSystemArtifact, IActualValueProvider
Implements a simple file artifact, i.e., an artifact which is represented as a file. Non-specialized file-based artifacts, e.g., composite artifacts shall be represented by this class or by specific subclasses which also shall act as default file artifact. In particular, the following methods shall be overridden by subclasses:#artifactChanged()selectAll()withoutInvisible annotation
- Author:
- Holger Eichelberger
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface net.ssehub.easy.instantiation.core.model.vilTypes.IStringValueProvider
IStringValueProvider.StringComparator
-
-
Field Summary
Fields Modifier and Type Field Description static FileArtifactDEFAULTprivate booleanisTemporaryprivate Pathpath
-
Constructor Summary
Constructors Modifier Constructor Description (package private)FileArtifact()Default constructor foractual value provider template.protectedFileArtifact(java.io.File file, ArtifactModel model)Creates a new file artifact.protectedFileArtifact(Path path, ArtifactModel model)Creates a new file artifact.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccept(IArtifactVisitor visitor)Visits this artifact (and dependent on the visitor also contained artifacts and fragments) using the given visitor.static FileArtifactconvert(java.lang.String val)Conversion operation.static Pathconvert(FileArtifact val)Conversion operation.static FileArtifactconvert(IFileSystemArtifact val)Conversion operation.static FileArtifactconvert(Path path)Conversion operation.Set<IFileSystemArtifact>copy(IFileSystemArtifact target)Copy this artifact.static FileArtifactcreate()Creates a temporary file artifact.protected BinarycreateBinary()Actually creates the binary representation.protected TextcreateText()Actually creates the text representation.voiddelete()Deletes this artifact.java.lang.ObjectdetermineActualValue(java.lang.Object object)Determines a more actual value forobjectin the context of using it for this type.booleanexists()Returns whether this artifact is exists.ArtifactModelgetArtifactModel()Returns the artifact model.java.lang.StringgetName()Returns the simple name of this artifact.PathgetPath()Returns the path artifact representing the path to this file system artifact.java.lang.StringgetPathSegments()Returns the path segments of this path (excluding the names).java.lang.StringgetPlainName()Returns the plain name without (possible) extension.java.lang.StringgetStringValue(IStringValueProvider.StringComparator comparator)Returns the string value of this object.booleanisTemporary()Returns whether this artifact is (considered to be) a temporary artifact.longlastModification()Returns the last modification timestamp of this artifact.Set<IFileSystemArtifact>move(IFileSystemArtifact target)Move this artifact.voidrename(java.lang.String name)Renames this artifact.Set<? extends FragmentArtifact>selectAll()Returns all artifacts this composite artifact is composed of.voidsetExecutable(boolean ownerOnly)Enables the (operation system specific) execution flag for this artifact.voidstore()Stores this artifact in case of changes.PathsubstituteExtension(java.lang.String extension)Substitutes the extension.-
Methods inherited from class net.ssehub.easy.instantiation.core.model.artifactModel.CompositeArtifact
artifactChanged, getBinary, getBinaryInstance, getRepresentationChanged, getText, getTextInstance, update
-
-
-
-
Field Detail
-
DEFAULT
public static final FileArtifact DEFAULT
-
path
private Path path
-
isTemporary
private boolean isTemporary
-
-
Constructor Detail
-
FileArtifact
FileArtifact()
Default constructor foractual value provider template.
-
FileArtifact
protected FileArtifact(java.io.File file, ArtifactModel model)Creates a new file artifact.- Parameters:
file- the physical file of this artifactmodel- the artifact model to create this folder artifact within
-
FileArtifact
protected FileArtifact(Path path, ArtifactModel model)
Creates a new file artifact.- Parameters:
path- the path representing this artifactmodel- the artifact model to create this folder artifact within
-
-
Method Detail
-
create
public static FileArtifact create() throws VilException
Creates a temporary file artifact.- Returns:
- the created file artifact
- Throws:
VilException- in case that the creation fails
-
isTemporary
public boolean isTemporary()
Returns whether this artifact is (considered to be) a temporary artifact.- Specified by:
isTemporaryin interfaceIFileSystemArtifact- Returns:
trueif it is temporary,falseelse
-
delete
public void delete() throws VilExceptionDescription copied from interface:IArtifactDeletes this artifact.- Specified by:
deletein interfaceIArtifact- Throws:
VilException- in case of serious problems so that this operation cannot continue
-
getArtifactModel
public ArtifactModel getArtifactModel()
Returns the artifact model.- Returns:
- the artifact model
-
getName
public java.lang.String getName() throws VilExceptionReturns the simple name of this artifact.- Specified by:
getNamein interfaceIArtifact- Returns:
- the simple name
- Throws:
VilException- in case that the operation cannot continue
-
getPlainName
public java.lang.String getPlainName() throws VilExceptionReturns the plain name without (possible) extension.- Returns:
- the plain name of the artifact
- Throws:
VilException- in case that errors occur
-
getPathSegments
public java.lang.String getPathSegments()
Returns the path segments of this path (excluding the names).- Returns:
- the path segments
-
getPath
public Path getPath()
Description copied from interface:IFileSystemArtifactReturns the path artifact representing the path to this file system artifact. The absolute and simple name can be obtained from the path. Note thatIArtifact.getName()will return the simple name of this artifact.- Specified by:
getPathin interfaceIFileSystemArtifact- Returns:
- the path
-
rename
public void rename(java.lang.String name) throws VilExceptionDescription copied from interface:IArtifactRenames this artifact.- Specified by:
renamein interfaceIArtifact- Parameters:
name- the new name of this artifact- Throws:
VilException- in case of serious problems so that this operation cannot continue
-
accept
public void accept(IArtifactVisitor visitor)
Description copied from interface:IArtifactVisits this artifact (and dependent on the visitor also contained artifacts and fragments) using the given visitor.
-
move
public Set<IFileSystemArtifact> move(IFileSystemArtifact target) throws VilException
Description copied from interface:IFileSystemArtifactMove this artifact.- Specified by:
movein interfaceIFileSystemArtifact- Parameters:
target- the target artifact. In case of a file, the target is supposed to be overridden. In case of a directory, this artifact shall after this operation be part of the directory.- Returns:
- this (for chained operations)
- Throws:
VilException- in case of serious problems
-
copy
public Set<IFileSystemArtifact> copy(IFileSystemArtifact target) throws VilException
Description copied from interface:IFileSystemArtifactCopy this artifact.- Specified by:
copyin interfaceIFileSystemArtifact- Parameters:
target- the target artifact. In case of a file, the target is supposed to be overridden by a copy of this artifact. In case of a directory, a copy of this artifact shall after this operation be part of the directory.- Returns:
- this (for chained operations)
- Throws:
VilException- in case of serious problems
-
selectAll
public Set<? extends FragmentArtifact> selectAll()
Description copied from class:CompositeArtifactReturns all artifacts this composite artifact is composed of.- Specified by:
selectAllin classCompositeArtifact- Returns:
- all fragments
-
createText
protected Text createText() throws VilException
Description copied from class:CompositeArtifactActually creates the text representation. Please note thatCompositeArtifact.getText()calls this method and registers the listeners appropriately.- Specified by:
createTextin classCompositeArtifact- Returns:
- the created text representation
- Throws:
VilException- in case of serious problems creating the representation
-
createBinary
protected Binary createBinary() throws VilException
Description copied from class:CompositeArtifactActually creates the binary representation. Please note thatCompositeArtifact.getBinary()calls this method and registers the listeners appropriately.- Specified by:
createBinaryin classCompositeArtifact- Returns:
- the created binary representation
- Throws:
VilException- in case of serious problems creating the representation
-
substituteExtension
public Path substituteExtension(java.lang.String extension) throws VilException
Substitutes the extension.- Parameters:
extension- the new extension- Returns:
- the path
- Throws:
VilException- in case of problems
-
convert
public static FileArtifact convert(java.lang.String val) throws VilException
Conversion operation.- Parameters:
val- the value to be converted- Returns:
- the converted value
- Throws:
VilException- in case that creating the artifact fails
-
convert
public static FileArtifact convert(IFileSystemArtifact val)
Conversion operation.- Parameters:
val- the value to be converted- Returns:
- the converted value
-
convert
public static Path convert(FileArtifact val) throws VilException
Conversion operation.- Parameters:
val- the value to be converted- Returns:
- the converted value
- Throws:
VilException- in case of problems
-
convert
public static FileArtifact convert(Path path) throws VilException
Conversion operation.- Parameters:
path- the path to be converted- Returns:
- the converted value
- Throws:
VilException- in case that creating the artifact fails
-
lastModification
public long lastModification()
Description copied from interface:IArtifactReturns the last modification timestamp of this artifact.- Specified by:
lastModificationin interfaceIArtifact- Returns:
- the last modification timestamp, 0 if unknown
-
exists
public boolean exists()
Description copied from interface:IArtifactReturns whether this artifact is exists.
-
getStringValue
public java.lang.String getStringValue(IStringValueProvider.StringComparator comparator)
Description copied from interface:IStringValueProviderReturns the string value of this object.- Specified by:
getStringValuein interfaceIStringValueProvider- Parameters:
comparator- if the sequence of elements, e.g., in case of collections, shall be ordered according to the comparator, null if the original sequence shall be returned- Returns:
- the string value
-
store
public void store() throws VilExceptionDescription copied from interface:IArtifactStores this artifact in case of changes.- Specified by:
storein interfaceIArtifact- Throws:
VilException- in case of problems storing this artifact
-
determineActualValue
public java.lang.Object determineActualValue(java.lang.Object object)
Description copied from interface:IActualValueProviderDetermines a more actual value forobjectin the context of using it for this type. Default types implementing this interface shall not use their attributes as this method will be called via a template object.- Specified by:
determineActualValuein interfaceIActualValueProvider- Parameters:
object- the initial object (may be null)- Returns:
- the actual object (may be
objectif no actual value is available, may be null ifobjectwas null)
-
setExecutable
public void setExecutable(boolean ownerOnly) throws VilExceptionDescription copied from interface:IFileSystemArtifactEnables the (operation system specific) execution flag for this artifact.- Specified by:
setExecutablein interfaceIFileSystemArtifact- Parameters:
ownerOnly- whether all users or just the owner shall be allowed to exectue this artifact- Throws:
VilException- if the executable flag cannot be set.
-
-