Skip to content

Commit f524ffe

Browse files
authored
Merge pull request #2 from gcarcassi/master
First pass at basic utilities and interface types
2 parents 6095e97 + 019d440 commit f524ffe

279 files changed

Lines changed: 22425 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

epics-util/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/target/

epics-util/HEADER.TXT

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Copyright (C) 2010-14 diirt developers. See COPYRIGHT.TXT
2+
All rights reserved. Use is subject to license terms. See LICENSE.TXT

epics-util/README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# org.epis.util
2+
3+
Basic Java utility classes to be shared across EPICS projects until suitable
4+
replacements are available in the JDK.
5+
6+
# org.epics.util.array
7+
8+
This package provides a class hierarchy to handle collections of primitives.
9+
The goals of the API are:
10+
* Allow access to the numeric data of a primitive array regardless of the
11+
type stored in the array
12+
* Allow unmodifiable views of the data, to increase encapsulation or to
13+
simplify multi-threading (by using effectively immutable types)
14+
* Allow basic array manipulation operation such as: splitting, copying,
15+
printing, comparison and so on.
16+
* Take care of type conversions, including unsigned primitives, which
17+
are in general not well supported in Java
18+
* With some reasonable restriction, there should be no performance cost when
19+
accessing a primitive array through the collection classes
20+
* With some reasonable restrictions, allow to access the internal primitive arrays
21+
for interoperability with other libraries
22+
23+
## Design choices
24+
25+
The library is designed to mimic as much as possible the standard Java collection
26+
classes. We do this for two reason:
27+
* to make the library more intuitive for a general Java programmer
28+
* there has been talk about generic reification / value classes, which may make
29+
the collection classes directly usable to access primitives with no penalties
30+
31+
## Package structure
32+
33+
The package is structured as follows:
34+
* CollectionNumber - provides the top level class of the hierarchy
35+
* CollectionXxx - provides the top level class of the hierarchy
36+

epics-util/nbactions.xml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<actions>
3+
<action>
4+
<actionName>CUSTOM-Site</actionName>
5+
<displayName>Site</displayName>
6+
<goals>
7+
<goal>site</goal>
8+
</goals>
9+
</action>
10+
<action>
11+
<actionName>CUSTOM-Release</actionName>
12+
<displayName>Release</displayName>
13+
<goals>
14+
<goal>release:prepare</goal>
15+
<goal>release:perform</goal>
16+
</goals>
17+
</action>
18+
<action>
19+
<actionName>CUSTOM-github deploy</actionName>
20+
<displayName>github deploy</displayName>
21+
<goals>
22+
<goal>site:site</goal>
23+
<goal>ghSite:site</goal>
24+
</goals>
25+
</action>
26+
</actions>

epics-util/pom.xml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<version>1.0.0-SNAPSHOT</version>
5+
<groupId>org.epics</groupId>
6+
<artifactId>epics-util</artifactId>
7+
<name>org.epics.util</name>
8+
<description>Basic Java utility classes to be shared across projects until
9+
suitable replacements are available in the JDK.</description>
10+
<properties>
11+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
12+
</properties>
13+
<build>
14+
<plugins>
15+
<plugin>
16+
<groupId>org.apache.maven.plugins</groupId>
17+
<artifactId>maven-compiler-plugin</artifactId>
18+
<version>3.6.2</version>
19+
<configuration>
20+
<source>1.8</source>
21+
<target>1.8</target>
22+
</configuration>
23+
</plugin>
24+
<plugin>
25+
<groupId>org.apache.maven.plugins</groupId>
26+
<artifactId>maven-source-plugin</artifactId>
27+
<version>3.0.1</version>
28+
<executions>
29+
<execution>
30+
<id>attach-sources</id>
31+
<goals>
32+
<goal>jar</goal>
33+
</goals>
34+
</execution>
35+
</executions>
36+
</plugin>
37+
<plugin>
38+
<groupId>org.apache.maven.plugins</groupId>
39+
<artifactId>maven-javadoc-plugin</artifactId>
40+
<version>2.10.4</version>
41+
<executions>
42+
<execution>
43+
<id>attach-javadocs</id>
44+
<goals>
45+
<goal>jar</goal>
46+
</goals>
47+
</execution>
48+
</executions>
49+
</plugin>
50+
</plugins>
51+
</build>
52+
<dependencies>
53+
<dependency>
54+
<groupId>junit</groupId>
55+
<artifactId>junit</artifactId>
56+
<version>4.12</version>
57+
<scope>test</scope>
58+
</dependency>
59+
<dependency>
60+
<groupId>org.mockito</groupId>
61+
<artifactId>mockito-all</artifactId>
62+
<version>1.10.19</version>
63+
<scope>test</scope>
64+
</dependency>
65+
<dependency>
66+
<groupId>org.hamcrest</groupId>
67+
<artifactId>hamcrest-all</artifactId>
68+
<version>1.3</version>
69+
<scope>test</scope>
70+
</dependency>
71+
</dependencies>
72+
</project>

