Return-Path: Delivered-To: apmail-poi-commits-archive@locus.apache.org Received: (qmail 80630 invoked from network); 16 Mar 2008 16:52:28 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 16 Mar 2008 16:52:28 -0000 Received: (qmail 54459 invoked by uid 500); 16 Mar 2008 16:52:26 -0000 Delivered-To: apmail-poi-commits-archive@poi.apache.org Received: (qmail 54413 invoked by uid 500); 16 Mar 2008 16:52:25 -0000 Mailing-List: contact commits-help@poi.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@poi.apache.org Delivered-To: mailing list commits@poi.apache.org Received: (qmail 54404 invoked by uid 99); 16 Mar 2008 16:52:25 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 16 Mar 2008 09:52:25 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 16 Mar 2008 16:51:55 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 696961A9832; Sun, 16 Mar 2008 09:52:06 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r637610 - in /poi/branches/ooxml/src/ooxml: interfaces-jdk14/org/apache/poi/ss/usermodel/ interfaces-jdk15/org/apache/poi/ss/usermodel/ java/org/apache/poi/xssf/usermodel/ Date: Sun, 16 Mar 2008 16:52:04 -0000 To: commits@poi.apache.org From: nick@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080316165206.696961A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: nick Date: Sun Mar 16 09:51:58 2008 New Revision: 637610 URL: http://svn.apache.org/viewvc?rev=637610&view=rev Log: Further workarounds for java being rubbish, by having a dedicated class to create concrete instances of interfaces for you Added: poi/branches/ooxml/src/ooxml/interfaces-jdk14/org/apache/poi/ss/usermodel/CreationHelper.java (with props) poi/branches/ooxml/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/CreationHelper.java (with props) poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCreationHelper.java (with props) poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDataFormat.java (with props) Modified: poi/branches/ooxml/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Cell.java poi/branches/ooxml/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/DataFormat.java poi/branches/ooxml/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Workbook.java poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java Added: poi/branches/ooxml/src/ooxml/interfaces-jdk14/org/apache/poi/ss/usermodel/CreationHelper.java URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/interfaces-jdk14/org/apache/poi/ss/usermodel/CreationHelper.java?rev=637610&view=auto ============================================================================== --- poi/branches/ooxml/src/ooxml/interfaces-jdk14/org/apache/poi/ss/usermodel/CreationHelper.java (added) +++ poi/branches/ooxml/src/ooxml/interfaces-jdk14/org/apache/poi/ss/usermodel/CreationHelper.java Sun Mar 16 09:51:58 2008 @@ -0,0 +1,19 @@ +/* ==================================================================== + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +==================================================================== */ +package org.apache.poi.ss.usermodel; + +public interface CreationHelper {} Propchange: poi/branches/ooxml/src/ooxml/interfaces-jdk14/org/apache/poi/ss/usermodel/CreationHelper.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: poi/branches/ooxml/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Cell.java URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Cell.java?rev=637610&r1=637609&r2=637610&view=diff ============================================================================== --- poi/branches/ooxml/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Cell.java (original) +++ poi/branches/ooxml/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Cell.java Sun Mar 16 09:51:58 2008 @@ -154,17 +154,6 @@ String getCellFormula(); /** - * Creates a RichTextString, which you can then pass to - * {@link #setCellValue(RichTextString)}. This is required - * because Java is broken, and won't allow you to define - * static methods or constructors on interfaces, and without - * that there's no way to get a RichTextString without - * creating the appropriate concrete class. - * @param text The text to initialise the RichTextString with - */ - RichTextString createRichTextString(String text); - - /** * get the value of the cell as a number. For strings we throw an exception. * For blank cells we return a 0. */ Added: poi/branches/ooxml/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/CreationHelper.java URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/CreationHelper.java?rev=637610&view=auto ============================================================================== --- poi/branches/ooxml/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/CreationHelper.java (added) +++ poi/branches/ooxml/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/CreationHelper.java Sun Mar 16 09:51:58 2008 @@ -0,0 +1,42 @@ +/* ==================================================================== + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +==================================================================== */ +package org.apache.poi.ss.usermodel; + +/** + * An object that handles instantiating concrete + * classes of the various instances one needs for + * HSSF and XSSF. + * Works around a major shortcoming in Java, where we + * can't have static methods on interfaces or abstract + * classes. + * This allows you to get the appropriate class for + * a given interface, without you having to worry + * about if you're dealing with HSSF or XSSF, despite + * Java being quite rubbish. + */ +public interface CreationHelper { + /** + * Creates a new RichTextString instance + * @param text The text to initialise the RichTextString with + */ + RichTextString createRichTextString(String text); + + /** + * Creates a new DataFormat instance + */ + DataFormat createDataFormat(); +} \ No newline at end of file Propchange: poi/branches/ooxml/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/CreationHelper.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: poi/branches/ooxml/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/DataFormat.java URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/DataFormat.java?rev=637610&r1=637609&r2=637610&view=diff ============================================================================== --- poi/branches/ooxml/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/DataFormat.java (original) +++ poi/branches/ooxml/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/DataFormat.java Sun Mar 16 09:51:58 2008 @@ -18,14 +18,12 @@ package org.apache.poi.ss.usermodel; public interface DataFormat { - /** * get the format index that matches the given format string. * Creates a new format if one is not found. Aliases text to the proper format. * @param format string matching a built in format * @return index of format. */ - short getFormat(String format); /** @@ -33,7 +31,5 @@ * @param index of a format * @return string represented at index of format or null if there is not a format at that index */ - String getFormat(short index); - } Modified: poi/branches/ooxml/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Workbook.java URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Workbook.java?rev=637610&r1=637609&r2=637610&view=diff ============================================================================== --- poi/branches/ooxml/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Workbook.java (original) +++ poi/branches/ooxml/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Workbook.java Sun Mar 16 09:51:58 2008 @@ -455,4 +455,13 @@ */ List getAllEmbeddedObjects(); + /** + * Returns an object that handles instantiating concrete + * classes of the various instances one needs for + * HSSF and XSSF. + * Works around a major shortcoming in Java, where we + * can't have static methods on interfaces or abstract + * classes. + */ + CreationHelper getCreationHelper(); } Added: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCreationHelper.java URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCreationHelper.java?rev=637610&view=auto ============================================================================== --- poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCreationHelper.java (added) +++ poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCreationHelper.java Sun Mar 16 09:51:58 2008 @@ -0,0 +1,43 @@ +/* ==================================================================== + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +==================================================================== */ +package org.apache.poi.xssf.usermodel; + +import org.apache.poi.ss.usermodel.CreationHelper; +import org.apache.poi.ss.usermodel.DataFormat; +import org.apache.poi.ss.usermodel.RichTextString; + +public class XSSFCreationHelper implements CreationHelper { + private XSSFWorkbook workbook; + private XSSFDataFormat dataFormat; + XSSFCreationHelper(XSSFWorkbook wb) { + workbook = wb; + + // Create the things we only ever need one of + dataFormat = new XSSFDataFormat(); + } + + /** + * Creates a new XSSFRichTextString for you. + */ + public RichTextString createRichTextString(String text) { + return new XSSFRichTextString(text); + } + + public DataFormat createDataFormat() { + return dataFormat; + } +} Propchange: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCreationHelper.java ------------------------------------------------------------------------------ svn:eol-style = native Added: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDataFormat.java URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDataFormat.java?rev=637610&view=auto ============================================================================== --- poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDataFormat.java (added) +++ poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDataFormat.java Sun Mar 16 09:51:58 2008 @@ -0,0 +1,32 @@ +/* ==================================================================== + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +==================================================================== */ +package org.apache.poi.xssf.usermodel; + +import org.apache.poi.ss.usermodel.DataFormat; + +/** + * TODO - figure out how this should really work for XSSF + */ +public class XSSFDataFormat implements DataFormat { + public short getFormat(String format) { + return -1; + } + + public String getFormat(short index) { + return null; + } +} Propchange: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDataFormat.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java?rev=637610&r1=637609&r2=637610&view=diff ============================================================================== --- poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java (original) +++ poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java Sun Mar 16 09:51:58 2008 @@ -27,6 +27,7 @@ import org.apache.poi.POIXMLDocument; import org.apache.poi.ss.usermodel.CellStyle; +import org.apache.poi.ss.usermodel.CreationHelper; import org.apache.poi.ss.usermodel.DataFormat; import org.apache.poi.ss.usermodel.Font; import org.apache.poi.ss.usermodel.Name; @@ -533,4 +534,7 @@ this.sharedStringSource = sharedStringSource; } + public CreationHelper getCreationHelper() { + return new XSSFCreationHelper(this); + } } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org For additional commands, e-mail: commits-help@poi.apache.org