Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * $Id: MetaData.java 22 2009-05-18 17:20:44Z mitcje $
   * $URL: https://ikasaneip.svn.sourceforge.net/svnroot/ikasaneip/tags/ikasan-0.7.3/common/src/main/java/org/ikasan/common/component/MetaData.java $
   * 
   * ====================================================================
   * Ikasan Enterprise Integration Platform
   * Copyright (c) 2003-2008 Mizuho International plc. and individual contributors as indicated
   * by the @authors tag. See the copyright.txt in the distribution for a
   * full listing of individual contributors.
  *
  * This is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as
  * published by the Free Software Foundation; either version 2.1 of
  * the License, or (at your option) any later version.
  *
  * This software is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this software; if not, write to the 
  * Free Software Foundation Europe e.V. Talstrasse 110, 40217 Dusseldorf, Germany 
  * or see the FSF site: http://www.fsfeurope.org/.
  * ====================================================================
  */
 package org.ikasan.common.component;
 
 import java.util.UUID;
 
 
 
 // Imported log4j classes
Meta Data extended by any data transport container, such as Payload or Envelope, to provide default implementation of meta data attributes..

Author(s):
Ikasan Development Team
 
 public abstract class MetaData implements Serializable
 {
    
Serialise ID
 
     private static final long serialVersionUID = 1L;

    
The logger instance
 
     private static Logger logger = Logger.getLogger(MetaData.class);

    
standard XSD schema URL for when we serialise payload to XML
 
XSD schema URL
 
     protected String noNamespaceSchemaLocation;

    
lifetime ID for the payload
 
     protected String id;

    
date/time the payload was originally created
 
     protected Long timestamp = new Long(0L);

    
date/time the payload was originally created
 
timezone of date/time
 
     protected String timezone = .;

    
priority of this payload relative to other payloads
 
     protected Integer priority = new Integer(0);

    
content name
 
     protected String name;

    
content MIME type specification
 
     protected String spec;

    
content encoding ie base64, hex, noenc
 
     protected String encoding;

    
content format ie xml, csv
 
     protected String format;

    
content character set
 
     protected String charset;

    
content size
 
     protected Long size = new Long(0L);

    
content calculated checksum
 
     protected String checksum;

    
calculated checksum algorithm
 
     protected String checksumAlg = .;

    
originating system
    protected String srcSystem;

    
Defined destination systems as an XML string fragment
    protected String targetSystems;

    
defined process IDs as an XML string fragment
    protected String processIds;

    
defined where this data requires resubmission back into the flow
    protected String resubmissionInfo;

    
Default Constructor
    public MetaData()
    {
        // Do nothing
    }

    
Sets the W3C XML Schema instance namespace URI.

Parameters:
schemaInstanceNSURI - W3C XML Schema Instance Namespace URI.
    public void setSchemaInstanceNSURI(String schemaInstanceNSURI)
    {
        this. = schemaInstanceNSURI;
    }

    
Returns the W3C XML Schema instance namespace URI.

Returns:
String
    {
        return this.;
    }

    
Sets the no namespace XML Schema location.

Parameters:
noNamespaceSchemaLocation - no namespace XML Schema location.
    public void setNoNamespaceSchemaLocation(String noNamespaceSchemaLocation)
    {
        this. = noNamespaceSchemaLocation;
    }

    
Returns the no namespace XML Schema location.

Returns:
String
    {
        return this.;
    }

    
Setter for id

Parameters:
id id to set
    public void setId(final String id)
    {
        this. = id;
        .debug("ID set to [" + this. + "]."); //$NON-NLS-1$ //$NON-NLS-2$
    }

    
Getter for id

Returns:
id
    public String getId()
    {
        .debug("Returning ID [" + this. + "]."); //$NON-NLS-1$ //$NON-NLS-2$
        return this.;
    }

    
Setter for timestamp

Parameters:
timestamp timestamp to set
    public void setTimestamp(final Long timestamp)
    {
        this. = timestamp;
        .debug("Timestamp set to [" + this. + "]."); //$NON-NLS-1$ //$NON-NLS-2$
    }

    
Getter for timestamp

Returns:
timestamp
    public Long getTimestamp()
    {
        .debug("Returning timestamp [" + this. + "]."); //$NON-NLS-1$ //$NON-NLS-2$
        return this.;
    }

    

Returns:
the timestampFormat
    public String getTimestampFormat()
    {
        .debug("Getting timestampFormat [" + this. + "]"); //$NON-NLS-1$//$NON-NLS-2$
        return this.;
    }

    

Parameters:
timestampFormat the timestampFormat to set
    public void setTimestampFormat(String timestampFormat)
    {
        this. = timestampFormat;
        .debug("Setting timestampFormat [" + this. + "]"); //$NON-NLS-1$ //$NON-NLS-2$
    }

    
Setter for timezone

Parameters:
timezone timezone to set
    public void setTimezone(final String timezone)
    {
        this. = TimeZone.getTimeZone(timezone).getDisplayName(true.);
        .debug("Timezone set to [" + this. + "]."); //$NON-NLS-1$ //$NON-NLS-2$
    }

    
Getter for timezone

Returns:
timezone
    public String getTimezone()
    {
        .debug("Returning timezone [" + this. + "]."); //$NON-NLS-1$//$NON-NLS-2$
        return this.;
    }

    
Setter for priority

Parameters:
priority priority to set
    public void setPriority(final Integer priority)
    {
        this. = priority;
        .debug("Priority set to [" + this. + "]."); //$NON-NLS-1$ //$NON-NLS-2$
    }

    
Getter for priority

Returns:
Priority
    public Integer getPriority()
    {
        .debug("Returning priority [" + this. + "]."); //$NON-NLS-1$ //$NON-NLS-2$
        return this.;
    }

    
Setter for name attribute

Parameters:
name name to set
    public void setName(final String name)
    {
        this. = name;
        .debug("Name set to [" + this. + "]."); //$NON-NLS-1$//$NON-NLS-2$
    }

    
Getter for name

Returns:
String
    public String getName()
    {
        .debug("Returning name [" + this. + "]."); //$NON-NLS-1$//$NON-NLS-2$
        return this.;
    }

    
Setter for spec attribute

Parameters:
spec spec to set
    public void setSpec(final String spec)
    {
        this. = spec;
        .debug("Spec set to [" + this. + "]."); //$NON-NLS-1$//$NON-NLS-2$
    }

    
Getter for spec

Returns:
String
    public String getSpec()
    {
        .debug("Returning spec [" + this. + "]."); //$NON-NLS-1$//$NON-NLS-2$
        return this.;
    }

    
Setter for encoding

Parameters:
encoding encoding to set
    public void setEncoding(final String encoding)
    {
        this. = encoding;
        .debug("Encoding set to [" + this. + "]."); //$NON-NLS-1$//$NON-NLS-2$
    }

    
Getter for encoding

Returns:
Encoding
    public String getEncoding()
    {
        .debug("Returning encoding [" + this. + "]."); //$NON-NLS-1$ //$NON-NLS-2$
        return this.;
    }

    
Setter for format

Parameters:
format format to set
    public void setFormat(final String format)
    {
        this. = format;
        .debug("Format set to [" + this. + "]."); //$NON-NLS-1$//$NON-NLS-2$
    }

    
Getter for format

Returns:
Format
    public String getFormat()
    {
        .debug("Returning format [" + this. + "]."); //$NON-NLS-1$//$NON-NLS-2$
        return this.;
    }

    
Setter for character set

Parameters:
charset character set to set
    public void setCharset(final String charset)
    {
        this. = charset;
        .debug("Charset set to [" + this. + "]."); //$NON-NLS-1$ //$NON-NLS-2$
    }

    
Getter for character set

Returns:
Charset
    public String getCharset()
    {
        .debug("Returning charset [" + this. + "]."); //$NON-NLS-1$//$NON-NLS-2$
        return this.;
    }

    
Setter for size attribute. This can be used to set the size attribute to an explicit value.

Parameters:
size size to set
    public void setSize(final Long size)
    {
        this. = size;
        .debug("Size set to [" + this. + "]."); //$NON-NLS-1$ //$NON-NLS-2$
    }

    
Utility setter for size.
    public abstract void setSize();

    
Getter for size

Returns:
Long
    public Long getSize()
    {
        .debug("Returning size [" + this. + "]."); //$NON-NLS-1$//$NON-NLS-2$
        return this.;
    }

    
Setter for checksum. This can be used to set checksum to an explicit value as provided by the checksum parameter.

Parameters:
checksum checksum to set
    public void setChecksum(final String checksum)
    {
        this. = checksum;
        .debug("Checksum set to [" + this. + "]."); //$NON-NLS-1$ //$NON-NLS-2$
    }

    
Utility setter for checksum. When this setter is used, the checksum is calculated and set automatically. The checksum is calculated based on the class default MD5 algorithm.
    public void setChecksum()
    {
        this. = this.calculateChecksum();
        .debug("Checksum set to [" + this. + "]."); //$NON-NLS-1$//$NON-NLS-2$
    }

    
Getter for checksum

Returns:
String
    public String getChecksum()
    {
        .debug("Returning checksum [" + this. + "]."); //$NON-NLS-1$//$NON-NLS-2$
        return this.;
    }

    
Utility setter for checksumAlg. When this setter is used, the checksum algorithm is set. The checksumAlg default is MD5 algorithm.

Parameters:
checksumAlg checksum algorithm to set
    public void setChecksumAlg(final String checksumAlg)
    {
        this. = checksumAlg;
        .debug("ChecksumAlg set to [" + this. + "]."); //$NON-NLS-1$//$NON-NLS-2$
    }

    
Getter for checksumAlg

Returns:
String
    public String getChecksumAlg()
    {
        .debug("Returning checksumAlg [" + this. + "]."); //$NON-NLS-1$ //$NON-NLS-2$
        return this.;
    }

    
Setter for srcSystem

Parameters:
srcSystem source system to set
    public void setSrcSystem(final String srcSystem)
    {
        this. = srcSystem;
        .debug("SrcSystem set to [" + this. + "]."); //$NON-NLS-1$ //$NON-NLS-2$
    }

    
Getter for srcSystem

Returns:
String
    public String getSrcSystem()
    {
        .debug("Returning srcSystem [" + this. + "]."); //$NON-NLS-1$ //$NON-NLS-2$
        return this.;
    }

    
Getter for targetSystems

Returns:
String
    public String getTargetSystems()
    {
        .debug("Returning targetSystems [" + this. + "]."); //$NON-NLS-1$//$NON-NLS-2$
        return this.;
    }

    
Setter for targetSystems

Parameters:
targetSystems target systems to set
    public void setTargetSystems(String targetSystems)
    {
        this. = targetSystems;
        .debug("TargetSystems set to [" + this. + "]."); //$NON-NLS-1$ //$NON-NLS-2$
    }

    
Getter for processIds

Returns:
String
    public String getProcessIds()
    {
        .debug("Returning processIds [" + this. + "]."); //$NON-NLS-1$//$NON-NLS-2$
        return this.;
    }

    
Setter for processIds

Parameters:
processIds process ids to set
    public void setProcessIds(String processIds)
    {
        this. = processIds;
        .debug("ProcessIds set to [" + this. + "]."); //$NON-NLS-1$ //$NON-NLS-2$
    }

    
Returns the formatted timestamp

Returns:
formatted timestamp
    public String getFormattedTimestamp()
    {
        return DateFormatUtils.format(this..longValue(), this., TimeZone
            .getTimeZone(this.));
    }

    

Returns:
the resubmissionInfo
    public String getResubmissionInfo()
    {
        .debug("Getting resubmissionInfo [" + this. + "]"); //$NON-NLS-1$ //$NON-NLS-2$
        return this.;
    }

    

Parameters:
resubmissionInfo the resubmissionInfo to set
    public void setResubmissionInfo(String resubmissionInfo)
    {
        this. = resubmissionInfo;
        .debug("Setting resubmissionInfo [" + this. + "]"); //$NON-NLS-1$ //$NON-NLS-2$
    }

    
no implementation required - method needed only as a requirement of introspection on this class.

Parameters:
formattedTimestamp formatted timestamp to set
    public void setFormattedTimestamp(@SuppressWarnings("unused"String formattedTimestamp)
    {
        // no implementation required - method needed only
        // as a requirement of introspection on this class.
    }

    
Method used to calculate the checksum of the content byte array. By defaul, the checksum is calculated using the MD5 algorithm.

Returns:
The MD5 checksum of the content as a hexadecimal String.
    protected abstract String calculateChecksum();

    
Create a formatted string detailing the payload id of the incoming payload.

Returns:
String
    public abstract String idToString();

    
Default id generator

Returns:
String
    protected static String generateId()
    {
        return UUID.randomUUID().toString();
    }

    
Default timestamp generator

Returns:
Long
    protected static Long generateTimestamp()
    {
        return new Long(new java.util.Date().getTime());
    }

    
Creates a String representation of the Payload showing all the objects properties and an many characters of the content as specified in the cLength parameter. If the cLength is negative, the content is display from the end of the content string.

Parameters:
cLength Used to restrict the length of the payload to a specific number of chars.
Returns:
A formatted String representing the Payload object.
    public String toString(int cLength)
    {
        StringBuilder sb = new StringBuilder(512);
        .debug("cLength [" + cLength + "]");
        sb.append("Id               = ["); //$NON-NLS-1$
        sb.append(this.);
        sb.append("]\n");//$NON-NLS-1$
        sb.append("timestamp        = [");//$NON-NLS-1$
        sb.append(this.);
        sb.append("]\n");//$NON-NLS-1$
        sb.append("timestampFormat  = [");//$NON-NLS-1$
        sb.append(this.);
        sb.append("]\n");//$NON-NLS-1$
        sb.append("Timezone         = [");//$NON-NLS-1$
        sb.append(this.);
        sb.append("]\n");//$NON-NLS-1$
        sb.append("Priority         = [");//$NON-NLS-1$
        sb.append(this.);
        sb.append("]\n");//$NON-NLS-1$
        sb.append("Name             = [");//$NON-NLS-1$
        sb.append(this.);
        sb.append("]\n");//$NON-NLS-1$
        sb.append("Specification    = [");//$NON-NLS-1$
        sb.append(this.);
        sb.append("]\n");//$NON-NLS-1$
        sb.append("Encoding         = [");//$NON-NLS-1$
        sb.append(this.);
        sb.append("]\n");//$NON-NLS-1$
        sb.append("Format           = [");//$NON-NLS-1$
        sb.append(this.);
        sb.append("]\n");//$NON-NLS-1$
        sb.append("Charset          = [");//$NON-NLS-1$
        sb.append(this.);
        sb.append("]\n");//$NON-NLS-1$
        sb.append("Size(bytes)      = [");//$NON-NLS-1$
        sb.append(this.);
        sb.append("]\n");//$NON-NLS-1$
        sb.append("Checksum (Hex)   = [");//$NON-NLS-1$
        sb.append(this.);
        sb.append("]\n");//$NON-NLS-1$
        sb.append("Source System    = [");//$NON-NLS-1$
        sb.append(this.);
        sb.append("]\n");//$NON-NLS-1$
        sb.append("Target Systems   = [");//$NON-NLS-1$
        sb.append(this.);
        sb.append("]\n");//$NON-NLS-1$
        sb.append("Process IDs      = [");//$NON-NLS-1$
        sb.append(this.);
        sb.append("]\n");//$NON-NLS-1$
        sb.append("ResubmissionInfo = [");//$NON-NLS-1$
        sb.append(this.);
        sb.append("]\n");//$NON-NLS-1$
        return sb.toString();
    }
New to GrepCode? Check out our FAQ X