PClobInfo.java from Texai at Krugle
Show PClobInfo.java syntax highlighted
/*
* PClobInfo.java
*
* Created on October 24, 2006, 1:56 PM
*
* Description: Contains the specialized fields for PClob.
*
* Copyright (C) 2006 Stephen L. Reed.
*
* This program is free software; you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program;
* if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package org.texai.kb.ejb.entity;
import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.OneToOne;
import javax.persistence.Transient;
import javax.sql.rowset.serial.SerialClob;
import javax.sql.rowset.serial.SerialException;
import org.texai.kb.Constants;
import org.texai.util.TexaiException;
/**
* Entity class PClobInfo
*
* @author reed
*/
@Entity
public class PClobInfo implements Serializable {
/**
* Determines if a de-serialized file is compatible with this class.
*
* Maintainers must change this value if and only if the new version
* of this class is not compatible with old versions. See Sun docs
* for <a href=http://java.sun.com/products/jdk/1.1/docs/guide
* /serialization/spec/version.doc.html> details. </a>
*
* Not necessary to include in first version of the class, but
* included here as a reminder of its importance.
*/
@Transient
private static final long serialVersionUID = 1L;
/** the id */
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long pClobInfoId; // NOPMD
/** the persistent character large object */
@OneToOne
private PClob pClob; // NOPMD
/** the character large object value */
@Lob @Basic
private SerialClob clobValue; // NOPMD
/** Creates a new instance of PClobInfo */
public PClobInfo() {
super();
}
/** Creates a new instance of PClobInfo.
*
* @param pClob the persistent character large object
* @param clobValue the character large object value
*/
public PClobInfo(final PClob pClob, final SerialClob clobValue) {
super();
//Preconditions
assert pClob != null : "pClob must not be null";
assert clobValue != null : "clobValue must not be null";
this.pClob = pClob;
this.clobValue = clobValue;
}
/**
* Gets the id of this PClobInfo.
*
* @return the id
*/
public Long getPClobInfoId() {
return this.pClobInfoId;
}
/** Gets the character large object value.
*
* @return the character large object value
*/
public SerialClob getClobValue() {
return clobValue;
}
/** Returns a string representation of this object.
*
* @return a string representation of this object
*/
@Override
public String toString() {
long lengthAsString;
try {
lengthAsString = clobValue.length();
if (lengthAsString > Constants.MAX_LENGTH_AS_STRING) {
lengthAsString = Constants.MAX_LENGTH_AS_STRING;
}
return clobValue.getSubString(1, (int) lengthAsString);
} catch (final SerialException ex) {
throw new TexaiException(ex);
}
}
/** Returns a CycL representation of this object.
*
* @return a CycL representation of this object
*/
public String toCycLString() {
return toString();
}
/** gets the persistent character large object
*
* @return the persistent character large object
*/
public PClob getPClob() {
return pClob;
}
}
See more files for this project here