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

Map List<T> to new CSList, which wraps an ArrayList

This commit is contained in:
Kevin Glynn 2011-10-22 14:51:44 +02:00
parent 9012b7c07a
commit 26667b96e3
7 changed files with 794 additions and 21 deletions

View File

@ -0,0 +1,205 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is
Copyright 2007,2008,2009,2010 Rustici Software, LLC
Copyright 2010,2011 Kevin Glynn (kevin.glynn@twigletsoftware.com)
-->
<Class variant="LCC" 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>CS2JNet.System.Collections.LCC.CSList</Import>
</Imports>
<Java>CSList*[${T}]*</Java>
<Name>System.Collections.Generic.List</Name>
<TypeParams>
<Name>T</Name>
</TypeParams>
<Uses />
<Inherits>
<Type>IList*[T]*</Type>
<Type>ICollection*[T]*</Type>
<Type>IEnumerable*[T]*</Type>
</Inherits>
<Iterable>
<ElementType>T</ElementType>
<Java>${expr}</Java>
</Iterable>
<Methods>
<Method>
<Imports />
<Java>${this:16}.add(${arg})</Java>
<Params>
<Param>
<Type>T</Type>
<Name>arg</Name>
</Param>
</Params>
<Name>Add</Name>
<Return>System.Void</Return>
</Method>
<Method>
<Java>${this:16}.addRange(${arg})</Java>
<Params>
<Param>
<Type>T[]</Type>
<Name>arg</Name>
</Param>
</Params>
<Name>AddRange</Name>
<Return>System.Void</Return>
</Method>
<Method>
<Imports />
<Java>${this:16}.addRange(${arg})</Java>
<Params>
<Param>
<Type>System.Collections.Generic.IEnumerable*[T]*</Type>
<Name>arg</Name>
</Param>
</Params>
<Name>AddRange</Name>
<Return>System.Void</Return>
</Method>
<Method>
<Imports />
<Java>${this:16}.clear()</Java>
<Params />
<Name>Clear</Name>
<Return>System.Void</Return>
</Method>
<Method>
<Imports />
<Java>${this:16}.contains(${key})</Java>
<Params>
<Param>
<Type>T</Type>
<Name>key</Name>
</Param>
</Params>
<Name>Contains</Name>
<Return>System.Boolean</Return>
</Method>
<Method>
<Imports />
<Java>${this:16}.add(${index}, ${value})</Java>
<Params>
<Param>
<Type>System.Int32</Type>
<Name>index</Name>
</Param>
<Param>
<Type>T</Type>
<Name>value</Name>
</Param>
</Params>
<Name>Insert</Name>
<Return>System.Void</Return>
</Method>
<Method>
<Imports />
<Java>${this:16}.remove(${value})</Java>
<Params>
<Param>
<Type>T</Type>
<Name>value</Name>
</Param>
</Params>
<Name>Remove</Name>
<Return>System.Boolean</Return>
</Method>
<Method>
<Imports />
<Java>${this:16}.remove((int)${value})</Java>
<Params>
<Param>
<Type>System.Int32</Type>
<Name>index</Name>
</Param>
</Params>
<Name>RemoveAt</Name>
<Return>System.Void</Return>
</Method>
<Method>
<Java>${this:16}.toArray(new ${T}[${this}.size()])</Java>
<Params>
</Params>
<Name>ToArray</Name>
<Return>T[]</Return>
</Method>
<Method>
<Imports>
<Import>java.util.Collections</Import>
</Imports>
<Java>Collections.sort(${this})</Java>
<Params />
<Name>Sort</Name>
<Return>System.Void</Return>
</Method>
</Methods>
<Properties>
<Property>
<Imports />
<Java>${this:16}.size()</Java>
<Type>System.Int32</Type>
<Name>Count</Name>
<Get>${this:16}.size()</Get>
<Set>${this:16}.setCount(${value})</Set>
</Property>
</Properties>
<Events />
<Indexers>
<Indexer>
<Imports />
<Params>
<Param>
<Type>System.Int32</Type>
<Name>i</Name>
</Param>
</Params>
<Type>T</Type>
<Get>${this:16}.get(${i})</Get>
<Set>${this:16}.add(${i}, ${value})</Set>
</Indexer>
</Indexers>
<Constructors>
<Constructor>
<Imports />
<Java>new CSList*[${T}]*()</Java>
<Params />
</Constructor>
<Constructor>
<Imports />
<Java>new CSList*[${T}]*(${length})</Java>
<Params>
<Param>
<Type>System.Int32</Type>
<Name>length</Name>
</Param>
</Params>
</Constructor>
<Constructor>
<Java>new CSList*[${T}]*(${collection})</Java>
<Params>
<Param>
<Type>T[]</Type>
<Name>collection</Name>
</Param>
</Params>
</Constructor>
<Constructor>
<Java>new CSList*[${T}]*(${collection})</Java>
<Params>
<Param>
<Type>System.Collections.Generic.IEnumerable*[T]*</Type>
<Name>collection</Name>
</Param>
</Params>
</Constructor>
</Constructors>
<Fields />
<Casts />
<UnaryOps />
<BinaryOps />
<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>dMxWahle6+JWazXF5rdEoxNFqHQ=</DigestValue></Reference></SignedInfo><SignatureValue>QHAtm2BA/7k2dSASQHMw6aKKJEGk6P2x5HAGuae81wbbLDkrnihhH2PFU+6WFudzrinE4JSp9WOHKzOxJ659kj6Wg8qx5asDxOhkhG06He0TE4jcq64/U0tM2GZxViqhaFHAExXAZoT9rxjqP5prxerSnSvfy16hhPAixY5XEEA=</SignatureValue></Signature></Class>

