mirror of
https://github.com/twiglet/cs2j.git
synced 2025-01-18 13:15:17 +01:00
merge from rustici cs2j_two branch to 431fb7d3c6d22669a8ec51d3421dacc10dc7b217
This commit is contained in:
parent
86bacb0014
commit
f6e7958041
@ -118,8 +118,10 @@
|
||||
<Return>System.Void</Return>
|
||||
</Method>
|
||||
<Method>
|
||||
<Imports />
|
||||
<Java>${this:16}.reverse()</Java>
|
||||
<Imports>
|
||||
<Import>java.util.Collections</Import>
|
||||
</Imports>
|
||||
<Java>Collections.reverse(${this:16})</Java>
|
||||
<Params>
|
||||
</Params>
|
||||
<Name>Reverse</Name>
|
||||
@ -171,7 +173,7 @@
|
||||
</Params>
|
||||
<Type>System.Object</Type>
|
||||
<Get>${this:16}.get(${i})</Get>
|
||||
<Set>${this:16}.add(${i}, ${value})</Set>
|
||||
<Set>${this:16}.set(${i}, ${value})</Set>
|
||||
</Indexer>
|
||||
</Indexers>
|
||||
<Constructors>
|
||||
|
@ -23,6 +23,13 @@
|
||||
<Java>${expr}</Java>
|
||||
</Iterable>
|
||||
<Properties>
|
||||
<Property>
|
||||
<Imports />
|
||||
<Java>${this:16}.size()</Java>
|
||||
<Type>System.Int32</Type>
|
||||
<Name>Count</Name>
|
||||
<Get>${this:16}.size()</Get>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Methods>
|
||||
<Method>
|
||||
|
@ -99,5 +99,12 @@
|
||||
<Name>Values</Name>
|
||||
<Get>${this:16}.values()</Get>
|
||||
</Property>
|
||||
<Property>
|
||||
<Imports />
|
||||
<Java>${this:16}.size()</Java>
|
||||
<Type>System.Int32</Type>
|
||||
<Name>Count</Name>
|
||||
<Get>${this:16}.size()</Get>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#"><SignedInfo><CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315" /><SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" /><Reference URI=""><Transforms><Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" /></Transforms><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" /><DigestValue>BBHaGzWIzkVajkMtIotxcu6p5VY=</DigestValue></Reference></SignedInfo><SignatureValue>WOOzmkxA0yBm1tFVetTcQxQc7SztNyQygCPbn5vaHLtHI/MoQMuTuytu5BrGb4UJ7KG68galgfmWUlUD99Txs44X+XdHA7wY0XcAUwXHV+/uti6FicyhHw7mDr9Bj4+Rjq4RIA2I0gS5P25V9nMEIEQCD3/jjc+wc4Lt5AHw/b4=</SignatureValue></Signature></Interface>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
|
||||
This file is
|
||||
@ -125,7 +125,7 @@
|
||||
<Return>System.Void</Return>
|
||||
</Method>
|
||||
<Method>
|
||||
<Java>${this:16}.toArray(new ${T}[${this}.size()])</Java>
|
||||
<Java>((${T}[]) ${this:16}.toArray())</Java>
|
||||
<Params>
|
||||
</Params>
|
||||
<Name>ToArray</Name>
|
||||
|
@ -9,9 +9,9 @@
|
||||
-->
|
||||
<Class xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:www.twigletsoftware.com:schemas:txtemplate:1:0">
|
||||
<Imports>
|
||||
<Import>javax.mail.internet.InternetAddress</Import>
|
||||
<Import>CS2JNet.System.Net.Mail.MailAddress</Import>
|
||||
</Imports>
|
||||
<Java>InternetAddress</Java>
|
||||
<Java>MailAddress</Java>
|
||||
<Name>System.Net.Mail.MailAddress</Name>
|
||||
<Uses />
|
||||
<Inherits>
|
||||
@ -24,9 +24,9 @@
|
||||
<Constructors>
|
||||
<Constructor>
|
||||
<Imports>
|
||||
<Import>javax.mail.internet.InternetAddress</Import>
|
||||
<Import>CS2JNet.System.Net.Mail.MailAddress</Import>
|
||||
</Imports>
|
||||
<Java>new InternetAddress(${address})</Java>
|
||||
<Java>new MailAddress(${address})</Java>
|
||||
<Params>
|
||||
<Param>
|
||||
<Type>System.String</Type>
|
||||
|
@ -26,6 +26,15 @@
|
||||
</Params>
|
||||
<Name>Equals</Name>
|
||||
<Return>System.Boolean</Return>
|
||||
</Method>
|
||||
<!-- added for Array.clone support, but since in java this is on Object, should be at System.Object level in
|
||||
translation for those .net objects which have Clone().-->
|
||||
<Method>
|
||||
<Imports />
|
||||
<Java>${this:16}.clone(${obj})</Java>
|
||||
<Params />
|
||||
<Name>Clone</Name>
|
||||
<Return>System.Object</Return>
|
||||
</Method>
|
||||
<Method>
|
||||
<Imports />
|
||||
@ -60,6 +69,24 @@
|
||||
<Name>GetHashCode</Name>
|
||||
<Return>System.Int</Return>
|
||||
</Method>
|
||||
<Method>
|
||||
<Imports>
|
||||
<Import>CS2JNet.System.ObjectSupport</Import>
|
||||
</Imports>
|
||||
<Java>ObjectSupport.Equals(${obj1}, ${obj2})</Java>
|
||||
<Params>
|
||||
<Param>
|
||||
<Type>System.Object</Type>
|
||||
<Name>obj1</Name>
|
||||
</Param>
|
||||
<Param>
|
||||
<Type>System.Object</Type>
|
||||
<Name>obj2</Name>
|
||||
</Param>
|
||||
</Params>
|
||||
<Name>Equals</Name>
|
||||
<Return>System.Boolean</Return>
|
||||
</Method>
|
||||
</Methods>
|
||||
<Properties />
|
||||
<Events />
|
||||
|
@ -40,10 +40,7 @@
|
||||
<Return>System.Int32</Return>
|
||||
</Method>
|
||||
<Method>
|
||||
<Imports>
|
||||
<Import>CS2JNet.System.StringSupport</Import>
|
||||
</Imports>
|
||||
<Java>StringSupport.Compare(${arg1}, ${this})</Java>
|
||||
<Java>${this:16}.compareTo(${arg1})</Java>
|
||||
<Params>
|
||||
<Param>
|
||||
<Type>System.String</Type>
|
||||
@ -68,7 +65,7 @@
|
||||
<Name>arg2</Name>
|
||||
</Param>
|
||||
<Param>
|
||||
<Type>System.Bool</Type>
|
||||
<Type>System.Boolean</Type>
|
||||
<Name>isCaseSensitive</Name>
|
||||
</Param>
|
||||
</Params>
|
||||
|
@ -115,6 +115,17 @@
|
||||
<Name>GetTypeCode</Name>
|
||||
<Return>System.TypeCode</Return>
|
||||
</Method>
|
||||
<Method>
|
||||
<Return>System.Boolean</Return>
|
||||
<Name>IsAssignableFrom</Name>
|
||||
<Params>
|
||||
<Param>
|
||||
<Name>arg1</Name>
|
||||
<Type>System.Type</Type>
|
||||
</Param>
|
||||
</Params>
|
||||
<Java>${this:16}.isAssignableFrom(${arg1})</Java>
|
||||
</Method>
|
||||
</Methods>
|
||||
<Properties>
|
||||
<Property>
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2007,2008,2009,2010 Rustici Software, LLC
|
||||
Copyright 2007,2008,2009,2010 Rustici Software, LLC
|
||||
Copyright 2010,2011 Kevin Glynn (kevin.glynn@twigletsoftware.com)
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@ -33,7 +33,7 @@ import CS2JNet.JavaSupport.util.LocaleSupport;
|
||||
public class DateTimeSupport {
|
||||
|
||||
public static String ToString(Date d, String format, Locale loc) {
|
||||
|
||||
|
||||
SimpleDateFormat formatter = null;
|
||||
if (format.equals("s")) {
|
||||
//TODO: Is this really a db-friendly sortable format?
|
||||
@ -43,14 +43,22 @@ public class DateTimeSupport {
|
||||
formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss'Z'", loc);
|
||||
} else if (format.equals("yyyy-MM-ddTHH:mm:ss.ffZ")) {
|
||||
formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SS'Z'", loc);
|
||||
} else {
|
||||
formatter = new SimpleDateFormat(format, loc);
|
||||
} else if (format.equals("yyyy-MM-ddTHH:mm:ss.fffZ")) {
|
||||
formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", loc);
|
||||
} else if (format.equals("ddd',' dd MMM yyyy HH':'mm':'ss'.'fff GMT")) {
|
||||
formatter = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss.SSS 'GMT'");
|
||||
} else {
|
||||
formatter = new SimpleDateFormat(format, loc);
|
||||
}
|
||||
|
||||
if (formatter.toPattern().contains("'Z'") || formatter.toPattern().contains("'GMT'")){
|
||||
formatter.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
}
|
||||
|
||||
|
||||
if (d instanceof DateTZ) {
|
||||
formatter.setTimeZone(((DateTZ)d).getTimeZone());
|
||||
}
|
||||
|
||||
|
||||
return formatter.format(d);
|
||||
}
|
||||
|
||||
@ -75,10 +83,14 @@ public class DateTimeSupport {
|
||||
private static final String[] DATE_FORMATS = new String[] {
|
||||
"E MMM d HH:mm:ss Z yyyy",
|
||||
"MM/dd/yyyy HH:mm:ss a",
|
||||
"yyyy-MM-dd HH:mm:ss'Z'",
|
||||
"yyyy-MM-dd'T'HH:mm:ss.SSSZ",
|
||||
"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'",
|
||||
"yyyy-MM-dd'T'HH:mm:ssZ",
|
||||
"yyyy-MM-dd'T'HH:mm:ss'Z'",
|
||||
"yyyy-MM-dd'T'HH:mm:ss'.'SSSZ",
|
||||
"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'",
|
||||
"yyyy-MM-dd'T'HH:mm:ss",
|
||||
"yyyy-MM-dd HH:mm:ss'Z'",
|
||||
"yyyy-MM-dd"};
|
||||
|
||||
public static Date parse(String s) throws ParseException
|
||||
@ -92,21 +104,21 @@ public class DateTimeSupport {
|
||||
return parse(val, DATE_FORMATS, Locale.getDefault(), utc);
|
||||
}
|
||||
|
||||
protected static String trimMilliSecondsToThreeDigits(String dateString){
|
||||
String val = dateString;
|
||||
if(val != null){
|
||||
int milliStart = val.lastIndexOf(".");
|
||||
if(milliStart != -1){
|
||||
milliStart = milliStart + 1;
|
||||
int milliEnd = val.lastIndexOf("Z");
|
||||
milliEnd = (milliEnd == -1) ? val.length() : milliEnd;
|
||||
if((milliEnd - milliStart) > 3){
|
||||
String newMillis = val.substring(milliStart).substring(0, 3);
|
||||
val = val.substring(0, milliStart) + newMillis + val.substring(milliEnd, val.length());
|
||||
}
|
||||
}
|
||||
}
|
||||
return val;
|
||||
protected static String trimMilliSecondsToThreeDigits(String dateString){
|
||||
String val = dateString;
|
||||
if(val != null){
|
||||
int milliStart = val.lastIndexOf(".");
|
||||
if(milliStart != -1){
|
||||
milliStart = milliStart + 1;
|
||||
int milliEnd = Math.max(val.lastIndexOf("+"), val.lastIndexOf("Z"));
|
||||
milliEnd = (milliEnd == -1) ? val.length() : milliEnd;
|
||||
if((milliEnd - milliStart) > 3){
|
||||
String newMillis = val.substring(milliStart).substring(0, 3);
|
||||
val = val.substring(0, milliStart) + newMillis + val.substring(milliEnd, val.length());
|
||||
}
|
||||
}
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
public static Date parse(String s, String f) throws ParseException
|
||||
@ -132,7 +144,7 @@ public class DateTimeSupport {
|
||||
try
|
||||
{
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(f);
|
||||
if(utc){
|
||||
if(utc || f.contains("Z")){
|
||||
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
}
|
||||
Date d = sdf.parse(s);
|
||||
@ -167,7 +179,7 @@ public class DateTimeSupport {
|
||||
cal.add(field, amount);
|
||||
return cal.getTime();
|
||||
}
|
||||
|
||||
|
||||
public static boolean equals(Date d1, Date d2) {
|
||||
return d1 == d2 || (d1 != null && d2 != null && d1.getTime() == d2.getTime());
|
||||
}
|
||||
|
11
CS2JLibrary/src/CS2JNet/System/ObjectSupport.java
Normal file
11
CS2JLibrary/src/CS2JNet/System/ObjectSupport.java
Normal file
@ -0,0 +1,11 @@
|
||||
package CS2JNet.System;
|
||||
|
||||
public class ObjectSupport {
|
||||
public static boolean Equals(Object obj1, Object obj2) {
|
||||
if (obj1 == null) {
|
||||
return obj2 == null;
|
||||
} else {
|
||||
return obj1.equals(obj2);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user