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

Merge from rustici/trunk:

------------------------------------------------------------------------
r13498 | ben.clark | 2010-08-20 23:04:52 +0200 (Fri, 20 Aug 2010) | 1 line

support for trimmed empty check w/o performing trim (avoid associated copy)
------------------------------------------------------------------------
r13354 | ben.clark | 2010-08-04 23:34:47 +0200 (Wed, 04 Aug 2010) | 1 line

fix for ontime 334, 'N#' format support
------------------------------------------------------------------------
r13303 | ben.clark | 2010-08-02 18:53:11 +0200 (Mon, 02 Aug 2010) | 1 line

fixed infinite loop in recurive directory delete
------------------------------------------------------------------------
r13222 | ben.clark | 2010-07-22 16:09:51 +0200 (Thu, 22 Jul 2010) | 1 line

need to know if an entry is a directory or not, to avoid writing directory entries as files
------------------------------------------------------------------------
r13200 | ben.clark | 2010-07-20 16:13:11 +0200 (Tue, 20 Jul 2010) | 1 line

merged back lastindexofany fix
------------------------------------------------------------------------
r12990 | ben.clark | 2010-06-22 04:44:58 +0200 (Tue, 22 Jun 2010) | 1 line

new translation needed for PENS
This commit is contained in:
Kevin Glynn 2010-08-26 12:54:07 +02:00
parent b8dffaab5b
commit d825e3c348
6 changed files with 51 additions and 3 deletions

View File

@ -16,5 +16,10 @@
<Name>Name</Name>
<Get>${this}.getName()</Get>
</Property>
<Property>
<Type>System.Boolean</Type>
<Name>IsDirectory</Name>
<Get>${this}.isDirectory()</Get>
</Property>
</Properties>
</Class>

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<Class xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="file://C:/Documents%20and%20Settings/kevin.glynn/My%20Documents/CS2JLibrary/Translation.xsd"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Name>System.Net.Mail.MailAddressCollection</Name>
<Properties>
<Property>
<!-- tried inheriting from ICollection and moving this definition there, didn't work so just
copying this from IDictionary -->
<Type>System.Int32</Type>
<Name>Count</Name>
<Get>${this}.size()</Get>
</Property>
</Properties>
</Class>

View File

@ -33,7 +33,7 @@ public class DoubleSupport {
String formattedValue = "";
if (format.toLowerCase().indexOf("g") == 0 && format.length() < 3) {
if ((format.toLowerCase().indexOf("g") == 0 || format.toLowerCase().indexOf("n") == 0) && format.length() < 3) {
if (format.length() == 2) {
String lengthStr = format.substring(1);

View File

@ -177,7 +177,7 @@ public class DirectorySupport {
for (int i=0; i<children.length; i++) {
File child = new File(dp, children[i]);
if (child.isDirectory())
DirectorySupport.delete(dp.getPath(), true);
DirectorySupport.delete(child.getPath(), true);
else
child.delete();
}

View File

@ -327,6 +327,19 @@ public class StringSupport {
public static final boolean IsNullOrEmpty(String str){
return isNullOrEmpty(str);
}
public static final boolean IsEmptyOrBlank(String str){
// Locate first non-trimmable index
int firstIdx = 0;
while (firstIdx < str.length())
{
if (isIn(str.charAt(firstIdx),wschars))
firstIdx++;
else
break;
}
return firstIdx == str.length();
}
public static final int lastIndexOfAny(String str, char[] anyOf)
@ -334,7 +347,7 @@ public class StringSupport {
int index = -1;
for (char test : anyOf)
{
index = Math.max(index, str.indexOf(test));
index = Math.max(index, str.lastIndexOf(test));
}
return index;
}

View File

@ -27,6 +27,8 @@ import java.util.Iterator;
import org.w3c.dom.*;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import RusticiSoftware.System.StringSupport;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
@ -179,6 +181,19 @@ public class XmlNode implements Iterable {
// I think the XML standard says that newlines in text are converted from their
// local encoding to "\n". Java does that, but .Net does not, so here we put 'em back.
return node.getTextContent().replace("\n", System.getProperty("line.separator"));
}
public boolean isEmptyElement()
{
if (StringSupport.IsEmptyOrBlank(node.getTextContent()) && getAttributes().size() == 0 && getChildNodes().size() == 0)
{
return true;
}
else
{
return false;
}
}
// This is a .Net extension to the DOM. It returns markup describing