View File

@ -9,17 +9,18 @@
-->
<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>java.util.ArrayList</Import>
<Import>CS2JNet.System.Collections.CSList</Import>
</Imports>
<Java>ArrayList*[${T}]*</Java>
<Java>CSList*[${T}]*</Java>
<Name>System.Collections.Generic.List</Name>
<TypeParams>
<Name>T</Name>
</TypeParams>
<Uses />
<Inherits>
<!-- <Type>IList<T>, ICollection<T>,
IEnumerable<T>, IList, ICollection, IEnumerable</Type> -->
<Type>IList*[T]*</Type>
<Type>ICollection*[T]*</Type>
<Type>IEnumerable*[T]*</Type>
</Inherits>
<Iterable>
<ElementType>T</ElementType>
@ -36,14 +37,10 @@
</Param>
</Params>
<Name>Add</Name>
<!-- TODO: this.add(e) actually always returns true -->
<Return>System.Int32</Return>
<Return>System.Void</Return>
</Method>
<Method>
<Imports>
<Import>java.util.Arrays</Import>
</Imports>
<Java>${this:16}.addAll(Arrays.asList(${arg}))</Java>
<Java>${this:16}.addRange(${arg})</Java>
<Params>
<Param>
<Type>T[]</Type>
@ -55,7 +52,7 @@
</Method>
<Method>
<Imports />
<Java>${this:16}.addAll(${arg})</Java>
<Java>${this:16}.addRange(${arg})</Java>
<Params>
<Param>
<Type>System.Collections.Generic.IEnumerable*[T]*</Type>
@ -169,12 +166,12 @@
<Constructors>
<Constructor>
<Imports />
<Java>new ArrayList*[${T}]*()</Java>
<Java>new CSList*[${T}]*()</Java>
<Params />
</Constructor>
<Constructor>
<Imports />
<Java>new ArrayList*[${T}]*(${length})</Java>
<Java>new CSList*[${T}]*(${length})</Java>
<Params>
<Param>
<Type>System.Int32</Type>
@ -183,10 +180,7 @@
</Params>
</Constructor>
<Constructor>
<Imports>
<Import>java.util.Arrays</Import>
</Imports>
<Java>new ArrayList*[${T}]*(Arrays.asList(${collection}))</Java>
<Java>new CSList*[${T}]*(${collection})</Java>
<Params>
<Param>
<Type>T[]</Type>
@ -195,10 +189,7 @@
</Params>
</Constructor>
<Constructor>
<Imports>
<Import>CS2JNet.System.Collections.Generic.GenArrayListSupport</Import>
</Imports>
<Java>GenArrayListSupport.*[${T}]*toList(${collection})</Java>
<Java>new CSList*[${T}]*(${collection})</Java>
<Params>
<Param>
<Type>System.Collections.Generic.IEnumerable*[T]*</Type>

