On this page

$file allows generating an output report file in a template file.

$file.silentCreate(templateFilename)

A shortcut to create a file, the output filename of which is the template name, not an import context object. For example:

$file.silentCreate('overview.html')
 Name Type Description 
Parameter(s) templateFilenamejava.lang.String 
  • The templateFilename parameter can be either an absolute or relative path to a file in the file system.
  • If the file is not found in the file system, the filename would be searched as an Attached File Element in a MagicDraw project in the File property.
 Return -void  

$file.silentCreate(attachedFile)

A shortcut to create a file, the output filename of which is the template name, not an import context object. For example:

$file.silentCreate($attachedFile)
 Name Type Description 
Parameter(s) attachedFilecom.nomagic.uml2.ext.magicdraw.classes.mdkernel.ElementAn Attached File Element.
 Return -void  

$file.silentCreate(templateFilename, importObject)

A shortcut to create a file, the output filename of which is the template name. For example:

$file.silentCreate('overview.html','')
 Name Type Description 
Parameter(s) templateFilename 

java.lang.String

 

  • The templateFilename parameter can be either an absolute or relative path to a file in the file system.
  • If the file is not found in the file system, the filename would be searched as an Attached File Element in a MagicDraw project in the File property.
importObject  java.lang.ObjectAn object reference, which will be $importer in the template file. You can use the $importer variable in the template file to get data.
 Return -void 

$file.silentCreate(attachedFile, importObject)

A shortcut to create a file, the output filename of which is the template name. For example:

$file.silentCreate($attachedFile,'')
 Name Type Description 
Parameter(s) 

attachedFile

com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element

An Attached File Element.
importObject  java.lang.ObjectAn object reference, which will be $importer in the template file. You can use the $importer variable in the template file to get data.
 Return -void -

$file.silentCreate(templateFilename, outputFileName, importObject)

Generate a report output from a given template name. For example:

$file.silentCreate('overview.html','overview.html','')
 Name Type Description 
Parameter(s) 

templateFilenamejava.lang.String 
  • The templateFilename parameter can be either an absolute or relative path to a file in the file system.
  • If the file is not found in the file system, the filename would be searched as an Attached File Element in a MagicDraw project in the File property.
outputFileNamejava.lang.StringThe output filename. 
importObjectjava.lang.ObjectAn object reference, which will be $importer in the template file. You can use the $importer variable in the template file to get data.
 Returnvoid 

$file.silentCreate(attachedFile, outputFileName, importObject)

Generate a report output from a given template name. For example:

$file.silentCreate($attachedFile,'overview.html','')
 Name Type Description 
Parameter(s) 

attachedFile

com.nomagic.uml2.ext.magicdraw.classes.mdkernel.ElementAn Attached File Element.
outputFileNamejava.lang.StringThe output filename. 
importObjectjava.lang.ObjectAn object reference, which will be $importer in the template file. You can use the $importer variable in the template file to get data.
 Returnvoid -

$file.silentCreate(templateType, templateFilename, outputname, importObject)

Generate a report output from a given template name. For example:

$file.silentCreate('html','overview','overview','')
 Name Type Description 
Parameter(s)


templateType java.lang.String A template type such as rtf, html, or htm.
templateFilename java.lang.String
  • The templateFilename parameter can be either an absolute or relative path to a file in the file system.
  • If the file is not found in the file system, the filename would be searched as an Attached File Element in a MagicDraw project in the File property.
 outputFileName java.lang.StringAn output filename without a filename extension.
 importObjectjava.lang.Object An object reference, which will be $importer in the template file. You can use the $importer variable in the template file to get data.
 Returnvoid 

$file.silentCreate(templateType, attachedFile, outputname, importObject)

Generate a report output from a given template name. For example:

$file.silentCreate('html',$attachedFile,'overview','')
 Name Type Description 
Parameter(s)


templateType java.lang.String A template type such as rtf, html, or htm.

attachedFile

com.nomagic.uml2.ext.magicdraw.classes.mdkernel.ElementAn Attached File Element.
outputFileNamejava.lang.StringAn output filename without a filename extension.
importObjectjava.lang.Object An object reference, which will be $importer in the template file. You can use the $importer variable in the template file to get data.
 Returnvoid 

