Return-Path: Delivered-To: apmail-jakarta-poi-dev-archive@www.apache.org Received: (qmail 65219 invoked from network); 19 Sep 2004 02:44:55 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 19 Sep 2004 02:44:55 -0000 Received: (qmail 24776 invoked by uid 500); 19 Sep 2004 02:44:54 -0000 Delivered-To: apmail-jakarta-poi-dev-archive@jakarta.apache.org Received: (qmail 24736 invoked by uid 500); 19 Sep 2004 02:44:54 -0000 Mailing-List: contact poi-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "POI Developers List" Reply-To: "POI Developers List" Delivered-To: mailing list poi-dev@jakarta.apache.org Received: (qmail 24719 invoked by uid 500); 19 Sep 2004 02:44:54 -0000 Received: (qmail 24714 invoked by uid 99); 19 Sep 2004 02:44:54 -0000 X-ASF-Spam-Status: No, hits=-10.0 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Sat, 18 Sep 2004 19:44:53 -0700 Received: (qmail 65211 invoked by uid 1445); 19 Sep 2004 02:44:52 -0000 Date: 19 Sep 2004 02:44:52 -0000 Message-ID: <20040919024452.65210.qmail@minotaur.apache.org> From: glens@apache.org To: jakarta-poi-cvs@apache.org Subject: cvs commit: jakarta-poi/src/java/org/apache/poi/hssf/usermodel HSSFHeader.java X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N glens 2004/09/18 19:44:52 Modified: src/java/org/apache/poi/hssf/usermodel HSSFHeader.java Log: Javadoc fixes and cleanup. Revision Changes Path 1.9 +221 -180 jakarta-poi/src/java/org/apache/poi/hssf/usermodel/HSSFHeader.java Index: HSSFHeader.java =================================================================== RCS file: /home/cvs/jakarta-poi/src/java/org/apache/poi/hssf/usermodel/HSSFHeader.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- HSSFHeader.java 23 Aug 2004 08:52:42 -0000 1.8 +++ HSSFHeader.java 19 Sep 2004 02:44:52 -0000 1.9 @@ -28,188 +28,229 @@ * that return the characters used to represent these. One can also change the * fonts by using similar methods. *

