1
0
mirror of https://github.com/twiglet/cs2j.git synced 2025-01-18 13:15:17 +01:00

take updates from ScormEngine codebase

This commit is contained in:
Kevin Glynn 2012-01-07 16:38:25 +01:00
parent e107488078
commit ea9e609506
10 changed files with 177 additions and 123 deletions

View File

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<runtime name="JVM 1.6.0 (MacOS X Default)"/>
</faceted-project>

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is
@ -117,6 +117,14 @@
<Name>RemoveAt</Name>
<Return>System.Void</Return>
</Method>
<Method>
<Imports />
<Java>${this:16}.reverse()</Java>
<Params>
</Params>
<Name>Reverse</Name>
<Return>System.Void</Return>
</Method>
<Method>
<Imports>
<Import>CS2JNet.System.Collections.ArrayListSupport</Import>

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is
@ -244,6 +244,12 @@
</Method>
</Methods>
<Properties>
<Property>
<Java>Calendar.getInstance().getTime()</Java>
<Type>System.DateTime</Type>
<Name>MinDate</Name>
<Get>new Date(Long.MIN_VALUE)</Get>
</Property>
<Property>
<Imports>
<Import>java.util.Calendar</Import>

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is
@ -18,7 +18,13 @@
<Type>System.Object</Type>
</Inherits>
<Methods />
<Properties />
<Properties>
<Property>
<Type>System.String</Type>
<Name>HttpMethod</Name>
<Get>${this:16}.getMethod()</Get>
</Property>
</Properties>
<Events />
<Indexers />
<Constructors />

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is
@ -17,7 +17,23 @@
<Inherits>
<Type>System.Object</Type>
</Inherits>
<Methods />
<Methods>
<Method>
<Return>System.Void</Return>
<Name>AddHeader</Name>
<Params>
<Param>
<Type>System.String</Type>
<Name>name</Name>
</Param>
<Param>
<Type>System.String</Type>
<Name>value</Name>
</Param>
</Params>
<Java>${this:16}.setHeader(${name},${value})</Java>
</Method>
</Methods>
<Properties />
<Events />
<Indexers />

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is
@ -14,7 +14,9 @@
<Java>XmlAttributeCollection</Java>
<Name>System.Xml.XmlAttributeCollection</Name>
<Uses />
<Inherits> <Type>System.Object</Type> </Inherits>
<Inherits>
<Type>System.Object</Type>
</Inherits>
<Methods>
<Method>
<Imports />

View File

@ -1,110 +1,115 @@
<project name="cs2jsupport" default="package" basedir=".">
<description>
This build file builds and packages the CS2J Support
library into a jar file.
</description>
<project name="cs2jsupport" default="package" basedir=".">
<description>
This build file builds and packages the CS2J Support
library into a jar file.
</description>
<property file="${user.home}/${ant.project.name}.build.properties" />
<property file="${user.home}/build.properties" />
<property file="build.properties" />
<tstamp>
<format property="timestamp.isoformat" pattern="yyyy-MM-dd'T'HH:mm:ss" />
</tstamp>
<property file="build.properties" />
<target name="revision" unless="svn.revision">
<exec executable="svnversion" outputproperty="svn.revision">
<arg value="." />
<tstamp>
<format property="timestamp.isoformat" pattern="yyyy-MM-dd'T'HH:mm:ss" />
</tstamp>
<target name="revision" unless="git.revision">
<exec executable="git" outputproperty="git.revision">
<arg value="rev-parse" />
<arg value="HEAD" />
</exec>
<echo message="_REVISION_=${svn.revision}" />
<exec executable="git" outputproperty="git.branch">
<arg value="name-rev" />
<arg value="--name-only" />
<arg value="--always" />
<arg value="${git.revision}" />
</exec>
<echo message="At revision ${git.revision} on branch ${git.branch}." />
</target>
<target name="package" depends="compile,revision">
<mkdir dir="${jar.dir}" />
<target name="package" depends="compile,revision">
<mkdir dir="${jar.dir}" />
<jar destfile="${jar.dir}/${ant.project.name}.jar" index="true">
<fileset dir="${classes.dir}/${ant.project.name}" id="jar.files">
<include name="**/*.class" />
</fileset>
<fileset dir="${src.dir}">
<include name="**/*.xsl" />
</fileset>
<metainf dir="${basedir}">
<include name="LICENSE" />
<include name="NOTICE" />
</metainf>
<manifest>
<fileset dir="${src.dir}">
<include name="**/*.xsl" />
</fileset>
<metainf dir="${basedir}">
<include name="LICENSE" />
<include name="NOTICE" />
</metainf>
<manifest>
<attribute name="Built-By" value="${user.name}" />
<attribute name="Built-On" value="${timestamp.isoformat}" />
</manifest>
</jar>
<!-- And copy any 3rd party jars needed by cs2j. -->
<copy todir="${jar.dir}">
<fileset dir="${basedir}/lib">
<include name="**/*.jar" />
</fileset>
</copy>
</target>
<target name="src" description="Make a source distribution">
<mkdir dir="${zip.dir}" />
<exec executable="git" outputproperty="build.version">
<arg line="describe"/>
</exec>
<property name="src.zip" value="${zip.dir}/cs2jlibrary-src-${build.version}.zip"/>
<zip destfile="${src.zip}">
<fileset dir="${basedir}">
<include name="src/**/*" />
<include name="LICENSE" />
<include name="NOTICE" />
<include name="build.*" />
<include name=".project" />
<include name=".classpath" />
<include name="lib/*" />
</fileset>
</zip>
</target>
<target name="clean-package" depends="clean,package">
</target>
<target name="compile" depends="init">
<echo message="Compiling Source files from ${basedir}/${src.dir}" />
<javac
srcdir="${src.dir}/"
includes="**/*.java"
excludes=""
destdir="${classes.dir}/${ant.project.name}"
fork="true"
deprecation="false"
debug="true"
memoryMaximumSize="512m"
nowarn="true"
target="${java.target.vm}">
<classpath>
<fileset dir="${lib.dir}">
<include name="**/*.jar" />
</fileset>
</classpath>
</javac>
</target>
<target name="init" depends="">
<mkdir dir="${build.dir}" />
<mkdir dir="${classes.dir}/${ant.project.name}" />
</target>
<attribute name="Git-Branch" value="${git.branch}" />
<attribute name="Git-Revision" value="${git.revision}" />
</manifest>
</jar>
<!-- And copy any 3rd party jars needed by cs2j. -->
<copy todir="${jar.dir}">
<fileset dir="${basedir}/lib">
<include name="**/*.jar" />
</fileset>
</copy>
</target>
<target name="src" description="Make a source distribution">
<mkdir dir="${zip.dir}" />
<zip destfile="${src.zip}">
<fileset dir="${basedir}">
<include name="src/**/*" />
<include name="LICENSE" />
<include name="NOTICE" />
<include name="build.*" />
<include name=".project" />
<include name=".classpath" />
<include name="lib/*" />
</fileset>
</zip>
</target>
<target name="clean-package" depends="clean,package">
</target>
<target name="compile" depends="init">
<echo message="Compiling Source files from ${basedir}/${src.dir}" />
<javac
srcdir="${src.dir}/"
includes="**/*.java"
excludes=""
destdir="${classes.dir}/${ant.project.name}"
fork="true"
deprecation="false"
debug="true"
memoryMaximumSize="512m"
nowarn="true"
target="${java.target.vm}">
<classpath>
<fileset dir="${lib.dir}">
<include name="**/*.jar" />
</fileset>
</classpath>
</javac>
</target>
<target name="init" depends="">
<mkdir dir="${build.dir}" />
<mkdir dir="${classes.dir}/${ant.project.name}" />
</target>
<target name="clean" depends="">
<delete failonerror="false" dir="${build.dir}" />
</target>
<target name="deploy" depends="package">
<copy file="${jar.dir}/${ant.project.name}.jar" todir="${export.dir}" />
</target>
<target name="dumpProperties" description="output all set properties, a useful sanity check">
<echoproperties/>
</target>
</project>
<delete failonerror="false" dir="${build.dir}" />
</target>
<target name="deploy" depends="package">
<copy file="${jar.dir}/${ant.project.name}.jar" todir="${export.dir}" />
</target>
<target name="dumpProperties" description="output all set properties, a useful sanity check">
<echoproperties/>
</target>
</project>

View File

@ -26,6 +26,7 @@ import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
import CS2JNet.JavaSupport.util.LocaleSupport;
@ -81,11 +82,16 @@ public class DateTimeSupport {
"yyyy-MM-dd"};
public static Date parse(String s) throws ParseException
{
{
return parse(s, false);
}
public static Date parse(String s, boolean utc) throws ParseException
{
String val = trimMilliSecondsToThreeDigits(s);
return parse(val, DATE_FORMATS, Locale.getDefault());
}
return parse(val, DATE_FORMATS, Locale.getDefault(), utc);
}
protected static String trimMilliSecondsToThreeDigits(String dateString){
String val = dateString;
if(val != null){
@ -115,12 +121,21 @@ public class DateTimeSupport {
}
public static Date parse(String s, String[] formats, Locale loc) throws ParseException
{
{
return parse(s, formats, loc, false);
}
public static Date parse(String s, String[] formats, Locale loc, boolean utc) throws ParseException
{
for (String f : formats)
{
try
{
Date d = (new SimpleDateFormat(f)).parse(s);
SimpleDateFormat sdf = new SimpleDateFormat(f);
if(utc){
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
}
Date d = sdf.parse(s);
// System.out.println("Date: "+ d.toString());
return d;
}

View File

@ -109,7 +109,7 @@ public class DirectorySupport {
String[] allFilePaths = new String[allFiles.length];
for (int i = 0; i < allFilePaths.length; i++) {
allFilePaths[i] = allFiles[i].getCanonicalPath();
allFilePaths[i] = allFiles[i].getAbsolutePath();
}
return allFilePaths;
@ -131,7 +131,7 @@ public class DirectorySupport {
File[] matchDirs = new File(path).listFiles(DirectorySupport.dirFilter(patternComponents[0]));
for (File d : matchDirs)
{
allMatches.addAll(Arrays.asList(getFiles(d.getCanonicalPath(),patternComponents[1])));
allMatches.addAll(Arrays.asList(getFiles(d.getAbsolutePath(),patternComponents[1])));
}
}
@ -142,7 +142,7 @@ public class DirectorySupport {
for (int i = 0; i < allFiles.length; i++)
{
allMatches.add(i,((File)allFiles[i]).getCanonicalPath());
allMatches.add(i,((File)allFiles[i]).getAbsolutePath());
}
}
@ -159,7 +159,7 @@ public class DirectorySupport {
String[] allDirPaths = new String[allDirs.length];
for (int i = 0; i < allDirPaths.length; i++) {
allDirPaths[i] = allDirs[i].getCanonicalPath();
allDirPaths[i] = allDirs[i].getAbsolutePath();
}
return allDirPaths;

View File

@ -259,8 +259,8 @@ public class XmlNode implements Iterable {
{
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Node dummyD = builder.parse(new InputSource(new StringReader("<DUMMY>" + value + "</DUMMY>")));
Node importableNode = getNode().getOwnerDocument().importNode(dummyD.getFirstChild(), true);
Document dummyDoc = builder.parse(new InputSource(new StringReader("<DUMMY>" + value + "</DUMMY>")));
Node importableNode = getNode().getOwnerDocument().importNode(dummyDoc.getDocumentElement(), true);
Node myNode = getNode();
// First we remove all existing children
@ -273,7 +273,7 @@ public class XmlNode implements Iterable {
}
// Now we insert the new children
child = importableNode.getLastChild();
child = importableNode.getFirstChild();
while (child != null)
{
Node tmp = child;