forked from LupusNobilis/java-org.hwo
Updates
parent
e271583f3e
commit
5c7987551f
|
@ -1,10 +1,16 @@
|
|||
package org.hwo;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
||||
public class StringHelper {
|
||||
|
||||
public static String join(String[] c,String del)
|
||||
{
|
||||
return join( Arrays.asList(c),del);
|
||||
}
|
||||
|
||||
public static String join(Collection<?> c,String del)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
|
|
@ -130,7 +130,7 @@ public class ServiceLink {
|
|||
if (chksum != ChkSum.chksum(rxbuffer, 0, bb.position() - 2))
|
||||
throw new ServiceLinkException();
|
||||
|
||||
System.err.println(String.format("recv(): %d.%d:%d = 0x%08x",achse,knoten,register,bb.getInt(5)));
|
||||
//System.err.println(String.format("recv(): %d.%d:%d = 0x%08x",achse,knoten,register,bb.getInt(5)));
|
||||
|
||||
} catch (IOException e) {
|
||||
getSerialPort().close();
|
||||
|
@ -185,7 +185,7 @@ public class ServiceLink {
|
|||
{
|
||||
this.retries = 3;
|
||||
this.serialPort = serialPort;
|
||||
this.serialPort.setTimeout(250);
|
||||
this.serialPort.setTimeout(500);
|
||||
this.serviceRegisterCache = new ServiceRegisterCache(this);
|
||||
this.requestTime = new Smoother();
|
||||
this.requestTime.setTn(16);
|
||||
|
|
|
@ -53,7 +53,10 @@ public class IntegerRegisterEditor extends JPanel implements ServiceRegisterCont
|
|||
|
||||
@Override
|
||||
public void readValue() {
|
||||
tfValue.setText(this.serviceRegister.readIntegerValue().toString());
|
||||
Integer i = this.serviceRegister.readIntegerValue();
|
||||
if ( i == null )
|
||||
i = 0;
|
||||
tfValue.setText(i.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -4,7 +4,10 @@ import java.io.IOException;
|
|||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import javax.xml.ws.http.HTTPException;
|
||||
|
||||
import org.hwo.net.ServerObject;
|
||||
import org.hwo.net.http.HttpException;
|
||||
import org.hwo.net.http.HttpServerRequest;
|
||||
|
||||
public abstract class AbstractServerObject implements ServerObject {
|
||||
|
@ -49,7 +52,7 @@ public abstract class AbstractServerObject implements ServerObject {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void climb(ServerObjectRequest request) throws IOException {
|
||||
public void climb(ServerObjectRequest request) throws IOException, HttpException {
|
||||
String nextChildName = request.popNextElement();
|
||||
|
||||
if (nextChildName == null)
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
package org.hwo.security;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class User {
|
||||
|
||||
private String username;
|
||||
private List<String> associatedRights;
|
||||
|
||||
public User()
|
||||
{
|
||||
username = null;
|
||||
associatedRights = new ArrayList<String>();
|
||||
}
|
||||
|
||||
public String[] getAssociatedRights()
|
||||
{
|
||||
return associatedRights.toArray(new String[0]);
|
||||
}
|
||||
|
||||
public String getUserName()
|
||||
{
|
||||
return this.username;
|
||||
}
|
||||
|
||||
public void deauthenticate()
|
||||
{
|
||||
this.username = null;
|
||||
this.associatedRights.clear();
|
||||
}
|
||||
|
||||
public boolean authenticate(String username,String password)
|
||||
{
|
||||
this.username = username;
|
||||
this.associatedRights.add("sys.default.user.implementation");
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package org.hwo.xml;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
public class NodeListIterator implements Iterable<Element>{
|
||||
|
||||
|
||||
private List<Element> elements;
|
||||
|
||||
public static NodeListIterator create(NodeList nodes)
|
||||
{
|
||||
return new NodeListIterator(nodes);
|
||||
}
|
||||
|
||||
public NodeListIterator(NodeList nodes)
|
||||
{
|
||||
this.elements = new ArrayList<Element>();
|
||||
for (int i=0;i<nodes.getLength();i++)
|
||||
if (nodes.item(i).getNodeType() == Node.ELEMENT_NODE)
|
||||
{
|
||||
elements.add((Element)nodes.item(i));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Iterator<Element> iterator() {
|
||||
return this.elements.iterator();
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue