PageRenderTime 68ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/src/org/apache/poi/hwpf/model/types/SHD80AbstractType.java

https://github.com/minstrelsy/SimpleAndroidDocView
Java | 194 lines | 107 code | 22 blank | 65 comment | 8 complexity | 8dacfcb44e6497e09a58a79febffd137 MD5 | raw file
Possible License(s): Apache-2.0
  1. /* ====================================================================
  2. Licensed to the Apache Software Foundation (ASF) under one or more
  3. contributor license agreements. See the NOTICE file distributed with
  4. this work for additional information regarding copyright ownership.
  5. The ASF licenses this file to You under the Apache License, Version 2.0
  6. (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. ==================================================================== */
  15. package org.apache.poi.hwpf.model.types;
  16. import org.apache.poi.util.BitField;
  17. import org.apache.poi.util.Internal;
  18. import org.apache.poi.util.LittleEndian;
  19. /**
  20. * The Shd80 structure specifies the colors and pattern that are used for background
  21. shading. As an exception to the constraints that are specified by Ico and Ipat, a Shd80 can
  22. be set to Shd80Nil and specifies that no shading is applied. <p>Class and fields
  23. descriptions are quoted from Word (.doc) Binary File Format by Microsoft Corporation
  24. * <p>
  25. * NOTE: This source is automatically generated please do not modify this file. Either subclass or
  26. * remove the record in src/types/definitions.
  27. * <p>
  28. * This class is internal. It content or properties may change without notice
  29. * due to changes in our knowledge of internal Microsoft Word binary structures.
  30. * @author Sergey Vladimirov; according to Word (.doc) Binary File Format by Microsoft Corporation.
  31. */
  32. @Internal
  33. public abstract class SHD80AbstractType
  34. {
  35. protected short field_1_value;
  36. /**/private static final BitField icoFore = new BitField(0x001F);
  37. /**/private static final BitField icoBack = new BitField(0x03E0);
  38. /**/private static final BitField ipat = new BitField(0xFC00);
  39. protected SHD80AbstractType()
  40. {
  41. }
  42. protected void fillFields( byte[] data, int offset )
  43. {
  44. field_1_value = LittleEndian.getShort( data, 0x0 + offset );
  45. }
  46. public void serialize( byte[] data, int offset )
  47. {
  48. LittleEndian.putShort( data, 0x0 + offset, field_1_value );
  49. }
  50. public byte[] serialize()
  51. {
  52. final byte[] result = new byte[ getSize() ];
  53. serialize( result, 0 );
  54. return result;
  55. }
  56. /**
  57. * Size of record
  58. */
  59. public static int getSize()
  60. {
  61. return 0 + 2;
  62. }
  63. @Override
  64. public boolean equals( Object obj )
  65. {
  66. if ( this == obj )
  67. return true;
  68. if ( obj == null )
  69. return false;
  70. if ( getClass() != obj.getClass() )
  71. return false;
  72. SHD80AbstractType other = (SHD80AbstractType) obj;
  73. if ( field_1_value != other.field_1_value )
  74. return false;
  75. return true;
  76. }
  77. @Override
  78. public int hashCode()
  79. {
  80. final int prime = 31;
  81. int result = 1;
  82. result = prime * result + field_1_value;
  83. return result;
  84. }
  85. public String toString()
  86. {
  87. StringBuilder builder = new StringBuilder();
  88. builder.append("[SHD80]\n");
  89. builder.append(" .value = ");
  90. builder.append(" (").append(getValue()).append(" )\n");
  91. builder.append(" .icoFore = ").append(getIcoFore()).append('\n');
  92. builder.append(" .icoBack = ").append(getIcoBack()).append('\n');
  93. builder.append(" .ipat = ").append(getIpat()).append('\n');
  94. builder.append("[/SHD80]\n");
  95. return builder.toString();
  96. }
  97. /**
  98. * Get the value field for the SHD80 record.
  99. */
  100. @Internal
  101. public short getValue()
  102. {
  103. return field_1_value;
  104. }
  105. /**
  106. * Set the value field for the SHD80 record.
  107. */
  108. @Internal
  109. public void setValue( short field_1_value )
  110. {
  111. this.field_1_value = field_1_value;
  112. }
  113. /**
  114. * Sets the icoFore field value.
  115. * Foreground color
  116. */
  117. @Internal
  118. public void setIcoFore( byte value )
  119. {
  120. field_1_value = (short)icoFore.setValue(field_1_value, value);
  121. }
  122. /**
  123. * Foreground color
  124. * @return the icoFore field value.
  125. */
  126. @Internal
  127. public byte getIcoFore()
  128. {
  129. return ( byte )icoFore.getValue(field_1_value);
  130. }
  131. /**
  132. * Sets the icoBack field value.
  133. * Background color
  134. */
  135. @Internal
  136. public void setIcoBack( byte value )
  137. {
  138. field_1_value = (short)icoBack.setValue(field_1_value, value);
  139. }
  140. /**
  141. * Background color
  142. * @return the icoBack field value.
  143. */
  144. @Internal
  145. public byte getIcoBack()
  146. {
  147. return ( byte )icoBack.getValue(field_1_value);
  148. }
  149. /**
  150. * Sets the ipat field value.
  151. * Shading pattern
  152. */
  153. @Internal
  154. public void setIpat( byte value )
  155. {
  156. field_1_value = (short)ipat.setValue(field_1_value, value);
  157. }
  158. /**
  159. * Shading pattern
  160. * @return the ipat field value.
  161. */
  162. @Internal
  163. public byte getIpat()
  164. {
  165. return ( byte )ipat.getValue(field_1_value);
  166. }
  167. } // END OF CLASS