Snapshot
This commit is contained in:
@@ -10,5 +10,5 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
compile 'com.esotericsoftware.yamlbeans:yamlbeans:1.09'
|
||||
}
|
||||
8
out.yml
Normal file
8
out.yml
Normal file
@@ -0,0 +1,8 @@
|
||||
address: 4011 16th Ave S
|
||||
phone numbers:
|
||||
- number: 206-555-5138
|
||||
name: Home
|
||||
- number: 425-555-2306
|
||||
name: Work
|
||||
name: Nathan Sweet
|
||||
age: 28
|
||||
52
src/main/java/connected/TestFromYaml.java
Normal file
52
src/main/java/connected/TestFromYaml.java
Normal file
@@ -0,0 +1,52 @@
|
||||
package connected;
|
||||
|
||||
import java.io.FileReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
import yaml.Contact;
|
||||
|
||||
import com.esotericsoftware.yamlbeans.YamlReader;
|
||||
import com.esotericsoftware.yamlbeans.YamlWriter;
|
||||
|
||||
public class TestFromYaml {
|
||||
|
||||
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
YamlReader reader = new YamlReader(new FileReader("test.yml"));
|
||||
|
||||
// while (true) {
|
||||
//Map contact = (Map) reader.read();
|
||||
//if (contact == null) break;
|
||||
//System.out.println(contact.get("age"));
|
||||
Class<?> clazz = Contact.class;
|
||||
for (Field field : clazz.getDeclaredFields()) {
|
||||
Class<?> type = field.getType();
|
||||
if (Collection.class.isAssignableFrom(type) || Map.class.isAssignableFrom(type)) {
|
||||
System.out.println(field.getName());
|
||||
ParameterizedType listType = (ParameterizedType) field.getGenericType();
|
||||
Class<?> x = (Class<?>) listType.getActualTypeArguments()[0];
|
||||
System.out.println(x);
|
||||
reader.getConfig().setPropertyElementType(clazz, field.getName(), x);
|
||||
}
|
||||
}
|
||||
//reader.getConfig().setPropertyElementType(Contact.class, "phoneNumbers", Phone.class);
|
||||
|
||||
Contact x = reader.read(Contact.class);
|
||||
System.out.println(x.phoneNumbers.get(0));
|
||||
System.out.println(x.phoneNumbers.get(0).number);
|
||||
//System.out.println(x.phoneNumbers.get(0).get("number"));
|
||||
YamlWriter writer = new YamlWriter(new OutputStreamWriter(System.out));
|
||||
//writer.write(contact);
|
||||
//writer.close();
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,54 +1,46 @@
|
||||
package connected;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import base.work.Work;
|
||||
|
||||
import com.github.boukefalos.ibuddy.iBuddy;
|
||||
import com.github.boukefalos.lirc.Lirc;
|
||||
import com.github.boukefalos.lirc.Loader;
|
||||
|
||||
import dummy.Dummy;
|
||||
|
||||
public class TestTcpCommunication {
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
Properties localProperties = new Properties();
|
||||
localProperties.setProperty("implementation", "local");
|
||||
localProperties.setProperty("server", "true");
|
||||
localProperties.setProperty("server.port", "8883");
|
||||
localProperties.setProperty("server.protocol", "tcp");
|
||||
|
||||
Properties remoteProperties = new Properties();
|
||||
remoteProperties.setProperty("implementation", "remote");
|
||||
remoteProperties.setProperty("protocol", "tcp");
|
||||
remoteProperties.setProperty("remote.host", "localhost");
|
||||
remoteProperties.setProperty("remote.port", "8883");
|
||||
|
||||
Loader localLoader = new Loader(localProperties);
|
||||
Loader remoteLoader = new Loader(remoteProperties);
|
||||
|
||||
//Lirc localLirc = localLoader.getLirc();
|
||||
Lirc remoteLirc = remoteLoader.getLirc();
|
||||
|
||||
Properties iBuddyProperties = new Properties();
|
||||
iBuddyProperties.setProperty("implementation", "local");
|
||||
iBuddy iBuddy = new com.github.boukefalos.ibuddy.Loader(iBuddyProperties).getiBuddy();
|
||||
Dummy dummy = new Dummy(remoteLirc, iBuddy);
|
||||
|
||||
Work server = localLoader.getServer();
|
||||
|
||||
// Can we reuse the same Thread for all Listens?
|
||||
//localLirc.start();
|
||||
remoteLirc.start();
|
||||
server.start();
|
||||
dummy.start();
|
||||
|
||||
|
||||
Thread.sleep(10000);
|
||||
//server.exit();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
package connected;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import base.Control;
|
||||
|
||||
import com.github.boukefalos.ibuddy.iBuddy;
|
||||
import com.github.boukefalos.lirc.Lirc;
|
||||
import com.github.boukefalos.lirc.Loader;
|
||||
|
||||
import dummy.Dummy;
|
||||
|
||||
public class TestTcpCommunication {
|
||||
public static void main(String[] args) throws Exception {
|
||||
Properties localProperties = new Properties();
|
||||
localProperties.setProperty("implementation", "local");
|
||||
localProperties.setProperty("server", "true");
|
||||
localProperties.setProperty("server.port", "8883");
|
||||
localProperties.setProperty("server.protocol", "tcp");
|
||||
|
||||
Properties remoteProperties = new Properties();
|
||||
remoteProperties.setProperty("implementation", "remote");
|
||||
remoteProperties.setProperty("protocol", "tcp");
|
||||
remoteProperties.setProperty("remote.host", "localhost");
|
||||
remoteProperties.setProperty("remote.port", "8883");
|
||||
|
||||
Loader localLoader = new Loader(localProperties);
|
||||
Loader remoteLoader = new Loader(remoteProperties);
|
||||
|
||||
Lirc localLirc = localLoader.getLirc();
|
||||
Lirc remoteLirc = remoteLoader.getLirc();
|
||||
|
||||
Properties iBuddyProperties = new Properties();
|
||||
iBuddyProperties.setProperty("implementation", "local");
|
||||
iBuddy iBuddy = new com.github.boukefalos.ibuddy.Loader(iBuddyProperties).getiBuddy();
|
||||
Dummy dummy = new Dummy(localLirc, iBuddy);
|
||||
|
||||
Control server = localLoader.getServer();
|
||||
|
||||
remoteLirc.start();
|
||||
server.start();
|
||||
dummy.start();
|
||||
|
||||
Thread.sleep(10000);
|
||||
}
|
||||
}
|
||||
|
||||
14
src/main/java/yaml/Contact.java
Normal file
14
src/main/java/yaml/Contact.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package yaml;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class Contact {
|
||||
public String name;
|
||||
public int age;
|
||||
public String address;
|
||||
public List<Phone> phoneNumbers; // HashMap<String,String>
|
||||
public Map<String,String> other;
|
||||
//public HashMap<Phone> x;
|
||||
}
|
||||
6
src/main/java/yaml/Phone.java
Normal file
6
src/main/java/yaml/Phone.java
Normal file
@@ -0,0 +1,6 @@
|
||||
package yaml;
|
||||
|
||||
public class Phone {
|
||||
public String name;
|
||||
public String number;
|
||||
}
|
||||
@@ -1,68 +1,68 @@
|
||||
package connected;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import lirc.Lirc;
|
||||
import base.work.Listen;
|
||||
|
||||
import com.github.boukefalos.lirc.LircButton;
|
||||
import com.github.boukefalos.lirc.implementation.LocalImplementation;
|
||||
import com.github.boukefalos.lirc.util.SignalObject;
|
||||
public class TestParsing extends Listen<SignalObject<LircButton>> {
|
||||
public static void main(String[] args) {
|
||||
new TestParsing().start();
|
||||
}
|
||||
|
||||
protected HashMap<String, LircButton[]> buttonMap;
|
||||
//protected LircTaskMapCycle taskMapCycle;
|
||||
//buttonMap = new HashMap<String, LircButton[]>();
|
||||
|
||||
public void start() {
|
||||
LocalImplementation lirc = new LocalImplementation();
|
||||
|
||||
/*public void put(String name, LircButton[] LircButtonArray) {
|
||||
buttonMap.put(name, LircButtonArray);
|
||||
}*/
|
||||
|
||||
|
||||
/*public LircButton parseButton(Scanner scanner) throws UnknownButtonException {
|
||||
try {
|
||||
|
||||
LircButton[] buttonArray = buttonMap.get(remote);
|
||||
f (buttonArray != null) {
|
||||
for (LircButton button : buttonArray) {
|
||||
if (button.getCode().equals(code)) {
|
||||
return button;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (InputMismatchException e) {
|
||||
logger.error("", e);
|
||||
} catch (NoSuchElementException e) {
|
||||
logger.error("", e);
|
||||
}
|
||||
throw new UnknownButtonException();
|
||||
}*/
|
||||
|
||||
/*put(PhiliphsRCLE011Button.NAME, PhiliphsRCLE011Button.values());
|
||||
put(DenonRC176Button.NAME, DenonRC176Button.values());
|
||||
put(SamsungBN5901015AButton.NAME, SamsungBN5901015AButton.values());*/
|
||||
|
||||
lirc.Lirc.Signal x = Lirc.Signal.BEGIN;
|
||||
//lirc.put(PhiliphsRCLE011Button.NAME, PhiliphsRCLE011Button.values());
|
||||
lirc.start();
|
||||
super.start();
|
||||
|
||||
try {
|
||||
Thread.sleep(100000000);
|
||||
} catch (InterruptedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void put(String name, LircButton[] LircButtonArray) {
|
||||
buttonMap.put(name, LircButtonArray);
|
||||
}
|
||||
}
|
||||
package yaml;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import lirc.Lirc;
|
||||
import base.work.Listen;
|
||||
|
||||
import com.github.boukefalos.lirc.LircButton;
|
||||
import com.github.boukefalos.lirc.implementation.Local;
|
||||
import com.github.boukefalos.lirc.util.SignalObject;
|
||||
public class TestParsing extends Listen<SignalObject<LircButton>> {
|
||||
public static void main(String[] args) {
|
||||
new TestParsing().start();
|
||||
}
|
||||
|
||||
protected HashMap<String, LircButton[]> buttonMap;
|
||||
//protected LircTaskMapCycle taskMapCycle;
|
||||
//buttonMap = new HashMap<String, LircButton[]>();
|
||||
|
||||
public void start() {
|
||||
Local lirc = new Local();
|
||||
|
||||
/*public void put(String name, LircButton[] LircButtonArray) {
|
||||
buttonMap.put(name, LircButtonArray);
|
||||
}*/
|
||||
|
||||
|
||||
/*public LircButton parseButton(Scanner scanner) throws UnknownButtonException {
|
||||
try {
|
||||
|
||||
LircButton[] buttonArray = buttonMap.get(remote);
|
||||
f (buttonArray != null) {
|
||||
for (LircButton button : buttonArray) {
|
||||
if (button.getCode().equals(code)) {
|
||||
return button;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (InputMismatchException e) {
|
||||
logger.error("", e);
|
||||
} catch (NoSuchElementException e) {
|
||||
logger.error("", e);
|
||||
}
|
||||
throw new UnknownButtonException();
|
||||
}*/
|
||||
|
||||
/*put(PhiliphsRCLE011Button.NAME, PhiliphsRCLE011Button.values());
|
||||
put(DenonRC176Button.NAME, DenonRC176Button.values());
|
||||
put(SamsungBN5901015AButton.NAME, SamsungBN5901015AButton.values());*/
|
||||
|
||||
lirc.Lirc.Signal x = Lirc.Signal.BEGIN;
|
||||
//lirc.put(PhiliphsRCLE011Button.NAME, PhiliphsRCLE011Button.values());
|
||||
lirc.start();
|
||||
super.start();
|
||||
|
||||
try {
|
||||
Thread.sleep(100000000);
|
||||
} catch (InterruptedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void put(String name, LircButton[] LircButtonArray) {
|
||||
buttonMap.put(name, LircButtonArray);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user