fix copyright header, javadoc, and warnings

This commit is contained in:
2021-01-09 12:43:02 +01:00
parent d970d07048
commit eb64cc60c5
41 changed files with 1856 additions and 541 deletions

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2015 MINRES Technologies GmbH and others.
* Copyright (c) 2015 - 2020 MINRES Technologies GmbH and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -25,67 +25,114 @@ import com.minres.scviewer.database.IWaveformDb;
import com.minres.scviewer.database.IWaveformDbLoader;
import com.minres.scviewer.database.RelationType;
/**
* The Class WaveformDb.
*/
public class WaveformDb extends HierNode implements IWaveformDb {
private static List<IWaveformDbLoader> loaders=new LinkedList<>();
/** The loaders. */
private static List<IWaveformDbLoader> loaders = new LinkedList<>();
/** The loaded. */
private boolean loaded;
/** The relation types. */
private List<RelationType> relationTypes;
/** The waveforms. */
private Map<String, IWaveform> waveforms;
/** The max time. */
private Long maxTime;
public synchronized void bind(IWaveformDbLoader loader){
/**
* Bind.
*
* @param loader the loader
*/
public synchronized void bind(IWaveformDbLoader loader) {
loaders.add(loader);
}
public synchronized void unbind(IWaveformDbLoader loader){
/**
* Unbind.
*
* @param loader the loader
*/
public synchronized void unbind(IWaveformDbLoader loader) {
loaders.remove(loader);
}
/**
* Gets the loaders.
*
* @return the loaders
*/
public static List<IWaveformDbLoader> getLoaders() {
return Collections.unmodifiableList(loaders);
}
/**
* Instantiates a new waveform db.
*/
public WaveformDb() {
super();
waveforms = new HashMap<>();
relationTypes=new ArrayList<>();
maxTime=0L;
relationTypes = new ArrayList<>();
maxTime = 0L;
}
/**
* Gets the max time.
*
* @return the max time
*/
@Override
public Long getMaxTime() {
return maxTime;
}
/**
* Gets the stream by name.
*
* @param name the name
* @return the stream by name
*/
@Override
public IWaveform getStreamByName(String name) {
return waveforms.get(name);
}
/**
* Gets the all waves.
*
* @return the all waves
*/
@Override
public List<IWaveform> getAllWaves() {
return new ArrayList<>(waveforms.values());
}
/**
* Load.
*
* @param inp the inp
* @return true, if successful
*/
@Override
public boolean load(File inp){
for(IWaveformDbLoader loader:loaders){
public boolean load(File inp) {
for (IWaveformDbLoader loader : loaders) {
try {
if(loader.load(this, inp)){
for(IWaveform w:loader.getAllWaves()){
waveforms.put(w.getFullName(),w);
if (loader.load(this, inp)) {
for (IWaveform w : loader.getAllWaves()) {
waveforms.put(w.getFullName(), w);
}
if(loader.getMaxTime()>maxTime){
maxTime=loader.getMaxTime();
if (loader.getMaxTime() > maxTime) {
maxTime = loader.getMaxTime();
}
if(name==null) name=getFileBasename(inp.getName());
buildHierarchyNodes() ;
if (name == null)
name = getFileBasename(inp.getName());
buildHierarchyNodes();
relationTypes.addAll(loader.getAllRelationTypes());
pcs.firePropertyChange("WAVEFORMS", null, waveforms);
pcs.firePropertyChange("CHILDS", null, childs);
@@ -95,67 +142,94 @@ public class WaveformDb extends HierNode implements IWaveformDb {
} catch (Exception e) {
return false;
}
}
}
return false;
}
/**
* Gets the file basename.
*
* @param f the f
* @return the file basename
*/
protected static String getFileBasename(String f) {
String ext = "";
int i = f.lastIndexOf('.');
if (i > 0 && i < f.length() - 1) {
ext = f.substring(0, i);
}
return ext;
}
String ext = "";
int i = f.lastIndexOf('.');
if (i > 0 && i < f.length() - 1) {
ext = f.substring(0, i);
}
return ext;
}
/**
* Clear.
*/
@Override
public void clear() {
waveforms.clear();
childs.clear();
loaded=false;
loaded = false;
}
/**
* Checks if is loaded.
*
* @return true, if is loaded
*/
public boolean isLoaded() {
return loaded;
}
/**
* Builds the hierarchy nodes.
*/
private void buildHierarchyNodes() {
for(IWaveform stream:getAllWaves()){
for (IWaveform stream : getAllWaves()) {
String[] hier = stream.getName().split("\\.");
IHierNode node = this;
for(int i=0; i<hier.length-1; ++i){
for (int i = 0; i < hier.length - 1; ++i) {
String name = hier[i];
IHierNode childNode = null;
for (IHierNode n : node.getChildNodes()) {
if (n.getName().equals(name)) {
childNode=n;
childNode = n;
break;
}
}
if(childNode != null) {
if (childNode != null) {
node = childNode;
break;
}
HierNode newNode = new HierNode(name, node);
node.getChildNodes().add(newNode);
node=newNode;
node = newNode;
}
node.getChildNodes().add(stream);
stream.setParent(node);
stream.setName(hier[hier.length-1]);
stream.setName(hier[hier.length - 1]);
}
sortRecursive(this);
}
/**
* Sort recursive.
*
* @param node the node
*/
private void sortRecursive(IHierNode node) {
Collections.sort(node.getChildNodes(), (IHierNode o1, IHierNode o2) -> o1.getName().compareTo(o2.getName()));
for(IHierNode n:node.getChildNodes()) {
if(!n.getChildNodes().isEmpty())
for (IHierNode n : node.getChildNodes()) {
if (!n.getChildNodes().isEmpty())
sortRecursive(n);
}
}
/**
* Gets the all relation types.
*
* @return the all relation types
*/
@Override
public List<RelationType> getAllRelationTypes() {
return relationTypes;

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2015 MINRES Technologies GmbH and others.
* Copyright (c) 2015 - 2020 MINRES Technologies GmbH and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -17,12 +17,20 @@ import com.minres.scviewer.database.IWaveformDb;
import com.minres.scviewer.database.IWaveformDbFactory;
/**
* @author eyck
* A factory for creating WaveformDb objects.
*
* @author eyck
*/
public class WaveformDbFactory implements IWaveformDbFactory {
/* (non-Javadoc)
/**
* Gets the database.
*
* @return the database
*/
/*
* (non-Javadoc)
*
* @see com.minres.scviewer.database.IWaveformDbFactory#getDatabase()
*/
@Override