View File

@ -0,0 +1,78 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is
Copyright 2010,2011 Kevin Glynn (kevin.glynn@twigletsoftware.com)
-->
<Delegate variant="LCC" 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>CS2JNet.System.LCC.Predicate</Import>
</Imports>
<Java>Predicate*[${T}]*</Java>
<Name>System.Predicate</Name>
<TypeParams>
<Name>T</Name>
</TypeParams>
<Uses />
<Inherits>
<Type>System.Object</Type>
</Inherits>
<Methods>
<Method static="true">
<Imports>
<Import>CS2JNet.System.LCC.__MultiPredicate</Import>
</Imports>
<Java>__MultiPredicate.combine(${a},${b})</Java>
<Params>
<Param>
<Type>System.Predicate*[T]*</Type>
<Name>a</Name>
</Param>
<Param>
<Type>System.Predicate*[T]*</Type>
<Name>b</Name>
</Param>
</Params>
<Name>Combine</Name>
<TypeParams>
<Name>T</Name>
</TypeParams>
<Return>System.Predicate*[T]*</Return>
</Method>
<Method static="true">
<Imports>
<Import>CS2JNet.System.LCC.__MultiPredicate</Import>
</Imports>
<Java>__MultiPredicate.remove(${a},${b})</Java>
<Params>
<Param>
<Type>System.Predicate*[T]*</Type>
<Name>a</Name>
</Param>
<Param>
<Type>System.Predicate*[T]*</Type>
<Name>b</Name>
</Param>
</Params>
<Name>Remove</Name>
<TypeParams>
<Name>T</Name>
</TypeParams>
<Return>System.Predicate*[T]*</Return>
</Method>
</Methods>
<Invoke>
<Java>${this:16}.invoke(${a})</Java>
<Params>
<Param>
<Type>T</Type>
<Name>a</Name>
</Param>
</Params>
<Name>Invoke</Name>
<TypeParams />
<Return>System.Boolean</Return>
</Invoke>
<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>yz+yOlqpwafASqBPdP2mB/lVgZk=</DigestValue></Reference></SignedInfo><SignatureValue>Nv+agoqBJd5WaI7/+c3HuvQ/dt5/5j3fHCKxNm4v8TZITAC8J+AbF8DN3l3ZZC1+zmhBzRTyrMMD7EWi7zumiRrhC2r/+rUpYbfOeiHANORPmwqP5NvSBeUbWvEp3VRBtQZHYNTDNG1gbOApoTGZi0z3dSv1ySftgALkYlxmbrc=</SignatureValue></Signature></Delegate>

View File

@ -0,0 +1,78 @@
/*
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");
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@twigletsoftware.com)
*/
package CS2JNet.System;
public class ArgumentNullException extends ArgumentException {
/**
*
*/
private static final long serialVersionUID = 5588457279046701403L;
/**
*
*/
public ArgumentNullException() {
}
/**
* @param arg0
*/
public ArgumentNullException(String arg0) {
super(arg0);
}
/**
* @param arg0
*/
public ArgumentNullException(Throwable arg0) {
super(arg0);
// TODO Auto-generated constructor stub
}
/**
* @param arg0 the detail message
* @param arg1 the cause
*/
public ArgumentNullException(String arg0, Throwable arg1) {
super(arg0, arg1);
}
/**
* @param arg0 the detail message
* @param arg1 the parameter name
*/
public ArgumentNullException(String arg0, String arg1) {
super(arg0, arg1);
}
/**
* @param arg0 the detail message
* @param p the parameter name
* @param arg1 the cause
*/
public ArgumentNullException(String arg0, String p, Throwable arg1) {
super(arg0, p, arg1);
}
}

View File

@ -0,0 +1,78 @@
/*
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");
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@twigletsoftware.com)
*/
package CS2JNet.System;
public class ArgumentOutOfRangeException extends ArgumentException {
/**
*
*/
private static final long serialVersionUID = 8718969647532507719L;
/**
*
*/
public ArgumentOutOfRangeException() {
}
/**
* @param arg0
*/
public ArgumentOutOfRangeException(String arg0) {
super(arg0);
}
/**
* @param arg0
*/
public ArgumentOutOfRangeException(Throwable arg0) {
super(arg0);
}
/**
* @param arg0 the detail message
* @param arg1 the cause
*/
public ArgumentOutOfRangeException(String arg0, Throwable arg1) {
super(arg0, arg1);
}
/**
* @param arg0 the detail message
* @param arg1 the parameter name
*/
public ArgumentOutOfRangeException(String arg0, String arg1) {
super(arg0, arg1);
}
/**
* @param arg0 the detail message
* @param p the parameter name
* @param arg1 the cause
*/
public ArgumentOutOfRangeException(String arg0, String p, Throwable arg1) {
super(arg0, p, arg1);
}
}

View File

@ -0,0 +1,168 @@
/*
Copyright 2010,2011 Kevin Glynn (kevin.glynn@twigletsoftware.com)
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@twigletsoftware.com)
*/
package CS2JNet.System.Collections;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import CS2JNet.JavaSupport.Collections.Generic.EnumeratorSupport;
import CS2JNet.System.ArgumentException;
import CS2JNet.System.ArgumentNullException;
import CS2JNet.System.ArgumentOutOfRangeException;
/**
* @author keving
*
*/
public class CSList<T> implements ICollection<T>, IEnumerable<T>, Collection<T> {
private List<T> myList = null;
public CSList() {
myList = new ArrayList<T>();
}
public CSList(int size) {
myList = new ArrayList<T>(size);
}
public CSList(IEnumerable<T> coll) {
myList = new ArrayList<T>();
for (T el : coll) {
myList.add(el);
}
}
public CSList(T[] coll) {
myList = new ArrayList<T>(coll.length);
for (T el : coll) {
myList.add(el);
}
}
@Override
public Iterator<T> iterator() {
return myList.iterator();
}
@Override
public boolean add(T arg0) {
return myList.add(arg0);
}
@Override
public boolean addAll(Collection<? extends T> arg0) {
return myList.addAll(arg0);
}
@Override
public void clear() {
myList.clear();
}
@Override
public boolean contains(Object arg0) {
return myList.contains(arg0);
}
@Override
public boolean containsAll(Collection<?> arg0) {
return myList.containsAll(arg0);
}
@Override
public boolean isEmpty() {
return myList.isEmpty();
}
@Override
public boolean remove(Object arg0) {
return myList.remove(arg0);
}
@Override
public boolean removeAll(Collection<?> arg0) {
return myList.removeAll(arg0);
}
@Override
public boolean retainAll(Collection<?> arg0) {
return myList.retainAll(arg0);
}
@Override
public int size() {
return myList.size();
}
@Override
public Object[] toArray() {
return myList.toArray();
}
@Override
public <S> S[] toArray(S[] arg0) {
return myList.toArray(arg0);
}
@Override
public boolean Contains(T x) throws Exception {
return myList.contains(x);
}
@Override
public void Add(T x) throws Exception {
myList.add(x);
}
@Override
public boolean Remove(T x) throws Exception {
return myList.remove(x);
}
@Override
public void Clear() throws Exception {
myList.clear();
}
@Override
public IEnumerator<T> GetEnumerator() throws Exception {
return EnumeratorSupport.mk(myList.iterator());
}
@Override
public void CopyTo(T[] arr, int i) throws Exception {
if (arr == null)
throw new ArgumentNullException();
if (i < 0)
throw new ArgumentOutOfRangeException();
if (i + arr.length < myList.size())
throw new ArgumentException();
for (int idx = 0; idx < arr.length; idx++){
arr[idx+i] = myList.get(idx);
}
}
}

View File

@ -0,0 +1,175 @@
/*
Copyright 2010,2011 Kevin Glynn (kevin.glynn@twigletsoftware.com)
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@twigletsoftware.com)
*/
package CS2JNet.System.Collections.LCC;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import CS2JNet.JavaSupport.Collections.Generic.LCC.EnumeratorSupport;
import CS2JNet.System.ArgumentException;
import CS2JNet.System.ArgumentNullException;
import CS2JNet.System.ArgumentOutOfRangeException;
/**
* @author keving
*
*/
public class CSList<T> implements ICollection<T>, IEnumerable<T>, Collection<T> {
private List<T> myList = null;
public CSList() {
myList = new ArrayList<T>();
}
public CSList(int size) {
myList = new ArrayList<T>(size);
}
public CSList(IEnumerable<T> coll) {
myList = new ArrayList<T>();
for (T el : coll) {
myList.add(el);
}
}
public CSList(T[] coll) {
myList = new ArrayList<T>(coll.length);
for (T el : coll) {
myList.add(el);
}
}
@Override
public Iterator<T> iterator() {
return myList.iterator();
}
@Override
public boolean add(T arg0) {
return myList.add(arg0);
}
@Override
public boolean addAll(Collection<? extends T> arg0) {
return myList.addAll(arg0);
}
@Override
public void clear() {
myList.clear();
}
@Override
public boolean contains(Object arg0) {
return myList.contains(arg0);
}
@Override
public boolean containsAll(Collection<?> arg0) {
return myList.containsAll(arg0);
}
@Override
public boolean isEmpty() {
return myList.isEmpty();
}
@Override
public boolean remove(Object arg0) {
return myList.remove(arg0);
}
@Override
public boolean removeAll(Collection<?> arg0) {
return myList.removeAll(arg0);
}
@Override
public boolean retainAll(Collection<?> arg0) {
return myList.retainAll(arg0);
}
@Override
public int size() {
return myList.size();
}
@Override
public Object[] toArray() {
return myList.toArray();
}
@Override
public <S> S[] toArray(S[] arg0) {
return myList.toArray(arg0);
}
@Override
public boolean Contains(T x) throws Exception {
return myList.contains(x);
}
@Override
public void Add(T x) throws Exception {
myList.add(x);
}
@Override
public boolean Remove(T x) throws Exception {
return myList.remove(x);
}
@Override
public void Clear() throws Exception {
myList.clear();
}
public IEnumerator<T> GetEnumerator() throws Exception {
return EnumeratorSupport.mk(myList.iterator());
}
public void CopyTo(T[] arr, int i) throws Exception {
if (arr == null)
throw new ArgumentNullException();
if (i < 0)
throw new ArgumentOutOfRangeException();
if (i + arr.length < myList.size())
throw new ArgumentException();
for (int idx = 0; idx < arr.length; idx++){
arr[idx+i] = myList.get(idx);
}
}
@Override
public IEnumerator<T> getEnumerator() throws Exception {
return GetEnumerator();
}
@Override
public void copyTo(T[] arr, int i) throws Exception {
CopyTo(arr, i);
}
}