$file.create(templateFilename)

A shortcut to create a file, the output filename of which is the template name, not an import context object. For example:

$file.create('overview.html')
 Name Type Description 
 Parameter(s)templateFilename java.lang.String 
  • The templateFilename parameter can be either an absolute or relative path to a file in the file system.
  • If the file is not found in the file system, the filename would be searched as an Attached File Element in a MagicDraw project in the File property.
 Return -java.lang.StringAn output pathname. It will return an empty string if there is an error. 

$file.create(attachedFile)

A shortcut to create a file, the output filename of which is the template name, not an import context object. For example:

$file.create($attachedFile)
 Name Type Description 
 Parameter(s)

attachedFile

com.nomagic.uml2.ext.magicdraw.classes.mdkernel.ElementAn Attached File Element.
 Return -java.lang.StringAn output pathname. It will return an empty string if there is an error.

$file.create(templateFilename, importObject)

A shortcut to create a file, the output filename of which is the template name. For example:

 $file.create('overview.html','')
 Name Type Description 
Parameter(s) templateFilename java.lang.String 
  • The templateFilename parameter can be either an absolute or relative path to a file in the file system.
  • If the file is not found in the file system, the filename would be searched as an Attached File Element in a MagicDraw project in the File property.
 importObject java.lang.ObjectAn object reference, which will be importer in the template file. You can use the $importer variable in the template file to get data.
 Return - java.lang.StringAn output pathname. It will return an empty string if there is an error.

$file.create(attachedFile, importObject)

A shortcut to create a file, the output filename of which is the template name. For example:

 $file.create($attachedFile,'')
 Name Type Description 
Parameter(s) 

attachedFile

com.nomagic.uml2.ext.magicdraw.classes.mdkernel.ElementAn Attached File Element.
importObjectjava.lang.ObjectAn object reference, which will be importer in the template file. You can use the $importer variable in the template file to get data.
 Return -java.lang.StringAn output pathname. It will return an empty string if there is an error.

$file.create(templateFilename, outputFileName, importObject)

Generate a report output from a given template name. For example:

$file.create('overview.html','overview.html','')
 Name Type Description 
Parameter(s) 

templateFilenamejava.lang.String 
  • The templateFilename parameter can be either an absolute or relative path to a file in the file system.
  • If the file is not found in the file system, the filename would be searched as an Attached File Element in a MagicDraw project in the File property.
outputFileName java.lang.StringAn output filename. 
 importObject java.lang.ObjectAn object reference, which will be $importer in the template file. You can use the $importer variable in the template file to get data.
 Return - java.lang.StringAn output pathname. It will return an empty string if there is an error.

$file.create(attachedFile, outputFileName, importObject)

Generate a report output from a given template name. For example:

$file.create($attachedFile,'overview.html','')
 Name Type Description 
Parameter(s) 

attachedFile

com.nomagic.uml2.ext.magicdraw.classes.mdkernel.ElementAn Attached File Element.
outputFileName java.lang.StringAn output filename. 
importObjectjava.lang.ObjectAn object reference, which will be $importer in the template file. You can use the $importer variable in the template file to get data.
 Return -java.lang.StringAn output pathname. It will return an empty string if there is an error.

$file.create(templateType, templateFilename, outputname, importObject)

Generate a report output from a given template name. For example:

$file.create('html','overview','overview','')
 Name Type Description 
Parameter(s) 


 templateTypejava.lang.String A template type such rtf, html, and htm. 
 templateFilenamejava.lang.String 
  • The templateFilename parameter can be either an absolute or relative path to a file in the file system.
  • If the file is not found in the file system, the filename would be searched as an Attached File Element in a MagicDraw project in the File property.
 outputnamejava.lang.String An output filename without a filename extension.
 importObject java.lang.ObjectAn object reference, which will be $importer in the template file. You can use the $importer variable in the template file to get data.
 Return -java.lang.String An output pathname. It will return an empty string if there is an error.

$file.create(templateType, attachedFile, outputname, importObject)

Generate a report output from a given template name. For example:

$file.create('html',$attachedFile,'overview','')
 Name Type Description 
Parameter(s) 


templateTypejava.lang.String A template type such rtf, html, and htm. 

attachedFile

com.nomagic.uml2.ext.magicdraw.classes.mdkernel.ElementAn Attached File Element.
outputnamejava.lang.String An output filename without a filename extension.
importObjectjava.lang.ObjectAn object reference, which will be $importer in the template file. You can use the $importer variable in the template file to get data.
 Return -java.lang.String An output pathname. It will return an empty string if there is an error.

$file.createAndWait(templateFilename)

Open a new template engine to generate a report and return a path to generate the file. The generated report will be given the template filename. For example:

$file.createAndWait('overview.html')
 Name Type Description 
Parameter(s)  templateFilenamejava.lang.String 
  • The templateFilename parameter can be either an absolute or relative path to a file in the file system.
  • If the file is not found in the file system, the filename would be searched as an Attached File Element in a MagicDraw project in the File property.
 Return -java.lang.StringAn absolute path
to generate a file.

$file.createAndWait(attachedFile)

Open a new template engine to generate a report and return a path to generate the file. The generated report will be given the template filename. For example:

$file.createAndWait($attachedFile)
 Name Type Description 
Parameter(s) 

attachedFile

com.nomagic.uml2.ext.magicdraw.classes.mdkernel.ElementAn Attached File Element.
 Return -java.lang.StringAn absolute path to generate a file.

$file.createAndWait(templateFilename, contextValue)

Open a new template engine to generate a report and return a path to generate the file. The generated report will be named after the template filename. For example:

$file.createAndWait('overview.html',$var)
 Name Type Description 
Parameter(s)  templateFilenamejava.lang.String 
  • The templateFilename parameter can be either an absolute or relative path to a file in the file system.
  • If the file is not found in the file system, the filename would be searched as an Attached File Element in a MagicDraw project in the File property.
 contextValuejava.lang.Object An additional object added to a new template context with a default $importer name.
 Return java.lang.String 

$file.createAndWait(attachedFile, contextValue)

Open a new template engine to generate a report and return a path to generate the file. The generated report will be named after the template filename. For example:

$file.createAndWait($attachedFile,$var)
 Name Type Description 
Parameter(s) attachedFilecom.nomagic.uml2.ext.magicdraw.classes.mdkernel.ElementAn Attached File Element.
contextValuejava.lang.Object An additional object added to a new template context with a default $importer name.
 Return java.lang.String 

$file.createAndWait(templateFileName, outputFileName, contextValue)

Open a new template engine to generate a report and return a path to generate the file. "importer" will be used as the name of a context value. For example:

$file.createAndWait('overview.html','overview.html',$var)
 NameType Description 
Parameter(s)   templateFilenamejava.lang.String 
  • The templateFilename parameter can be either an absolute or relative path to a file in the file system.
  • If the file is not found in the file system, the filename would be searched as an Attached File Element in a MagicDraw project in the File property.
outputFilename java.lang.String An output report filename.
contextValuejava.lang.Object An additional object added to a new template context with a default $importer name.
Return  java.lang.String An absolute path to generate a file.

$file.createAndWait(attachedFile, outputFileName, contextValue)

Open a new template engine to generate a report and return a path to generate the file. "importer" will be used as the name of a context value. For example:

$file.createAndWait($attachedFile,'overview.html',$var)
 NameType Description 
Parameter(s)   

attachedFile

com.nomagic.uml2.ext.magicdraw.classes.mdkernel.ElementAn Attached File Element.
outputFilename java.lang.String An output report filename.
contextValuejava.lang.Object An additional object added to a new template context with a default $importer name.
Return  java.lang.String  An absolute path to generate a file.

$file.createAndWait(templateFileName, outputFileName, ContextName, contextValue)

Open a new template engine to generate a report and return a path to generate the file. For example:

$file.createAndWait('overview.html','overview.html','var',$var)
 Name Type Description 
Parameter(s)     templateFilenamejava.lang.String 
  • The templateFilename parameter can be either an absolute or relative path to a file in the file system.
  • If the file is not found in the file system, the filename would be searched as an Attached File Element in a MagicDraw project in the File property.
 outputFilenamejava.lang.StringAn output report filename.
 contextNamejava.lang.String Add an object context's name.
 contextValuejava.lang.Object An additional object added to a new template context with a default $importer name.
 Return -java.lang.StringAn absolute path to generate a file. 

$file.createAndWait(attachedFile, outputFileName, ContextName, contextValue)

Open a new template engine to generate a report and return a path to generate the file. For example:

$file.createAndWait($attachedFile,'overview.html','var',$var)
 Name Type Description 
Parameter(s)    attachedFilecom.nomagic.uml2.ext.magicdraw.classes.mdkernel.ElementAn Attached File Element.
outputFilenamejava.lang.StringAn output report filename.
contextNamejava.lang.String Add an object context's name.
contextValuejava.lang.Object An additional object added to a new template context with a default $importer name.
 Return -java.lang.StringAn absolute path to generate a file. 

$file.createAndWait(templateFileName, outputFileName, context)

Open a new template engine to generate a report and return a path to generate the file. For example:

$file.createAndWait('overview.html','overview.html',$map)
 Name Type Description 
 Parameter(s)  templateFilenamejava.lang.String 
  • The templateFilename parameter can be either an absolute or relative path to a file in the file system.
  • If the file is not found in the file system, the filename would be searched as an Attached File Element in a MagicDraw project in the File property.
 outputFilenamejava.lang.StringAn output report
filename.
 contextjava.util.Map<String, Object> An additional context
added to a new template. 
 Return -java.lang.StringAn absolute path to
generate a file. 

$file.createAndWait(attachedFile, outputFileName, context)

Open a new template engine to generate a report and return a path to generate the file. For example:

$file.createAndWait($attachedFile,'overview.html',$map)
 Name Type Description 
 Parameter(s)  attachedFilecom.nomagic.uml2.ext.magicdraw.classes.mdkernel.ElementAn Attached File Element.
outputFilenamejava.lang.StringAn output report filename.
contextjava.util.Map<String, Object> An additional context added to a new template. 
 Return-java.lang.StringAn absolute path to generate a file. 

$file.copy(inputFilename)

Copy an input file to an output file using the same name in the binary format. For example:

$file.copy('icon.gif')
 Name Type Description 
Parameter(s)  inputFilenamejava.lang.String An input filename 
 Return -java.lang.String An output pathname.
It will return an empty
string if there is an error. 


$file.copy(inputFilename, outputFilename)

Copy an input file to an output file in the binary format. For example:

 $file.copy('icon.gif','icon.gif')
 Name Type Description 
Parameter(s)   inputFilename java.lang.String An input
filename. 
 outputFilenamejava.lang.StringAn output
filename. 
 Return -java.lang.String An output pathname.
It will return an empty
string if there is an error.


$file.exists(pathname)

Test if a file denoted by a specific pathname exists. By default, the current directory refers to a template location. For example:

$file.exists("$template.resourcesLocation/myimage.png")
$file.exists("C:/myfolder/myimage.png")
$file.exists("mytemplate.txt")
 Name Type Description 
Parameter(s) pathname java.lang.String A pathname string. 
 Return -java.lang.String True if and only if a file
or directory denoted by
a specific pathname exists;
otherwise, false. 


$file.computeName(directory, name)

Create a pathname string from a given directory and name.

 Name Type Description 
 Parameter(s) directory java.lang.String A parent directory
of a file. 
 namejava.lang.String A filename (excludes
the filename extension).
 Return -java.lang.String A pathname from the
given directory and name.

For example:

$file.computeName('actors', $ac.ID, 'html')
output: 'actor/_123456789.html'


$file.computeName(directory, name, fileType)

Create a pathname string from a given directory, name, and file type.

 Name Type Description 
Parameter(s) directory java.lang.String A parent directory
of a file. 
 namejava.lang.String A filename (excluding
the extension).
 fileType  java.lang.StringA file type, such as rtf,
txt, and html. 
 Return -java.lang.StringA pathname from the
given directory, name,
and file type.