1 24 package org.objectweb.jalisto.se.impl.meta; 25 26 import org.objectweb.jalisto.se.api.query.Index; 27 import org.objectweb.jalisto.se.exception.JalistoException; 28 import org.objectweb.jalisto.se.impl.InFileAddress; 29 import org.objectweb.jalisto.se.impl.server.page.LeafPage; 30 import org.objectweb.jalisto.se.impl.server.page.NodePage; 31 32 import java.io.Serializable ; 33 34 public class IndexDescription implements Serializable { 35 36 public IndexDescription(FieldDescriptionImpl fieldDescription) { 37 this.fieldDescription = fieldDescription; 38 this.nodePageSize = NodePage.DEFAULT_SIZE; 39 this.leafPageSize = LeafPage.DEFAULT_SIZE; 40 this.nodeSize = Index.NODE_DEFAULT_SIZE; 41 } 42 43 public boolean hasIndex() { 44 return (valueIndexIfa != null); 45 } 46 47 public FieldDescriptionImpl getFieldDescription() { 48 return fieldDescription; 49 } 50 51 public short getLeafPageSize() { 52 return leafPageSize; 53 } 54 55 public void setLeafPageSize(short leafPageSize) { 56 this.leafPageSize = leafPageSize; 57 } 58 59 public short getNodePageSize() { 60 return nodePageSize; 61 } 62 63 public void setNodePageSize(short nodePageSize) { 64 this.nodePageSize = nodePageSize; 65 } 66 67 public short getNodeSize() { 68 return nodeSize; 69 } 70 71 public void setNodeSize(short nodeSize) { 72 this.nodeSize = nodeSize; 73 } 74 75 public boolean isIndexDefined() { 76 return (valueIndexIfa != null); 77 } 78 79 public InFileAddress getValueIndexIfa() { 80 if (!fieldDescription.getType().isBasicType()) { 81 throw new JalistoException("cannot use or define index on none basic type field : " + fieldDescription); 82 } 83 return valueIndexIfa; 84 } 85 86 public void setValueIndexIfa(InFileAddress valueIndexIfa) { 87 if (!fieldDescription.getType().isBasicType()) { 88 throw new JalistoException("cannot use or define index on none basic type field : " + fieldDescription); 89 } 90 this.valueIndexIfa = valueIndexIfa; 91 } 92 93 public short getValueIndexType() { 94 return valueIndexType; 95 } 96 97 public void setValueIndexType(short valueIndexType) { 98 this.valueIndexType = valueIndexType; 99 } 100 101 public boolean equals(Object o) { 102 try { 103 IndexDescription candidate = (IndexDescription) o; 104 return (candidate.valueIndexIfa.equals(this.valueIndexIfa) && 105 (candidate.valueIndexType == this.valueIndexType) && 106 (candidate.nodeSize == this.nodeSize) && 107 (candidate.nodePageSize == this.nodePageSize) && 108 (candidate.leafPageSize == this.leafPageSize)); 109 } catch (Exception e) { 110 } 111 return false; 112 } 113 114 private FieldDescriptionImpl fieldDescription; 115 private InFileAddress valueIndexIfa; 116 private short valueIndexType; 117 private short nodeSize; 118 private short nodePageSize; 119 private short leafPageSize; 120 121 122 static final long serialVersionUID = -6989377087964761459L; 123 } 124 | Popular Tags |