SphinxDocInfo.java 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. package org.sphx.api;
  2. import java.util.*;
  3. /**
  4. * Document information helper class.
  5. * Can be found in SphinxResult.matches
  6. */
  7. public class SphinxDocInfo
  8. {
  9. private long docId;
  10. private int weight;
  11. private ArrayList attrValues = null;
  12. /**
  13. * Create document info using document id and its weight
  14. *
  15. * @param docId
  16. * @param weight
  17. */
  18. public SphinxDocInfo(long docId, int weight)
  19. {
  20. this.attrValues = new ArrayList();
  21. this.docId = docId;
  22. this.weight = weight;
  23. }
  24. /**
  25. * Get attribute set for this document.
  26. *
  27. * @return set of doc attributes
  28. */
  29. public ArrayList getAttrValues()
  30. {
  31. return attrValues;
  32. }
  33. public long getDocId()
  34. {
  35. return docId;
  36. }
  37. public int getWeight()
  38. {
  39. return weight;
  40. }
  41. /**
  42. * Get attribute value for given attribute name for this document
  43. *
  44. * @return attribute value for this document
  45. */
  46. public int getAttr(int no)
  47. {
  48. Integer value = (Integer) this.attrValues.get(no);
  49. return value.intValue();
  50. }
  51. /**
  52. * Set attribute value for given attribute name for this document
  53. *
  54. * @param attrName attribute name
  55. * @param value value for this document
  56. */
  57. public void setAttr(String attrName, Object value)
  58. {
  59. this.attrValues.add(value);
  60. }
  61. /**
  62. * Set integer attribute value for given attribute name for this document
  63. * @param value value for this document
  64. */
  65. public void setAttr(int no, int value)
  66. {
  67. Integer iBox = new Integer(value);
  68. this.attrValues.add(no, iBox);
  69. }
  70. /**
  71. * Set integer attribute value for given attribute name for this document
  72. * @param value value for this document
  73. */
  74. public void setAttr(int no, float value)
  75. {
  76. Float iBox = new Float(value);
  77. this.attrValues.add(no, iBox);
  78. }
  79. }