Initial commit
This commit is contained in:
commit
1f2c6849c4
15 files changed
+423
No files matched your search
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="target/classes" path="src/main/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
||||
@@ -0,0 +1 @@
|
||||
/target
|
||||
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>ch.psi.fda.core</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -0,0 +1,5 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
|
||||
org.eclipse.jdt.core.compiler.compliance=1.5
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.source=1.5
|
||||
@@ -0,0 +1,4 @@
|
||||
activeProfiles=
|
||||
eclipse.preferences.version=1
|
||||
resolveWorkspaceProjects=true
|
||||
version=1
|
||||
@@ -0,0 +1,14 @@
|
||||
<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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>ch.psi</groupId>
|
||||
<artifactId>ch.psi.fda.core</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>15.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
*
|
||||
* Copyright 2010 Paul Scherrer Institute. All rights reserved.
|
||||
*
|
||||
* This code is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful,
|
||||
* but without any warranty; without even the implied warranty of
|
||||
* merchantability or fitness for a particular purpose. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this code. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.psi.fda.core.messages;
|
||||
|
||||
|
||||
/**
|
||||
* A control message that is not holding any data but
|
||||
* control information (like end of loop, etc.)
|
||||
*/
|
||||
public abstract class ControlMessage extends Message{
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
/**
|
||||
*
|
||||
* Copyright 2010 Paul Scherrer Institute. All rights reserved.
|
||||
*
|
||||
* This code is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful,
|
||||
* but without any warranty; without even the implied warranty of
|
||||
* merchantability or fitness for a particular purpose. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this code. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.psi.fda.core.messages;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Message holding data
|
||||
*/
|
||||
public class DataMessage extends Message{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final List<Object> data;
|
||||
private List<Metadata> metadata;
|
||||
|
||||
// public DataMessage(){
|
||||
// this.data = new ArrayList<Object>();
|
||||
// this.metadata = new ArrayList<>();
|
||||
// }
|
||||
//
|
||||
public DataMessage(List<Metadata> metadata){
|
||||
this.data = new ArrayList<Object>();
|
||||
this.metadata = metadata;
|
||||
}
|
||||
|
||||
public List<Object> getData(){
|
||||
return(data);
|
||||
}
|
||||
public List<Metadata> getMetadata(){
|
||||
return metadata;
|
||||
}
|
||||
public void setMetadata(List<Metadata> metadata){
|
||||
this.metadata = metadata;
|
||||
}
|
||||
|
||||
// Utility functions
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T getData(String id){
|
||||
int i=0;
|
||||
for(Metadata m: metadata){
|
||||
if(m.getId().equals(id)){
|
||||
return (T) data.get(i);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
throw new IllegalArgumentException("No data found for id: "+id);
|
||||
}
|
||||
|
||||
public Metadata getMetadata(String id){
|
||||
for(Metadata m: metadata){
|
||||
if(m.getId().equals(id)){
|
||||
return m;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("No data found for id: "+id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer b = new StringBuffer();
|
||||
b.append("Message [ ");
|
||||
for (Object o : data) {
|
||||
if (o.getClass().isArray()) {
|
||||
// If the array object is of type double[] display its content
|
||||
if (o instanceof double[]) {
|
||||
double[] oa = (double[]) o;
|
||||
b.append("[ ");
|
||||
for (double o1 : oa) {
|
||||
b.append(o1);
|
||||
b.append(" ");
|
||||
}
|
||||
b.append("]");
|
||||
} else {
|
||||
b.append(o.toString());
|
||||
}
|
||||
} else {
|
||||
b.append(o);
|
||||
}
|
||||
|
||||
b.append(" ");
|
||||
}
|
||||
b.append("]");
|
||||
return b.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
*
|
||||
* Copyright 2010 Paul Scherrer Institute. All rights reserved.
|
||||
*
|
||||
* This code is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful,
|
||||
* but without any warranty; without even the implied warranty of
|
||||
* merchantability or fitness for a particular purpose. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this code. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.psi.fda.core.messages;
|
||||
|
||||
/**
|
||||
* Message that is send at the end of the action loop inside an ActionLoop implementation
|
||||
* of just to indicate that a particular stream has finished
|
||||
*/
|
||||
public class EndOfStreamMessage extends ControlMessage {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Intersect flag - flag to indicate that stream should be intersected
|
||||
* after this message.
|
||||
*/
|
||||
private final boolean iflag;
|
||||
|
||||
public EndOfStreamMessage(){
|
||||
this(false);
|
||||
}
|
||||
|
||||
public EndOfStreamMessage(boolean iflag){
|
||||
this.iflag = iflag;
|
||||
}
|
||||
|
||||
public boolean isIflag(){
|
||||
return(iflag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Message[ c message: end of stream ]";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
*
|
||||
* Copyright 2010 Paul Scherrer Institute. All rights reserved.
|
||||
*
|
||||
* This code is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful,
|
||||
* but without any warranty; without even the implied warranty of
|
||||
* merchantability or fitness for a particular purpose. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this code. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.psi.fda.core.messages;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Message that can be put to the data queue
|
||||
*/
|
||||
public abstract class Message implements Serializable{
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
*
|
||||
* Copyright 2010 Paul Scherrer Institute. All rights reserved.
|
||||
*
|
||||
* This code is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful,
|
||||
* but without any warranty; without even the implied warranty of
|
||||
* merchantability or fitness for a particular purpose. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this code. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.psi.fda.core.messages;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Metadata of a component of a message. Each component has a global id.
|
||||
* Optionally the component can also belong to a dimension. However, depending on the
|
||||
* view the number of the dimension might vary. Therefore the dimension number
|
||||
* might change during the lifetime of a message (component).
|
||||
*/
|
||||
public class Metadata implements Serializable{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final String id;
|
||||
private int dimension;
|
||||
|
||||
public Metadata(String id){
|
||||
this.id = id;
|
||||
this.dimension = 0;
|
||||
}
|
||||
|
||||
public Metadata(String id, int dimension){
|
||||
this.id = id;
|
||||
this.dimension = dimension;
|
||||
}
|
||||
|
||||
public void setDimension(int dimension){
|
||||
this.dimension = dimension;
|
||||
}
|
||||
|
||||
public int getDimension() {
|
||||
return dimension;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/**
|
||||
*
|
||||
* Copyright 2010 Paul Scherrer Institute. All rights reserved.
|
||||
*
|
||||
* This code is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful,
|
||||
* but without any warranty; without even the implied warranty of
|
||||
* merchantability or fitness for a particular purpose. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this code. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.psi.fda.core.messages;
|
||||
|
||||
/**
|
||||
* Message that is send at the end of the action loop inside an ActionLoop implementation
|
||||
*/
|
||||
public class StreamDelimiterMessage extends ControlMessage{
|
||||
private static final long serialVersionUID = 1L;
|
||||
/**
|
||||
* Number of the dimension this delimiter belongs to.
|
||||
*/
|
||||
private final int number;
|
||||
|
||||
/**
|
||||
* Intersect flag - flag to indicate that stream should be intersected
|
||||
* after this message.
|
||||
*/
|
||||
private final boolean iflag;
|
||||
|
||||
/**
|
||||
* @param number Number of the dimension this delimiter belongs to
|
||||
*/
|
||||
public StreamDelimiterMessage(int number){
|
||||
this(number, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param number
|
||||
* @param iflag Flag to indicate that data is grouped
|
||||
*/
|
||||
public StreamDelimiterMessage(int number, boolean iflag){
|
||||
this.number = number;
|
||||
this.iflag = iflag;
|
||||
}
|
||||
|
||||
public int getNumber() {
|
||||
return number;
|
||||
}
|
||||
|
||||
public boolean isIflag(){
|
||||
return iflag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
// TODO Auto-generated method stub
|
||||
return "Message [ c message: delimiter dimension "+number+" ]";
|
||||
}
|
||||
}
|
||||
Whitespace-only changes.
Whitespace-only changes.
Whitespace-only changes.
Reference in new issue
Block a user