epics-util/src/changes/changes.xml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<document xmlns="http://maven.apache.org/changes/1.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/changes/1.0.0 http://maven.apache.org/xsd/changes-1.0.0.xsd">
5+
<properties>
6+
<title>epics-util changes</title>
7+
<author email="carcassi_AT_bnl.gov">Gabriele Carcassi</author>
8+
</properties>
9+
10+
<body>
11+
<release version="0.3.2" date="2014/07/31" description="Minor improvements.">
12+
<action dev="carcassi" type="update">
13+
text: handles empty columns as the first column
14+
</action>
15+
<action dev="carcassi" type="add">
16+
array: sublist support
17+
</action>
18+
<action dev="carcassi" type="add">
19+
stats: consolidating from graphene
20+
</action>
21+
</release>
22+
<release version="0.3.1" date="2014/05/23" description="Move to github. Minor improvements.">
23+
<action dev="carcassi" type="add">
24+
stats: minor improvements to numeric range support
25+
</action>
26+
<action dev="carcassi" type="add">
27+
array: better support for linear numeric lists
28+
</action>
29+
<action dev="carcassi" type="update">
30+
infrastructure: move to github
31+
</action>
32+
</release>
33+
<release version="0.3" date="2014/03/27" description="CSV parser improvements. ListMath improvements">
34+
<action dev="sfnrendra3" type="add">
35+
array: adding some element-wise operations in ListMath
36+
</action>
37+
<action dev="carcassi" type="update">
38+
text: greatly improved CSV parser
39+
</action>
40+
</release>
41+
</body>
42+
</document>
43+
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/**
2+
* Copyright (C) 2010-14 diirt developers. See COPYRIGHT.TXT
3+
* All rights reserved. Use is subject to license terms. See LICENSE.TXT
4+
*/
5+
package org.epics.util.array;
6+
7+
import java.io.Serializable;
8+
import java.util.Arrays;
9+
10+
/**
11+
* Wraps a {@code boolean[]} into a {@link ListBoolean}.
12+
*
13+
* @author Gabriele Carcassi
14+
*/
15+
public final class ArrayBoolean extends ListBoolean implements Serializable {
16+
17+
private static final long serialVersionUID = 7493025761455302915L;
18+
19+
private final boolean[] array;
20+
private final boolean readOnly;
21+
22+
/**
23+
* A new read-only {@code ArrayBoolean} that wraps around the given array.
24+
*
25+
* @param array an array
26+
*/
27+
public ArrayBoolean(boolean... array) {
28+
this(array, true);
29+
}
30+
31+
/**
32+
* A new {@code ArrayBoolean} that wraps around the given array.
33+
*
34+
* @param array an array
35+
* @param readOnly if false the wrapper allows writes to the array
36+
*/
37+
public ArrayBoolean(boolean[] array, boolean readOnly) {
38+
this.array = array;
39+
this.readOnly = readOnly;
40+
}
41+
42+
@Override
43+
public final int size() {
44+
return array.length;
45+
}
46+
47+
@Override
48+
public boolean getBoolean(int index) {
49+
return array[index];
50+
}
51+
52+
@Override
53+
public void setBoolean(int index, boolean value) {
54+
if (!readOnly) {
55+
array[index] = value;
56+
} else {
57+
throw new UnsupportedOperationException("Read only list.");
58+
}
59+
}
60+
61+
@Override
62+
public boolean equals(Object obj) {
63+
if (obj instanceof ArrayBoolean) {
64+
return Arrays.equals(array, ((ArrayBoolean) obj).array);
65+
}
66+
67+
return super.equals(obj);
68+
}
69+
70+
boolean[] wrappedArray() {
71+
return array;
72+
}
73+
74+
}

0 commit comments

Comments
 (0)