From 6262fde7e29fe584625c8c81a541a5796f6404a2 Mon Sep 17 00:00:00 2001 From: Kevin Glynn Date: Mon, 21 Jun 2010 16:31:42 -0500 Subject: [PATCH] Sync from svn trunk --- .../System/Collections/IDictionary.xml | 5 + .../NetTranslations/System/DateTime.xml | 92 ++++++++++++++++++- .../NetTranslations/System/Environment.xml | 8 ++ .../NetTranslations/System/IDisposable.xml | 4 + CS2JLibrary/NetTranslations/System/String.xml | 10 +- .../System/Threading/Thread.xml | 10 ++ .../System/DateTimeSupport.java | 49 ++++++---- .../RusticiSoftware/System/IDisposable.java | 5 + .../System/Xml/XmlDocument.java | 63 +++++++------ .../RusticiSoftware/System/Xml/XmlNode.java | 42 ++++----- .../System/Xml/XmlTextReader.java | 54 ++++++----- .../System/Xml/Xsl/XslTransform.java | 44 ++++----- 12 files changed, 266 insertions(+), 120 deletions(-) create mode 100644 CS2JLibrary/src/RusticiSoftware/System/IDisposable.java diff --git a/CS2JLibrary/NetTranslations/System/Collections/IDictionary.xml b/CS2JLibrary/NetTranslations/System/Collections/IDictionary.xml index 564cf41..da580a7 100644 --- a/CS2JLibrary/NetTranslations/System/Collections/IDictionary.xml +++ b/CS2JLibrary/NetTranslations/System/Collections/IDictionary.xml @@ -18,6 +18,11 @@ Keys ${this}.keySet() + + System.Collections.ICollection + Values + ${this}.values() + diff --git a/CS2JLibrary/NetTranslations/System/DateTime.xml b/CS2JLibrary/NetTranslations/System/DateTime.xml index 8d38777..2010117 100755 --- a/CS2JLibrary/NetTranslations/System/DateTime.xml +++ b/CS2JLibrary/NetTranslations/System/DateTime.xml @@ -169,5 +169,95 @@ (new DateTZ(${this}.getTime(), TimeZone.getTimeZone("UTC"))) - + + System.DateTime + AddMinutes + + + System.Int32 + amount + + + + RusticiSoftware.System.DateTimeSupport + java.util.Calendar + + DateTimeSupport.add(${this},Calendar.MINUTE,${amount}) + + + System.DateTime + AddHours + + + System.Int32 + amount + + + + RusticiSoftware.System.DateTimeSupport + java.util.Calendar + + DateTimeSupport.add(${this},Calendar.HOUR,${amount}) + + + System.DateTime + AddMilliseconds + + + System.Int32 + amount + + + + RusticiSoftware.System.DateTimeSupport + java.util.Calendar + + DateTimeSupport.add(${this},Calendar.MILLISECOND,${amount}) + + + System.DateTime + AddSeconds + + + System.Int32 + amount + + + + RusticiSoftware.System.DateTimeSupport + java.util.Calendar + + DateTimeSupport.add(${this},Calendar.SECOND,${amount}) + + + System.DateTime + AddDays + + + System.Int32 + amount + + + + RusticiSoftware.System.DateTimeSupport + java.util.Calendar + + DateTimeSupport.add(${this},Calendar.DAY_OF_YEAR,${amount}) + + + System.DateTime + AddMonths + + + System.Int32 + amount + + + + RusticiSoftware.System.DateTimeSupport + java.util.Calendar + + DateTimeSupport.add(${this},Calendar.MONTH,${amount}) + + diff --git a/CS2JLibrary/NetTranslations/System/Environment.xml b/CS2JLibrary/NetTranslations/System/Environment.xml index 59e8ea5..ec759a7 100644 --- a/CS2JLibrary/NetTranslations/System/Environment.xml +++ b/CS2JLibrary/NetTranslations/System/Environment.xml @@ -12,5 +12,13 @@ System.String System.getProperty("line.separator") + + + java.net.InetAddress + + MachineName + System.String + InetAddress.getLocalHost().getHostName() + diff --git a/CS2JLibrary/NetTranslations/System/IDisposable.xml b/CS2JLibrary/NetTranslations/System/IDisposable.xml index f256831..7141ea0 100755 --- a/CS2JLibrary/NetTranslations/System/IDisposable.xml +++ b/CS2JLibrary/NetTranslations/System/IDisposable.xml @@ -3,6 +3,10 @@ xsi:SchemaLocation="http://www.w3.org/2001/XMLSchema file://C:/Documents%20and%20Settings/kevin.glynn/My%20Documents/CS2JLibrary/Translation.xsd" > System.IDisposable + IDisposable + + RusticiSoftware.System.IDisposable + System.Void diff --git a/CS2JLibrary/NetTranslations/System/String.xml b/CS2JLibrary/NetTranslations/System/String.xml index ee72a73..27cc26c 100755 --- a/CS2JLibrary/NetTranslations/System/String.xml +++ b/CS2JLibrary/NetTranslations/System/String.xml @@ -61,7 +61,10 @@ System.String - StringSupport.Compare(${arg1}, ${arg2)) + StringSupport.Compare(${arg1}, ${arg2}) + + RusticiSoftware.System.StringSupport + System.Int32 @@ -80,7 +83,10 @@ System.Bool - StringSupport.Compare(${arg1}, ${arg2), ${isCaseSensitive}) + StringSupport.Compare(${arg1}, ${arg2}, ${isCaseSensitive}) + + RusticiSoftware.System.StringSupport + System.String diff --git a/CS2JLibrary/NetTranslations/System/Threading/Thread.xml b/CS2JLibrary/NetTranslations/System/Threading/Thread.xml index ca58ac9..97c5c88 100755 --- a/CS2JLibrary/NetTranslations/System/Threading/Thread.xml +++ b/CS2JLibrary/NetTranslations/System/Threading/Thread.xml @@ -8,6 +8,11 @@ + + System.Boolean + IsAlive + ${this}.isAlive() + @@ -21,5 +26,10 @@ Thread.sleep(${sleepTime}) + + + Start + ${this}.start() + diff --git a/CS2JLibrary/src/RusticiSoftware/System/DateTimeSupport.java b/CS2JLibrary/src/RusticiSoftware/System/DateTimeSupport.java index 6e5289e..0a754ba 100755 --- a/CS2JLibrary/src/RusticiSoftware/System/DateTimeSupport.java +++ b/CS2JLibrary/src/RusticiSoftware/System/DateTimeSupport.java @@ -1,27 +1,28 @@ -/* - Copyright 2007-2010 Rustici Software, LLC - - Licensed 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. - - Author(s): - - Kevin Glynn (kevin.glynn@scorm.com) -*/ - +/* + Copyright 2007-2010 Rustici Software, LLC + + Licensed 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. + + Author(s): + + Kevin Glynn (kevin.glynn@scorm.com) +*/ + package RusticiSoftware.System; import java.text.ParseException; import java.text.SimpleDateFormat; +import java.util.Calendar; import java.util.Date; import java.util.Locale; @@ -125,5 +126,13 @@ public class DateTimeSupport { throw new ParseException("Could not parse " + s + " as a date", 0); } + + public static Date add(Date base,int field, int amount) + { + Calendar cal = Calendar.getInstance(); + cal.setTime(base); + cal.add(field, amount); + return cal.getTime(); + } } \ No newline at end of file diff --git a/CS2JLibrary/src/RusticiSoftware/System/IDisposable.java b/CS2JLibrary/src/RusticiSoftware/System/IDisposable.java new file mode 100644 index 0000000..40ff4ab --- /dev/null +++ b/CS2JLibrary/src/RusticiSoftware/System/IDisposable.java @@ -0,0 +1,5 @@ +package RusticiSoftware.System; + +public interface IDisposable { + void Dispose() throws Exception; +} diff --git a/CS2JLibrary/src/RusticiSoftware/System/Xml/XmlDocument.java b/CS2JLibrary/src/RusticiSoftware/System/Xml/XmlDocument.java index d0eb218..821fca0 100755 --- a/CS2JLibrary/src/RusticiSoftware/System/Xml/XmlDocument.java +++ b/CS2JLibrary/src/RusticiSoftware/System/Xml/XmlDocument.java @@ -1,23 +1,23 @@ -/* - Copyright 2007-2010 Rustici Software, LLC - - Licensed 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. - - Author(s): - - Kevin Glynn (kevin.glynn@scorm.com) -*/ - +/* + Copyright 2007-2010 Rustici Software, LLC + + Licensed 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. + + Author(s): + + Kevin Glynn (kevin.glynn@scorm.com) +*/ + package RusticiSoftware.System.Xml; import javax.xml.parsers.*; @@ -36,18 +36,21 @@ import java.io.StringReader; import java.util.logging.Level; import java.util.logging.Logger; +import org.w3c.dom.DOMImplementation; import org.w3c.dom.Document; -import org.xml.sax.InputSource; - -import com.sun.org.apache.xerces.internal.dom.DocumentImpl; public class XmlDocument extends XmlNode { private static Logger logger = Logger.getLogger("com.rusticisoftware.scormcontentplayer"); - public XmlDocument() + public XmlDocument() throws ParserConfigurationException { - setNode(new DocumentImpl()); + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + DOMImplementation impl = builder.getDOMImplementation(); + + Document doc = impl.createDocument(null,null,null); + setNode(doc); } public XmlDocument(Document d) { @@ -79,12 +82,12 @@ public class XmlDocument extends XmlNode { DocumentBuilder builder = factory.newDocumentBuilder(); setNode(builder.parse(r)); } - + // overload for translation from .net, which treats load() as namespace aware - public void load(InputStream r) throws ParserConfigurationException, SAXException, IOException - { - load(r,true); - } + public void load(InputStream r) throws ParserConfigurationException, SAXException, IOException + { + load(r,true); + } public void loadXml(String content) throws ParserConfigurationException, SAXException, IOException { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); diff --git a/CS2JLibrary/src/RusticiSoftware/System/Xml/XmlNode.java b/CS2JLibrary/src/RusticiSoftware/System/Xml/XmlNode.java index afcfa78..2a5685f 100755 --- a/CS2JLibrary/src/RusticiSoftware/System/Xml/XmlNode.java +++ b/CS2JLibrary/src/RusticiSoftware/System/Xml/XmlNode.java @@ -1,23 +1,23 @@ -/* - Copyright 2007-2010 Rustici Software, LLC - - Licensed 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. - - Author(s): - - Kevin Glynn (kevin.glynn@scorm.com) -*/ - +/* + Copyright 2007-2010 Rustici Software, LLC + + Licensed 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. + + Author(s): + + Kevin Glynn (kevin.glynn@scorm.com) +*/ + package RusticiSoftware.System.Xml; import java.io.IOException; @@ -28,8 +28,6 @@ import org.w3c.dom.*; import org.xml.sax.InputSource; import org.xml.sax.SAXException; -import com.sun.org.apache.xalan.internal.xsltc.runtime.AttributeList; - import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; diff --git a/CS2JLibrary/src/RusticiSoftware/System/Xml/XmlTextReader.java b/CS2JLibrary/src/RusticiSoftware/System/Xml/XmlTextReader.java index df6e09f..6808178 100644 --- a/CS2JLibrary/src/RusticiSoftware/System/Xml/XmlTextReader.java +++ b/CS2JLibrary/src/RusticiSoftware/System/Xml/XmlTextReader.java @@ -1,23 +1,23 @@ -/* - Copyright 2007-2010 Rustici Software, LLC - - Licensed 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. - - Author(s): - - Kevin Glynn (kevin.glynn@scorm.com) -*/ - +/* + Copyright 2007-2010 Rustici Software, LLC + + Licensed 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. + + Author(s): + + Kevin Glynn (kevin.glynn@scorm.com) +*/ + package RusticiSoftware.System.Xml; import java.io.IOException; @@ -31,17 +31,23 @@ import RusticiSoftware.System.Xml.XmlDocument; import RusticiSoftware.System.NotImplementedException; public class XmlTextReader { - protected XmlDocument xmlDocument = new XmlDocument(); + protected XmlDocument xmlDocument = null; + protected XmlDocument getXmlDocument() throws ParserConfigurationException { + if (xmlDocument == null) { + xmlDocument = new XmlDocument(); + } + return xmlDocument; + } public XmlTextReader() throws NotImplementedException { throw new NotImplementedException(); } public XmlTextReader(StringReader stringReader) throws NotImplementedException, ParserConfigurationException, SAXException, IOException { - xmlDocument.load(stringReader); + getXmlDocument().load(stringReader); } - public String ToString() { - return xmlDocument.getOuterXml(); + public String ToString() throws ParserConfigurationException { + return getXmlDocument().getOuterXml(); } } diff --git a/CS2JLibrary/src/RusticiSoftware/System/Xml/Xsl/XslTransform.java b/CS2JLibrary/src/RusticiSoftware/System/Xml/Xsl/XslTransform.java index f9fd5ca..e592839 100644 --- a/CS2JLibrary/src/RusticiSoftware/System/Xml/Xsl/XslTransform.java +++ b/CS2JLibrary/src/RusticiSoftware/System/Xml/Xsl/XslTransform.java @@ -1,29 +1,31 @@ -/* - Copyright 2007-2010 Rustici Software, LLC - - Licensed 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. - - Author(s): - - Kevin Glynn (kevin.glynn@scorm.com) -*/ - +/* + Copyright 2007-2010 Rustici Software, LLC + + Licensed 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. + + Author(s): + + Kevin Glynn (kevin.glynn@scorm.com) +*/ + package RusticiSoftware.System.Xml.Xsl; // // This is now a wrapper for XslCompiledTransform because that has superseded XslTransform going to .Net 2.0 import java.io.StringWriter; import java.io.StringReader; + +import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.stream.StreamSource; import javax.xml.transform.stream.StreamResult; import javax.xml.transform.Transformer; @@ -40,7 +42,7 @@ public class XslTransform { } - public void load(XmlTextReader xmlTextReader, String ignore, String ignore2) throws TransformerConfigurationException { + public void load(XmlTextReader xmlTextReader, String ignore, String ignore2) throws TransformerConfigurationException, ParserConfigurationException { String xmlString = xmlTextReader.ToString(); StringReader stringReader = new StringReader(xmlString); StreamSource streamSource = new StreamSource(stringReader);