Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 2.81 KB | None | 0 0
  1. package com.eyeq.kona.model.resource;
  2.  
  3. import java.io.IOException;
  4. import java.io.ObjectInputStream;
  5. import java.io.ObjectOutputStream;
  6.  
  7. import org.apache.commons.lang.builder.EqualsBuilder;
  8. import org.apache.commons.lang.builder.HashCodeBuilder;
  9. import org.apache.commons.lang.builder.ToStringBuilder;
  10.  
  11. import com.eyeq.kona.util.SerializeUtils;
  12.  
  13. public class MondrianResource extends AbstractResource implements OLAPResource {
  14.  
  15.     private static final long serialVersionUID = 8633821094895837285L;
  16.  
  17.     private JDBCResource resource;
  18.  
  19.     private String catalog;
  20.  
  21.     /**
  22.      * @see com.eyeq.kona.model.datasource.EISDataSource#getType()
  23.      */
  24.     public final ResourceType getType() {
  25.         return ResourceType.Mondrian;
  26.     }
  27.  
  28.     /**
  29.      * @return the resource
  30.      */
  31.     public JDBCResource getResource() {
  32.         return resource;
  33.     }
  34.  
  35.     /**
  36.      * @param resource
  37.      *            the resource to set
  38.      */
  39.     public void setResource(JDBCResource resource) {
  40.         this.resource = resource;
  41.     }
  42.  
  43.     /**
  44.      * @return the catalog
  45.      */
  46.     public String getCatalog() {
  47.         return catalog;
  48.     }
  49.  
  50.     /**
  51.      * @param catalog
  52.      *            the catalog to set
  53.      */
  54.     public void setCatalog(String catalog) {
  55.         this.catalog = catalog;
  56.     }
  57.  
  58.     /**
  59.      * @see java.lang.Object#equals(java.lang.Object)
  60.      */
  61.     @Override
  62.     public boolean equals(Object obj) {
  63.         if (!(obj instanceof MondrianResource)) {
  64.             return false;
  65.         }
  66.  
  67.         if (this == obj) {
  68.             return true;
  69.         }
  70.  
  71.         MondrianResource resource = (MondrianResource) obj;
  72.  
  73.         return new EqualsBuilder().append(getId(), resource.getId())
  74.                 .append(getName(), resource.getName())
  75.                 .append(catalog, resource.getCatalog())
  76.                 .append(getResource(), resource.getResource()).isEquals();
  77.     }
  78.  
  79.     /**
  80.      * @see java.lang.Object#hashCode()
  81.      */
  82.     @Override
  83.     public int hashCode() {
  84.         return new HashCodeBuilder().append(getId()).append(getName())
  85.                 .append(catalog).append(resource).toHashCode();
  86.     }
  87.  
  88.     /**
  89.      * @see java.lang.Object#toString()
  90.      */
  91.     @Override
  92.     public String toString() {
  93.         return new ToStringBuilder(this).append("id", getId())
  94.                 .append("name", getName()).append("catalog", catalog)
  95.                 .toString();
  96.     }
  97.  
  98.     /**
  99.      * @param os
  100.      * @throws IOException
  101.      */
  102.     private void writeObject(ObjectOutputStream os) throws IOException {
  103.         SerializeUtils.writeNullSafeUTF(getId(), os);
  104.         SerializeUtils.writeNullSafeUTF(getName(), os);
  105.         SerializeUtils.writeNullSafeUTF(catalog, os);
  106.  
  107.         os.writeObject(resource);
  108.     }
  109.  
  110.     /**
  111.      * @param is
  112.      * @throws IOException
  113.      * @throws ClassNotFoundException
  114.      */
  115.     private void readObject(ObjectInputStream is) throws IOException,
  116.             ClassNotFoundException {
  117.         setId(SerializeUtils.readNullSafeUTF(is));
  118.         setName(SerializeUtils.readNullSafeUTF(is));
  119.         this.catalog = SerializeUtils.readNullSafeUTF(is);
  120.  
  121.         this.resource = (JDBCResource) is.readObject();
  122.     }
  123. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement