Show PBlob.java syntax highlighted
/*
* PBlob.java
*
* Created on October 16, 2006, 12:57 PM
*
* Description: PBlob is a large binary bits term in the Texai logical representation language.
*
* 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 javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Transient;
import javax.sql.rowset.serial.SerialBlob;
import org.texai.kb.Constants;
/**
* Entity class PBlob
*
* @author reed
*/
@Entity
@NamedQuery(name=Constants.QUERY_FIND_PBLOB_BY_BLOB_VALUE,
query="SELECT b FROM PBlob b, PBlobInfo bi WHERE bi.blobValue = :blobValue AND bi.pBlob = b")
public class PBlob extends AbstractTerm {
/**
* 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 persistent binary large object information */
@OneToOne(fetch=FetchType.LAZY, mappedBy = "pBlob", cascade=CascadeType.ALL)
private PBlobInfo pBlobInfo; // NOPMD
/** Creates a new instance of PBlob */
public PBlob() {
super();
}
/** Creates a new instance of PBlob.
*
* @param blobValue the binary large object value
*/
public PBlob(final SerialBlob blobValue) {
super();
//Preconditions
assert blobValue != null : "blobValue must not be null";
pBlobInfo = new PBlobInfo(this, blobValue);
}
/** Gets the persistent binary large object information.
*
* @return persistent binary large object information
*/
public PBlobInfo getPBlobInfo() {
return pBlobInfo;
}
/** Gets the binary large object value.
*
* @return the binary large object value
*/
public SerialBlob getBlobValue() {
return getPBlobInfo().getBlobValue();
}
/** Returns a string representation of this object.
*
* @return a string representation of this object
*/
@Override
public String toString() {
return getPBlobInfo().toString();
}
/** Returns a CycL representation of this object.
*
* @return a CycL representation of this object
*/
public String toCycLString() {
return getPBlobInfo().toCycLString();
}
}
See more files for this project here