WIP161028 HF3

thobaben_serialize
Harald Wolff 2016-10-28 10:45:44 +02:00
parent 32059369c6
commit f91581c7b0
10 changed files with 258 additions and 8 deletions

View File

@ -5,7 +5,7 @@
<attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="org.hwo/src/native"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="lib" path="contrib/javassist-3.15.0-GA.jar"/>
<classpathentry kind="lib" path="contrib/hibernate-jpa-2.0-api-1.0.1.Final.jar"/>
<classpathentry kind="lib" path="contrib/cglib-nodep-3.1.jar"/>

View File

@ -1,11 +1,11 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6
org.eclipse.jdt.core.compiler.source=1.7

View File

@ -52,6 +52,8 @@ public class ByteArrayHexlifier {
buffer[i] = (byte)((source[2*i] - '0')<<4);
}
buffer[i] <<= 4;
if ((source[(2*i)+1] >= 'A')&&(source[(2*i)+1] <= 'F'))
{
buffer[i] |= (byte)((source[(2*i)+1] - 'A' + 10));

View File

@ -72,7 +72,11 @@ public class BitField {
}
}
public synchronized String toText(Integer value)
public synchronized String toText(Integer value){
return toText(value,false);
}
public synchronized String toText(Integer value,boolean extended)
{
StringBuilder sb = new StringBuilder();
@ -80,7 +84,7 @@ public class BitField {
{
for (Field field:this.fields)
{
String st = field.toText(value);
String st = field.toText(value,extended);
if (st != null)
{
if (sb.length() > 0)

View File

@ -69,7 +69,10 @@ public class Field {
return bitField;
}
public String toText(int srcValue)
public String toText(int srcValue){
return toText(srcValue,false);
}
public String toText(int srcValue,boolean extended)
{
if (len == 1)
if (getValue(srcValue)!= 0)
@ -78,7 +81,7 @@ public class Field {
return null;
else
{
return String.format("%s:%d", label, getValue(srcValue));
return String.format("%s: [0x%x] %d", label, getValue(srcValue),getValue(srcValue));
}
}

View File

@ -0,0 +1,27 @@
package org.hwo.collections;
import java.util.Enumeration;
import java.util.Iterator;
public class IteratorEnumeration<E> implements Enumeration<E> {
Iterator<E> iter;
public IteratorEnumeration(Iterator<E> iter){
this.iter = iter;
}
@Override
public boolean hasMoreElements() {
return this.iter.hasNext();
}
@Override
public E nextElement() {
return this.iter.next();
}
}

View File

@ -0,0 +1,88 @@
package org.hwo.collections;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Set;
public class LinkedListSet<T> implements Set<T> {
private LinkedList<T> elements;
public LinkedListSet(){
this.elements = new LinkedList<>();
}
@Override
public boolean add(T e) {
if (elements.contains(e))
return false;
return elements.add(e);
}
@Override
public boolean addAll(Collection<? extends T> c) {
boolean changed = false;
for (T e: c) {
if (add(e))
changed = true;
}
return changed;
}
@Override
public void clear() {
elements.clear();
}
@Override
public boolean contains(Object o) {
return elements.contains(o);
}
@Override
public boolean containsAll(Collection<?> c) {
return elements.containsAll(c);
}
@Override
public boolean isEmpty() {
return elements.isEmpty();
}
@Override
public Iterator<T> iterator() {
return elements.iterator();
}
@Override
public boolean remove(Object o) {
return elements.remove(o);
}
@Override
public boolean removeAll(Collection<?> c) {
return elements.removeAll(c);
}
@Override
public boolean retainAll(Collection<?> c) {
return elements.retainAll(c);
}
@Override
public int size() {
return elements.size();
}
@Override
public Object[] toArray() {
return elements.toArray();
}
@Override
public <T> T[] toArray(T[] a) {
return elements.toArray(a);
}
}

View File

@ -0,0 +1,78 @@
package org.hwo.collections;
import java.util.ArrayList;
import java.util.List;
public class SortedList<T extends Comparable<T>> {
private List<T> backingStore;
public SortedList(){
this.backingStore = new ArrayList<T>();
}
public SortedList(List<T> backingStore){
this.backingStore = backingStore;
}
public T after(T element){
for (int i=0;i<backingStore.size();i++){
System.err.format("after(): compare = %d\n", backingStore.get(i).compareTo(element));
if (backingStore.get(i).compareTo(element) > 0)
return backingStore.get(i);
}
return null;
}
public T before(T element){
for (int i=backingStore.size();i>0;i--){
if (backingStore.get(i-1).compareTo(element) < 0)
return backingStore.get(i-1);
}
return null;
}
public boolean add(T element){
if (backingStore.contains(element))
return false;
T a = after(element);
if (a == null){
System.err.println("a == null");
return backingStore.add(element);
}
System.err.println(String.format("Add: %d", backingStore.indexOf(a)));
backingStore.add(backingStore.indexOf(a), element);
return true;
}
public boolean remove(T element){
return backingStore.remove( element );
}
public boolean remove(int index){
return backingStore.remove( backingStore.get(index));
}
public int indexOf(T element){
return this.backingStore.indexOf(element);
}
public T get(int index){
return backingStore.get(index);
}
public boolean contains(T element){
return backingStore.contains(element);
}
public Object[] toArray(){
return backingStore.toArray();
}
public T[] toArray(T[] a){
return backingStore.toArray(a);
}
}

View File

@ -28,6 +28,10 @@ public class ObjectEditorUIHelper {
public static IObjectEditorUI editor(Object item) throws NoClassDefFoundError{
IObjectEditorUI editor;
if (item == null){
throw new NullPointerException("editor(...) needs object");
}
if (hashEditors.containsKey(item.getClass())){
return hashEditors.get(item.getClass());
}

View File

@ -0,0 +1,44 @@
package org.hwo.xml;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
import org.hwo.logging.Logging;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
public class XMLHelper {
static XPath _xpath;
public static NodeList select(Node node,String xpath){
try {
return (NodeList)_xpath.evaluate(xpath, node, XPathConstants.NODESET);
} catch (XPathExpressionException e) {
Logging.log(e);
}
return null;
}
public static Element firstNamedElement(Node node,String name){
try {
return (Element)_xpath.evaluate(name, node, XPathConstants.NODE);
} catch (XPathExpressionException e) {
Logging.log(e);
}
return null;
}
static {
_xpath = XPathFactory.newInstance().newXPath();
}
}