You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ComplexValueForeignKey.java 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. /*
  2. Copyright (c) 2013 James Ahlborn
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package com.healthmarketscience.jackcess.complex;
  14. import java.io.IOException;
  15. import java.io.ObjectStreamException;
  16. import java.util.Date;
  17. import java.util.List;
  18. import java.util.Map;
  19. import com.healthmarketscience.jackcess.Column;
  20. /**
  21. * Value which is returned for a complex column. This value corresponds to a
  22. * foreign key in a secondary table which contains the actual complex data for
  23. * this row (which could be 0 or more complex values for a given row). This
  24. * class contains various convenience methods for interacting with the actual
  25. * complex values.
  26. * <p>
  27. * This class will cache the associated complex values returned from one of
  28. * the lookup methods. The various modification methods will clear this cache
  29. * automatically. The {@link #reset} method may be called manually to clear
  30. * this internal cache.
  31. *
  32. * @author James Ahlborn
  33. */
  34. public abstract class ComplexValueForeignKey extends Number
  35. {
  36. private static final long serialVersionUID = 20130319L;
  37. @Override
  38. public byte byteValue() {
  39. return (byte)get();
  40. }
  41. @Override
  42. public short shortValue() {
  43. return (short)get();
  44. }
  45. @Override
  46. public int intValue() {
  47. return get();
  48. }
  49. @Override
  50. public long longValue() {
  51. return get();
  52. }
  53. @Override
  54. public float floatValue() {
  55. return get();
  56. }
  57. @Override
  58. public double doubleValue() {
  59. return get();
  60. }
  61. protected final Object writeReplace() throws ObjectStreamException {
  62. // if we are going to serialize this ComplexValueForeignKey, convert it
  63. // back to a normal Integer (in case it is restored outside of the context
  64. // of jackcess)
  65. return Integer.valueOf(get());
  66. }
  67. @Override
  68. public int hashCode() {
  69. return get();
  70. }
  71. @Override
  72. public boolean equals(Object o) {
  73. return ((this == o) ||
  74. ((o != null) && (getClass() == o.getClass()) &&
  75. (get() == ((ComplexValueForeignKey)o).get())));
  76. }
  77. @Override
  78. public String toString() {
  79. return String.valueOf(get());
  80. }
  81. public abstract int get();
  82. public abstract Column getColumn();
  83. public abstract ComplexDataType getComplexType();
  84. public abstract int countValues() throws IOException;
  85. public abstract List<? extends ComplexValue> getValues() throws IOException;
  86. public abstract List<Version> getVersions() throws IOException;
  87. public abstract List<Attachment> getAttachments()
  88. throws IOException;
  89. public abstract List<SingleValue> getMultiValues()
  90. throws IOException;
  91. public abstract List<UnsupportedValue> getUnsupportedValues()
  92. throws IOException;
  93. public abstract void reset();
  94. public abstract Version addVersion(String value)
  95. throws IOException;
  96. public abstract Version addVersion(String value, Date modifiedDate)
  97. throws IOException;
  98. public abstract Attachment addAttachment(byte[] data)
  99. throws IOException;
  100. public abstract Attachment addAttachment(
  101. String url, String name, String type, byte[] data,
  102. Date timeStamp, Integer flags)
  103. throws IOException;
  104. public abstract Attachment addEncodedAttachment(byte[] encodedData)
  105. throws IOException;
  106. public abstract Attachment addEncodedAttachment(
  107. String url, String name, String type, byte[] encodedData,
  108. Date timeStamp, Integer flags)
  109. throws IOException;
  110. public abstract Attachment updateAttachment(Attachment attachment)
  111. throws IOException;
  112. public abstract Attachment deleteAttachment(Attachment attachment)
  113. throws IOException;
  114. public abstract SingleValue addMultiValue(Object value)
  115. throws IOException;
  116. public abstract SingleValue updateMultiValue(SingleValue value)
  117. throws IOException;
  118. public abstract SingleValue deleteMultiValue(SingleValue value)
  119. throws IOException;
  120. public abstract UnsupportedValue addUnsupportedValue(Map<String,?> values)
  121. throws IOException;
  122. public abstract UnsupportedValue updateUnsupportedValue(UnsupportedValue value)
  123. throws IOException;
  124. public abstract UnsupportedValue deleteUnsupportedValue(UnsupportedValue value)
  125. throws IOException;
  126. public abstract void deleteAllValues()
  127. throws IOException;
  128. }