+ * * @author Shawn Laubach (slaubach at apache dot org) */ -public class HSSFHeader extends Object { +public class HSSFHeader +{ - HeaderRecord headerRecord; - String left; - String center; - String right; - - /** - * Constructor. Creates a new header interface from a header record - * @param headerRecord Header record to create the header with - */ - protected HSSFHeader(HeaderRecord headerRecord) { - this.headerRecord = headerRecord; - String head = headerRecord.getHeader(); - while (head != null && head.length() > 1) { - int pos = head.length(); - switch (head.substring(1, 2).charAt(0)) { - case 'L' : - if (head.indexOf("&C") >= 0) { - pos = Math.min(pos, head.indexOf("&C")); - } - if (head.indexOf("&R") >= 0) { - pos = Math.min(pos, head.indexOf("&R")); - } - left = head.substring(2, pos); - head = head.substring(pos); - break; - case 'C' : - if (head.indexOf("&L") >= 0) { - pos = Math.min(pos, head.indexOf("&L")); - } - if (head.indexOf("&R") >= 0) { - pos = Math.min(pos, head.indexOf("&R")); - } - center = head.substring(2, pos); - head = head.substring(pos); - break; - case 'R' : - if (head.indexOf("&C") >= 0) { - pos = Math.min(pos, head.indexOf("&C")); - } - if (head.indexOf("&L") >= 0) { - pos = Math.min(pos, head.indexOf("&L")); - } - right = head.substring(2, pos); - head = head.substring(pos); - break; - default : head = null; - } - } - } - - /** - * Get the left side of the header. - * @return The string representing the left side. - */ - public String getLeft() { - return left; - } - - /** - * Sets the left string. - * @newLeft The string to set as the left side. - */ - public void setLeft(String newLeft) { - left = newLeft; - createHeaderString(); - } - - /** - * Get the center of the header. - * @return The string representing the center. - */ - public String getCenter() { - return center; - } - - /** - * Sets the center string. - * @newLeft The string to set as the center. - */ - public void setCenter(String newCenter) { - center = newCenter; - createHeaderString(); - } - - /** - * Get the right side of the header. - * @return The string representing the right side. - */ - public String getRight() { - return right; - } - - /** - * Sets the right string. - * @newLeft The string to set as the right side. - */ - public void setRight(String newRight) { - right = newRight; - createHeaderString(); - } - - /** - * Creates the complete header string based on the left, center, and middle - * strings. - */ - private void createHeaderString() { - headerRecord.setHeader( - "&C" + (center == null ? "" : center) + - "&L" + (left == null ? "" : left) + - "&R" + (right == null ? "" : right)); - headerRecord.setHeaderLength((byte)headerRecord.getHeader().length()); - } - - /** - * Returns the string that represents the change in font size. - * @param size the new font size - * @return The special string to represent a new font size - */ - public static String fontSize(short size) { - return "&" + size; - } - - /** - * Returns the string that represents the change in font. - * @param font the new font - * @param style the fonts style - * @return The special string to represent a new font size - */ - public static String font(String font, String style) { - return "&\"" + font + "," + style + "\""; - } - - /** - * Returns the string representing the current page number - * @return The special string for page number - */ - public static String page() { - return "&P"; - } - - /** - * Returns the string representing the number of pages. - * @return The special string for the number of pages - */ - public static String numPages() { - return "&N"; - } - - /** - * Returns the string representing the current date - * @return The special string for the date - */ - public static String date() { - return "&D"; - } - - /** - * Returns the string representing the current time - * @return The special string for the time - */ - public static String time() { - return "&T"; - } - - /** - * Returns the string representing the current file name - * @return The special string for the file name - */ - public static String file() { - return "&F"; - } - - /** - * Returns the string representing the current tab (sheet) name - * @return The special string for tab name - */ - public static String tab() { - return "&A"; - } + HeaderRecord headerRecord; + String left; + String center; + String right; + + /** + * Constructor. Creates a new header interface from a header record + * + * @param headerRecord Header record to create the header with + */ + protected HSSFHeader( HeaderRecord headerRecord ) + { + this.headerRecord = headerRecord; + String head = headerRecord.getHeader(); + while ( head != null && head.length() > 1 ) + { + int pos = head.length(); + switch ( head.substring( 1, 2 ).charAt( 0 ) ) + { + case 'L': + if ( head.indexOf( "&C" ) >= 0 ) + { + pos = Math.min( pos, head.indexOf( "&C" ) ); + } + if ( head.indexOf( "&R" ) >= 0 ) + { + pos = Math.min( pos, head.indexOf( "&R" ) ); + } + left = head.substring( 2, pos ); + head = head.substring( pos ); + break; + case 'C': + if ( head.indexOf( "&L" ) >= 0 ) + { + pos = Math.min( pos, head.indexOf( "&L" ) ); + } + if ( head.indexOf( "&R" ) >= 0 ) + { + pos = Math.min( pos, head.indexOf( "&R" ) ); + } + center = head.substring( 2, pos ); + head = head.substring( pos ); + break; + case 'R': + if ( head.indexOf( "&C" ) >= 0 ) + { + pos = Math.min( pos, head.indexOf( "&C" ) ); + } + if ( head.indexOf( "&L" ) >= 0 ) + { + pos = Math.min( pos, head.indexOf( "&L" ) ); + } + right = head.substring( 2, pos ); + head = head.substring( pos ); + break; + default : + head = null; + } + } + } + + /** + * Get the left side of the header. + * + * @return The string representing the left side. + */ + public String getLeft() + { + return left; + } + + /** + * Sets the left string. + * + * @param newLeft The string to set as the left side. + */ + public void setLeft( String newLeft ) + { + left = newLeft; + createHeaderString(); + } + + /** + * Get the center of the header. + * + * @return The string representing the center. + */ + public String getCenter() + { + return center; + } + + /** + * Sets the center string. + * + * @param newCenter The string to set as the center. + */ + public void setCenter( String newCenter ) + { + center = newCenter; + createHeaderString(); + } + + /** + * Get the right side of the header. + * + * @return The string representing the right side. + */ + public String getRight() + { + return right; + } + + /** + * Sets the right string. + * + * @param newRight The string to set as the right side. + */ + public void setRight( String newRight ) + { + right = newRight; + createHeaderString(); + } + + /** + * Creates the complete header string based on the left, center, and middle + * strings. + */ + private void createHeaderString() + { + headerRecord.setHeader( "&C" + ( center == null ? "" : center ) + + "&L" + ( left == null ? "" : left ) + + "&R" + ( right == null ? "" : right ) ); + headerRecord.setHeaderLength( (byte) headerRecord.getHeader().length() ); + } + + /** + * Returns the string that represents the change in font size. + * + * @param size the new font size + * @return The special string to represent a new font size + */ + public static String fontSize( short size ) + { + return "&" + size; + } + + /** + * Returns the string that represents the change in font. + * + * @param font the new font + * @param style the fonts style + * @return The special string to represent a new font size + */ + public static String font( String font, String style ) + { + return "&\"" + font + "," + style + "\""; + } + + /** + * Returns the string representing the current page number + * + * @return The special string for page number + */ + public static String page() + { + return "&P"; + } + + /** + * Returns the string representing the number of pages. + * + * @return The special string for the number of pages + */ + public static String numPages() + { + return "&N"; + } + + /** + * Returns the string representing the current date + * + * @return The special string for the date + */ + public static String date() + { + return "&D"; + } + + /** + * Returns the string representing the current time + * + * @return The special string for the time + */ + public static String time() + { + return "&T"; + } + + /** + * Returns the string representing the current file name + * + * @return The special string for the file name + */ + public static String file() + { + return "&F"; + } + + /** + * Returns the string representing the current tab (sheet) name + * + * @return The special string for tab name + */ + public static String tab() + { + return "&A"; + } } --------------------------------------------------------------------- To unsubscribe, e-mail: poi-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: poi-dev-help@jakarta.apache.org