選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

getInitialValue.html 7.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <html>
  3. <head>
  4. <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  5. <title>Generating Initial Values</title>
  6. <link type="text/css" href="../../../page.css" rel="stylesheet">
  7. </head>
  8. <body marginheight="0" marginwidth="0" topmargin="0" leftmargin="0" text="#000000" bgcolor="#FFFFFF">
  9. <div class="content">
  10. <h1>Generating Initial Values</h1>
  11. <p>
  12. <font size="-2">by&nbsp;Peter B. West</font>
  13. </p>
  14. <ul class="minitoc">
  15. <li>
  16. <a href="#N10014">Introduction</a>
  17. </li>
  18. <li>
  19. <a href="#N10021">
  20. Generating &amp; Accessing Initial Values
  21. </a>
  22. <ul class="minitoc">
  23. <li>
  24. <a href="#N10062">Properties without
  25. getInitialValue()</a>
  26. </li>
  27. </ul>
  28. </li>
  29. </ul>
  30. <a name="N10014"></a>
  31. <h3>Introduction</h3>
  32. <p>
  33. The <a href="simple-properties.html">previous section</a>
  34. discussed the common data elements in the simplest examples of
  35. property classes. This section discusses more complex classes
  36. whose facilities are accessed only through various methods.
  37. </p>
  38. <a name="N10021"></a>
  39. <h3>
  40. Generating &amp; Accessing Initial Values
  41. </h3>
  42. <p>
  43. <a href= "javascript:window.top.displayCode( 'AutoRestore.html' )"
  44. ><span class="codefrag"
  45. >org.apache.fop.fo.properties.AutoRestore</span></a> is an
  46. example of the next most complex property class. In
  47. addition to all of the common static fields, these classes
  48. have initial data value types which require the dynamic
  49. generation of a PropertyValue instance.
  50. </p>
  51. <p>
  52. The method <a href= "javascript:window.top.displayCode(
  53. 'AutoRestore.html#getInitialValue' )" ><span
  54. class="codefrag">PropertyValue getInitialValue(int)</span></a>
  55. returns an instance of PropertyValue of the appropriate
  56. subclass containing the initial value for this property. Like
  57. the static data fields, this value is, in turn, stored in the
  58. array of initial values maintained in the <a href=
  59. "javascript:window.top.displayCode(
  60. 'PropertyConsts.html#PropertyConstsClass' )" ><span
  61. class="codefrag">PropertyConsts</span></a> singleton <a href=
  62. "javascript:window.top.displayCode( 'PropertyConsts.html#pconsts'
  63. )" ><span class="codefrag">pconsts</span></a>.` As with the
  64. fields, the first invocation of the method <a href=
  65. "javascript:window.top.displayCode(
  66. 'PropertyConsts.html#setupProperty' )" ><span
  67. class="codefrag">setupProperty</span></a> on the property
  68. instantiates the singleton instance of the class, and stores
  69. that instance in the in the <a href=
  70. "javascript:window.top.displayCode(
  71. 'PropertyConsts.html#properties' )" ><span
  72. class="codefrag">Property[] properties</span></a> array of <a
  73. href= "javascript:window.top.displayCode(
  74. 'PropertyConsts.html#pconsts' )" ><span
  75. class="codefrag">pconsts</span></a>.
  76. </p>
  77. <p>
  78. Unlike the static data fields, however, the initial value is
  79. not immediately generated. It is generated by a call to <a
  80. href= "javascript:window.top.displayCode(
  81. 'PropertyConsts.html#getInitialValue' )" ><span
  82. class="codefrag">PropertyValue getInitialValue(int)</span></a>
  83. in <a href= "javascript:window.top.displayCode(
  84. 'PropertyConsts.html#pconsts' )" ><span
  85. class="codefrag">pconsts</span></a>. This call, in turn,
  86. locates the relevant instance of the particular property class
  87. in the <a href= "javascript:window.top.displayCode(
  88. 'PropertyConsts.html#properties' )" ><span class= "codefrag"
  89. >properties</span> array of <span class= "codefrag"
  90. >PropertyConsts</span></a>, and invokes the <span class=
  91. "codefrag" >getInitialValue()</span> of that instance. A
  92. side-effect of this call is to store the initial value in <a
  93. href= "javascript:window.top.displayCode(
  94. 'PropertyConsts.html#initialValues' )" ><span
  95. class="codefrag">PropertyValue[] initialValues</span></a>.
  96. </p>
  97. <a name="N10062"></a>
  98. <h4>Properties without
  99. getInitialValue()</h4>
  100. <p>
  101. What about property classes which have no <span
  102. class="codefrag">getInitialValue()</span> method? The
  103. simplest classes, e.g. <span
  104. class="codefrag">Character</span>, fall into this category.
  105. As <a href="classes-overview.html#property-classes">noted
  106. previously</a>, all of the property classes extend <span
  107. class="codefrag">org.apache.fop.fo.properties.Property</span>.
  108. <a href= "javascript:window.top.displayCode(
  109. 'Property.html#PropertyClass' )" ><span
  110. class="codefrag">Property</span></a> provides a base <a href=
  111. "javascript:window.top.displayCode(
  112. 'Property.html#getInitialValue' )" ><span
  113. class="codefrag">PropertyValue getInitialValue(int)</span></a>
  114. method to which the simple classes fall back. Note that it is
  115. only valid for <span class="codefrag">NOTYPE_IT</span>, <span
  116. class="codefrag">AUTO_IT</span>, <span
  117. class="codefrag">NONE_IT</span> and <span
  118. class="codefrag">AURAL_IT</span> initial value types, so all
  119. classes which have any other initial value type must override
  120. this method.
  121. </p>
  122. <p>
  123. <strong>Previous:</strong> <a href = "simple-properties.html"
  124. >Simple property classes</a>
  125. </p>
  126. <p>
  127. <strong>Next:</strong> <a href= "enumerated-values.html"
  128. >Enumerated values</a>
  129. </p>
  130. </div>
  131. <table summary="footer" cellspacing="0" cellpadding="0" width="100%" height="20" border="0">
  132. <tr>
  133. <td colspan="2" height="1" bgcolor="#4C6C8F"><img height="1"
  134. width="1" alt="" src="../../../skin/images/spacer.gif"><a
  135. href="../../../skin/images/label.gif"></a><a
  136. href="../../../skin/images/page.gif"></a><a
  137. href="../../../skin/images/chapter.gif"></a><a
  138. href="../../../skin/images/chapter_open.gif"></a><a
  139. href="../../../skin/images/current.gif"></a><a
  140. href="../../..//favicon.ico"></a></td>
  141. </tr>
  142. <tr>
  143. <td colspan="2" bgcolor="#CFDCED" class="copyright"
  144. align="center"><font size="2" face="Arial, Helvetica,
  145. Sans-Serif">Copyright &copy; 1999-2002&nbsp;The Apache
  146. Software Foundation. All rights reserved.<script
  147. type="text/javascript" language="JavaScript"><!--
  148. document.write(" - "+"Last Published: " +
  149. document.lastModified); // --></script></font></td>
  150. </tr>
  151. <tr>
  152. <td align="left" bgcolor="#CFDCED" class="logos"></td><td
  153. align="right" bgcolor="#CFDCED" class="logos"></td>
  154. </tr>
  155. </table>
  156. </body>
  157. </html>