Class FieldsMetadata

java.lang.Object
fr.opensagres.xdocreport.template.formatter.FieldsMetadata

public class FieldsMetadata extends Object
Fields Metadata is used in the preprocessing step to modify some XML entries like generate script (Freemarker, Velocity...) for loop for Table row, generate script for Image...
  • Field Details

  • Constructor Details

    • FieldsMetadata

      public FieldsMetadata()
    • FieldsMetadata

      public FieldsMetadata(TemplateEngineKind templateEngineKind)
    • FieldsMetadata

      public FieldsMetadata(String templateEngineKind)
  • Method Details

    • addFieldAsImage

      public FieldMetadata addFieldAsImage(String fieldName)
      Add a field name which is considered as an image.
      Parameters:
      fieldName -
    • addFieldAsImage

      public FieldMetadata addFieldAsImage(String fieldName, boolean useImageSize)
      Add a field name which is considered as an image.
      Parameters:
      fieldName -
    • addFieldAsImage

      public FieldMetadata addFieldAsImage(String fieldName, NullImageBehaviour behaviour)
      Add a field name which is considered as an image.
      Parameters:
      fieldName -
    • addFieldAsImage

      public FieldMetadata addFieldAsImage(String fieldName, NullImageBehaviour behaviour, boolean useImageSize)
      Add a field name which is considered as an image.
      Parameters:
      fieldName -
    • addFieldAsImage

      public FieldMetadata addFieldAsImage(String imageName, String fieldName)
      Add a field name which is considered as an image.
      Parameters:
      imageName -
      fieldName -
    • addFieldAsImage

      public FieldMetadata addFieldAsImage(String imageName, String fieldName, boolean useImageSize)
    • addFieldAsImage

      public FieldMetadata addFieldAsImage(String imageName, String fieldName, NullImageBehaviour behaviour)
    • addFieldAsImage

      public FieldMetadata addFieldAsImage(String imageName, String fieldName, NullImageBehaviour behaviour, boolean useImageSize)
      Add a field name which is considered as an image.
      Parameters:
      imageName -
      fieldName -
    • addFieldAsTextStyling

      public FieldMetadata addFieldAsTextStyling(String fieldName, fr.opensagres.xdocreport.core.document.SyntaxKind syntaxKind)
      Add a field name which can contains text stylink (Html, Wikipedia, etc..).
      Parameters:
      fieldName -
      syntaxKind -
    • addFieldAsTextStyling

      public FieldMetadata addFieldAsTextStyling(String fieldName, fr.opensagres.xdocreport.core.document.SyntaxKind syntaxKind, boolean syntaxWithDirective)
      Add a field name which can contains text stylink (Html, Wikipedia, etc..).
      Parameters:
      fieldName -
      syntaxKind -
    • addFieldAsTextStyling

      public FieldMetadata addFieldAsTextStyling(String fieldName, String syntaxKind)
      Add a field name which can contains text stylink (Html, Wikipedia, etc..).
      Parameters:
      fieldName -
      syntaxKind -
    • addFieldAsTextStyling

      public FieldMetadata addFieldAsTextStyling(String fieldName, String syntaxKind, boolean syntaxWithDirective)
      Add a field name which can contains text stylink (Html, Wikipedia, etc..).
      Parameters:
      fieldName -
      syntaxKind -
    • addFieldAsList

      public FieldMetadata addFieldAsList(String fieldName)
      Add a field name which belongs to a list.
      Parameters:
      fieldName -
    • addField

      public FieldMetadata addField(String fieldName, Boolean listType, String imageName, String syntaxKind, Boolean syntaxWithDirective)
    • getFieldAsImage

      public FieldMetadata getFieldAsImage(String fieldName)
    • getFieldsAsList

      public Collection<String> getFieldsAsList()
      Returns list of fields name which belongs to a list.
      Returns:
    • getFieldsAsImage

      public Collection<FieldMetadata> getFieldsAsImage()
      Returns list of fields name which are considered as an image.
      Returns:
    • getFieldsAsTextStyling

      public Collection<FieldMetadata> getFieldsAsTextStyling()
      Returns list of fields name which can contains text styling.
      Returns:
    • getFieldAsTextStyling

      public FieldMetadata getFieldAsTextStyling(String content)
      Returns the fields metadata as text styling from the given content and null otherwise.
      Parameters:
      content -
      Returns:
      the fields metadata as text styling from the given content and null otherwise.
    • hasFieldsAsImage

      public boolean hasFieldsAsImage()
      Returns true if there are fields as image and false otherwise.
      Returns:
    • isFieldAsImage

      public boolean isFieldAsImage(String fieldName)
    • getImageFieldName

      public String getImageFieldName(String fieldName)
    • getBeforeTableToken

      public String getBeforeTableToken()
    • setBeforeTableToken

      public void setBeforeTableToken(String beforeTableToken)
    • getAfterTableToken

      public String getAfterTableToken()
    • setAfterTableToken

      public void setAfterTableToken(String afterTableToken)
    • getBeforeRowToken

      public String getBeforeRowToken()
    • setBeforeRowToken

      public void setBeforeRowToken(String beforeRowToken)
    • getAfterRowToken

      public String getAfterRowToken()
    • setAfterRowToken

      public void setAfterRowToken(String afterRowToken)
    • getBeforeTableCellToken

      public String getBeforeTableCellToken()
    • setBeforeTableCellToken

      public void setBeforeTableCellToken(String beforeTableCellToken)
    • getAfterTableCellToken

      public String getAfterTableCellToken()
    • setAfterTableCellToken

      public void setAfterTableCellToken(String afterTableCellToken)
    • getFields

      public List<FieldMetadata> getFields()
      Returns list of fields metadata.
      Returns:
    • saveXML

      public void saveXML(Writer writer) throws IOException
      Serialize as XML without indentation the fields metadata to the given XML writer. Here a sample of XML writer :
       
        
        
       
       
       
      Parameters:
      writer -
      Throws:
      IOException
    • saveXML

      public void saveXML(Writer writer, boolean indent) throws IOException
      Serialize as XML the fields metadata to the given XML writer. Here a sample of XML writer :
       
        
        
       
       
       
      Parameters:
      writer - XML writer.
      indent - true if indent must be managed and false otherwise.
      Throws:
      IOException
    • saveXML

      public void saveXML(Writer writer, boolean indent, boolean formatAsJavaString) throws IOException
      Serialize as XML the fields metadata to the given XML writer. Here a sample of XML writer :
       
        
        
       
       
       
      Parameters:
      writer - XML writer.
      indent - true if indent must be managed and false otherwise.
      Throws:
      IOException
    • saveXML

      public void saveXML(OutputStream out) throws IOException
      Serialize as XML without indentation the fields metadata to the given OutputStream. Here a sample of XML out:
       
        
        
       
       
       
      Parameters:
      writer -
      Throws:
      IOException
    • saveXML

      public void saveXML(OutputStream out, boolean indent) throws IOException
      Serialize as XML the fields metadata to the given OutputStream. Here a sample of XML out :
       
        
        
       
       
       
      Parameters:
      writer - XML writer.
      indent - true if indent must be managed and false otherwise.
      Throws:
      IOException
    • load

      public void load(String key, Class<?> clazz) throws fr.opensagres.xdocreport.core.XDocReportException
      Load simple fields metadata in the given fieldsMetadata by using the given key and Java Class.
      Parameters:
      key - the key (first token) to use to generate field name.
      clazz - the Java class model to use to load fields metadata.
      Throws:
      fr.opensagres.xdocreport.core.XDocReportException
    • load

      public void load(String key, Class<?> clazz, boolean listType) throws fr.opensagres.xdocreport.core.XDocReportException
      Load simple/list fields metadata in the given fieldsMetadata by using the given key and Java Class.
      Parameters:
      key - the key (first token) to use to generate field name.
      clazz - the Java class model to use to load fields metadata.
      listType - true if it's a list and false otherwise.
      Throws:
      fr.opensagres.xdocreport.core.XDocReportException
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getDescription

      public String getDescription()
      Returns the description of fields metadata.
      Returns:
    • setDescription

      public void setDescription(String description)
      Set the description of fields metadata.
      Parameters:
      templateEngineKind -
    • getTemplateEngineKind

      public String getTemplateEngineKind()
      Returns the template engine kind.
      Returns:
    • setTemplateEngineKind

      public void setTemplateEngineKind(String templateEngineKind)
      Set the template engine kind.
      Parameters:
      templateEngineKind -
    • isEvaluateEngineOnlyForFields

      public boolean isEvaluateEngineOnlyForFields()
      Returns true if evaluation of the template engine should be done only for directive inserted in a field (MergeField for MS Word, Text-Inpout for ODT, etc) and false otherwise.
      Returns:
    • setEvaluateEngineOnlyForFields

      public void setEvaluateEngineOnlyForFields(boolean evaluateEngineOnlyForFields)
      Set true if evaluation of the template engine should be done only for directive inserted in a field (MergeField for MS Word, Text-Inpout for ODT, etc) and false otherwises.
      Parameters:
      evaluateEngineOnlyForFields -
    • getBehaviour

      public NullImageBehaviour getBehaviour()
      Returns the "global" behaviour to use when the stream of the image is null.
      Returns:
    • setBehaviour

      public void setBehaviour(NullImageBehaviour behaviour)
      Set the "global" behaviour to use when the stream of the image is null.
      Parameters:
      behaviour -
    • isUseImageSize

      public boolean isUseImageSize()
    • setUseImageSize

      public void setUseImageSize(boolean useImageSize)
    • addCustomFormatter

      public void addCustomFormatter(ICustomFormatter customFormatter)
      Add custom formatter.
      Parameters:
      customFormatter -
    • getCustomFormatter

      public List<ICustomFormatter> getCustomFormatter()
      Returns list of custom formatters and null otherwise.
      Returns:
    • addFieldReplacement

      public void addFieldReplacement(String search, String replacement)
      Add field replacement.
      Parameters:
      search -
      replacement -
    • customFormat

      public String customFormat(String content, IDocumentFormatter formatter)
      Format the given content by using custom formatter.
      Parameters:
      content -
      formatter -
      Returns: