repo_name
stringlengths 7
104
| file_path
stringlengths 13
198
| context
stringlengths 67
7.15k
| import_statement
stringlengths 16
4.43k
| code
stringlengths 40
6.98k
| prompt
stringlengths 227
8.27k
| next_line
stringlengths 8
795
|
---|---|---|---|---|---|---|
insightfullogic/java-multi-inherit | src/test/java/com/insightfullogic/multiinherit/TestGeneration.java | // Path: src/main/java/com/insightfullogic/multiinherit/api/MultiModule.java
// public class MultiModule extends AbstractModule {
//
// private final Class<?>[] classes;
// private final boolean useGeneration;
// private final boolean dumpClasses;
//
// public MultiModule(final boolean useGeneration, final Class<?>... classes) {
// this(useGeneration, false, classes);
// }
//
// public MultiModule(final boolean useGeneration, final boolean dumpClasses, final Class<?>... classes) {
// if (!useGeneration && dumpClasses) {
// throw new IllegalArgumentException("You cannot dump the generate class files if you're not generating class files");
// }
// this.classes = classes;
// this.useGeneration = useGeneration;
// this.dumpClasses = dumpClasses;
// }
//
// @SuppressWarnings({ "rawtypes", "unchecked" })
// private void bindMulti(final Class<?>... classes) {
// if (useGeneration) {
// bind(MultiInjector.class).to(GenerationMultiInjector.class);
// bind(Boolean.class).annotatedWith(Names.named("dump")).toInstance(dumpClasses);
// } else {
// bind(MultiInjector.class).to(ReflectionMultiInjector.class);
// }
// for (final Class cls : classes) {
// bind(cls).toProvider(new MultiProvider(cls));
// }
// }
//
// @Override
// protected void configure() {
// bindMulti(classes);
// }
//
// }
//
// Path: src/test/java/com/insightfullogic/multiinherit/simple/Combined.java
// public interface Combined extends A, B {
//
// }
| import java.lang.reflect.Field;
import junit.framework.Assert;
import org.junit.Test;
import com.google.inject.Guice;
import com.google.inject.Inject;
import com.google.inject.Injector;
import com.insightfullogic.multiinherit.api.MultiModule;
import com.insightfullogic.multiinherit.simple.Combined; | package com.insightfullogic.multiinherit;
public class TestGeneration {
@Test
public void simple() { | // Path: src/main/java/com/insightfullogic/multiinherit/api/MultiModule.java
// public class MultiModule extends AbstractModule {
//
// private final Class<?>[] classes;
// private final boolean useGeneration;
// private final boolean dumpClasses;
//
// public MultiModule(final boolean useGeneration, final Class<?>... classes) {
// this(useGeneration, false, classes);
// }
//
// public MultiModule(final boolean useGeneration, final boolean dumpClasses, final Class<?>... classes) {
// if (!useGeneration && dumpClasses) {
// throw new IllegalArgumentException("You cannot dump the generate class files if you're not generating class files");
// }
// this.classes = classes;
// this.useGeneration = useGeneration;
// this.dumpClasses = dumpClasses;
// }
//
// @SuppressWarnings({ "rawtypes", "unchecked" })
// private void bindMulti(final Class<?>... classes) {
// if (useGeneration) {
// bind(MultiInjector.class).to(GenerationMultiInjector.class);
// bind(Boolean.class).annotatedWith(Names.named("dump")).toInstance(dumpClasses);
// } else {
// bind(MultiInjector.class).to(ReflectionMultiInjector.class);
// }
// for (final Class cls : classes) {
// bind(cls).toProvider(new MultiProvider(cls));
// }
// }
//
// @Override
// protected void configure() {
// bindMulti(classes);
// }
//
// }
//
// Path: src/test/java/com/insightfullogic/multiinherit/simple/Combined.java
// public interface Combined extends A, B {
//
// }
// Path: src/test/java/com/insightfullogic/multiinherit/TestGeneration.java
import java.lang.reflect.Field;
import junit.framework.Assert;
import org.junit.Test;
import com.google.inject.Guice;
import com.google.inject.Inject;
import com.google.inject.Injector;
import com.insightfullogic.multiinherit.api.MultiModule;
import com.insightfullogic.multiinherit.simple.Combined;
package com.insightfullogic.multiinherit;
public class TestGeneration {
@Test
public void simple() { | final Injector injector = Guice.createInjector(new MultiModule(true, Combined.class)); |
insightfullogic/java-multi-inherit | src/test/java/com/insightfullogic/multiinherit/TestGeneration.java | // Path: src/main/java/com/insightfullogic/multiinherit/api/MultiModule.java
// public class MultiModule extends AbstractModule {
//
// private final Class<?>[] classes;
// private final boolean useGeneration;
// private final boolean dumpClasses;
//
// public MultiModule(final boolean useGeneration, final Class<?>... classes) {
// this(useGeneration, false, classes);
// }
//
// public MultiModule(final boolean useGeneration, final boolean dumpClasses, final Class<?>... classes) {
// if (!useGeneration && dumpClasses) {
// throw new IllegalArgumentException("You cannot dump the generate class files if you're not generating class files");
// }
// this.classes = classes;
// this.useGeneration = useGeneration;
// this.dumpClasses = dumpClasses;
// }
//
// @SuppressWarnings({ "rawtypes", "unchecked" })
// private void bindMulti(final Class<?>... classes) {
// if (useGeneration) {
// bind(MultiInjector.class).to(GenerationMultiInjector.class);
// bind(Boolean.class).annotatedWith(Names.named("dump")).toInstance(dumpClasses);
// } else {
// bind(MultiInjector.class).to(ReflectionMultiInjector.class);
// }
// for (final Class cls : classes) {
// bind(cls).toProvider(new MultiProvider(cls));
// }
// }
//
// @Override
// protected void configure() {
// bindMulti(classes);
// }
//
// }
//
// Path: src/test/java/com/insightfullogic/multiinherit/simple/Combined.java
// public interface Combined extends A, B {
//
// }
| import java.lang.reflect.Field;
import junit.framework.Assert;
import org.junit.Test;
import com.google.inject.Guice;
import com.google.inject.Inject;
import com.google.inject.Injector;
import com.insightfullogic.multiinherit.api.MultiModule;
import com.insightfullogic.multiinherit.simple.Combined; | package com.insightfullogic.multiinherit;
public class TestGeneration {
@Test
public void simple() { | // Path: src/main/java/com/insightfullogic/multiinherit/api/MultiModule.java
// public class MultiModule extends AbstractModule {
//
// private final Class<?>[] classes;
// private final boolean useGeneration;
// private final boolean dumpClasses;
//
// public MultiModule(final boolean useGeneration, final Class<?>... classes) {
// this(useGeneration, false, classes);
// }
//
// public MultiModule(final boolean useGeneration, final boolean dumpClasses, final Class<?>... classes) {
// if (!useGeneration && dumpClasses) {
// throw new IllegalArgumentException("You cannot dump the generate class files if you're not generating class files");
// }
// this.classes = classes;
// this.useGeneration = useGeneration;
// this.dumpClasses = dumpClasses;
// }
//
// @SuppressWarnings({ "rawtypes", "unchecked" })
// private void bindMulti(final Class<?>... classes) {
// if (useGeneration) {
// bind(MultiInjector.class).to(GenerationMultiInjector.class);
// bind(Boolean.class).annotatedWith(Names.named("dump")).toInstance(dumpClasses);
// } else {
// bind(MultiInjector.class).to(ReflectionMultiInjector.class);
// }
// for (final Class cls : classes) {
// bind(cls).toProvider(new MultiProvider(cls));
// }
// }
//
// @Override
// protected void configure() {
// bindMulti(classes);
// }
//
// }
//
// Path: src/test/java/com/insightfullogic/multiinherit/simple/Combined.java
// public interface Combined extends A, B {
//
// }
// Path: src/test/java/com/insightfullogic/multiinherit/TestGeneration.java
import java.lang.reflect.Field;
import junit.framework.Assert;
import org.junit.Test;
import com.google.inject.Guice;
import com.google.inject.Inject;
import com.google.inject.Injector;
import com.insightfullogic.multiinherit.api.MultiModule;
import com.insightfullogic.multiinherit.simple.Combined;
package com.insightfullogic.multiinherit;
public class TestGeneration {
@Test
public void simple() { | final Injector injector = Guice.createInjector(new MultiModule(true, Combined.class)); |
insightfullogic/java-multi-inherit | src/test/java/com/insightfullogic/multiinherit/arguments/TestArgumentCases.java | // Path: src/test/java/com/insightfullogic/multiinherit/Util.java
// public class Util {
//
// public static interface Do<T> {
// public void apply(T t);
// }
//
// public static void withBools(final Do<Boolean> what) {
// what.apply(true);
// what.apply(false);
// }
// }
//
// Path: src/test/java/com/insightfullogic/multiinherit/Util.java
// public static interface Do<T> {
// public void apply(T t);
// }
//
// Path: src/main/java/com/insightfullogic/multiinherit/api/MultiModule.java
// public class MultiModule extends AbstractModule {
//
// private final Class<?>[] classes;
// private final boolean useGeneration;
// private final boolean dumpClasses;
//
// public MultiModule(final boolean useGeneration, final Class<?>... classes) {
// this(useGeneration, false, classes);
// }
//
// public MultiModule(final boolean useGeneration, final boolean dumpClasses, final Class<?>... classes) {
// if (!useGeneration && dumpClasses) {
// throw new IllegalArgumentException("You cannot dump the generate class files if you're not generating class files");
// }
// this.classes = classes;
// this.useGeneration = useGeneration;
// this.dumpClasses = dumpClasses;
// }
//
// @SuppressWarnings({ "rawtypes", "unchecked" })
// private void bindMulti(final Class<?>... classes) {
// if (useGeneration) {
// bind(MultiInjector.class).to(GenerationMultiInjector.class);
// bind(Boolean.class).annotatedWith(Names.named("dump")).toInstance(dumpClasses);
// } else {
// bind(MultiInjector.class).to(ReflectionMultiInjector.class);
// }
// for (final Class cls : classes) {
// bind(cls).toProvider(new MultiProvider(cls));
// }
// }
//
// @Override
// protected void configure() {
// bindMulti(classes);
// }
//
// }
| import static junit.framework.Assert.assertEquals;
import org.junit.Test;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.insightfullogic.multiinherit.Util;
import com.insightfullogic.multiinherit.Util.Do;
import com.insightfullogic.multiinherit.api.MultiModule;
| package com.insightfullogic.multiinherit.arguments;
public class TestArgumentCases {
@Test
public void checkArguments() {
| // Path: src/test/java/com/insightfullogic/multiinherit/Util.java
// public class Util {
//
// public static interface Do<T> {
// public void apply(T t);
// }
//
// public static void withBools(final Do<Boolean> what) {
// what.apply(true);
// what.apply(false);
// }
// }
//
// Path: src/test/java/com/insightfullogic/multiinherit/Util.java
// public static interface Do<T> {
// public void apply(T t);
// }
//
// Path: src/main/java/com/insightfullogic/multiinherit/api/MultiModule.java
// public class MultiModule extends AbstractModule {
//
// private final Class<?>[] classes;
// private final boolean useGeneration;
// private final boolean dumpClasses;
//
// public MultiModule(final boolean useGeneration, final Class<?>... classes) {
// this(useGeneration, false, classes);
// }
//
// public MultiModule(final boolean useGeneration, final boolean dumpClasses, final Class<?>... classes) {
// if (!useGeneration && dumpClasses) {
// throw new IllegalArgumentException("You cannot dump the generate class files if you're not generating class files");
// }
// this.classes = classes;
// this.useGeneration = useGeneration;
// this.dumpClasses = dumpClasses;
// }
//
// @SuppressWarnings({ "rawtypes", "unchecked" })
// private void bindMulti(final Class<?>... classes) {
// if (useGeneration) {
// bind(MultiInjector.class).to(GenerationMultiInjector.class);
// bind(Boolean.class).annotatedWith(Names.named("dump")).toInstance(dumpClasses);
// } else {
// bind(MultiInjector.class).to(ReflectionMultiInjector.class);
// }
// for (final Class cls : classes) {
// bind(cls).toProvider(new MultiProvider(cls));
// }
// }
//
// @Override
// protected void configure() {
// bindMulti(classes);
// }
//
// }
// Path: src/test/java/com/insightfullogic/multiinherit/arguments/TestArgumentCases.java
import static junit.framework.Assert.assertEquals;
import org.junit.Test;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.insightfullogic.multiinherit.Util;
import com.insightfullogic.multiinherit.Util.Do;
import com.insightfullogic.multiinherit.api.MultiModule;
package com.insightfullogic.multiinherit.arguments;
public class TestArgumentCases {
@Test
public void checkArguments() {
| Util.withBools(new Do<Boolean>() {
|
insightfullogic/java-multi-inherit | src/test/java/com/insightfullogic/multiinherit/arguments/TestArgumentCases.java | // Path: src/test/java/com/insightfullogic/multiinherit/Util.java
// public class Util {
//
// public static interface Do<T> {
// public void apply(T t);
// }
//
// public static void withBools(final Do<Boolean> what) {
// what.apply(true);
// what.apply(false);
// }
// }
//
// Path: src/test/java/com/insightfullogic/multiinherit/Util.java
// public static interface Do<T> {
// public void apply(T t);
// }
//
// Path: src/main/java/com/insightfullogic/multiinherit/api/MultiModule.java
// public class MultiModule extends AbstractModule {
//
// private final Class<?>[] classes;
// private final boolean useGeneration;
// private final boolean dumpClasses;
//
// public MultiModule(final boolean useGeneration, final Class<?>... classes) {
// this(useGeneration, false, classes);
// }
//
// public MultiModule(final boolean useGeneration, final boolean dumpClasses, final Class<?>... classes) {
// if (!useGeneration && dumpClasses) {
// throw new IllegalArgumentException("You cannot dump the generate class files if you're not generating class files");
// }
// this.classes = classes;
// this.useGeneration = useGeneration;
// this.dumpClasses = dumpClasses;
// }
//
// @SuppressWarnings({ "rawtypes", "unchecked" })
// private void bindMulti(final Class<?>... classes) {
// if (useGeneration) {
// bind(MultiInjector.class).to(GenerationMultiInjector.class);
// bind(Boolean.class).annotatedWith(Names.named("dump")).toInstance(dumpClasses);
// } else {
// bind(MultiInjector.class).to(ReflectionMultiInjector.class);
// }
// for (final Class cls : classes) {
// bind(cls).toProvider(new MultiProvider(cls));
// }
// }
//
// @Override
// protected void configure() {
// bindMulti(classes);
// }
//
// }
| import static junit.framework.Assert.assertEquals;
import org.junit.Test;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.insightfullogic.multiinherit.Util;
import com.insightfullogic.multiinherit.Util.Do;
import com.insightfullogic.multiinherit.api.MultiModule;
| package com.insightfullogic.multiinherit.arguments;
public class TestArgumentCases {
@Test
public void checkArguments() {
| // Path: src/test/java/com/insightfullogic/multiinherit/Util.java
// public class Util {
//
// public static interface Do<T> {
// public void apply(T t);
// }
//
// public static void withBools(final Do<Boolean> what) {
// what.apply(true);
// what.apply(false);
// }
// }
//
// Path: src/test/java/com/insightfullogic/multiinherit/Util.java
// public static interface Do<T> {
// public void apply(T t);
// }
//
// Path: src/main/java/com/insightfullogic/multiinherit/api/MultiModule.java
// public class MultiModule extends AbstractModule {
//
// private final Class<?>[] classes;
// private final boolean useGeneration;
// private final boolean dumpClasses;
//
// public MultiModule(final boolean useGeneration, final Class<?>... classes) {
// this(useGeneration, false, classes);
// }
//
// public MultiModule(final boolean useGeneration, final boolean dumpClasses, final Class<?>... classes) {
// if (!useGeneration && dumpClasses) {
// throw new IllegalArgumentException("You cannot dump the generate class files if you're not generating class files");
// }
// this.classes = classes;
// this.useGeneration = useGeneration;
// this.dumpClasses = dumpClasses;
// }
//
// @SuppressWarnings({ "rawtypes", "unchecked" })
// private void bindMulti(final Class<?>... classes) {
// if (useGeneration) {
// bind(MultiInjector.class).to(GenerationMultiInjector.class);
// bind(Boolean.class).annotatedWith(Names.named("dump")).toInstance(dumpClasses);
// } else {
// bind(MultiInjector.class).to(ReflectionMultiInjector.class);
// }
// for (final Class cls : classes) {
// bind(cls).toProvider(new MultiProvider(cls));
// }
// }
//
// @Override
// protected void configure() {
// bindMulti(classes);
// }
//
// }
// Path: src/test/java/com/insightfullogic/multiinherit/arguments/TestArgumentCases.java
import static junit.framework.Assert.assertEquals;
import org.junit.Test;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.insightfullogic.multiinherit.Util;
import com.insightfullogic.multiinherit.Util.Do;
import com.insightfullogic.multiinherit.api.MultiModule;
package com.insightfullogic.multiinherit.arguments;
public class TestArgumentCases {
@Test
public void checkArguments() {
| Util.withBools(new Do<Boolean>() {
|
insightfullogic/java-multi-inherit | src/test/java/com/insightfullogic/multiinherit/arguments/TestArgumentCases.java | // Path: src/test/java/com/insightfullogic/multiinherit/Util.java
// public class Util {
//
// public static interface Do<T> {
// public void apply(T t);
// }
//
// public static void withBools(final Do<Boolean> what) {
// what.apply(true);
// what.apply(false);
// }
// }
//
// Path: src/test/java/com/insightfullogic/multiinherit/Util.java
// public static interface Do<T> {
// public void apply(T t);
// }
//
// Path: src/main/java/com/insightfullogic/multiinherit/api/MultiModule.java
// public class MultiModule extends AbstractModule {
//
// private final Class<?>[] classes;
// private final boolean useGeneration;
// private final boolean dumpClasses;
//
// public MultiModule(final boolean useGeneration, final Class<?>... classes) {
// this(useGeneration, false, classes);
// }
//
// public MultiModule(final boolean useGeneration, final boolean dumpClasses, final Class<?>... classes) {
// if (!useGeneration && dumpClasses) {
// throw new IllegalArgumentException("You cannot dump the generate class files if you're not generating class files");
// }
// this.classes = classes;
// this.useGeneration = useGeneration;
// this.dumpClasses = dumpClasses;
// }
//
// @SuppressWarnings({ "rawtypes", "unchecked" })
// private void bindMulti(final Class<?>... classes) {
// if (useGeneration) {
// bind(MultiInjector.class).to(GenerationMultiInjector.class);
// bind(Boolean.class).annotatedWith(Names.named("dump")).toInstance(dumpClasses);
// } else {
// bind(MultiInjector.class).to(ReflectionMultiInjector.class);
// }
// for (final Class cls : classes) {
// bind(cls).toProvider(new MultiProvider(cls));
// }
// }
//
// @Override
// protected void configure() {
// bindMulti(classes);
// }
//
// }
| import static junit.framework.Assert.assertEquals;
import org.junit.Test;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.insightfullogic.multiinherit.Util;
import com.insightfullogic.multiinherit.Util.Do;
import com.insightfullogic.multiinherit.api.MultiModule;
| package com.insightfullogic.multiinherit.arguments;
public class TestArgumentCases {
@Test
public void checkArguments() {
Util.withBools(new Do<Boolean>() {
@Override
public void apply(final Boolean b) {
| // Path: src/test/java/com/insightfullogic/multiinherit/Util.java
// public class Util {
//
// public static interface Do<T> {
// public void apply(T t);
// }
//
// public static void withBools(final Do<Boolean> what) {
// what.apply(true);
// what.apply(false);
// }
// }
//
// Path: src/test/java/com/insightfullogic/multiinherit/Util.java
// public static interface Do<T> {
// public void apply(T t);
// }
//
// Path: src/main/java/com/insightfullogic/multiinherit/api/MultiModule.java
// public class MultiModule extends AbstractModule {
//
// private final Class<?>[] classes;
// private final boolean useGeneration;
// private final boolean dumpClasses;
//
// public MultiModule(final boolean useGeneration, final Class<?>... classes) {
// this(useGeneration, false, classes);
// }
//
// public MultiModule(final boolean useGeneration, final boolean dumpClasses, final Class<?>... classes) {
// if (!useGeneration && dumpClasses) {
// throw new IllegalArgumentException("You cannot dump the generate class files if you're not generating class files");
// }
// this.classes = classes;
// this.useGeneration = useGeneration;
// this.dumpClasses = dumpClasses;
// }
//
// @SuppressWarnings({ "rawtypes", "unchecked" })
// private void bindMulti(final Class<?>... classes) {
// if (useGeneration) {
// bind(MultiInjector.class).to(GenerationMultiInjector.class);
// bind(Boolean.class).annotatedWith(Names.named("dump")).toInstance(dumpClasses);
// } else {
// bind(MultiInjector.class).to(ReflectionMultiInjector.class);
// }
// for (final Class cls : classes) {
// bind(cls).toProvider(new MultiProvider(cls));
// }
// }
//
// @Override
// protected void configure() {
// bindMulti(classes);
// }
//
// }
// Path: src/test/java/com/insightfullogic/multiinherit/arguments/TestArgumentCases.java
import static junit.framework.Assert.assertEquals;
import org.junit.Test;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.insightfullogic.multiinherit.Util;
import com.insightfullogic.multiinherit.Util.Do;
import com.insightfullogic.multiinherit.api.MultiModule;
package com.insightfullogic.multiinherit.arguments;
public class TestArgumentCases {
@Test
public void checkArguments() {
Util.withBools(new Do<Boolean>() {
@Override
public void apply(final Boolean b) {
| final Injector injector = Guice.createInjector(new MultiModule(b, CombinedArguments.class));
|
insightfullogic/java-multi-inherit | src/test/java/com/insightfullogic/multiinherit/TestApi.java | // Path: src/main/java/com/insightfullogic/multiinherit/api/MultiModule.java
// public class MultiModule extends AbstractModule {
//
// private final Class<?>[] classes;
// private final boolean useGeneration;
// private final boolean dumpClasses;
//
// public MultiModule(final boolean useGeneration, final Class<?>... classes) {
// this(useGeneration, false, classes);
// }
//
// public MultiModule(final boolean useGeneration, final boolean dumpClasses, final Class<?>... classes) {
// if (!useGeneration && dumpClasses) {
// throw new IllegalArgumentException("You cannot dump the generate class files if you're not generating class files");
// }
// this.classes = classes;
// this.useGeneration = useGeneration;
// this.dumpClasses = dumpClasses;
// }
//
// @SuppressWarnings({ "rawtypes", "unchecked" })
// private void bindMulti(final Class<?>... classes) {
// if (useGeneration) {
// bind(MultiInjector.class).to(GenerationMultiInjector.class);
// bind(Boolean.class).annotatedWith(Names.named("dump")).toInstance(dumpClasses);
// } else {
// bind(MultiInjector.class).to(ReflectionMultiInjector.class);
// }
// for (final Class cls : classes) {
// bind(cls).toProvider(new MultiProvider(cls));
// }
// }
//
// @Override
// protected void configure() {
// bindMulti(classes);
// }
//
// }
| import org.junit.Test;
import com.insightfullogic.multiinherit.api.MultiModule; | package com.insightfullogic.multiinherit;
public class TestApi {
@SuppressWarnings("unused")
@Test(expected = IllegalArgumentException.class)
public void dumpClassesOption() { | // Path: src/main/java/com/insightfullogic/multiinherit/api/MultiModule.java
// public class MultiModule extends AbstractModule {
//
// private final Class<?>[] classes;
// private final boolean useGeneration;
// private final boolean dumpClasses;
//
// public MultiModule(final boolean useGeneration, final Class<?>... classes) {
// this(useGeneration, false, classes);
// }
//
// public MultiModule(final boolean useGeneration, final boolean dumpClasses, final Class<?>... classes) {
// if (!useGeneration && dumpClasses) {
// throw new IllegalArgumentException("You cannot dump the generate class files if you're not generating class files");
// }
// this.classes = classes;
// this.useGeneration = useGeneration;
// this.dumpClasses = dumpClasses;
// }
//
// @SuppressWarnings({ "rawtypes", "unchecked" })
// private void bindMulti(final Class<?>... classes) {
// if (useGeneration) {
// bind(MultiInjector.class).to(GenerationMultiInjector.class);
// bind(Boolean.class).annotatedWith(Names.named("dump")).toInstance(dumpClasses);
// } else {
// bind(MultiInjector.class).to(ReflectionMultiInjector.class);
// }
// for (final Class cls : classes) {
// bind(cls).toProvider(new MultiProvider(cls));
// }
// }
//
// @Override
// protected void configure() {
// bindMulti(classes);
// }
//
// }
// Path: src/test/java/com/insightfullogic/multiinherit/TestApi.java
import org.junit.Test;
import com.insightfullogic.multiinherit.api.MultiModule;
package com.insightfullogic.multiinherit;
public class TestApi {
@SuppressWarnings("unused")
@Test(expected = IllegalArgumentException.class)
public void dumpClassesOption() { | new MultiModule(false, true); |
insightfullogic/java-multi-inherit | src/main/java/com/insightfullogic/multiinherit/generation/GenerationMultiInjector.java | // Path: src/main/java/com/insightfullogic/multiinherit/api/MultiInjector.java
// public interface MultiInjector {
//
// public <T> T getInstance(Class<T> combined);
//
// }
//
// Path: src/main/java/com/insightfullogic/multiinherit/api/TypeHierachyException.java
// public class TypeHierachyException extends RuntimeException {
//
// public TypeHierachyException(final String message) {
// super(message);
// }
//
// /**
// *
// */
// private static final long serialVersionUID = -2994395832274210972L;
//
// }
| import static java.util.Arrays.asList;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type;
import org.objectweb.asm.tree.AnnotationNode;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.FieldInsnNode;
import org.objectweb.asm.tree.FieldNode;
import org.objectweb.asm.tree.InsnList;
import org.objectweb.asm.tree.InsnNode;
import org.objectweb.asm.tree.MethodInsnNode;
import org.objectweb.asm.tree.MethodNode;
import org.objectweb.asm.tree.VarInsnNode;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.google.inject.Inject;
import com.google.inject.Injector;
import com.insightfullogic.multiinherit.api.MultiInjector;
import com.insightfullogic.multiinherit.api.Prefer;
import com.insightfullogic.multiinherit.api.TraitWith;
import com.insightfullogic.multiinherit.api.TypeHierachyException; | final FieldNode field = new FieldNode(Opcodes.ACC_PUBLIC, fieldName, descriptor, null, null);
// The Trait case:
final TraitWith traitWith = inter.getAnnotation(TraitWith.class);
if (traitWith != null) {
final Class<?> impl = traitWith.value();
immediateTraits.add(inter);
addTrait(combined, traits, inter, impl);
} else {
field.visibleAnnotations = asList(new AnnotationNode(injectAnn));
}
final String internal = Type.getInternalName(inter);
cn.interfaces.add(internal);
cn.fields.add(field);
for (final Method meth : inter.getMethods()) {
methods.put(meth, new FieldInfo(fieldName, internal, Type.getDescriptor(inter)));
}
}
// Validate trait final method implementations
for (final Class<?> key : immediateTraits) {
final TraitInfo info = traits.get(key);
for (final Class<?> parent : info.getParentTraits().values()) {
removeImplementedMethods(parent, info.getToImplement());
}
final List<Method> toImplement = new ArrayList<Method>(info.getToImplement());
removeImplementedMethods(combined, toImplement);
if (!toImplement.isEmpty()) { | // Path: src/main/java/com/insightfullogic/multiinherit/api/MultiInjector.java
// public interface MultiInjector {
//
// public <T> T getInstance(Class<T> combined);
//
// }
//
// Path: src/main/java/com/insightfullogic/multiinherit/api/TypeHierachyException.java
// public class TypeHierachyException extends RuntimeException {
//
// public TypeHierachyException(final String message) {
// super(message);
// }
//
// /**
// *
// */
// private static final long serialVersionUID = -2994395832274210972L;
//
// }
// Path: src/main/java/com/insightfullogic/multiinherit/generation/GenerationMultiInjector.java
import static java.util.Arrays.asList;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type;
import org.objectweb.asm.tree.AnnotationNode;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.FieldInsnNode;
import org.objectweb.asm.tree.FieldNode;
import org.objectweb.asm.tree.InsnList;
import org.objectweb.asm.tree.InsnNode;
import org.objectweb.asm.tree.MethodInsnNode;
import org.objectweb.asm.tree.MethodNode;
import org.objectweb.asm.tree.VarInsnNode;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.google.inject.Inject;
import com.google.inject.Injector;
import com.insightfullogic.multiinherit.api.MultiInjector;
import com.insightfullogic.multiinherit.api.Prefer;
import com.insightfullogic.multiinherit.api.TraitWith;
import com.insightfullogic.multiinherit.api.TypeHierachyException;
final FieldNode field = new FieldNode(Opcodes.ACC_PUBLIC, fieldName, descriptor, null, null);
// The Trait case:
final TraitWith traitWith = inter.getAnnotation(TraitWith.class);
if (traitWith != null) {
final Class<?> impl = traitWith.value();
immediateTraits.add(inter);
addTrait(combined, traits, inter, impl);
} else {
field.visibleAnnotations = asList(new AnnotationNode(injectAnn));
}
final String internal = Type.getInternalName(inter);
cn.interfaces.add(internal);
cn.fields.add(field);
for (final Method meth : inter.getMethods()) {
methods.put(meth, new FieldInfo(fieldName, internal, Type.getDescriptor(inter)));
}
}
// Validate trait final method implementations
for (final Class<?> key : immediateTraits) {
final TraitInfo info = traits.get(key);
for (final Class<?> parent : info.getParentTraits().values()) {
removeImplementedMethods(parent, info.getToImplement());
}
final List<Method> toImplement = new ArrayList<Method>(info.getToImplement());
removeImplementedMethods(combined, toImplement);
if (!toImplement.isEmpty()) { | throw new TypeHierachyException(MessageFormat.format( |
insightfullogic/java-multi-inherit | src/test/java/com/insightfullogic/multiinherit/generics/TestGenericCases.java | // Path: src/main/java/com/insightfullogic/multiinherit/api/MultiModule.java
// public class MultiModule extends AbstractModule {
//
// private final Class<?>[] classes;
// private final boolean useGeneration;
// private final boolean dumpClasses;
//
// public MultiModule(final boolean useGeneration, final Class<?>... classes) {
// this(useGeneration, false, classes);
// }
//
// public MultiModule(final boolean useGeneration, final boolean dumpClasses, final Class<?>... classes) {
// if (!useGeneration && dumpClasses) {
// throw new IllegalArgumentException("You cannot dump the generate class files if you're not generating class files");
// }
// this.classes = classes;
// this.useGeneration = useGeneration;
// this.dumpClasses = dumpClasses;
// }
//
// @SuppressWarnings({ "rawtypes", "unchecked" })
// private void bindMulti(final Class<?>... classes) {
// if (useGeneration) {
// bind(MultiInjector.class).to(GenerationMultiInjector.class);
// bind(Boolean.class).annotatedWith(Names.named("dump")).toInstance(dumpClasses);
// } else {
// bind(MultiInjector.class).to(ReflectionMultiInjector.class);
// }
// for (final Class cls : classes) {
// bind(cls).toProvider(new MultiProvider(cls));
// }
// }
//
// @Override
// protected void configure() {
// bindMulti(classes);
// }
//
// }
| import junit.framework.Assert;
import org.junit.Test;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.insightfullogic.multiinherit.api.MultiModule; | package com.insightfullogic.multiinherit.generics;
public class TestGenericCases {
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void simpleCases() { | // Path: src/main/java/com/insightfullogic/multiinherit/api/MultiModule.java
// public class MultiModule extends AbstractModule {
//
// private final Class<?>[] classes;
// private final boolean useGeneration;
// private final boolean dumpClasses;
//
// public MultiModule(final boolean useGeneration, final Class<?>... classes) {
// this(useGeneration, false, classes);
// }
//
// public MultiModule(final boolean useGeneration, final boolean dumpClasses, final Class<?>... classes) {
// if (!useGeneration && dumpClasses) {
// throw new IllegalArgumentException("You cannot dump the generate class files if you're not generating class files");
// }
// this.classes = classes;
// this.useGeneration = useGeneration;
// this.dumpClasses = dumpClasses;
// }
//
// @SuppressWarnings({ "rawtypes", "unchecked" })
// private void bindMulti(final Class<?>... classes) {
// if (useGeneration) {
// bind(MultiInjector.class).to(GenerationMultiInjector.class);
// bind(Boolean.class).annotatedWith(Names.named("dump")).toInstance(dumpClasses);
// } else {
// bind(MultiInjector.class).to(ReflectionMultiInjector.class);
// }
// for (final Class cls : classes) {
// bind(cls).toProvider(new MultiProvider(cls));
// }
// }
//
// @Override
// protected void configure() {
// bindMulti(classes);
// }
//
// }
// Path: src/test/java/com/insightfullogic/multiinherit/generics/TestGenericCases.java
import junit.framework.Assert;
import org.junit.Test;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.insightfullogic.multiinherit.api.MultiModule;
package com.insightfullogic.multiinherit.generics;
public class TestGenericCases {
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void simpleCases() { | final Injector injector = Guice.createInjector(new MultiModule(true, GenericCombined.class)); |
insightfullogic/java-multi-inherit | src/test/java/com/insightfullogic/multiinherit/hierachy/TestHierachyCases.java | // Path: src/main/java/com/insightfullogic/multiinherit/api/MultiModule.java
// public class MultiModule extends AbstractModule {
//
// private final Class<?>[] classes;
// private final boolean useGeneration;
// private final boolean dumpClasses;
//
// public MultiModule(final boolean useGeneration, final Class<?>... classes) {
// this(useGeneration, false, classes);
// }
//
// public MultiModule(final boolean useGeneration, final boolean dumpClasses, final Class<?>... classes) {
// if (!useGeneration && dumpClasses) {
// throw new IllegalArgumentException("You cannot dump the generate class files if you're not generating class files");
// }
// this.classes = classes;
// this.useGeneration = useGeneration;
// this.dumpClasses = dumpClasses;
// }
//
// @SuppressWarnings({ "rawtypes", "unchecked" })
// private void bindMulti(final Class<?>... classes) {
// if (useGeneration) {
// bind(MultiInjector.class).to(GenerationMultiInjector.class);
// bind(Boolean.class).annotatedWith(Names.named("dump")).toInstance(dumpClasses);
// } else {
// bind(MultiInjector.class).to(ReflectionMultiInjector.class);
// }
// for (final Class cls : classes) {
// bind(cls).toProvider(new MultiProvider(cls));
// }
// }
//
// @Override
// protected void configure() {
// bindMulti(classes);
// }
//
// }
//
// Path: src/test/java/com/insightfullogic/multiinherit/simple/Combined.java
// public interface Combined extends A, B {
//
// }
| import static junit.framework.Assert.assertEquals;
import org.junit.Test;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.insightfullogic.multiinherit.api.MultiModule;
import com.insightfullogic.multiinherit.simple.Combined; | package com.insightfullogic.multiinherit.hierachy;
public class TestHierachyCases {
@Test
public void reallyCombined() { | // Path: src/main/java/com/insightfullogic/multiinherit/api/MultiModule.java
// public class MultiModule extends AbstractModule {
//
// private final Class<?>[] classes;
// private final boolean useGeneration;
// private final boolean dumpClasses;
//
// public MultiModule(final boolean useGeneration, final Class<?>... classes) {
// this(useGeneration, false, classes);
// }
//
// public MultiModule(final boolean useGeneration, final boolean dumpClasses, final Class<?>... classes) {
// if (!useGeneration && dumpClasses) {
// throw new IllegalArgumentException("You cannot dump the generate class files if you're not generating class files");
// }
// this.classes = classes;
// this.useGeneration = useGeneration;
// this.dumpClasses = dumpClasses;
// }
//
// @SuppressWarnings({ "rawtypes", "unchecked" })
// private void bindMulti(final Class<?>... classes) {
// if (useGeneration) {
// bind(MultiInjector.class).to(GenerationMultiInjector.class);
// bind(Boolean.class).annotatedWith(Names.named("dump")).toInstance(dumpClasses);
// } else {
// bind(MultiInjector.class).to(ReflectionMultiInjector.class);
// }
// for (final Class cls : classes) {
// bind(cls).toProvider(new MultiProvider(cls));
// }
// }
//
// @Override
// protected void configure() {
// bindMulti(classes);
// }
//
// }
//
// Path: src/test/java/com/insightfullogic/multiinherit/simple/Combined.java
// public interface Combined extends A, B {
//
// }
// Path: src/test/java/com/insightfullogic/multiinherit/hierachy/TestHierachyCases.java
import static junit.framework.Assert.assertEquals;
import org.junit.Test;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.insightfullogic.multiinherit.api.MultiModule;
import com.insightfullogic.multiinherit.simple.Combined;
package com.insightfullogic.multiinherit.hierachy;
public class TestHierachyCases {
@Test
public void reallyCombined() { | final Injector in = Guice.createInjector(new MultiModule(true, true, Combined.class, MoreCombined.class)); |
insightfullogic/java-multi-inherit | src/test/java/com/insightfullogic/multiinherit/hierachy/TestHierachyCases.java | // Path: src/main/java/com/insightfullogic/multiinherit/api/MultiModule.java
// public class MultiModule extends AbstractModule {
//
// private final Class<?>[] classes;
// private final boolean useGeneration;
// private final boolean dumpClasses;
//
// public MultiModule(final boolean useGeneration, final Class<?>... classes) {
// this(useGeneration, false, classes);
// }
//
// public MultiModule(final boolean useGeneration, final boolean dumpClasses, final Class<?>... classes) {
// if (!useGeneration && dumpClasses) {
// throw new IllegalArgumentException("You cannot dump the generate class files if you're not generating class files");
// }
// this.classes = classes;
// this.useGeneration = useGeneration;
// this.dumpClasses = dumpClasses;
// }
//
// @SuppressWarnings({ "rawtypes", "unchecked" })
// private void bindMulti(final Class<?>... classes) {
// if (useGeneration) {
// bind(MultiInjector.class).to(GenerationMultiInjector.class);
// bind(Boolean.class).annotatedWith(Names.named("dump")).toInstance(dumpClasses);
// } else {
// bind(MultiInjector.class).to(ReflectionMultiInjector.class);
// }
// for (final Class cls : classes) {
// bind(cls).toProvider(new MultiProvider(cls));
// }
// }
//
// @Override
// protected void configure() {
// bindMulti(classes);
// }
//
// }
//
// Path: src/test/java/com/insightfullogic/multiinherit/simple/Combined.java
// public interface Combined extends A, B {
//
// }
| import static junit.framework.Assert.assertEquals;
import org.junit.Test;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.insightfullogic.multiinherit.api.MultiModule;
import com.insightfullogic.multiinherit.simple.Combined; | package com.insightfullogic.multiinherit.hierachy;
public class TestHierachyCases {
@Test
public void reallyCombined() { | // Path: src/main/java/com/insightfullogic/multiinherit/api/MultiModule.java
// public class MultiModule extends AbstractModule {
//
// private final Class<?>[] classes;
// private final boolean useGeneration;
// private final boolean dumpClasses;
//
// public MultiModule(final boolean useGeneration, final Class<?>... classes) {
// this(useGeneration, false, classes);
// }
//
// public MultiModule(final boolean useGeneration, final boolean dumpClasses, final Class<?>... classes) {
// if (!useGeneration && dumpClasses) {
// throw new IllegalArgumentException("You cannot dump the generate class files if you're not generating class files");
// }
// this.classes = classes;
// this.useGeneration = useGeneration;
// this.dumpClasses = dumpClasses;
// }
//
// @SuppressWarnings({ "rawtypes", "unchecked" })
// private void bindMulti(final Class<?>... classes) {
// if (useGeneration) {
// bind(MultiInjector.class).to(GenerationMultiInjector.class);
// bind(Boolean.class).annotatedWith(Names.named("dump")).toInstance(dumpClasses);
// } else {
// bind(MultiInjector.class).to(ReflectionMultiInjector.class);
// }
// for (final Class cls : classes) {
// bind(cls).toProvider(new MultiProvider(cls));
// }
// }
//
// @Override
// protected void configure() {
// bindMulti(classes);
// }
//
// }
//
// Path: src/test/java/com/insightfullogic/multiinherit/simple/Combined.java
// public interface Combined extends A, B {
//
// }
// Path: src/test/java/com/insightfullogic/multiinherit/hierachy/TestHierachyCases.java
import static junit.framework.Assert.assertEquals;
import org.junit.Test;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.insightfullogic.multiinherit.api.MultiModule;
import com.insightfullogic.multiinherit.simple.Combined;
package com.insightfullogic.multiinherit.hierachy;
public class TestHierachyCases {
@Test
public void reallyCombined() { | final Injector in = Guice.createInjector(new MultiModule(true, true, Combined.class, MoreCombined.class)); |
BennSandoval/Woodmin | app/src/main/java/app/bennsandoval/com/woodmin/models/v3/shop/Store.java | // Path: app/src/main/java/app/bennsandoval/com/woodmin/models/v3/orders/Meta.java
// public class Meta {
//
// private String timezone;
// private String currency;
// @SerializedName("currency_format")
// private String currencyFormat;
// @SerializedName("tax_included")
// private boolean taxIncluded;
// @SerializedName("weight_unit")
// private String weightUnit;
// @SerializedName("dimension_unit")
// private String dimensionUnit;
// @SerializedName("ssl_enabled")
// private boolean sslEnabled;
// @SerializedName("permalinks_enabled")
// private boolean permalinks_enabled;
//
// public String getTimezone() {
// return timezone;
// }
//
// public void setTimezone(String timezone) {
// this.timezone = timezone;
// }
//
// public String getCurrency() {
// return currency;
// }
//
// public void setCurrency(String currency) {
// this.currency = currency;
// }
//
// public String getCurrencyFormat() {
// return currencyFormat;
// }
//
// public void setCurrencyFormat(String currencyFormat) {
// this.currencyFormat = currencyFormat;
// }
//
// public boolean isTaxIncluded() {
// return taxIncluded;
// }
//
// public void setTaxIncluded(boolean taxIncluded) {
// this.taxIncluded = taxIncluded;
// }
//
// public String getWeightUnit() {
// return weightUnit;
// }
//
// public void setWeightUnit(String weightUnit) {
// this.weightUnit = weightUnit;
// }
//
// public String getDimensionUnit() {
// return dimensionUnit;
// }
//
// public void setDimensionUnit(String dimensionUnit) {
// this.dimensionUnit = dimensionUnit;
// }
//
// public boolean isSslEnabled() {
// return sslEnabled;
// }
//
// public void setSslEnabled(boolean sslEnabled) {
// this.sslEnabled = sslEnabled;
// }
//
// public boolean isPermalinks_enabled() {
// return permalinks_enabled;
// }
//
// public void setPermalinks_enabled(boolean permalinks_enabled) {
// this.permalinks_enabled = permalinks_enabled;
// }
// }
| import com.google.gson.annotations.SerializedName;
import app.bennsandoval.com.woodmin.models.v3.orders.Meta; | package app.bennsandoval.com.woodmin.models.v3.shop;
public class Store {
private String name;
private String description;
@SerializedName("URL")
private String url;
@SerializedName("wc_version")
private String wcVersion; | // Path: app/src/main/java/app/bennsandoval/com/woodmin/models/v3/orders/Meta.java
// public class Meta {
//
// private String timezone;
// private String currency;
// @SerializedName("currency_format")
// private String currencyFormat;
// @SerializedName("tax_included")
// private boolean taxIncluded;
// @SerializedName("weight_unit")
// private String weightUnit;
// @SerializedName("dimension_unit")
// private String dimensionUnit;
// @SerializedName("ssl_enabled")
// private boolean sslEnabled;
// @SerializedName("permalinks_enabled")
// private boolean permalinks_enabled;
//
// public String getTimezone() {
// return timezone;
// }
//
// public void setTimezone(String timezone) {
// this.timezone = timezone;
// }
//
// public String getCurrency() {
// return currency;
// }
//
// public void setCurrency(String currency) {
// this.currency = currency;
// }
//
// public String getCurrencyFormat() {
// return currencyFormat;
// }
//
// public void setCurrencyFormat(String currencyFormat) {
// this.currencyFormat = currencyFormat;
// }
//
// public boolean isTaxIncluded() {
// return taxIncluded;
// }
//
// public void setTaxIncluded(boolean taxIncluded) {
// this.taxIncluded = taxIncluded;
// }
//
// public String getWeightUnit() {
// return weightUnit;
// }
//
// public void setWeightUnit(String weightUnit) {
// this.weightUnit = weightUnit;
// }
//
// public String getDimensionUnit() {
// return dimensionUnit;
// }
//
// public void setDimensionUnit(String dimensionUnit) {
// this.dimensionUnit = dimensionUnit;
// }
//
// public boolean isSslEnabled() {
// return sslEnabled;
// }
//
// public void setSslEnabled(boolean sslEnabled) {
// this.sslEnabled = sslEnabled;
// }
//
// public boolean isPermalinks_enabled() {
// return permalinks_enabled;
// }
//
// public void setPermalinks_enabled(boolean permalinks_enabled) {
// this.permalinks_enabled = permalinks_enabled;
// }
// }
// Path: app/src/main/java/app/bennsandoval/com/woodmin/models/v3/shop/Store.java
import com.google.gson.annotations.SerializedName;
import app.bennsandoval.com.woodmin.models.v3.orders.Meta;
package app.bennsandoval.com.woodmin.models.v3.shop;
public class Store {
private String name;
private String description;
@SerializedName("URL")
private String url;
@SerializedName("wc_version")
private String wcVersion; | private Meta meta; |
m-szalik/tjconsole | src/main/java/org/jsoftware/tjconsole/command/definition/AbstractCommandDefinition.java | // Path: src/main/java/org/jsoftware/tjconsole/TJContext.java
// public class TJContext extends Observable {
// private MBeanServerConnection serverConnection;
// private ObjectName objectName;
// private final Map<String, Object> environment;
// private Object serverURL;
// private int exitCode = 0;
//
// public TJContext() {
// environment = new LinkedHashMap<String, Object>();
// }
//
// public Map<String, Object> getEnvironment() {
// return Collections.unmodifiableMap(environment);
// }
//
// public void setEnvironmentVariable(String key, Object value, boolean check) {
// if (check) {
// if (!environment.containsKey(key)) {
// throw new IllegalArgumentException("Invalid key - " + key);
// }
// Object old = environment.get(key);
// if (!old.getClass().equals(value.getClass())) {
// value = ConvertUtils.convert(value, old.getClass());
// if (!old.getClass().equals(value.getClass())) {
// throw new IllegalArgumentException("Invalid value type - " + value.getClass().getName() + " should be " + old.getClass().getName());
// }
// }
// }
// Object prev = environment.get(key);
// if ((value != null && !value.equals(prev)) || (value == null && prev != null)) {
// setChanged();
// }
// notifyObservers(new UpdateEnvironmentEvent(key, prev, value));
// environment.put(key, value);
// }
//
// public MBeanServerConnection getServer() {
// return serverConnection;
// }
//
// public void setServer(MBeanServerConnection serverConnection, String url) {
// this.serverConnection = serverConnection;
// this.serverURL = url;
// this.objectName = null;
// }
//
// public ObjectName getObjectName() {
// return objectName;
// }
//
// public void setObjectName(ObjectName objectName) {
// this.objectName = objectName;
// }
//
// public boolean isConnected() {
// return serverConnection != null;
// }
//
// public List<MBeanAttributeInfo> getAttributes() throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException {
// if (serverConnection == null || objectName == null) {
// return Collections.emptyList();
// }
// MBeanInfo beanInfo = serverConnection.getMBeanInfo(objectName);
// return Arrays.asList(beanInfo.getAttributes());
// }
//
// public boolean isBeanSelected() {
// return objectName != null;
// }
//
//
// public Object getServerURL() {
// return serverURL;
// }
//
// public void fail(CommandAction action, int code) {
// if (exitCode == 0) {
// exitCode = code;
// }
// }
//
// public int getExitCode() {
// return exitCode;
// }
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/command/CmdDescription.java
// public class CmdDescription implements Serializable {
// private static final long serialVersionUID = 974727180626249506L;
// private final String description;
// private final String full;
// private final String prefix;
// private final boolean requiresBean;
//
// public CmdDescription(String description, String full, String prefix, boolean requiresBean) {
// super();
// this.description = description;
// this.full = full;
// this.prefix = prefix;
// this.requiresBean = requiresBean;
// }
//
// public String getDescription() {
// return description;
// }
//
// public String getFull() {
// return full;
// }
//
// public String getPrefix() {
// return prefix;
// }
//
// public boolean canBeUsed(TJContext tjContext) {
// return !requiresBean || tjContext.isBeanSelected();
// }
//
//
// }
| import jline.console.completer.Completer;
import org.jsoftware.tjconsole.TJContext;
import org.jsoftware.tjconsole.command.CmdDescription;
import java.util.Observable; | package org.jsoftware.tjconsole.command.definition;
/**
* @author szalik
*/
abstract class AbstractCommandDefinition extends Observable implements CommandDefinition {
private final CmdDescription description;
final String prefix;
AbstractCommandDefinition(String description, String full, String prefix, boolean requiresBean) {
this.description = new CmdDescription(description, full, prefix, requiresBean);
this.prefix = prefix;
}
@Override
public boolean matches(String input) {
return input.trim().startsWith(prefix);
}
@Override
public CmdDescription getDescription() {
return description;
}
@Override | // Path: src/main/java/org/jsoftware/tjconsole/TJContext.java
// public class TJContext extends Observable {
// private MBeanServerConnection serverConnection;
// private ObjectName objectName;
// private final Map<String, Object> environment;
// private Object serverURL;
// private int exitCode = 0;
//
// public TJContext() {
// environment = new LinkedHashMap<String, Object>();
// }
//
// public Map<String, Object> getEnvironment() {
// return Collections.unmodifiableMap(environment);
// }
//
// public void setEnvironmentVariable(String key, Object value, boolean check) {
// if (check) {
// if (!environment.containsKey(key)) {
// throw new IllegalArgumentException("Invalid key - " + key);
// }
// Object old = environment.get(key);
// if (!old.getClass().equals(value.getClass())) {
// value = ConvertUtils.convert(value, old.getClass());
// if (!old.getClass().equals(value.getClass())) {
// throw new IllegalArgumentException("Invalid value type - " + value.getClass().getName() + " should be " + old.getClass().getName());
// }
// }
// }
// Object prev = environment.get(key);
// if ((value != null && !value.equals(prev)) || (value == null && prev != null)) {
// setChanged();
// }
// notifyObservers(new UpdateEnvironmentEvent(key, prev, value));
// environment.put(key, value);
// }
//
// public MBeanServerConnection getServer() {
// return serverConnection;
// }
//
// public void setServer(MBeanServerConnection serverConnection, String url) {
// this.serverConnection = serverConnection;
// this.serverURL = url;
// this.objectName = null;
// }
//
// public ObjectName getObjectName() {
// return objectName;
// }
//
// public void setObjectName(ObjectName objectName) {
// this.objectName = objectName;
// }
//
// public boolean isConnected() {
// return serverConnection != null;
// }
//
// public List<MBeanAttributeInfo> getAttributes() throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException {
// if (serverConnection == null || objectName == null) {
// return Collections.emptyList();
// }
// MBeanInfo beanInfo = serverConnection.getMBeanInfo(objectName);
// return Arrays.asList(beanInfo.getAttributes());
// }
//
// public boolean isBeanSelected() {
// return objectName != null;
// }
//
//
// public Object getServerURL() {
// return serverURL;
// }
//
// public void fail(CommandAction action, int code) {
// if (exitCode == 0) {
// exitCode = code;
// }
// }
//
// public int getExitCode() {
// return exitCode;
// }
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/command/CmdDescription.java
// public class CmdDescription implements Serializable {
// private static final long serialVersionUID = 974727180626249506L;
// private final String description;
// private final String full;
// private final String prefix;
// private final boolean requiresBean;
//
// public CmdDescription(String description, String full, String prefix, boolean requiresBean) {
// super();
// this.description = description;
// this.full = full;
// this.prefix = prefix;
// this.requiresBean = requiresBean;
// }
//
// public String getDescription() {
// return description;
// }
//
// public String getFull() {
// return full;
// }
//
// public String getPrefix() {
// return prefix;
// }
//
// public boolean canBeUsed(TJContext tjContext) {
// return !requiresBean || tjContext.isBeanSelected();
// }
//
//
// }
// Path: src/main/java/org/jsoftware/tjconsole/command/definition/AbstractCommandDefinition.java
import jline.console.completer.Completer;
import org.jsoftware.tjconsole.TJContext;
import org.jsoftware.tjconsole.command.CmdDescription;
import java.util.Observable;
package org.jsoftware.tjconsole.command.definition;
/**
* @author szalik
*/
abstract class AbstractCommandDefinition extends Observable implements CommandDefinition {
private final CmdDescription description;
final String prefix;
AbstractCommandDefinition(String description, String full, String prefix, boolean requiresBean) {
this.description = new CmdDescription(description, full, prefix, requiresBean);
this.prefix = prefix;
}
@Override
public boolean matches(String input) {
return input.trim().startsWith(prefix);
}
@Override
public CmdDescription getDescription() {
return description;
}
@Override | public Completer getCompleter(TJContext tjContext) { |
m-szalik/tjconsole | src/test/java/org/jsoftware/tjconsole/TJConsoleE2ETest.java | // Path: src/main/java/org/jsoftware/tjconsole/console/Output.java
// public class Output implements Closeable {
// private final Pattern ansiRemovePattern = Pattern.compile("(@\\|\\w* )|( ?\\|@)");
// private final PrintStream out;
// private boolean useColors = true, ansiInstalled, filterInfo;
//
// public Output(PrintStream out, boolean useColors) {
// this.out = out;
// setUseColors(useColors);
// }
//
// public void setFilterInfo(boolean filterInfo) {
// this.filterInfo = filterInfo;
// }
//
// public boolean isUseColors() {
// return useColors;
// }
//
//
// public void setUseColors(boolean useColors) {
// this.useColors = useColors;
// if (useColors) {
// AnsiConsole.systemInstall();
// ansiInstalled = true;
// } else {
// AnsiConsole.systemUninstall();
// ansiInstalled = false;
// }
// }
//
//
// public void print(String text) {
// if (useColors) {
// out.print(ansi().render(text));
// } else {
// String s = ansiRemovePattern.matcher(text).replaceAll("");
// out.print(s);
// }
// out.flush();
// }
//
//
// public void println(String text) {
// print(text);
// out.println();
// out.flush();
// }
//
//
// @Override
// public void close() throws IOException {
// if (ansiInstalled) {
// AnsiConsole.systemUninstall();
// }
// out.close();
// }
//
// public void outError(String text) {
// println("@|red " + text + "|@");
// }
//
// public void outInfo(String text) {
// if (! filterInfo) {
// println("@|cyan " + text + "|@");
// }
// }
// }
| import org.jsoftware.tjconsole.console.Output;
import org.junit.Before;
import org.junit.Test;
import javax.management.MBeanServer;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.lang.management.ManagementFactory;
import java.util.Properties;
import java.util.regex.Pattern;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail; | tjConsole.executeCommand("env DATE_FORMAT=yyyy-MMM-dd", outputHelper.getOutput());
outputHelper.clear();
tjConsole.executeCommand("env", outputHelper.getOutput());
System.out.println(outputHelper);
assertTrue(outputHelper.toString().contains("DATE_FORMAT = yyyy-MMM-dd"));
}
@Test
public void testCmdPs() throws Exception {
Pattern processLinePattern = Pattern.compile("^\\d{1,} .*$");
tjConsole.executeCommand("ps", outputHelper.getOutput());
String[] processList = outputHelper.toString().trim().split("\n");
int psCount = 0;
for(String psLine : processList) {
psLine = psLine.trim();
if (psLine.length() == 0) {
continue;
}
psCount++;
if (! processLinePattern.matcher(psLine).matches()) {
fail("Line '" + psLine + "' doesn't look like ps line!");
}
}
assertTrue("We don't have even one process on the list", psCount > 0);
}
}
class TestOutputHelper {
private ByteArrayOutputStream out = new ByteArrayOutputStream();
| // Path: src/main/java/org/jsoftware/tjconsole/console/Output.java
// public class Output implements Closeable {
// private final Pattern ansiRemovePattern = Pattern.compile("(@\\|\\w* )|( ?\\|@)");
// private final PrintStream out;
// private boolean useColors = true, ansiInstalled, filterInfo;
//
// public Output(PrintStream out, boolean useColors) {
// this.out = out;
// setUseColors(useColors);
// }
//
// public void setFilterInfo(boolean filterInfo) {
// this.filterInfo = filterInfo;
// }
//
// public boolean isUseColors() {
// return useColors;
// }
//
//
// public void setUseColors(boolean useColors) {
// this.useColors = useColors;
// if (useColors) {
// AnsiConsole.systemInstall();
// ansiInstalled = true;
// } else {
// AnsiConsole.systemUninstall();
// ansiInstalled = false;
// }
// }
//
//
// public void print(String text) {
// if (useColors) {
// out.print(ansi().render(text));
// } else {
// String s = ansiRemovePattern.matcher(text).replaceAll("");
// out.print(s);
// }
// out.flush();
// }
//
//
// public void println(String text) {
// print(text);
// out.println();
// out.flush();
// }
//
//
// @Override
// public void close() throws IOException {
// if (ansiInstalled) {
// AnsiConsole.systemUninstall();
// }
// out.close();
// }
//
// public void outError(String text) {
// println("@|red " + text + "|@");
// }
//
// public void outInfo(String text) {
// if (! filterInfo) {
// println("@|cyan " + text + "|@");
// }
// }
// }
// Path: src/test/java/org/jsoftware/tjconsole/TJConsoleE2ETest.java
import org.jsoftware.tjconsole.console.Output;
import org.junit.Before;
import org.junit.Test;
import javax.management.MBeanServer;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.lang.management.ManagementFactory;
import java.util.Properties;
import java.util.regex.Pattern;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
tjConsole.executeCommand("env DATE_FORMAT=yyyy-MMM-dd", outputHelper.getOutput());
outputHelper.clear();
tjConsole.executeCommand("env", outputHelper.getOutput());
System.out.println(outputHelper);
assertTrue(outputHelper.toString().contains("DATE_FORMAT = yyyy-MMM-dd"));
}
@Test
public void testCmdPs() throws Exception {
Pattern processLinePattern = Pattern.compile("^\\d{1,} .*$");
tjConsole.executeCommand("ps", outputHelper.getOutput());
String[] processList = outputHelper.toString().trim().split("\n");
int psCount = 0;
for(String psLine : processList) {
psLine = psLine.trim();
if (psLine.length() == 0) {
continue;
}
psCount++;
if (! processLinePattern.matcher(psLine).matches()) {
fail("Line '" + psLine + "' doesn't look like ps line!");
}
}
assertTrue("We don't have even one process on the list", psCount > 0);
}
}
class TestOutputHelper {
private ByteArrayOutputStream out = new ByteArrayOutputStream();
| public Output getOutput() { |
m-szalik/tjconsole | src/main/java/org/jsoftware/tjconsole/command/definition/AbstractAttributeCompleter.java | // Path: src/main/java/org/jsoftware/tjconsole/TJContext.java
// public class TJContext extends Observable {
// private MBeanServerConnection serverConnection;
// private ObjectName objectName;
// private final Map<String, Object> environment;
// private Object serverURL;
// private int exitCode = 0;
//
// public TJContext() {
// environment = new LinkedHashMap<String, Object>();
// }
//
// public Map<String, Object> getEnvironment() {
// return Collections.unmodifiableMap(environment);
// }
//
// public void setEnvironmentVariable(String key, Object value, boolean check) {
// if (check) {
// if (!environment.containsKey(key)) {
// throw new IllegalArgumentException("Invalid key - " + key);
// }
// Object old = environment.get(key);
// if (!old.getClass().equals(value.getClass())) {
// value = ConvertUtils.convert(value, old.getClass());
// if (!old.getClass().equals(value.getClass())) {
// throw new IllegalArgumentException("Invalid value type - " + value.getClass().getName() + " should be " + old.getClass().getName());
// }
// }
// }
// Object prev = environment.get(key);
// if ((value != null && !value.equals(prev)) || (value == null && prev != null)) {
// setChanged();
// }
// notifyObservers(new UpdateEnvironmentEvent(key, prev, value));
// environment.put(key, value);
// }
//
// public MBeanServerConnection getServer() {
// return serverConnection;
// }
//
// public void setServer(MBeanServerConnection serverConnection, String url) {
// this.serverConnection = serverConnection;
// this.serverURL = url;
// this.objectName = null;
// }
//
// public ObjectName getObjectName() {
// return objectName;
// }
//
// public void setObjectName(ObjectName objectName) {
// this.objectName = objectName;
// }
//
// public boolean isConnected() {
// return serverConnection != null;
// }
//
// public List<MBeanAttributeInfo> getAttributes() throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException {
// if (serverConnection == null || objectName == null) {
// return Collections.emptyList();
// }
// MBeanInfo beanInfo = serverConnection.getMBeanInfo(objectName);
// return Arrays.asList(beanInfo.getAttributes());
// }
//
// public boolean isBeanSelected() {
// return objectName != null;
// }
//
//
// public Object getServerURL() {
// return serverURL;
// }
//
// public void fail(CommandAction action, int code) {
// if (exitCode == 0) {
// exitCode = code;
// }
// }
//
// public int getExitCode() {
// return exitCode;
// }
// }
| import jline.console.completer.Completer;
import org.jsoftware.tjconsole.TJContext;
import javax.management.MBeanAttributeInfo;
import java.util.List;
import java.util.logging.Logger; | package org.jsoftware.tjconsole.command.definition;
abstract class AbstractAttributeCompleter implements Completer {
private final Logger logger = Logger.getLogger(getClass().getName()); | // Path: src/main/java/org/jsoftware/tjconsole/TJContext.java
// public class TJContext extends Observable {
// private MBeanServerConnection serverConnection;
// private ObjectName objectName;
// private final Map<String, Object> environment;
// private Object serverURL;
// private int exitCode = 0;
//
// public TJContext() {
// environment = new LinkedHashMap<String, Object>();
// }
//
// public Map<String, Object> getEnvironment() {
// return Collections.unmodifiableMap(environment);
// }
//
// public void setEnvironmentVariable(String key, Object value, boolean check) {
// if (check) {
// if (!environment.containsKey(key)) {
// throw new IllegalArgumentException("Invalid key - " + key);
// }
// Object old = environment.get(key);
// if (!old.getClass().equals(value.getClass())) {
// value = ConvertUtils.convert(value, old.getClass());
// if (!old.getClass().equals(value.getClass())) {
// throw new IllegalArgumentException("Invalid value type - " + value.getClass().getName() + " should be " + old.getClass().getName());
// }
// }
// }
// Object prev = environment.get(key);
// if ((value != null && !value.equals(prev)) || (value == null && prev != null)) {
// setChanged();
// }
// notifyObservers(new UpdateEnvironmentEvent(key, prev, value));
// environment.put(key, value);
// }
//
// public MBeanServerConnection getServer() {
// return serverConnection;
// }
//
// public void setServer(MBeanServerConnection serverConnection, String url) {
// this.serverConnection = serverConnection;
// this.serverURL = url;
// this.objectName = null;
// }
//
// public ObjectName getObjectName() {
// return objectName;
// }
//
// public void setObjectName(ObjectName objectName) {
// this.objectName = objectName;
// }
//
// public boolean isConnected() {
// return serverConnection != null;
// }
//
// public List<MBeanAttributeInfo> getAttributes() throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException {
// if (serverConnection == null || objectName == null) {
// return Collections.emptyList();
// }
// MBeanInfo beanInfo = serverConnection.getMBeanInfo(objectName);
// return Arrays.asList(beanInfo.getAttributes());
// }
//
// public boolean isBeanSelected() {
// return objectName != null;
// }
//
//
// public Object getServerURL() {
// return serverURL;
// }
//
// public void fail(CommandAction action, int code) {
// if (exitCode == 0) {
// exitCode = code;
// }
// }
//
// public int getExitCode() {
// return exitCode;
// }
// }
// Path: src/main/java/org/jsoftware/tjconsole/command/definition/AbstractAttributeCompleter.java
import jline.console.completer.Completer;
import org.jsoftware.tjconsole.TJContext;
import javax.management.MBeanAttributeInfo;
import java.util.List;
import java.util.logging.Logger;
package org.jsoftware.tjconsole.command.definition;
abstract class AbstractAttributeCompleter implements Completer {
private final Logger logger = Logger.getLogger(getClass().getName()); | private final TJContext ctx; |
m-szalik/tjconsole | src/main/java/org/jsoftware/tjconsole/command/definition/InfoCommandDefinition.java | // Path: src/main/java/org/jsoftware/tjconsole/TJContext.java
// public class TJContext extends Observable {
// private MBeanServerConnection serverConnection;
// private ObjectName objectName;
// private final Map<String, Object> environment;
// private Object serverURL;
// private int exitCode = 0;
//
// public TJContext() {
// environment = new LinkedHashMap<String, Object>();
// }
//
// public Map<String, Object> getEnvironment() {
// return Collections.unmodifiableMap(environment);
// }
//
// public void setEnvironmentVariable(String key, Object value, boolean check) {
// if (check) {
// if (!environment.containsKey(key)) {
// throw new IllegalArgumentException("Invalid key - " + key);
// }
// Object old = environment.get(key);
// if (!old.getClass().equals(value.getClass())) {
// value = ConvertUtils.convert(value, old.getClass());
// if (!old.getClass().equals(value.getClass())) {
// throw new IllegalArgumentException("Invalid value type - " + value.getClass().getName() + " should be " + old.getClass().getName());
// }
// }
// }
// Object prev = environment.get(key);
// if ((value != null && !value.equals(prev)) || (value == null && prev != null)) {
// setChanged();
// }
// notifyObservers(new UpdateEnvironmentEvent(key, prev, value));
// environment.put(key, value);
// }
//
// public MBeanServerConnection getServer() {
// return serverConnection;
// }
//
// public void setServer(MBeanServerConnection serverConnection, String url) {
// this.serverConnection = serverConnection;
// this.serverURL = url;
// this.objectName = null;
// }
//
// public ObjectName getObjectName() {
// return objectName;
// }
//
// public void setObjectName(ObjectName objectName) {
// this.objectName = objectName;
// }
//
// public boolean isConnected() {
// return serverConnection != null;
// }
//
// public List<MBeanAttributeInfo> getAttributes() throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException {
// if (serverConnection == null || objectName == null) {
// return Collections.emptyList();
// }
// MBeanInfo beanInfo = serverConnection.getMBeanInfo(objectName);
// return Arrays.asList(beanInfo.getAttributes());
// }
//
// public boolean isBeanSelected() {
// return objectName != null;
// }
//
//
// public Object getServerURL() {
// return serverURL;
// }
//
// public void fail(CommandAction action, int code) {
// if (exitCode == 0) {
// exitCode = code;
// }
// }
//
// public int getExitCode() {
// return exitCode;
// }
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/command/CommandAction.java
// public interface CommandAction {
//
// void doAction(TJContext tjContext, Output output) throws Exception;
//
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/console/Output.java
// public class Output implements Closeable {
// private final Pattern ansiRemovePattern = Pattern.compile("(@\\|\\w* )|( ?\\|@)");
// private final PrintStream out;
// private boolean useColors = true, ansiInstalled, filterInfo;
//
// public Output(PrintStream out, boolean useColors) {
// this.out = out;
// setUseColors(useColors);
// }
//
// public void setFilterInfo(boolean filterInfo) {
// this.filterInfo = filterInfo;
// }
//
// public boolean isUseColors() {
// return useColors;
// }
//
//
// public void setUseColors(boolean useColors) {
// this.useColors = useColors;
// if (useColors) {
// AnsiConsole.systemInstall();
// ansiInstalled = true;
// } else {
// AnsiConsole.systemUninstall();
// ansiInstalled = false;
// }
// }
//
//
// public void print(String text) {
// if (useColors) {
// out.print(ansi().render(text));
// } else {
// String s = ansiRemovePattern.matcher(text).replaceAll("");
// out.print(s);
// }
// out.flush();
// }
//
//
// public void println(String text) {
// print(text);
// out.println();
// out.flush();
// }
//
//
// @Override
// public void close() throws IOException {
// if (ansiInstalled) {
// AnsiConsole.systemUninstall();
// }
// out.close();
// }
//
// public void outError(String text) {
// println("@|red " + text + "|@");
// }
//
// public void outInfo(String text) {
// if (! filterInfo) {
// println("@|cyan " + text + "|@");
// }
// }
// }
| import org.jsoftware.tjconsole.TJContext;
import org.jsoftware.tjconsole.command.CommandAction;
import org.jsoftware.tjconsole.console.Output; | package org.jsoftware.tjconsole.command.definition;
/**
* Show current state
*
* @author szalik
*/
public class InfoCommandDefinition extends AbstractCommandDefinition {
public InfoCommandDefinition() {
super("Display current state.", "info", "info", false);
}
| // Path: src/main/java/org/jsoftware/tjconsole/TJContext.java
// public class TJContext extends Observable {
// private MBeanServerConnection serverConnection;
// private ObjectName objectName;
// private final Map<String, Object> environment;
// private Object serverURL;
// private int exitCode = 0;
//
// public TJContext() {
// environment = new LinkedHashMap<String, Object>();
// }
//
// public Map<String, Object> getEnvironment() {
// return Collections.unmodifiableMap(environment);
// }
//
// public void setEnvironmentVariable(String key, Object value, boolean check) {
// if (check) {
// if (!environment.containsKey(key)) {
// throw new IllegalArgumentException("Invalid key - " + key);
// }
// Object old = environment.get(key);
// if (!old.getClass().equals(value.getClass())) {
// value = ConvertUtils.convert(value, old.getClass());
// if (!old.getClass().equals(value.getClass())) {
// throw new IllegalArgumentException("Invalid value type - " + value.getClass().getName() + " should be " + old.getClass().getName());
// }
// }
// }
// Object prev = environment.get(key);
// if ((value != null && !value.equals(prev)) || (value == null && prev != null)) {
// setChanged();
// }
// notifyObservers(new UpdateEnvironmentEvent(key, prev, value));
// environment.put(key, value);
// }
//
// public MBeanServerConnection getServer() {
// return serverConnection;
// }
//
// public void setServer(MBeanServerConnection serverConnection, String url) {
// this.serverConnection = serverConnection;
// this.serverURL = url;
// this.objectName = null;
// }
//
// public ObjectName getObjectName() {
// return objectName;
// }
//
// public void setObjectName(ObjectName objectName) {
// this.objectName = objectName;
// }
//
// public boolean isConnected() {
// return serverConnection != null;
// }
//
// public List<MBeanAttributeInfo> getAttributes() throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException {
// if (serverConnection == null || objectName == null) {
// return Collections.emptyList();
// }
// MBeanInfo beanInfo = serverConnection.getMBeanInfo(objectName);
// return Arrays.asList(beanInfo.getAttributes());
// }
//
// public boolean isBeanSelected() {
// return objectName != null;
// }
//
//
// public Object getServerURL() {
// return serverURL;
// }
//
// public void fail(CommandAction action, int code) {
// if (exitCode == 0) {
// exitCode = code;
// }
// }
//
// public int getExitCode() {
// return exitCode;
// }
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/command/CommandAction.java
// public interface CommandAction {
//
// void doAction(TJContext tjContext, Output output) throws Exception;
//
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/console/Output.java
// public class Output implements Closeable {
// private final Pattern ansiRemovePattern = Pattern.compile("(@\\|\\w* )|( ?\\|@)");
// private final PrintStream out;
// private boolean useColors = true, ansiInstalled, filterInfo;
//
// public Output(PrintStream out, boolean useColors) {
// this.out = out;
// setUseColors(useColors);
// }
//
// public void setFilterInfo(boolean filterInfo) {
// this.filterInfo = filterInfo;
// }
//
// public boolean isUseColors() {
// return useColors;
// }
//
//
// public void setUseColors(boolean useColors) {
// this.useColors = useColors;
// if (useColors) {
// AnsiConsole.systemInstall();
// ansiInstalled = true;
// } else {
// AnsiConsole.systemUninstall();
// ansiInstalled = false;
// }
// }
//
//
// public void print(String text) {
// if (useColors) {
// out.print(ansi().render(text));
// } else {
// String s = ansiRemovePattern.matcher(text).replaceAll("");
// out.print(s);
// }
// out.flush();
// }
//
//
// public void println(String text) {
// print(text);
// out.println();
// out.flush();
// }
//
//
// @Override
// public void close() throws IOException {
// if (ansiInstalled) {
// AnsiConsole.systemUninstall();
// }
// out.close();
// }
//
// public void outError(String text) {
// println("@|red " + text + "|@");
// }
//
// public void outInfo(String text) {
// if (! filterInfo) {
// println("@|cyan " + text + "|@");
// }
// }
// }
// Path: src/main/java/org/jsoftware/tjconsole/command/definition/InfoCommandDefinition.java
import org.jsoftware.tjconsole.TJContext;
import org.jsoftware.tjconsole.command.CommandAction;
import org.jsoftware.tjconsole.console.Output;
package org.jsoftware.tjconsole.command.definition;
/**
* Show current state
*
* @author szalik
*/
public class InfoCommandDefinition extends AbstractCommandDefinition {
public InfoCommandDefinition() {
super("Display current state.", "info", "info", false);
}
| public CommandAction action(String input) { |
m-szalik/tjconsole | src/main/java/org/jsoftware/tjconsole/command/definition/InfoCommandDefinition.java | // Path: src/main/java/org/jsoftware/tjconsole/TJContext.java
// public class TJContext extends Observable {
// private MBeanServerConnection serverConnection;
// private ObjectName objectName;
// private final Map<String, Object> environment;
// private Object serverURL;
// private int exitCode = 0;
//
// public TJContext() {
// environment = new LinkedHashMap<String, Object>();
// }
//
// public Map<String, Object> getEnvironment() {
// return Collections.unmodifiableMap(environment);
// }
//
// public void setEnvironmentVariable(String key, Object value, boolean check) {
// if (check) {
// if (!environment.containsKey(key)) {
// throw new IllegalArgumentException("Invalid key - " + key);
// }
// Object old = environment.get(key);
// if (!old.getClass().equals(value.getClass())) {
// value = ConvertUtils.convert(value, old.getClass());
// if (!old.getClass().equals(value.getClass())) {
// throw new IllegalArgumentException("Invalid value type - " + value.getClass().getName() + " should be " + old.getClass().getName());
// }
// }
// }
// Object prev = environment.get(key);
// if ((value != null && !value.equals(prev)) || (value == null && prev != null)) {
// setChanged();
// }
// notifyObservers(new UpdateEnvironmentEvent(key, prev, value));
// environment.put(key, value);
// }
//
// public MBeanServerConnection getServer() {
// return serverConnection;
// }
//
// public void setServer(MBeanServerConnection serverConnection, String url) {
// this.serverConnection = serverConnection;
// this.serverURL = url;
// this.objectName = null;
// }
//
// public ObjectName getObjectName() {
// return objectName;
// }
//
// public void setObjectName(ObjectName objectName) {
// this.objectName = objectName;
// }
//
// public boolean isConnected() {
// return serverConnection != null;
// }
//
// public List<MBeanAttributeInfo> getAttributes() throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException {
// if (serverConnection == null || objectName == null) {
// return Collections.emptyList();
// }
// MBeanInfo beanInfo = serverConnection.getMBeanInfo(objectName);
// return Arrays.asList(beanInfo.getAttributes());
// }
//
// public boolean isBeanSelected() {
// return objectName != null;
// }
//
//
// public Object getServerURL() {
// return serverURL;
// }
//
// public void fail(CommandAction action, int code) {
// if (exitCode == 0) {
// exitCode = code;
// }
// }
//
// public int getExitCode() {
// return exitCode;
// }
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/command/CommandAction.java
// public interface CommandAction {
//
// void doAction(TJContext tjContext, Output output) throws Exception;
//
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/console/Output.java
// public class Output implements Closeable {
// private final Pattern ansiRemovePattern = Pattern.compile("(@\\|\\w* )|( ?\\|@)");
// private final PrintStream out;
// private boolean useColors = true, ansiInstalled, filterInfo;
//
// public Output(PrintStream out, boolean useColors) {
// this.out = out;
// setUseColors(useColors);
// }
//
// public void setFilterInfo(boolean filterInfo) {
// this.filterInfo = filterInfo;
// }
//
// public boolean isUseColors() {
// return useColors;
// }
//
//
// public void setUseColors(boolean useColors) {
// this.useColors = useColors;
// if (useColors) {
// AnsiConsole.systemInstall();
// ansiInstalled = true;
// } else {
// AnsiConsole.systemUninstall();
// ansiInstalled = false;
// }
// }
//
//
// public void print(String text) {
// if (useColors) {
// out.print(ansi().render(text));
// } else {
// String s = ansiRemovePattern.matcher(text).replaceAll("");
// out.print(s);
// }
// out.flush();
// }
//
//
// public void println(String text) {
// print(text);
// out.println();
// out.flush();
// }
//
//
// @Override
// public void close() throws IOException {
// if (ansiInstalled) {
// AnsiConsole.systemUninstall();
// }
// out.close();
// }
//
// public void outError(String text) {
// println("@|red " + text + "|@");
// }
//
// public void outInfo(String text) {
// if (! filterInfo) {
// println("@|cyan " + text + "|@");
// }
// }
// }
| import org.jsoftware.tjconsole.TJContext;
import org.jsoftware.tjconsole.command.CommandAction;
import org.jsoftware.tjconsole.console.Output; | package org.jsoftware.tjconsole.command.definition;
/**
* Show current state
*
* @author szalik
*/
public class InfoCommandDefinition extends AbstractCommandDefinition {
public InfoCommandDefinition() {
super("Display current state.", "info", "info", false);
}
public CommandAction action(String input) {
return new CommandAction() {
@Override | // Path: src/main/java/org/jsoftware/tjconsole/TJContext.java
// public class TJContext extends Observable {
// private MBeanServerConnection serverConnection;
// private ObjectName objectName;
// private final Map<String, Object> environment;
// private Object serverURL;
// private int exitCode = 0;
//
// public TJContext() {
// environment = new LinkedHashMap<String, Object>();
// }
//
// public Map<String, Object> getEnvironment() {
// return Collections.unmodifiableMap(environment);
// }
//
// public void setEnvironmentVariable(String key, Object value, boolean check) {
// if (check) {
// if (!environment.containsKey(key)) {
// throw new IllegalArgumentException("Invalid key - " + key);
// }
// Object old = environment.get(key);
// if (!old.getClass().equals(value.getClass())) {
// value = ConvertUtils.convert(value, old.getClass());
// if (!old.getClass().equals(value.getClass())) {
// throw new IllegalArgumentException("Invalid value type - " + value.getClass().getName() + " should be " + old.getClass().getName());
// }
// }
// }
// Object prev = environment.get(key);
// if ((value != null && !value.equals(prev)) || (value == null && prev != null)) {
// setChanged();
// }
// notifyObservers(new UpdateEnvironmentEvent(key, prev, value));
// environment.put(key, value);
// }
//
// public MBeanServerConnection getServer() {
// return serverConnection;
// }
//
// public void setServer(MBeanServerConnection serverConnection, String url) {
// this.serverConnection = serverConnection;
// this.serverURL = url;
// this.objectName = null;
// }
//
// public ObjectName getObjectName() {
// return objectName;
// }
//
// public void setObjectName(ObjectName objectName) {
// this.objectName = objectName;
// }
//
// public boolean isConnected() {
// return serverConnection != null;
// }
//
// public List<MBeanAttributeInfo> getAttributes() throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException {
// if (serverConnection == null || objectName == null) {
// return Collections.emptyList();
// }
// MBeanInfo beanInfo = serverConnection.getMBeanInfo(objectName);
// return Arrays.asList(beanInfo.getAttributes());
// }
//
// public boolean isBeanSelected() {
// return objectName != null;
// }
//
//
// public Object getServerURL() {
// return serverURL;
// }
//
// public void fail(CommandAction action, int code) {
// if (exitCode == 0) {
// exitCode = code;
// }
// }
//
// public int getExitCode() {
// return exitCode;
// }
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/command/CommandAction.java
// public interface CommandAction {
//
// void doAction(TJContext tjContext, Output output) throws Exception;
//
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/console/Output.java
// public class Output implements Closeable {
// private final Pattern ansiRemovePattern = Pattern.compile("(@\\|\\w* )|( ?\\|@)");
// private final PrintStream out;
// private boolean useColors = true, ansiInstalled, filterInfo;
//
// public Output(PrintStream out, boolean useColors) {
// this.out = out;
// setUseColors(useColors);
// }
//
// public void setFilterInfo(boolean filterInfo) {
// this.filterInfo = filterInfo;
// }
//
// public boolean isUseColors() {
// return useColors;
// }
//
//
// public void setUseColors(boolean useColors) {
// this.useColors = useColors;
// if (useColors) {
// AnsiConsole.systemInstall();
// ansiInstalled = true;
// } else {
// AnsiConsole.systemUninstall();
// ansiInstalled = false;
// }
// }
//
//
// public void print(String text) {
// if (useColors) {
// out.print(ansi().render(text));
// } else {
// String s = ansiRemovePattern.matcher(text).replaceAll("");
// out.print(s);
// }
// out.flush();
// }
//
//
// public void println(String text) {
// print(text);
// out.println();
// out.flush();
// }
//
//
// @Override
// public void close() throws IOException {
// if (ansiInstalled) {
// AnsiConsole.systemUninstall();
// }
// out.close();
// }
//
// public void outError(String text) {
// println("@|red " + text + "|@");
// }
//
// public void outInfo(String text) {
// if (! filterInfo) {
// println("@|cyan " + text + "|@");
// }
// }
// }
// Path: src/main/java/org/jsoftware/tjconsole/command/definition/InfoCommandDefinition.java
import org.jsoftware.tjconsole.TJContext;
import org.jsoftware.tjconsole.command.CommandAction;
import org.jsoftware.tjconsole.console.Output;
package org.jsoftware.tjconsole.command.definition;
/**
* Show current state
*
* @author szalik
*/
public class InfoCommandDefinition extends AbstractCommandDefinition {
public InfoCommandDefinition() {
super("Display current state.", "info", "info", false);
}
public CommandAction action(String input) {
return new CommandAction() {
@Override | public void doAction(TJContext tjContext, Output output) { |
m-szalik/tjconsole | src/main/java/org/jsoftware/tjconsole/command/definition/InfoCommandDefinition.java | // Path: src/main/java/org/jsoftware/tjconsole/TJContext.java
// public class TJContext extends Observable {
// private MBeanServerConnection serverConnection;
// private ObjectName objectName;
// private final Map<String, Object> environment;
// private Object serverURL;
// private int exitCode = 0;
//
// public TJContext() {
// environment = new LinkedHashMap<String, Object>();
// }
//
// public Map<String, Object> getEnvironment() {
// return Collections.unmodifiableMap(environment);
// }
//
// public void setEnvironmentVariable(String key, Object value, boolean check) {
// if (check) {
// if (!environment.containsKey(key)) {
// throw new IllegalArgumentException("Invalid key - " + key);
// }
// Object old = environment.get(key);
// if (!old.getClass().equals(value.getClass())) {
// value = ConvertUtils.convert(value, old.getClass());
// if (!old.getClass().equals(value.getClass())) {
// throw new IllegalArgumentException("Invalid value type - " + value.getClass().getName() + " should be " + old.getClass().getName());
// }
// }
// }
// Object prev = environment.get(key);
// if ((value != null && !value.equals(prev)) || (value == null && prev != null)) {
// setChanged();
// }
// notifyObservers(new UpdateEnvironmentEvent(key, prev, value));
// environment.put(key, value);
// }
//
// public MBeanServerConnection getServer() {
// return serverConnection;
// }
//
// public void setServer(MBeanServerConnection serverConnection, String url) {
// this.serverConnection = serverConnection;
// this.serverURL = url;
// this.objectName = null;
// }
//
// public ObjectName getObjectName() {
// return objectName;
// }
//
// public void setObjectName(ObjectName objectName) {
// this.objectName = objectName;
// }
//
// public boolean isConnected() {
// return serverConnection != null;
// }
//
// public List<MBeanAttributeInfo> getAttributes() throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException {
// if (serverConnection == null || objectName == null) {
// return Collections.emptyList();
// }
// MBeanInfo beanInfo = serverConnection.getMBeanInfo(objectName);
// return Arrays.asList(beanInfo.getAttributes());
// }
//
// public boolean isBeanSelected() {
// return objectName != null;
// }
//
//
// public Object getServerURL() {
// return serverURL;
// }
//
// public void fail(CommandAction action, int code) {
// if (exitCode == 0) {
// exitCode = code;
// }
// }
//
// public int getExitCode() {
// return exitCode;
// }
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/command/CommandAction.java
// public interface CommandAction {
//
// void doAction(TJContext tjContext, Output output) throws Exception;
//
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/console/Output.java
// public class Output implements Closeable {
// private final Pattern ansiRemovePattern = Pattern.compile("(@\\|\\w* )|( ?\\|@)");
// private final PrintStream out;
// private boolean useColors = true, ansiInstalled, filterInfo;
//
// public Output(PrintStream out, boolean useColors) {
// this.out = out;
// setUseColors(useColors);
// }
//
// public void setFilterInfo(boolean filterInfo) {
// this.filterInfo = filterInfo;
// }
//
// public boolean isUseColors() {
// return useColors;
// }
//
//
// public void setUseColors(boolean useColors) {
// this.useColors = useColors;
// if (useColors) {
// AnsiConsole.systemInstall();
// ansiInstalled = true;
// } else {
// AnsiConsole.systemUninstall();
// ansiInstalled = false;
// }
// }
//
//
// public void print(String text) {
// if (useColors) {
// out.print(ansi().render(text));
// } else {
// String s = ansiRemovePattern.matcher(text).replaceAll("");
// out.print(s);
// }
// out.flush();
// }
//
//
// public void println(String text) {
// print(text);
// out.println();
// out.flush();
// }
//
//
// @Override
// public void close() throws IOException {
// if (ansiInstalled) {
// AnsiConsole.systemUninstall();
// }
// out.close();
// }
//
// public void outError(String text) {
// println("@|red " + text + "|@");
// }
//
// public void outInfo(String text) {
// if (! filterInfo) {
// println("@|cyan " + text + "|@");
// }
// }
// }
| import org.jsoftware.tjconsole.TJContext;
import org.jsoftware.tjconsole.command.CommandAction;
import org.jsoftware.tjconsole.console.Output; | package org.jsoftware.tjconsole.command.definition;
/**
* Show current state
*
* @author szalik
*/
public class InfoCommandDefinition extends AbstractCommandDefinition {
public InfoCommandDefinition() {
super("Display current state.", "info", "info", false);
}
public CommandAction action(String input) {
return new CommandAction() {
@Override | // Path: src/main/java/org/jsoftware/tjconsole/TJContext.java
// public class TJContext extends Observable {
// private MBeanServerConnection serverConnection;
// private ObjectName objectName;
// private final Map<String, Object> environment;
// private Object serverURL;
// private int exitCode = 0;
//
// public TJContext() {
// environment = new LinkedHashMap<String, Object>();
// }
//
// public Map<String, Object> getEnvironment() {
// return Collections.unmodifiableMap(environment);
// }
//
// public void setEnvironmentVariable(String key, Object value, boolean check) {
// if (check) {
// if (!environment.containsKey(key)) {
// throw new IllegalArgumentException("Invalid key - " + key);
// }
// Object old = environment.get(key);
// if (!old.getClass().equals(value.getClass())) {
// value = ConvertUtils.convert(value, old.getClass());
// if (!old.getClass().equals(value.getClass())) {
// throw new IllegalArgumentException("Invalid value type - " + value.getClass().getName() + " should be " + old.getClass().getName());
// }
// }
// }
// Object prev = environment.get(key);
// if ((value != null && !value.equals(prev)) || (value == null && prev != null)) {
// setChanged();
// }
// notifyObservers(new UpdateEnvironmentEvent(key, prev, value));
// environment.put(key, value);
// }
//
// public MBeanServerConnection getServer() {
// return serverConnection;
// }
//
// public void setServer(MBeanServerConnection serverConnection, String url) {
// this.serverConnection = serverConnection;
// this.serverURL = url;
// this.objectName = null;
// }
//
// public ObjectName getObjectName() {
// return objectName;
// }
//
// public void setObjectName(ObjectName objectName) {
// this.objectName = objectName;
// }
//
// public boolean isConnected() {
// return serverConnection != null;
// }
//
// public List<MBeanAttributeInfo> getAttributes() throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException {
// if (serverConnection == null || objectName == null) {
// return Collections.emptyList();
// }
// MBeanInfo beanInfo = serverConnection.getMBeanInfo(objectName);
// return Arrays.asList(beanInfo.getAttributes());
// }
//
// public boolean isBeanSelected() {
// return objectName != null;
// }
//
//
// public Object getServerURL() {
// return serverURL;
// }
//
// public void fail(CommandAction action, int code) {
// if (exitCode == 0) {
// exitCode = code;
// }
// }
//
// public int getExitCode() {
// return exitCode;
// }
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/command/CommandAction.java
// public interface CommandAction {
//
// void doAction(TJContext tjContext, Output output) throws Exception;
//
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/console/Output.java
// public class Output implements Closeable {
// private final Pattern ansiRemovePattern = Pattern.compile("(@\\|\\w* )|( ?\\|@)");
// private final PrintStream out;
// private boolean useColors = true, ansiInstalled, filterInfo;
//
// public Output(PrintStream out, boolean useColors) {
// this.out = out;
// setUseColors(useColors);
// }
//
// public void setFilterInfo(boolean filterInfo) {
// this.filterInfo = filterInfo;
// }
//
// public boolean isUseColors() {
// return useColors;
// }
//
//
// public void setUseColors(boolean useColors) {
// this.useColors = useColors;
// if (useColors) {
// AnsiConsole.systemInstall();
// ansiInstalled = true;
// } else {
// AnsiConsole.systemUninstall();
// ansiInstalled = false;
// }
// }
//
//
// public void print(String text) {
// if (useColors) {
// out.print(ansi().render(text));
// } else {
// String s = ansiRemovePattern.matcher(text).replaceAll("");
// out.print(s);
// }
// out.flush();
// }
//
//
// public void println(String text) {
// print(text);
// out.println();
// out.flush();
// }
//
//
// @Override
// public void close() throws IOException {
// if (ansiInstalled) {
// AnsiConsole.systemUninstall();
// }
// out.close();
// }
//
// public void outError(String text) {
// println("@|red " + text + "|@");
// }
//
// public void outInfo(String text) {
// if (! filterInfo) {
// println("@|cyan " + text + "|@");
// }
// }
// }
// Path: src/main/java/org/jsoftware/tjconsole/command/definition/InfoCommandDefinition.java
import org.jsoftware.tjconsole.TJContext;
import org.jsoftware.tjconsole.command.CommandAction;
import org.jsoftware.tjconsole.console.Output;
package org.jsoftware.tjconsole.command.definition;
/**
* Show current state
*
* @author szalik
*/
public class InfoCommandDefinition extends AbstractCommandDefinition {
public InfoCommandDefinition() {
super("Display current state.", "info", "info", false);
}
public CommandAction action(String input) {
return new CommandAction() {
@Override | public void doAction(TJContext tjContext, Output output) { |
m-szalik/tjconsole | src/main/java/org/jsoftware/tjconsole/command/CmdDescription.java | // Path: src/main/java/org/jsoftware/tjconsole/TJContext.java
// public class TJContext extends Observable {
// private MBeanServerConnection serverConnection;
// private ObjectName objectName;
// private final Map<String, Object> environment;
// private Object serverURL;
// private int exitCode = 0;
//
// public TJContext() {
// environment = new LinkedHashMap<String, Object>();
// }
//
// public Map<String, Object> getEnvironment() {
// return Collections.unmodifiableMap(environment);
// }
//
// public void setEnvironmentVariable(String key, Object value, boolean check) {
// if (check) {
// if (!environment.containsKey(key)) {
// throw new IllegalArgumentException("Invalid key - " + key);
// }
// Object old = environment.get(key);
// if (!old.getClass().equals(value.getClass())) {
// value = ConvertUtils.convert(value, old.getClass());
// if (!old.getClass().equals(value.getClass())) {
// throw new IllegalArgumentException("Invalid value type - " + value.getClass().getName() + " should be " + old.getClass().getName());
// }
// }
// }
// Object prev = environment.get(key);
// if ((value != null && !value.equals(prev)) || (value == null && prev != null)) {
// setChanged();
// }
// notifyObservers(new UpdateEnvironmentEvent(key, prev, value));
// environment.put(key, value);
// }
//
// public MBeanServerConnection getServer() {
// return serverConnection;
// }
//
// public void setServer(MBeanServerConnection serverConnection, String url) {
// this.serverConnection = serverConnection;
// this.serverURL = url;
// this.objectName = null;
// }
//
// public ObjectName getObjectName() {
// return objectName;
// }
//
// public void setObjectName(ObjectName objectName) {
// this.objectName = objectName;
// }
//
// public boolean isConnected() {
// return serverConnection != null;
// }
//
// public List<MBeanAttributeInfo> getAttributes() throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException {
// if (serverConnection == null || objectName == null) {
// return Collections.emptyList();
// }
// MBeanInfo beanInfo = serverConnection.getMBeanInfo(objectName);
// return Arrays.asList(beanInfo.getAttributes());
// }
//
// public boolean isBeanSelected() {
// return objectName != null;
// }
//
//
// public Object getServerURL() {
// return serverURL;
// }
//
// public void fail(CommandAction action, int code) {
// if (exitCode == 0) {
// exitCode = code;
// }
// }
//
// public int getExitCode() {
// return exitCode;
// }
// }
| import org.jsoftware.tjconsole.TJContext;
import java.io.Serializable; | package org.jsoftware.tjconsole.command;
/**
* Help description for a command
*
* @author szalik
*/
public class CmdDescription implements Serializable {
private static final long serialVersionUID = 974727180626249506L;
private final String description;
private final String full;
private final String prefix;
private final boolean requiresBean;
public CmdDescription(String description, String full, String prefix, boolean requiresBean) {
super();
this.description = description;
this.full = full;
this.prefix = prefix;
this.requiresBean = requiresBean;
}
public String getDescription() {
return description;
}
public String getFull() {
return full;
}
public String getPrefix() {
return prefix;
}
| // Path: src/main/java/org/jsoftware/tjconsole/TJContext.java
// public class TJContext extends Observable {
// private MBeanServerConnection serverConnection;
// private ObjectName objectName;
// private final Map<String, Object> environment;
// private Object serverURL;
// private int exitCode = 0;
//
// public TJContext() {
// environment = new LinkedHashMap<String, Object>();
// }
//
// public Map<String, Object> getEnvironment() {
// return Collections.unmodifiableMap(environment);
// }
//
// public void setEnvironmentVariable(String key, Object value, boolean check) {
// if (check) {
// if (!environment.containsKey(key)) {
// throw new IllegalArgumentException("Invalid key - " + key);
// }
// Object old = environment.get(key);
// if (!old.getClass().equals(value.getClass())) {
// value = ConvertUtils.convert(value, old.getClass());
// if (!old.getClass().equals(value.getClass())) {
// throw new IllegalArgumentException("Invalid value type - " + value.getClass().getName() + " should be " + old.getClass().getName());
// }
// }
// }
// Object prev = environment.get(key);
// if ((value != null && !value.equals(prev)) || (value == null && prev != null)) {
// setChanged();
// }
// notifyObservers(new UpdateEnvironmentEvent(key, prev, value));
// environment.put(key, value);
// }
//
// public MBeanServerConnection getServer() {
// return serverConnection;
// }
//
// public void setServer(MBeanServerConnection serverConnection, String url) {
// this.serverConnection = serverConnection;
// this.serverURL = url;
// this.objectName = null;
// }
//
// public ObjectName getObjectName() {
// return objectName;
// }
//
// public void setObjectName(ObjectName objectName) {
// this.objectName = objectName;
// }
//
// public boolean isConnected() {
// return serverConnection != null;
// }
//
// public List<MBeanAttributeInfo> getAttributes() throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException {
// if (serverConnection == null || objectName == null) {
// return Collections.emptyList();
// }
// MBeanInfo beanInfo = serverConnection.getMBeanInfo(objectName);
// return Arrays.asList(beanInfo.getAttributes());
// }
//
// public boolean isBeanSelected() {
// return objectName != null;
// }
//
//
// public Object getServerURL() {
// return serverURL;
// }
//
// public void fail(CommandAction action, int code) {
// if (exitCode == 0) {
// exitCode = code;
// }
// }
//
// public int getExitCode() {
// return exitCode;
// }
// }
// Path: src/main/java/org/jsoftware/tjconsole/command/CmdDescription.java
import org.jsoftware.tjconsole.TJContext;
import java.io.Serializable;
package org.jsoftware.tjconsole.command;
/**
* Help description for a command
*
* @author szalik
*/
public class CmdDescription implements Serializable {
private static final long serialVersionUID = 974727180626249506L;
private final String description;
private final String full;
private final String prefix;
private final boolean requiresBean;
public CmdDescription(String description, String full, String prefix, boolean requiresBean) {
super();
this.description = description;
this.full = full;
this.prefix = prefix;
this.requiresBean = requiresBean;
}
public String getDescription() {
return description;
}
public String getFull() {
return full;
}
public String getPrefix() {
return prefix;
}
| public boolean canBeUsed(TJContext tjContext) { |
m-szalik/tjconsole | src/main/java/org/jsoftware/tjconsole/command/definition/QuitCommandDefinition.java | // Path: src/main/java/org/jsoftware/tjconsole/TJContext.java
// public class TJContext extends Observable {
// private MBeanServerConnection serverConnection;
// private ObjectName objectName;
// private final Map<String, Object> environment;
// private Object serverURL;
// private int exitCode = 0;
//
// public TJContext() {
// environment = new LinkedHashMap<String, Object>();
// }
//
// public Map<String, Object> getEnvironment() {
// return Collections.unmodifiableMap(environment);
// }
//
// public void setEnvironmentVariable(String key, Object value, boolean check) {
// if (check) {
// if (!environment.containsKey(key)) {
// throw new IllegalArgumentException("Invalid key - " + key);
// }
// Object old = environment.get(key);
// if (!old.getClass().equals(value.getClass())) {
// value = ConvertUtils.convert(value, old.getClass());
// if (!old.getClass().equals(value.getClass())) {
// throw new IllegalArgumentException("Invalid value type - " + value.getClass().getName() + " should be " + old.getClass().getName());
// }
// }
// }
// Object prev = environment.get(key);
// if ((value != null && !value.equals(prev)) || (value == null && prev != null)) {
// setChanged();
// }
// notifyObservers(new UpdateEnvironmentEvent(key, prev, value));
// environment.put(key, value);
// }
//
// public MBeanServerConnection getServer() {
// return serverConnection;
// }
//
// public void setServer(MBeanServerConnection serverConnection, String url) {
// this.serverConnection = serverConnection;
// this.serverURL = url;
// this.objectName = null;
// }
//
// public ObjectName getObjectName() {
// return objectName;
// }
//
// public void setObjectName(ObjectName objectName) {
// this.objectName = objectName;
// }
//
// public boolean isConnected() {
// return serverConnection != null;
// }
//
// public List<MBeanAttributeInfo> getAttributes() throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException {
// if (serverConnection == null || objectName == null) {
// return Collections.emptyList();
// }
// MBeanInfo beanInfo = serverConnection.getMBeanInfo(objectName);
// return Arrays.asList(beanInfo.getAttributes());
// }
//
// public boolean isBeanSelected() {
// return objectName != null;
// }
//
//
// public Object getServerURL() {
// return serverURL;
// }
//
// public void fail(CommandAction action, int code) {
// if (exitCode == 0) {
// exitCode = code;
// }
// }
//
// public int getExitCode() {
// return exitCode;
// }
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/command/CommandAction.java
// public interface CommandAction {
//
// void doAction(TJContext tjContext, Output output) throws Exception;
//
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/console/EndOfInputException.java
// public class EndOfInputException extends Exception {
//
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/console/Output.java
// public class Output implements Closeable {
// private final Pattern ansiRemovePattern = Pattern.compile("(@\\|\\w* )|( ?\\|@)");
// private final PrintStream out;
// private boolean useColors = true, ansiInstalled, filterInfo;
//
// public Output(PrintStream out, boolean useColors) {
// this.out = out;
// setUseColors(useColors);
// }
//
// public void setFilterInfo(boolean filterInfo) {
// this.filterInfo = filterInfo;
// }
//
// public boolean isUseColors() {
// return useColors;
// }
//
//
// public void setUseColors(boolean useColors) {
// this.useColors = useColors;
// if (useColors) {
// AnsiConsole.systemInstall();
// ansiInstalled = true;
// } else {
// AnsiConsole.systemUninstall();
// ansiInstalled = false;
// }
// }
//
//
// public void print(String text) {
// if (useColors) {
// out.print(ansi().render(text));
// } else {
// String s = ansiRemovePattern.matcher(text).replaceAll("");
// out.print(s);
// }
// out.flush();
// }
//
//
// public void println(String text) {
// print(text);
// out.println();
// out.flush();
// }
//
//
// @Override
// public void close() throws IOException {
// if (ansiInstalled) {
// AnsiConsole.systemUninstall();
// }
// out.close();
// }
//
// public void outError(String text) {
// println("@|red " + text + "|@");
// }
//
// public void outInfo(String text) {
// if (! filterInfo) {
// println("@|cyan " + text + "|@");
// }
// }
// }
| import org.jsoftware.tjconsole.TJContext;
import org.jsoftware.tjconsole.command.CommandAction;
import org.jsoftware.tjconsole.console.EndOfInputException;
import org.jsoftware.tjconsole.console.Output; | package org.jsoftware.tjconsole.command.definition;
/**
* Quit command. Quits an application.
*
* @author szalik
*/
public class QuitCommandDefinition extends AbstractCommandDefinition {
public QuitCommandDefinition() {
super("Quit.", "q or quit", "quit", false);
}
@Override | // Path: src/main/java/org/jsoftware/tjconsole/TJContext.java
// public class TJContext extends Observable {
// private MBeanServerConnection serverConnection;
// private ObjectName objectName;
// private final Map<String, Object> environment;
// private Object serverURL;
// private int exitCode = 0;
//
// public TJContext() {
// environment = new LinkedHashMap<String, Object>();
// }
//
// public Map<String, Object> getEnvironment() {
// return Collections.unmodifiableMap(environment);
// }
//
// public void setEnvironmentVariable(String key, Object value, boolean check) {
// if (check) {
// if (!environment.containsKey(key)) {
// throw new IllegalArgumentException("Invalid key - " + key);
// }
// Object old = environment.get(key);
// if (!old.getClass().equals(value.getClass())) {
// value = ConvertUtils.convert(value, old.getClass());
// if (!old.getClass().equals(value.getClass())) {
// throw new IllegalArgumentException("Invalid value type - " + value.getClass().getName() + " should be " + old.getClass().getName());
// }
// }
// }
// Object prev = environment.get(key);
// if ((value != null && !value.equals(prev)) || (value == null && prev != null)) {
// setChanged();
// }
// notifyObservers(new UpdateEnvironmentEvent(key, prev, value));
// environment.put(key, value);
// }
//
// public MBeanServerConnection getServer() {
// return serverConnection;
// }
//
// public void setServer(MBeanServerConnection serverConnection, String url) {
// this.serverConnection = serverConnection;
// this.serverURL = url;
// this.objectName = null;
// }
//
// public ObjectName getObjectName() {
// return objectName;
// }
//
// public void setObjectName(ObjectName objectName) {
// this.objectName = objectName;
// }
//
// public boolean isConnected() {
// return serverConnection != null;
// }
//
// public List<MBeanAttributeInfo> getAttributes() throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException {
// if (serverConnection == null || objectName == null) {
// return Collections.emptyList();
// }
// MBeanInfo beanInfo = serverConnection.getMBeanInfo(objectName);
// return Arrays.asList(beanInfo.getAttributes());
// }
//
// public boolean isBeanSelected() {
// return objectName != null;
// }
//
//
// public Object getServerURL() {
// return serverURL;
// }
//
// public void fail(CommandAction action, int code) {
// if (exitCode == 0) {
// exitCode = code;
// }
// }
//
// public int getExitCode() {
// return exitCode;
// }
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/command/CommandAction.java
// public interface CommandAction {
//
// void doAction(TJContext tjContext, Output output) throws Exception;
//
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/console/EndOfInputException.java
// public class EndOfInputException extends Exception {
//
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/console/Output.java
// public class Output implements Closeable {
// private final Pattern ansiRemovePattern = Pattern.compile("(@\\|\\w* )|( ?\\|@)");
// private final PrintStream out;
// private boolean useColors = true, ansiInstalled, filterInfo;
//
// public Output(PrintStream out, boolean useColors) {
// this.out = out;
// setUseColors(useColors);
// }
//
// public void setFilterInfo(boolean filterInfo) {
// this.filterInfo = filterInfo;
// }
//
// public boolean isUseColors() {
// return useColors;
// }
//
//
// public void setUseColors(boolean useColors) {
// this.useColors = useColors;
// if (useColors) {
// AnsiConsole.systemInstall();
// ansiInstalled = true;
// } else {
// AnsiConsole.systemUninstall();
// ansiInstalled = false;
// }
// }
//
//
// public void print(String text) {
// if (useColors) {
// out.print(ansi().render(text));
// } else {
// String s = ansiRemovePattern.matcher(text).replaceAll("");
// out.print(s);
// }
// out.flush();
// }
//
//
// public void println(String text) {
// print(text);
// out.println();
// out.flush();
// }
//
//
// @Override
// public void close() throws IOException {
// if (ansiInstalled) {
// AnsiConsole.systemUninstall();
// }
// out.close();
// }
//
// public void outError(String text) {
// println("@|red " + text + "|@");
// }
//
// public void outInfo(String text) {
// if (! filterInfo) {
// println("@|cyan " + text + "|@");
// }
// }
// }
// Path: src/main/java/org/jsoftware/tjconsole/command/definition/QuitCommandDefinition.java
import org.jsoftware.tjconsole.TJContext;
import org.jsoftware.tjconsole.command.CommandAction;
import org.jsoftware.tjconsole.console.EndOfInputException;
import org.jsoftware.tjconsole.console.Output;
package org.jsoftware.tjconsole.command.definition;
/**
* Quit command. Quits an application.
*
* @author szalik
*/
public class QuitCommandDefinition extends AbstractCommandDefinition {
public QuitCommandDefinition() {
super("Quit.", "q or quit", "quit", false);
}
@Override | public CommandAction action(String input) { |
m-szalik/tjconsole | src/main/java/org/jsoftware/tjconsole/command/definition/QuitCommandDefinition.java | // Path: src/main/java/org/jsoftware/tjconsole/TJContext.java
// public class TJContext extends Observable {
// private MBeanServerConnection serverConnection;
// private ObjectName objectName;
// private final Map<String, Object> environment;
// private Object serverURL;
// private int exitCode = 0;
//
// public TJContext() {
// environment = new LinkedHashMap<String, Object>();
// }
//
// public Map<String, Object> getEnvironment() {
// return Collections.unmodifiableMap(environment);
// }
//
// public void setEnvironmentVariable(String key, Object value, boolean check) {
// if (check) {
// if (!environment.containsKey(key)) {
// throw new IllegalArgumentException("Invalid key - " + key);
// }
// Object old = environment.get(key);
// if (!old.getClass().equals(value.getClass())) {
// value = ConvertUtils.convert(value, old.getClass());
// if (!old.getClass().equals(value.getClass())) {
// throw new IllegalArgumentException("Invalid value type - " + value.getClass().getName() + " should be " + old.getClass().getName());
// }
// }
// }
// Object prev = environment.get(key);
// if ((value != null && !value.equals(prev)) || (value == null && prev != null)) {
// setChanged();
// }
// notifyObservers(new UpdateEnvironmentEvent(key, prev, value));
// environment.put(key, value);
// }
//
// public MBeanServerConnection getServer() {
// return serverConnection;
// }
//
// public void setServer(MBeanServerConnection serverConnection, String url) {
// this.serverConnection = serverConnection;
// this.serverURL = url;
// this.objectName = null;
// }
//
// public ObjectName getObjectName() {
// return objectName;
// }
//
// public void setObjectName(ObjectName objectName) {
// this.objectName = objectName;
// }
//
// public boolean isConnected() {
// return serverConnection != null;
// }
//
// public List<MBeanAttributeInfo> getAttributes() throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException {
// if (serverConnection == null || objectName == null) {
// return Collections.emptyList();
// }
// MBeanInfo beanInfo = serverConnection.getMBeanInfo(objectName);
// return Arrays.asList(beanInfo.getAttributes());
// }
//
// public boolean isBeanSelected() {
// return objectName != null;
// }
//
//
// public Object getServerURL() {
// return serverURL;
// }
//
// public void fail(CommandAction action, int code) {
// if (exitCode == 0) {
// exitCode = code;
// }
// }
//
// public int getExitCode() {
// return exitCode;
// }
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/command/CommandAction.java
// public interface CommandAction {
//
// void doAction(TJContext tjContext, Output output) throws Exception;
//
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/console/EndOfInputException.java
// public class EndOfInputException extends Exception {
//
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/console/Output.java
// public class Output implements Closeable {
// private final Pattern ansiRemovePattern = Pattern.compile("(@\\|\\w* )|( ?\\|@)");
// private final PrintStream out;
// private boolean useColors = true, ansiInstalled, filterInfo;
//
// public Output(PrintStream out, boolean useColors) {
// this.out = out;
// setUseColors(useColors);
// }
//
// public void setFilterInfo(boolean filterInfo) {
// this.filterInfo = filterInfo;
// }
//
// public boolean isUseColors() {
// return useColors;
// }
//
//
// public void setUseColors(boolean useColors) {
// this.useColors = useColors;
// if (useColors) {
// AnsiConsole.systemInstall();
// ansiInstalled = true;
// } else {
// AnsiConsole.systemUninstall();
// ansiInstalled = false;
// }
// }
//
//
// public void print(String text) {
// if (useColors) {
// out.print(ansi().render(text));
// } else {
// String s = ansiRemovePattern.matcher(text).replaceAll("");
// out.print(s);
// }
// out.flush();
// }
//
//
// public void println(String text) {
// print(text);
// out.println();
// out.flush();
// }
//
//
// @Override
// public void close() throws IOException {
// if (ansiInstalled) {
// AnsiConsole.systemUninstall();
// }
// out.close();
// }
//
// public void outError(String text) {
// println("@|red " + text + "|@");
// }
//
// public void outInfo(String text) {
// if (! filterInfo) {
// println("@|cyan " + text + "|@");
// }
// }
// }
| import org.jsoftware.tjconsole.TJContext;
import org.jsoftware.tjconsole.command.CommandAction;
import org.jsoftware.tjconsole.console.EndOfInputException;
import org.jsoftware.tjconsole.console.Output; | package org.jsoftware.tjconsole.command.definition;
/**
* Quit command. Quits an application.
*
* @author szalik
*/
public class QuitCommandDefinition extends AbstractCommandDefinition {
public QuitCommandDefinition() {
super("Quit.", "q or quit", "quit", false);
}
@Override
public CommandAction action(String input) {
return new CommandAction() {
@Override | // Path: src/main/java/org/jsoftware/tjconsole/TJContext.java
// public class TJContext extends Observable {
// private MBeanServerConnection serverConnection;
// private ObjectName objectName;
// private final Map<String, Object> environment;
// private Object serverURL;
// private int exitCode = 0;
//
// public TJContext() {
// environment = new LinkedHashMap<String, Object>();
// }
//
// public Map<String, Object> getEnvironment() {
// return Collections.unmodifiableMap(environment);
// }
//
// public void setEnvironmentVariable(String key, Object value, boolean check) {
// if (check) {
// if (!environment.containsKey(key)) {
// throw new IllegalArgumentException("Invalid key - " + key);
// }
// Object old = environment.get(key);
// if (!old.getClass().equals(value.getClass())) {
// value = ConvertUtils.convert(value, old.getClass());
// if (!old.getClass().equals(value.getClass())) {
// throw new IllegalArgumentException("Invalid value type - " + value.getClass().getName() + " should be " + old.getClass().getName());
// }
// }
// }
// Object prev = environment.get(key);
// if ((value != null && !value.equals(prev)) || (value == null && prev != null)) {
// setChanged();
// }
// notifyObservers(new UpdateEnvironmentEvent(key, prev, value));
// environment.put(key, value);
// }
//
// public MBeanServerConnection getServer() {
// return serverConnection;
// }
//
// public void setServer(MBeanServerConnection serverConnection, String url) {
// this.serverConnection = serverConnection;
// this.serverURL = url;
// this.objectName = null;
// }
//
// public ObjectName getObjectName() {
// return objectName;
// }
//
// public void setObjectName(ObjectName objectName) {
// this.objectName = objectName;
// }
//
// public boolean isConnected() {
// return serverConnection != null;
// }
//
// public List<MBeanAttributeInfo> getAttributes() throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException {
// if (serverConnection == null || objectName == null) {
// return Collections.emptyList();
// }
// MBeanInfo beanInfo = serverConnection.getMBeanInfo(objectName);
// return Arrays.asList(beanInfo.getAttributes());
// }
//
// public boolean isBeanSelected() {
// return objectName != null;
// }
//
//
// public Object getServerURL() {
// return serverURL;
// }
//
// public void fail(CommandAction action, int code) {
// if (exitCode == 0) {
// exitCode = code;
// }
// }
//
// public int getExitCode() {
// return exitCode;
// }
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/command/CommandAction.java
// public interface CommandAction {
//
// void doAction(TJContext tjContext, Output output) throws Exception;
//
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/console/EndOfInputException.java
// public class EndOfInputException extends Exception {
//
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/console/Output.java
// public class Output implements Closeable {
// private final Pattern ansiRemovePattern = Pattern.compile("(@\\|\\w* )|( ?\\|@)");
// private final PrintStream out;
// private boolean useColors = true, ansiInstalled, filterInfo;
//
// public Output(PrintStream out, boolean useColors) {
// this.out = out;
// setUseColors(useColors);
// }
//
// public void setFilterInfo(boolean filterInfo) {
// this.filterInfo = filterInfo;
// }
//
// public boolean isUseColors() {
// return useColors;
// }
//
//
// public void setUseColors(boolean useColors) {
// this.useColors = useColors;
// if (useColors) {
// AnsiConsole.systemInstall();
// ansiInstalled = true;
// } else {
// AnsiConsole.systemUninstall();
// ansiInstalled = false;
// }
// }
//
//
// public void print(String text) {
// if (useColors) {
// out.print(ansi().render(text));
// } else {
// String s = ansiRemovePattern.matcher(text).replaceAll("");
// out.print(s);
// }
// out.flush();
// }
//
//
// public void println(String text) {
// print(text);
// out.println();
// out.flush();
// }
//
//
// @Override
// public void close() throws IOException {
// if (ansiInstalled) {
// AnsiConsole.systemUninstall();
// }
// out.close();
// }
//
// public void outError(String text) {
// println("@|red " + text + "|@");
// }
//
// public void outInfo(String text) {
// if (! filterInfo) {
// println("@|cyan " + text + "|@");
// }
// }
// }
// Path: src/main/java/org/jsoftware/tjconsole/command/definition/QuitCommandDefinition.java
import org.jsoftware.tjconsole.TJContext;
import org.jsoftware.tjconsole.command.CommandAction;
import org.jsoftware.tjconsole.console.EndOfInputException;
import org.jsoftware.tjconsole.console.Output;
package org.jsoftware.tjconsole.command.definition;
/**
* Quit command. Quits an application.
*
* @author szalik
*/
public class QuitCommandDefinition extends AbstractCommandDefinition {
public QuitCommandDefinition() {
super("Quit.", "q or quit", "quit", false);
}
@Override
public CommandAction action(String input) {
return new CommandAction() {
@Override | public void doAction(TJContext tjContext, Output output) throws Exception { |
m-szalik/tjconsole | src/main/java/org/jsoftware/tjconsole/command/definition/QuitCommandDefinition.java | // Path: src/main/java/org/jsoftware/tjconsole/TJContext.java
// public class TJContext extends Observable {
// private MBeanServerConnection serverConnection;
// private ObjectName objectName;
// private final Map<String, Object> environment;
// private Object serverURL;
// private int exitCode = 0;
//
// public TJContext() {
// environment = new LinkedHashMap<String, Object>();
// }
//
// public Map<String, Object> getEnvironment() {
// return Collections.unmodifiableMap(environment);
// }
//
// public void setEnvironmentVariable(String key, Object value, boolean check) {
// if (check) {
// if (!environment.containsKey(key)) {
// throw new IllegalArgumentException("Invalid key - " + key);
// }
// Object old = environment.get(key);
// if (!old.getClass().equals(value.getClass())) {
// value = ConvertUtils.convert(value, old.getClass());
// if (!old.getClass().equals(value.getClass())) {
// throw new IllegalArgumentException("Invalid value type - " + value.getClass().getName() + " should be " + old.getClass().getName());
// }
// }
// }
// Object prev = environment.get(key);
// if ((value != null && !value.equals(prev)) || (value == null && prev != null)) {
// setChanged();
// }
// notifyObservers(new UpdateEnvironmentEvent(key, prev, value));
// environment.put(key, value);
// }
//
// public MBeanServerConnection getServer() {
// return serverConnection;
// }
//
// public void setServer(MBeanServerConnection serverConnection, String url) {
// this.serverConnection = serverConnection;
// this.serverURL = url;
// this.objectName = null;
// }
//
// public ObjectName getObjectName() {
// return objectName;
// }
//
// public void setObjectName(ObjectName objectName) {
// this.objectName = objectName;
// }
//
// public boolean isConnected() {
// return serverConnection != null;
// }
//
// public List<MBeanAttributeInfo> getAttributes() throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException {
// if (serverConnection == null || objectName == null) {
// return Collections.emptyList();
// }
// MBeanInfo beanInfo = serverConnection.getMBeanInfo(objectName);
// return Arrays.asList(beanInfo.getAttributes());
// }
//
// public boolean isBeanSelected() {
// return objectName != null;
// }
//
//
// public Object getServerURL() {
// return serverURL;
// }
//
// public void fail(CommandAction action, int code) {
// if (exitCode == 0) {
// exitCode = code;
// }
// }
//
// public int getExitCode() {
// return exitCode;
// }
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/command/CommandAction.java
// public interface CommandAction {
//
// void doAction(TJContext tjContext, Output output) throws Exception;
//
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/console/EndOfInputException.java
// public class EndOfInputException extends Exception {
//
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/console/Output.java
// public class Output implements Closeable {
// private final Pattern ansiRemovePattern = Pattern.compile("(@\\|\\w* )|( ?\\|@)");
// private final PrintStream out;
// private boolean useColors = true, ansiInstalled, filterInfo;
//
// public Output(PrintStream out, boolean useColors) {
// this.out = out;
// setUseColors(useColors);
// }
//
// public void setFilterInfo(boolean filterInfo) {
// this.filterInfo = filterInfo;
// }
//
// public boolean isUseColors() {
// return useColors;
// }
//
//
// public void setUseColors(boolean useColors) {
// this.useColors = useColors;
// if (useColors) {
// AnsiConsole.systemInstall();
// ansiInstalled = true;
// } else {
// AnsiConsole.systemUninstall();
// ansiInstalled = false;
// }
// }
//
//
// public void print(String text) {
// if (useColors) {
// out.print(ansi().render(text));
// } else {
// String s = ansiRemovePattern.matcher(text).replaceAll("");
// out.print(s);
// }
// out.flush();
// }
//
//
// public void println(String text) {
// print(text);
// out.println();
// out.flush();
// }
//
//
// @Override
// public void close() throws IOException {
// if (ansiInstalled) {
// AnsiConsole.systemUninstall();
// }
// out.close();
// }
//
// public void outError(String text) {
// println("@|red " + text + "|@");
// }
//
// public void outInfo(String text) {
// if (! filterInfo) {
// println("@|cyan " + text + "|@");
// }
// }
// }
| import org.jsoftware.tjconsole.TJContext;
import org.jsoftware.tjconsole.command.CommandAction;
import org.jsoftware.tjconsole.console.EndOfInputException;
import org.jsoftware.tjconsole.console.Output; | package org.jsoftware.tjconsole.command.definition;
/**
* Quit command. Quits an application.
*
* @author szalik
*/
public class QuitCommandDefinition extends AbstractCommandDefinition {
public QuitCommandDefinition() {
super("Quit.", "q or quit", "quit", false);
}
@Override
public CommandAction action(String input) {
return new CommandAction() {
@Override | // Path: src/main/java/org/jsoftware/tjconsole/TJContext.java
// public class TJContext extends Observable {
// private MBeanServerConnection serverConnection;
// private ObjectName objectName;
// private final Map<String, Object> environment;
// private Object serverURL;
// private int exitCode = 0;
//
// public TJContext() {
// environment = new LinkedHashMap<String, Object>();
// }
//
// public Map<String, Object> getEnvironment() {
// return Collections.unmodifiableMap(environment);
// }
//
// public void setEnvironmentVariable(String key, Object value, boolean check) {
// if (check) {
// if (!environment.containsKey(key)) {
// throw new IllegalArgumentException("Invalid key - " + key);
// }
// Object old = environment.get(key);
// if (!old.getClass().equals(value.getClass())) {
// value = ConvertUtils.convert(value, old.getClass());
// if (!old.getClass().equals(value.getClass())) {
// throw new IllegalArgumentException("Invalid value type - " + value.getClass().getName() + " should be " + old.getClass().getName());
// }
// }
// }
// Object prev = environment.get(key);
// if ((value != null && !value.equals(prev)) || (value == null && prev != null)) {
// setChanged();
// }
// notifyObservers(new UpdateEnvironmentEvent(key, prev, value));
// environment.put(key, value);
// }
//
// public MBeanServerConnection getServer() {
// return serverConnection;
// }
//
// public void setServer(MBeanServerConnection serverConnection, String url) {
// this.serverConnection = serverConnection;
// this.serverURL = url;
// this.objectName = null;
// }
//
// public ObjectName getObjectName() {
// return objectName;
// }
//
// public void setObjectName(ObjectName objectName) {
// this.objectName = objectName;
// }
//
// public boolean isConnected() {
// return serverConnection != null;
// }
//
// public List<MBeanAttributeInfo> getAttributes() throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException {
// if (serverConnection == null || objectName == null) {
// return Collections.emptyList();
// }
// MBeanInfo beanInfo = serverConnection.getMBeanInfo(objectName);
// return Arrays.asList(beanInfo.getAttributes());
// }
//
// public boolean isBeanSelected() {
// return objectName != null;
// }
//
//
// public Object getServerURL() {
// return serverURL;
// }
//
// public void fail(CommandAction action, int code) {
// if (exitCode == 0) {
// exitCode = code;
// }
// }
//
// public int getExitCode() {
// return exitCode;
// }
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/command/CommandAction.java
// public interface CommandAction {
//
// void doAction(TJContext tjContext, Output output) throws Exception;
//
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/console/EndOfInputException.java
// public class EndOfInputException extends Exception {
//
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/console/Output.java
// public class Output implements Closeable {
// private final Pattern ansiRemovePattern = Pattern.compile("(@\\|\\w* )|( ?\\|@)");
// private final PrintStream out;
// private boolean useColors = true, ansiInstalled, filterInfo;
//
// public Output(PrintStream out, boolean useColors) {
// this.out = out;
// setUseColors(useColors);
// }
//
// public void setFilterInfo(boolean filterInfo) {
// this.filterInfo = filterInfo;
// }
//
// public boolean isUseColors() {
// return useColors;
// }
//
//
// public void setUseColors(boolean useColors) {
// this.useColors = useColors;
// if (useColors) {
// AnsiConsole.systemInstall();
// ansiInstalled = true;
// } else {
// AnsiConsole.systemUninstall();
// ansiInstalled = false;
// }
// }
//
//
// public void print(String text) {
// if (useColors) {
// out.print(ansi().render(text));
// } else {
// String s = ansiRemovePattern.matcher(text).replaceAll("");
// out.print(s);
// }
// out.flush();
// }
//
//
// public void println(String text) {
// print(text);
// out.println();
// out.flush();
// }
//
//
// @Override
// public void close() throws IOException {
// if (ansiInstalled) {
// AnsiConsole.systemUninstall();
// }
// out.close();
// }
//
// public void outError(String text) {
// println("@|red " + text + "|@");
// }
//
// public void outInfo(String text) {
// if (! filterInfo) {
// println("@|cyan " + text + "|@");
// }
// }
// }
// Path: src/main/java/org/jsoftware/tjconsole/command/definition/QuitCommandDefinition.java
import org.jsoftware.tjconsole.TJContext;
import org.jsoftware.tjconsole.command.CommandAction;
import org.jsoftware.tjconsole.console.EndOfInputException;
import org.jsoftware.tjconsole.console.Output;
package org.jsoftware.tjconsole.command.definition;
/**
* Quit command. Quits an application.
*
* @author szalik
*/
public class QuitCommandDefinition extends AbstractCommandDefinition {
public QuitCommandDefinition() {
super("Quit.", "q or quit", "quit", false);
}
@Override
public CommandAction action(String input) {
return new CommandAction() {
@Override | public void doAction(TJContext tjContext, Output output) throws Exception { |
m-szalik/tjconsole | src/main/java/org/jsoftware/tjconsole/command/definition/QuitCommandDefinition.java | // Path: src/main/java/org/jsoftware/tjconsole/TJContext.java
// public class TJContext extends Observable {
// private MBeanServerConnection serverConnection;
// private ObjectName objectName;
// private final Map<String, Object> environment;
// private Object serverURL;
// private int exitCode = 0;
//
// public TJContext() {
// environment = new LinkedHashMap<String, Object>();
// }
//
// public Map<String, Object> getEnvironment() {
// return Collections.unmodifiableMap(environment);
// }
//
// public void setEnvironmentVariable(String key, Object value, boolean check) {
// if (check) {
// if (!environment.containsKey(key)) {
// throw new IllegalArgumentException("Invalid key - " + key);
// }
// Object old = environment.get(key);
// if (!old.getClass().equals(value.getClass())) {
// value = ConvertUtils.convert(value, old.getClass());
// if (!old.getClass().equals(value.getClass())) {
// throw new IllegalArgumentException("Invalid value type - " + value.getClass().getName() + " should be " + old.getClass().getName());
// }
// }
// }
// Object prev = environment.get(key);
// if ((value != null && !value.equals(prev)) || (value == null && prev != null)) {
// setChanged();
// }
// notifyObservers(new UpdateEnvironmentEvent(key, prev, value));
// environment.put(key, value);
// }
//
// public MBeanServerConnection getServer() {
// return serverConnection;
// }
//
// public void setServer(MBeanServerConnection serverConnection, String url) {
// this.serverConnection = serverConnection;
// this.serverURL = url;
// this.objectName = null;
// }
//
// public ObjectName getObjectName() {
// return objectName;
// }
//
// public void setObjectName(ObjectName objectName) {
// this.objectName = objectName;
// }
//
// public boolean isConnected() {
// return serverConnection != null;
// }
//
// public List<MBeanAttributeInfo> getAttributes() throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException {
// if (serverConnection == null || objectName == null) {
// return Collections.emptyList();
// }
// MBeanInfo beanInfo = serverConnection.getMBeanInfo(objectName);
// return Arrays.asList(beanInfo.getAttributes());
// }
//
// public boolean isBeanSelected() {
// return objectName != null;
// }
//
//
// public Object getServerURL() {
// return serverURL;
// }
//
// public void fail(CommandAction action, int code) {
// if (exitCode == 0) {
// exitCode = code;
// }
// }
//
// public int getExitCode() {
// return exitCode;
// }
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/command/CommandAction.java
// public interface CommandAction {
//
// void doAction(TJContext tjContext, Output output) throws Exception;
//
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/console/EndOfInputException.java
// public class EndOfInputException extends Exception {
//
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/console/Output.java
// public class Output implements Closeable {
// private final Pattern ansiRemovePattern = Pattern.compile("(@\\|\\w* )|( ?\\|@)");
// private final PrintStream out;
// private boolean useColors = true, ansiInstalled, filterInfo;
//
// public Output(PrintStream out, boolean useColors) {
// this.out = out;
// setUseColors(useColors);
// }
//
// public void setFilterInfo(boolean filterInfo) {
// this.filterInfo = filterInfo;
// }
//
// public boolean isUseColors() {
// return useColors;
// }
//
//
// public void setUseColors(boolean useColors) {
// this.useColors = useColors;
// if (useColors) {
// AnsiConsole.systemInstall();
// ansiInstalled = true;
// } else {
// AnsiConsole.systemUninstall();
// ansiInstalled = false;
// }
// }
//
//
// public void print(String text) {
// if (useColors) {
// out.print(ansi().render(text));
// } else {
// String s = ansiRemovePattern.matcher(text).replaceAll("");
// out.print(s);
// }
// out.flush();
// }
//
//
// public void println(String text) {
// print(text);
// out.println();
// out.flush();
// }
//
//
// @Override
// public void close() throws IOException {
// if (ansiInstalled) {
// AnsiConsole.systemUninstall();
// }
// out.close();
// }
//
// public void outError(String text) {
// println("@|red " + text + "|@");
// }
//
// public void outInfo(String text) {
// if (! filterInfo) {
// println("@|cyan " + text + "|@");
// }
// }
// }
| import org.jsoftware.tjconsole.TJContext;
import org.jsoftware.tjconsole.command.CommandAction;
import org.jsoftware.tjconsole.console.EndOfInputException;
import org.jsoftware.tjconsole.console.Output; | package org.jsoftware.tjconsole.command.definition;
/**
* Quit command. Quits an application.
*
* @author szalik
*/
public class QuitCommandDefinition extends AbstractCommandDefinition {
public QuitCommandDefinition() {
super("Quit.", "q or quit", "quit", false);
}
@Override
public CommandAction action(String input) {
return new CommandAction() {
@Override
public void doAction(TJContext tjContext, Output output) throws Exception { | // Path: src/main/java/org/jsoftware/tjconsole/TJContext.java
// public class TJContext extends Observable {
// private MBeanServerConnection serverConnection;
// private ObjectName objectName;
// private final Map<String, Object> environment;
// private Object serverURL;
// private int exitCode = 0;
//
// public TJContext() {
// environment = new LinkedHashMap<String, Object>();
// }
//
// public Map<String, Object> getEnvironment() {
// return Collections.unmodifiableMap(environment);
// }
//
// public void setEnvironmentVariable(String key, Object value, boolean check) {
// if (check) {
// if (!environment.containsKey(key)) {
// throw new IllegalArgumentException("Invalid key - " + key);
// }
// Object old = environment.get(key);
// if (!old.getClass().equals(value.getClass())) {
// value = ConvertUtils.convert(value, old.getClass());
// if (!old.getClass().equals(value.getClass())) {
// throw new IllegalArgumentException("Invalid value type - " + value.getClass().getName() + " should be " + old.getClass().getName());
// }
// }
// }
// Object prev = environment.get(key);
// if ((value != null && !value.equals(prev)) || (value == null && prev != null)) {
// setChanged();
// }
// notifyObservers(new UpdateEnvironmentEvent(key, prev, value));
// environment.put(key, value);
// }
//
// public MBeanServerConnection getServer() {
// return serverConnection;
// }
//
// public void setServer(MBeanServerConnection serverConnection, String url) {
// this.serverConnection = serverConnection;
// this.serverURL = url;
// this.objectName = null;
// }
//
// public ObjectName getObjectName() {
// return objectName;
// }
//
// public void setObjectName(ObjectName objectName) {
// this.objectName = objectName;
// }
//
// public boolean isConnected() {
// return serverConnection != null;
// }
//
// public List<MBeanAttributeInfo> getAttributes() throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException {
// if (serverConnection == null || objectName == null) {
// return Collections.emptyList();
// }
// MBeanInfo beanInfo = serverConnection.getMBeanInfo(objectName);
// return Arrays.asList(beanInfo.getAttributes());
// }
//
// public boolean isBeanSelected() {
// return objectName != null;
// }
//
//
// public Object getServerURL() {
// return serverURL;
// }
//
// public void fail(CommandAction action, int code) {
// if (exitCode == 0) {
// exitCode = code;
// }
// }
//
// public int getExitCode() {
// return exitCode;
// }
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/command/CommandAction.java
// public interface CommandAction {
//
// void doAction(TJContext tjContext, Output output) throws Exception;
//
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/console/EndOfInputException.java
// public class EndOfInputException extends Exception {
//
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/console/Output.java
// public class Output implements Closeable {
// private final Pattern ansiRemovePattern = Pattern.compile("(@\\|\\w* )|( ?\\|@)");
// private final PrintStream out;
// private boolean useColors = true, ansiInstalled, filterInfo;
//
// public Output(PrintStream out, boolean useColors) {
// this.out = out;
// setUseColors(useColors);
// }
//
// public void setFilterInfo(boolean filterInfo) {
// this.filterInfo = filterInfo;
// }
//
// public boolean isUseColors() {
// return useColors;
// }
//
//
// public void setUseColors(boolean useColors) {
// this.useColors = useColors;
// if (useColors) {
// AnsiConsole.systemInstall();
// ansiInstalled = true;
// } else {
// AnsiConsole.systemUninstall();
// ansiInstalled = false;
// }
// }
//
//
// public void print(String text) {
// if (useColors) {
// out.print(ansi().render(text));
// } else {
// String s = ansiRemovePattern.matcher(text).replaceAll("");
// out.print(s);
// }
// out.flush();
// }
//
//
// public void println(String text) {
// print(text);
// out.println();
// out.flush();
// }
//
//
// @Override
// public void close() throws IOException {
// if (ansiInstalled) {
// AnsiConsole.systemUninstall();
// }
// out.close();
// }
//
// public void outError(String text) {
// println("@|red " + text + "|@");
// }
//
// public void outInfo(String text) {
// if (! filterInfo) {
// println("@|cyan " + text + "|@");
// }
// }
// }
// Path: src/main/java/org/jsoftware/tjconsole/command/definition/QuitCommandDefinition.java
import org.jsoftware.tjconsole.TJContext;
import org.jsoftware.tjconsole.command.CommandAction;
import org.jsoftware.tjconsole.console.EndOfInputException;
import org.jsoftware.tjconsole.console.Output;
package org.jsoftware.tjconsole.command.definition;
/**
* Quit command. Quits an application.
*
* @author szalik
*/
public class QuitCommandDefinition extends AbstractCommandDefinition {
public QuitCommandDefinition() {
super("Quit.", "q or quit", "quit", false);
}
@Override
public CommandAction action(String input) {
return new CommandAction() {
@Override
public void doAction(TJContext tjContext, Output output) throws Exception { | throw new EndOfInputException(); // it's not good for flow control, but.... |
m-szalik/tjconsole | src/main/java/org/jsoftware/tjconsole/TJContext.java | // Path: src/main/java/org/jsoftware/tjconsole/command/CommandAction.java
// public interface CommandAction {
//
// void doAction(TJContext tjContext, Output output) throws Exception;
//
// }
| import org.apache.commons.beanutils.ConvertUtils;
import org.jsoftware.tjconsole.command.CommandAction;
import javax.management.*;
import java.io.IOException;
import java.util.*; |
public ObjectName getObjectName() {
return objectName;
}
public void setObjectName(ObjectName objectName) {
this.objectName = objectName;
}
public boolean isConnected() {
return serverConnection != null;
}
public List<MBeanAttributeInfo> getAttributes() throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException {
if (serverConnection == null || objectName == null) {
return Collections.emptyList();
}
MBeanInfo beanInfo = serverConnection.getMBeanInfo(objectName);
return Arrays.asList(beanInfo.getAttributes());
}
public boolean isBeanSelected() {
return objectName != null;
}
public Object getServerURL() {
return serverURL;
}
| // Path: src/main/java/org/jsoftware/tjconsole/command/CommandAction.java
// public interface CommandAction {
//
// void doAction(TJContext tjContext, Output output) throws Exception;
//
// }
// Path: src/main/java/org/jsoftware/tjconsole/TJContext.java
import org.apache.commons.beanutils.ConvertUtils;
import org.jsoftware.tjconsole.command.CommandAction;
import javax.management.*;
import java.io.IOException;
import java.util.*;
public ObjectName getObjectName() {
return objectName;
}
public void setObjectName(ObjectName objectName) {
this.objectName = objectName;
}
public boolean isConnected() {
return serverConnection != null;
}
public List<MBeanAttributeInfo> getAttributes() throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException {
if (serverConnection == null || objectName == null) {
return Collections.emptyList();
}
MBeanInfo beanInfo = serverConnection.getMBeanInfo(objectName);
return Arrays.asList(beanInfo.getAttributes());
}
public boolean isBeanSelected() {
return objectName != null;
}
public Object getServerURL() {
return serverURL;
}
| public void fail(CommandAction action, int code) { |
m-szalik/tjconsole | src/main/java/org/jsoftware/tjconsole/command/definition/CommandDefinition.java | // Path: src/main/java/org/jsoftware/tjconsole/TJContext.java
// public class TJContext extends Observable {
// private MBeanServerConnection serverConnection;
// private ObjectName objectName;
// private final Map<String, Object> environment;
// private Object serverURL;
// private int exitCode = 0;
//
// public TJContext() {
// environment = new LinkedHashMap<String, Object>();
// }
//
// public Map<String, Object> getEnvironment() {
// return Collections.unmodifiableMap(environment);
// }
//
// public void setEnvironmentVariable(String key, Object value, boolean check) {
// if (check) {
// if (!environment.containsKey(key)) {
// throw new IllegalArgumentException("Invalid key - " + key);
// }
// Object old = environment.get(key);
// if (!old.getClass().equals(value.getClass())) {
// value = ConvertUtils.convert(value, old.getClass());
// if (!old.getClass().equals(value.getClass())) {
// throw new IllegalArgumentException("Invalid value type - " + value.getClass().getName() + " should be " + old.getClass().getName());
// }
// }
// }
// Object prev = environment.get(key);
// if ((value != null && !value.equals(prev)) || (value == null && prev != null)) {
// setChanged();
// }
// notifyObservers(new UpdateEnvironmentEvent(key, prev, value));
// environment.put(key, value);
// }
//
// public MBeanServerConnection getServer() {
// return serverConnection;
// }
//
// public void setServer(MBeanServerConnection serverConnection, String url) {
// this.serverConnection = serverConnection;
// this.serverURL = url;
// this.objectName = null;
// }
//
// public ObjectName getObjectName() {
// return objectName;
// }
//
// public void setObjectName(ObjectName objectName) {
// this.objectName = objectName;
// }
//
// public boolean isConnected() {
// return serverConnection != null;
// }
//
// public List<MBeanAttributeInfo> getAttributes() throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException {
// if (serverConnection == null || objectName == null) {
// return Collections.emptyList();
// }
// MBeanInfo beanInfo = serverConnection.getMBeanInfo(objectName);
// return Arrays.asList(beanInfo.getAttributes());
// }
//
// public boolean isBeanSelected() {
// return objectName != null;
// }
//
//
// public Object getServerURL() {
// return serverURL;
// }
//
// public void fail(CommandAction action, int code) {
// if (exitCode == 0) {
// exitCode = code;
// }
// }
//
// public int getExitCode() {
// return exitCode;
// }
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/command/CmdDescription.java
// public class CmdDescription implements Serializable {
// private static final long serialVersionUID = 974727180626249506L;
// private final String description;
// private final String full;
// private final String prefix;
// private final boolean requiresBean;
//
// public CmdDescription(String description, String full, String prefix, boolean requiresBean) {
// super();
// this.description = description;
// this.full = full;
// this.prefix = prefix;
// this.requiresBean = requiresBean;
// }
//
// public String getDescription() {
// return description;
// }
//
// public String getFull() {
// return full;
// }
//
// public String getPrefix() {
// return prefix;
// }
//
// public boolean canBeUsed(TJContext tjContext) {
// return !requiresBean || tjContext.isBeanSelected();
// }
//
//
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/command/CommandAction.java
// public interface CommandAction {
//
// void doAction(TJContext tjContext, Output output) throws Exception;
//
// }
| import jline.console.completer.Completer;
import org.jsoftware.tjconsole.TJContext;
import org.jsoftware.tjconsole.command.CmdDescription;
import org.jsoftware.tjconsole.command.CommandAction; | package org.jsoftware.tjconsole.command.definition;
/**
* Command definition
*
* @author szalik
*/
public interface CommandDefinition {
/**
* If input matches the command
*
* @param input input to check
* @return true if matched, otherwise false
*/
boolean matches(String input);
/**
* Create command to execute
*
* @param input command input
*/ | // Path: src/main/java/org/jsoftware/tjconsole/TJContext.java
// public class TJContext extends Observable {
// private MBeanServerConnection serverConnection;
// private ObjectName objectName;
// private final Map<String, Object> environment;
// private Object serverURL;
// private int exitCode = 0;
//
// public TJContext() {
// environment = new LinkedHashMap<String, Object>();
// }
//
// public Map<String, Object> getEnvironment() {
// return Collections.unmodifiableMap(environment);
// }
//
// public void setEnvironmentVariable(String key, Object value, boolean check) {
// if (check) {
// if (!environment.containsKey(key)) {
// throw new IllegalArgumentException("Invalid key - " + key);
// }
// Object old = environment.get(key);
// if (!old.getClass().equals(value.getClass())) {
// value = ConvertUtils.convert(value, old.getClass());
// if (!old.getClass().equals(value.getClass())) {
// throw new IllegalArgumentException("Invalid value type - " + value.getClass().getName() + " should be " + old.getClass().getName());
// }
// }
// }
// Object prev = environment.get(key);
// if ((value != null && !value.equals(prev)) || (value == null && prev != null)) {
// setChanged();
// }
// notifyObservers(new UpdateEnvironmentEvent(key, prev, value));
// environment.put(key, value);
// }
//
// public MBeanServerConnection getServer() {
// return serverConnection;
// }
//
// public void setServer(MBeanServerConnection serverConnection, String url) {
// this.serverConnection = serverConnection;
// this.serverURL = url;
// this.objectName = null;
// }
//
// public ObjectName getObjectName() {
// return objectName;
// }
//
// public void setObjectName(ObjectName objectName) {
// this.objectName = objectName;
// }
//
// public boolean isConnected() {
// return serverConnection != null;
// }
//
// public List<MBeanAttributeInfo> getAttributes() throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException {
// if (serverConnection == null || objectName == null) {
// return Collections.emptyList();
// }
// MBeanInfo beanInfo = serverConnection.getMBeanInfo(objectName);
// return Arrays.asList(beanInfo.getAttributes());
// }
//
// public boolean isBeanSelected() {
// return objectName != null;
// }
//
//
// public Object getServerURL() {
// return serverURL;
// }
//
// public void fail(CommandAction action, int code) {
// if (exitCode == 0) {
// exitCode = code;
// }
// }
//
// public int getExitCode() {
// return exitCode;
// }
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/command/CmdDescription.java
// public class CmdDescription implements Serializable {
// private static final long serialVersionUID = 974727180626249506L;
// private final String description;
// private final String full;
// private final String prefix;
// private final boolean requiresBean;
//
// public CmdDescription(String description, String full, String prefix, boolean requiresBean) {
// super();
// this.description = description;
// this.full = full;
// this.prefix = prefix;
// this.requiresBean = requiresBean;
// }
//
// public String getDescription() {
// return description;
// }
//
// public String getFull() {
// return full;
// }
//
// public String getPrefix() {
// return prefix;
// }
//
// public boolean canBeUsed(TJContext tjContext) {
// return !requiresBean || tjContext.isBeanSelected();
// }
//
//
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/command/CommandAction.java
// public interface CommandAction {
//
// void doAction(TJContext tjContext, Output output) throws Exception;
//
// }
// Path: src/main/java/org/jsoftware/tjconsole/command/definition/CommandDefinition.java
import jline.console.completer.Completer;
import org.jsoftware.tjconsole.TJContext;
import org.jsoftware.tjconsole.command.CmdDescription;
import org.jsoftware.tjconsole.command.CommandAction;
package org.jsoftware.tjconsole.command.definition;
/**
* Command definition
*
* @author szalik
*/
public interface CommandDefinition {
/**
* If input matches the command
*
* @param input input to check
* @return true if matched, otherwise false
*/
boolean matches(String input);
/**
* Create command to execute
*
* @param input command input
*/ | CommandAction action(String input); |
m-szalik/tjconsole | src/main/java/org/jsoftware/tjconsole/command/definition/CommandDefinition.java | // Path: src/main/java/org/jsoftware/tjconsole/TJContext.java
// public class TJContext extends Observable {
// private MBeanServerConnection serverConnection;
// private ObjectName objectName;
// private final Map<String, Object> environment;
// private Object serverURL;
// private int exitCode = 0;
//
// public TJContext() {
// environment = new LinkedHashMap<String, Object>();
// }
//
// public Map<String, Object> getEnvironment() {
// return Collections.unmodifiableMap(environment);
// }
//
// public void setEnvironmentVariable(String key, Object value, boolean check) {
// if (check) {
// if (!environment.containsKey(key)) {
// throw new IllegalArgumentException("Invalid key - " + key);
// }
// Object old = environment.get(key);
// if (!old.getClass().equals(value.getClass())) {
// value = ConvertUtils.convert(value, old.getClass());
// if (!old.getClass().equals(value.getClass())) {
// throw new IllegalArgumentException("Invalid value type - " + value.getClass().getName() + " should be " + old.getClass().getName());
// }
// }
// }
// Object prev = environment.get(key);
// if ((value != null && !value.equals(prev)) || (value == null && prev != null)) {
// setChanged();
// }
// notifyObservers(new UpdateEnvironmentEvent(key, prev, value));
// environment.put(key, value);
// }
//
// public MBeanServerConnection getServer() {
// return serverConnection;
// }
//
// public void setServer(MBeanServerConnection serverConnection, String url) {
// this.serverConnection = serverConnection;
// this.serverURL = url;
// this.objectName = null;
// }
//
// public ObjectName getObjectName() {
// return objectName;
// }
//
// public void setObjectName(ObjectName objectName) {
// this.objectName = objectName;
// }
//
// public boolean isConnected() {
// return serverConnection != null;
// }
//
// public List<MBeanAttributeInfo> getAttributes() throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException {
// if (serverConnection == null || objectName == null) {
// return Collections.emptyList();
// }
// MBeanInfo beanInfo = serverConnection.getMBeanInfo(objectName);
// return Arrays.asList(beanInfo.getAttributes());
// }
//
// public boolean isBeanSelected() {
// return objectName != null;
// }
//
//
// public Object getServerURL() {
// return serverURL;
// }
//
// public void fail(CommandAction action, int code) {
// if (exitCode == 0) {
// exitCode = code;
// }
// }
//
// public int getExitCode() {
// return exitCode;
// }
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/command/CmdDescription.java
// public class CmdDescription implements Serializable {
// private static final long serialVersionUID = 974727180626249506L;
// private final String description;
// private final String full;
// private final String prefix;
// private final boolean requiresBean;
//
// public CmdDescription(String description, String full, String prefix, boolean requiresBean) {
// super();
// this.description = description;
// this.full = full;
// this.prefix = prefix;
// this.requiresBean = requiresBean;
// }
//
// public String getDescription() {
// return description;
// }
//
// public String getFull() {
// return full;
// }
//
// public String getPrefix() {
// return prefix;
// }
//
// public boolean canBeUsed(TJContext tjContext) {
// return !requiresBean || tjContext.isBeanSelected();
// }
//
//
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/command/CommandAction.java
// public interface CommandAction {
//
// void doAction(TJContext tjContext, Output output) throws Exception;
//
// }
| import jline.console.completer.Completer;
import org.jsoftware.tjconsole.TJContext;
import org.jsoftware.tjconsole.command.CmdDescription;
import org.jsoftware.tjconsole.command.CommandAction; | package org.jsoftware.tjconsole.command.definition;
/**
* Command definition
*
* @author szalik
*/
public interface CommandDefinition {
/**
* If input matches the command
*
* @param input input to check
* @return true if matched, otherwise false
*/
boolean matches(String input);
/**
* Create command to execute
*
* @param input command input
*/
CommandAction action(String input);
/**
* @return get help description for the command
*/ | // Path: src/main/java/org/jsoftware/tjconsole/TJContext.java
// public class TJContext extends Observable {
// private MBeanServerConnection serverConnection;
// private ObjectName objectName;
// private final Map<String, Object> environment;
// private Object serverURL;
// private int exitCode = 0;
//
// public TJContext() {
// environment = new LinkedHashMap<String, Object>();
// }
//
// public Map<String, Object> getEnvironment() {
// return Collections.unmodifiableMap(environment);
// }
//
// public void setEnvironmentVariable(String key, Object value, boolean check) {
// if (check) {
// if (!environment.containsKey(key)) {
// throw new IllegalArgumentException("Invalid key - " + key);
// }
// Object old = environment.get(key);
// if (!old.getClass().equals(value.getClass())) {
// value = ConvertUtils.convert(value, old.getClass());
// if (!old.getClass().equals(value.getClass())) {
// throw new IllegalArgumentException("Invalid value type - " + value.getClass().getName() + " should be " + old.getClass().getName());
// }
// }
// }
// Object prev = environment.get(key);
// if ((value != null && !value.equals(prev)) || (value == null && prev != null)) {
// setChanged();
// }
// notifyObservers(new UpdateEnvironmentEvent(key, prev, value));
// environment.put(key, value);
// }
//
// public MBeanServerConnection getServer() {
// return serverConnection;
// }
//
// public void setServer(MBeanServerConnection serverConnection, String url) {
// this.serverConnection = serverConnection;
// this.serverURL = url;
// this.objectName = null;
// }
//
// public ObjectName getObjectName() {
// return objectName;
// }
//
// public void setObjectName(ObjectName objectName) {
// this.objectName = objectName;
// }
//
// public boolean isConnected() {
// return serverConnection != null;
// }
//
// public List<MBeanAttributeInfo> getAttributes() throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException {
// if (serverConnection == null || objectName == null) {
// return Collections.emptyList();
// }
// MBeanInfo beanInfo = serverConnection.getMBeanInfo(objectName);
// return Arrays.asList(beanInfo.getAttributes());
// }
//
// public boolean isBeanSelected() {
// return objectName != null;
// }
//
//
// public Object getServerURL() {
// return serverURL;
// }
//
// public void fail(CommandAction action, int code) {
// if (exitCode == 0) {
// exitCode = code;
// }
// }
//
// public int getExitCode() {
// return exitCode;
// }
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/command/CmdDescription.java
// public class CmdDescription implements Serializable {
// private static final long serialVersionUID = 974727180626249506L;
// private final String description;
// private final String full;
// private final String prefix;
// private final boolean requiresBean;
//
// public CmdDescription(String description, String full, String prefix, boolean requiresBean) {
// super();
// this.description = description;
// this.full = full;
// this.prefix = prefix;
// this.requiresBean = requiresBean;
// }
//
// public String getDescription() {
// return description;
// }
//
// public String getFull() {
// return full;
// }
//
// public String getPrefix() {
// return prefix;
// }
//
// public boolean canBeUsed(TJContext tjContext) {
// return !requiresBean || tjContext.isBeanSelected();
// }
//
//
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/command/CommandAction.java
// public interface CommandAction {
//
// void doAction(TJContext tjContext, Output output) throws Exception;
//
// }
// Path: src/main/java/org/jsoftware/tjconsole/command/definition/CommandDefinition.java
import jline.console.completer.Completer;
import org.jsoftware.tjconsole.TJContext;
import org.jsoftware.tjconsole.command.CmdDescription;
import org.jsoftware.tjconsole.command.CommandAction;
package org.jsoftware.tjconsole.command.definition;
/**
* Command definition
*
* @author szalik
*/
public interface CommandDefinition {
/**
* If input matches the command
*
* @param input input to check
* @return true if matched, otherwise false
*/
boolean matches(String input);
/**
* Create command to execute
*
* @param input command input
*/
CommandAction action(String input);
/**
* @return get help description for the command
*/ | CmdDescription getDescription(); |
m-szalik/tjconsole | src/main/java/org/jsoftware/tjconsole/command/definition/CommandDefinition.java | // Path: src/main/java/org/jsoftware/tjconsole/TJContext.java
// public class TJContext extends Observable {
// private MBeanServerConnection serverConnection;
// private ObjectName objectName;
// private final Map<String, Object> environment;
// private Object serverURL;
// private int exitCode = 0;
//
// public TJContext() {
// environment = new LinkedHashMap<String, Object>();
// }
//
// public Map<String, Object> getEnvironment() {
// return Collections.unmodifiableMap(environment);
// }
//
// public void setEnvironmentVariable(String key, Object value, boolean check) {
// if (check) {
// if (!environment.containsKey(key)) {
// throw new IllegalArgumentException("Invalid key - " + key);
// }
// Object old = environment.get(key);
// if (!old.getClass().equals(value.getClass())) {
// value = ConvertUtils.convert(value, old.getClass());
// if (!old.getClass().equals(value.getClass())) {
// throw new IllegalArgumentException("Invalid value type - " + value.getClass().getName() + " should be " + old.getClass().getName());
// }
// }
// }
// Object prev = environment.get(key);
// if ((value != null && !value.equals(prev)) || (value == null && prev != null)) {
// setChanged();
// }
// notifyObservers(new UpdateEnvironmentEvent(key, prev, value));
// environment.put(key, value);
// }
//
// public MBeanServerConnection getServer() {
// return serverConnection;
// }
//
// public void setServer(MBeanServerConnection serverConnection, String url) {
// this.serverConnection = serverConnection;
// this.serverURL = url;
// this.objectName = null;
// }
//
// public ObjectName getObjectName() {
// return objectName;
// }
//
// public void setObjectName(ObjectName objectName) {
// this.objectName = objectName;
// }
//
// public boolean isConnected() {
// return serverConnection != null;
// }
//
// public List<MBeanAttributeInfo> getAttributes() throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException {
// if (serverConnection == null || objectName == null) {
// return Collections.emptyList();
// }
// MBeanInfo beanInfo = serverConnection.getMBeanInfo(objectName);
// return Arrays.asList(beanInfo.getAttributes());
// }
//
// public boolean isBeanSelected() {
// return objectName != null;
// }
//
//
// public Object getServerURL() {
// return serverURL;
// }
//
// public void fail(CommandAction action, int code) {
// if (exitCode == 0) {
// exitCode = code;
// }
// }
//
// public int getExitCode() {
// return exitCode;
// }
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/command/CmdDescription.java
// public class CmdDescription implements Serializable {
// private static final long serialVersionUID = 974727180626249506L;
// private final String description;
// private final String full;
// private final String prefix;
// private final boolean requiresBean;
//
// public CmdDescription(String description, String full, String prefix, boolean requiresBean) {
// super();
// this.description = description;
// this.full = full;
// this.prefix = prefix;
// this.requiresBean = requiresBean;
// }
//
// public String getDescription() {
// return description;
// }
//
// public String getFull() {
// return full;
// }
//
// public String getPrefix() {
// return prefix;
// }
//
// public boolean canBeUsed(TJContext tjContext) {
// return !requiresBean || tjContext.isBeanSelected();
// }
//
//
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/command/CommandAction.java
// public interface CommandAction {
//
// void doAction(TJContext tjContext, Output output) throws Exception;
//
// }
| import jline.console.completer.Completer;
import org.jsoftware.tjconsole.TJContext;
import org.jsoftware.tjconsole.command.CmdDescription;
import org.jsoftware.tjconsole.command.CommandAction; | package org.jsoftware.tjconsole.command.definition;
/**
* Command definition
*
* @author szalik
*/
public interface CommandDefinition {
/**
* If input matches the command
*
* @param input input to check
* @return true if matched, otherwise false
*/
boolean matches(String input);
/**
* Create command to execute
*
* @param input command input
*/
CommandAction action(String input);
/**
* @return get help description for the command
*/
CmdDescription getDescription();
/**
* @return can be null if completion is not supported by this command
*/ | // Path: src/main/java/org/jsoftware/tjconsole/TJContext.java
// public class TJContext extends Observable {
// private MBeanServerConnection serverConnection;
// private ObjectName objectName;
// private final Map<String, Object> environment;
// private Object serverURL;
// private int exitCode = 0;
//
// public TJContext() {
// environment = new LinkedHashMap<String, Object>();
// }
//
// public Map<String, Object> getEnvironment() {
// return Collections.unmodifiableMap(environment);
// }
//
// public void setEnvironmentVariable(String key, Object value, boolean check) {
// if (check) {
// if (!environment.containsKey(key)) {
// throw new IllegalArgumentException("Invalid key - " + key);
// }
// Object old = environment.get(key);
// if (!old.getClass().equals(value.getClass())) {
// value = ConvertUtils.convert(value, old.getClass());
// if (!old.getClass().equals(value.getClass())) {
// throw new IllegalArgumentException("Invalid value type - " + value.getClass().getName() + " should be " + old.getClass().getName());
// }
// }
// }
// Object prev = environment.get(key);
// if ((value != null && !value.equals(prev)) || (value == null && prev != null)) {
// setChanged();
// }
// notifyObservers(new UpdateEnvironmentEvent(key, prev, value));
// environment.put(key, value);
// }
//
// public MBeanServerConnection getServer() {
// return serverConnection;
// }
//
// public void setServer(MBeanServerConnection serverConnection, String url) {
// this.serverConnection = serverConnection;
// this.serverURL = url;
// this.objectName = null;
// }
//
// public ObjectName getObjectName() {
// return objectName;
// }
//
// public void setObjectName(ObjectName objectName) {
// this.objectName = objectName;
// }
//
// public boolean isConnected() {
// return serverConnection != null;
// }
//
// public List<MBeanAttributeInfo> getAttributes() throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException {
// if (serverConnection == null || objectName == null) {
// return Collections.emptyList();
// }
// MBeanInfo beanInfo = serverConnection.getMBeanInfo(objectName);
// return Arrays.asList(beanInfo.getAttributes());
// }
//
// public boolean isBeanSelected() {
// return objectName != null;
// }
//
//
// public Object getServerURL() {
// return serverURL;
// }
//
// public void fail(CommandAction action, int code) {
// if (exitCode == 0) {
// exitCode = code;
// }
// }
//
// public int getExitCode() {
// return exitCode;
// }
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/command/CmdDescription.java
// public class CmdDescription implements Serializable {
// private static final long serialVersionUID = 974727180626249506L;
// private final String description;
// private final String full;
// private final String prefix;
// private final boolean requiresBean;
//
// public CmdDescription(String description, String full, String prefix, boolean requiresBean) {
// super();
// this.description = description;
// this.full = full;
// this.prefix = prefix;
// this.requiresBean = requiresBean;
// }
//
// public String getDescription() {
// return description;
// }
//
// public String getFull() {
// return full;
// }
//
// public String getPrefix() {
// return prefix;
// }
//
// public boolean canBeUsed(TJContext tjContext) {
// return !requiresBean || tjContext.isBeanSelected();
// }
//
//
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/command/CommandAction.java
// public interface CommandAction {
//
// void doAction(TJContext tjContext, Output output) throws Exception;
//
// }
// Path: src/main/java/org/jsoftware/tjconsole/command/definition/CommandDefinition.java
import jline.console.completer.Completer;
import org.jsoftware.tjconsole.TJContext;
import org.jsoftware.tjconsole.command.CmdDescription;
import org.jsoftware.tjconsole.command.CommandAction;
package org.jsoftware.tjconsole.command.definition;
/**
* Command definition
*
* @author szalik
*/
public interface CommandDefinition {
/**
* If input matches the command
*
* @param input input to check
* @return true if matched, otherwise false
*/
boolean matches(String input);
/**
* Create command to execute
*
* @param input command input
*/
CommandAction action(String input);
/**
* @return get help description for the command
*/
CmdDescription getDescription();
/**
* @return can be null if completion is not supported by this command
*/ | Completer getCompleter(TJContext tjContext); |
m-szalik/tjconsole | src/main/java/org/jsoftware/tjconsole/command/definition/SetAttributeCommandDefinition.java | // Path: src/main/java/org/jsoftware/tjconsole/TJContext.java
// public class TJContext extends Observable {
// private MBeanServerConnection serverConnection;
// private ObjectName objectName;
// private final Map<String, Object> environment;
// private Object serverURL;
// private int exitCode = 0;
//
// public TJContext() {
// environment = new LinkedHashMap<String, Object>();
// }
//
// public Map<String, Object> getEnvironment() {
// return Collections.unmodifiableMap(environment);
// }
//
// public void setEnvironmentVariable(String key, Object value, boolean check) {
// if (check) {
// if (!environment.containsKey(key)) {
// throw new IllegalArgumentException("Invalid key - " + key);
// }
// Object old = environment.get(key);
// if (!old.getClass().equals(value.getClass())) {
// value = ConvertUtils.convert(value, old.getClass());
// if (!old.getClass().equals(value.getClass())) {
// throw new IllegalArgumentException("Invalid value type - " + value.getClass().getName() + " should be " + old.getClass().getName());
// }
// }
// }
// Object prev = environment.get(key);
// if ((value != null && !value.equals(prev)) || (value == null && prev != null)) {
// setChanged();
// }
// notifyObservers(new UpdateEnvironmentEvent(key, prev, value));
// environment.put(key, value);
// }
//
// public MBeanServerConnection getServer() {
// return serverConnection;
// }
//
// public void setServer(MBeanServerConnection serverConnection, String url) {
// this.serverConnection = serverConnection;
// this.serverURL = url;
// this.objectName = null;
// }
//
// public ObjectName getObjectName() {
// return objectName;
// }
//
// public void setObjectName(ObjectName objectName) {
// this.objectName = objectName;
// }
//
// public boolean isConnected() {
// return serverConnection != null;
// }
//
// public List<MBeanAttributeInfo> getAttributes() throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException {
// if (serverConnection == null || objectName == null) {
// return Collections.emptyList();
// }
// MBeanInfo beanInfo = serverConnection.getMBeanInfo(objectName);
// return Arrays.asList(beanInfo.getAttributes());
// }
//
// public boolean isBeanSelected() {
// return objectName != null;
// }
//
//
// public Object getServerURL() {
// return serverURL;
// }
//
// public void fail(CommandAction action, int code) {
// if (exitCode == 0) {
// exitCode = code;
// }
// }
//
// public int getExitCode() {
// return exitCode;
// }
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/command/CommandAction.java
// public interface CommandAction {
//
// void doAction(TJContext tjContext, Output output) throws Exception;
//
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/console/Output.java
// public class Output implements Closeable {
// private final Pattern ansiRemovePattern = Pattern.compile("(@\\|\\w* )|( ?\\|@)");
// private final PrintStream out;
// private boolean useColors = true, ansiInstalled, filterInfo;
//
// public Output(PrintStream out, boolean useColors) {
// this.out = out;
// setUseColors(useColors);
// }
//
// public void setFilterInfo(boolean filterInfo) {
// this.filterInfo = filterInfo;
// }
//
// public boolean isUseColors() {
// return useColors;
// }
//
//
// public void setUseColors(boolean useColors) {
// this.useColors = useColors;
// if (useColors) {
// AnsiConsole.systemInstall();
// ansiInstalled = true;
// } else {
// AnsiConsole.systemUninstall();
// ansiInstalled = false;
// }
// }
//
//
// public void print(String text) {
// if (useColors) {
// out.print(ansi().render(text));
// } else {
// String s = ansiRemovePattern.matcher(text).replaceAll("");
// out.print(s);
// }
// out.flush();
// }
//
//
// public void println(String text) {
// print(text);
// out.println();
// out.flush();
// }
//
//
// @Override
// public void close() throws IOException {
// if (ansiInstalled) {
// AnsiConsole.systemUninstall();
// }
// out.close();
// }
//
// public void outError(String text) {
// println("@|red " + text + "|@");
// }
//
// public void outInfo(String text) {
// if (! filterInfo) {
// println("@|cyan " + text + "|@");
// }
// }
// }
| import jline.console.completer.Completer;
import org.jsoftware.tjconsole.TJContext;
import org.jsoftware.tjconsole.command.CommandAction;
import org.jsoftware.tjconsole.console.Output;
import javax.management.Attribute;
import javax.management.MBeanAttributeInfo; | package org.jsoftware.tjconsole.command.definition;
/**
* Operation to set mxBean attribute value
*
* @author szalik
*/
public class SetAttributeCommandDefinition extends AbstractCommandDefinition {
public SetAttributeCommandDefinition() {
super("Set attribute value.", "set <attributeName>=<newValue>", "set", true);
}
@Override | // Path: src/main/java/org/jsoftware/tjconsole/TJContext.java
// public class TJContext extends Observable {
// private MBeanServerConnection serverConnection;
// private ObjectName objectName;
// private final Map<String, Object> environment;
// private Object serverURL;
// private int exitCode = 0;
//
// public TJContext() {
// environment = new LinkedHashMap<String, Object>();
// }
//
// public Map<String, Object> getEnvironment() {
// return Collections.unmodifiableMap(environment);
// }
//
// public void setEnvironmentVariable(String key, Object value, boolean check) {
// if (check) {
// if (!environment.containsKey(key)) {
// throw new IllegalArgumentException("Invalid key - " + key);
// }
// Object old = environment.get(key);
// if (!old.getClass().equals(value.getClass())) {
// value = ConvertUtils.convert(value, old.getClass());
// if (!old.getClass().equals(value.getClass())) {
// throw new IllegalArgumentException("Invalid value type - " + value.getClass().getName() + " should be " + old.getClass().getName());
// }
// }
// }
// Object prev = environment.get(key);
// if ((value != null && !value.equals(prev)) || (value == null && prev != null)) {
// setChanged();
// }
// notifyObservers(new UpdateEnvironmentEvent(key, prev, value));
// environment.put(key, value);
// }
//
// public MBeanServerConnection getServer() {
// return serverConnection;
// }
//
// public void setServer(MBeanServerConnection serverConnection, String url) {
// this.serverConnection = serverConnection;
// this.serverURL = url;
// this.objectName = null;
// }
//
// public ObjectName getObjectName() {
// return objectName;
// }
//
// public void setObjectName(ObjectName objectName) {
// this.objectName = objectName;
// }
//
// public boolean isConnected() {
// return serverConnection != null;
// }
//
// public List<MBeanAttributeInfo> getAttributes() throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException {
// if (serverConnection == null || objectName == null) {
// return Collections.emptyList();
// }
// MBeanInfo beanInfo = serverConnection.getMBeanInfo(objectName);
// return Arrays.asList(beanInfo.getAttributes());
// }
//
// public boolean isBeanSelected() {
// return objectName != null;
// }
//
//
// public Object getServerURL() {
// return serverURL;
// }
//
// public void fail(CommandAction action, int code) {
// if (exitCode == 0) {
// exitCode = code;
// }
// }
//
// public int getExitCode() {
// return exitCode;
// }
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/command/CommandAction.java
// public interface CommandAction {
//
// void doAction(TJContext tjContext, Output output) throws Exception;
//
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/console/Output.java
// public class Output implements Closeable {
// private final Pattern ansiRemovePattern = Pattern.compile("(@\\|\\w* )|( ?\\|@)");
// private final PrintStream out;
// private boolean useColors = true, ansiInstalled, filterInfo;
//
// public Output(PrintStream out, boolean useColors) {
// this.out = out;
// setUseColors(useColors);
// }
//
// public void setFilterInfo(boolean filterInfo) {
// this.filterInfo = filterInfo;
// }
//
// public boolean isUseColors() {
// return useColors;
// }
//
//
// public void setUseColors(boolean useColors) {
// this.useColors = useColors;
// if (useColors) {
// AnsiConsole.systemInstall();
// ansiInstalled = true;
// } else {
// AnsiConsole.systemUninstall();
// ansiInstalled = false;
// }
// }
//
//
// public void print(String text) {
// if (useColors) {
// out.print(ansi().render(text));
// } else {
// String s = ansiRemovePattern.matcher(text).replaceAll("");
// out.print(s);
// }
// out.flush();
// }
//
//
// public void println(String text) {
// print(text);
// out.println();
// out.flush();
// }
//
//
// @Override
// public void close() throws IOException {
// if (ansiInstalled) {
// AnsiConsole.systemUninstall();
// }
// out.close();
// }
//
// public void outError(String text) {
// println("@|red " + text + "|@");
// }
//
// public void outInfo(String text) {
// if (! filterInfo) {
// println("@|cyan " + text + "|@");
// }
// }
// }
// Path: src/main/java/org/jsoftware/tjconsole/command/definition/SetAttributeCommandDefinition.java
import jline.console.completer.Completer;
import org.jsoftware.tjconsole.TJContext;
import org.jsoftware.tjconsole.command.CommandAction;
import org.jsoftware.tjconsole.console.Output;
import javax.management.Attribute;
import javax.management.MBeanAttributeInfo;
package org.jsoftware.tjconsole.command.definition;
/**
* Operation to set mxBean attribute value
*
* @author szalik
*/
public class SetAttributeCommandDefinition extends AbstractCommandDefinition {
public SetAttributeCommandDefinition() {
super("Set attribute value.", "set <attributeName>=<newValue>", "set", true);
}
@Override | public CommandAction action(String input) { |
m-szalik/tjconsole | src/main/java/org/jsoftware/tjconsole/command/definition/SetAttributeCommandDefinition.java | // Path: src/main/java/org/jsoftware/tjconsole/TJContext.java
// public class TJContext extends Observable {
// private MBeanServerConnection serverConnection;
// private ObjectName objectName;
// private final Map<String, Object> environment;
// private Object serverURL;
// private int exitCode = 0;
//
// public TJContext() {
// environment = new LinkedHashMap<String, Object>();
// }
//
// public Map<String, Object> getEnvironment() {
// return Collections.unmodifiableMap(environment);
// }
//
// public void setEnvironmentVariable(String key, Object value, boolean check) {
// if (check) {
// if (!environment.containsKey(key)) {
// throw new IllegalArgumentException("Invalid key - " + key);
// }
// Object old = environment.get(key);
// if (!old.getClass().equals(value.getClass())) {
// value = ConvertUtils.convert(value, old.getClass());
// if (!old.getClass().equals(value.getClass())) {
// throw new IllegalArgumentException("Invalid value type - " + value.getClass().getName() + " should be " + old.getClass().getName());
// }
// }
// }
// Object prev = environment.get(key);
// if ((value != null && !value.equals(prev)) || (value == null && prev != null)) {
// setChanged();
// }
// notifyObservers(new UpdateEnvironmentEvent(key, prev, value));
// environment.put(key, value);
// }
//
// public MBeanServerConnection getServer() {
// return serverConnection;
// }
//
// public void setServer(MBeanServerConnection serverConnection, String url) {
// this.serverConnection = serverConnection;
// this.serverURL = url;
// this.objectName = null;
// }
//
// public ObjectName getObjectName() {
// return objectName;
// }
//
// public void setObjectName(ObjectName objectName) {
// this.objectName = objectName;
// }
//
// public boolean isConnected() {
// return serverConnection != null;
// }
//
// public List<MBeanAttributeInfo> getAttributes() throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException {
// if (serverConnection == null || objectName == null) {
// return Collections.emptyList();
// }
// MBeanInfo beanInfo = serverConnection.getMBeanInfo(objectName);
// return Arrays.asList(beanInfo.getAttributes());
// }
//
// public boolean isBeanSelected() {
// return objectName != null;
// }
//
//
// public Object getServerURL() {
// return serverURL;
// }
//
// public void fail(CommandAction action, int code) {
// if (exitCode == 0) {
// exitCode = code;
// }
// }
//
// public int getExitCode() {
// return exitCode;
// }
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/command/CommandAction.java
// public interface CommandAction {
//
// void doAction(TJContext tjContext, Output output) throws Exception;
//
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/console/Output.java
// public class Output implements Closeable {
// private final Pattern ansiRemovePattern = Pattern.compile("(@\\|\\w* )|( ?\\|@)");
// private final PrintStream out;
// private boolean useColors = true, ansiInstalled, filterInfo;
//
// public Output(PrintStream out, boolean useColors) {
// this.out = out;
// setUseColors(useColors);
// }
//
// public void setFilterInfo(boolean filterInfo) {
// this.filterInfo = filterInfo;
// }
//
// public boolean isUseColors() {
// return useColors;
// }
//
//
// public void setUseColors(boolean useColors) {
// this.useColors = useColors;
// if (useColors) {
// AnsiConsole.systemInstall();
// ansiInstalled = true;
// } else {
// AnsiConsole.systemUninstall();
// ansiInstalled = false;
// }
// }
//
//
// public void print(String text) {
// if (useColors) {
// out.print(ansi().render(text));
// } else {
// String s = ansiRemovePattern.matcher(text).replaceAll("");
// out.print(s);
// }
// out.flush();
// }
//
//
// public void println(String text) {
// print(text);
// out.println();
// out.flush();
// }
//
//
// @Override
// public void close() throws IOException {
// if (ansiInstalled) {
// AnsiConsole.systemUninstall();
// }
// out.close();
// }
//
// public void outError(String text) {
// println("@|red " + text + "|@");
// }
//
// public void outInfo(String text) {
// if (! filterInfo) {
// println("@|cyan " + text + "|@");
// }
// }
// }
| import jline.console.completer.Completer;
import org.jsoftware.tjconsole.TJContext;
import org.jsoftware.tjconsole.command.CommandAction;
import org.jsoftware.tjconsole.console.Output;
import javax.management.Attribute;
import javax.management.MBeanAttributeInfo; | package org.jsoftware.tjconsole.command.definition;
/**
* Operation to set mxBean attribute value
*
* @author szalik
*/
public class SetAttributeCommandDefinition extends AbstractCommandDefinition {
public SetAttributeCommandDefinition() {
super("Set attribute value.", "set <attributeName>=<newValue>", "set", true);
}
@Override
public CommandAction action(String input) {
String[] data = input.substring(prefix.length()).trim().split("=", 2);
final String attribute = data[0].trim();
final String valueStr = data[1].trim();
return new CommandAction() {
@Override | // Path: src/main/java/org/jsoftware/tjconsole/TJContext.java
// public class TJContext extends Observable {
// private MBeanServerConnection serverConnection;
// private ObjectName objectName;
// private final Map<String, Object> environment;
// private Object serverURL;
// private int exitCode = 0;
//
// public TJContext() {
// environment = new LinkedHashMap<String, Object>();
// }
//
// public Map<String, Object> getEnvironment() {
// return Collections.unmodifiableMap(environment);
// }
//
// public void setEnvironmentVariable(String key, Object value, boolean check) {
// if (check) {
// if (!environment.containsKey(key)) {
// throw new IllegalArgumentException("Invalid key - " + key);
// }
// Object old = environment.get(key);
// if (!old.getClass().equals(value.getClass())) {
// value = ConvertUtils.convert(value, old.getClass());
// if (!old.getClass().equals(value.getClass())) {
// throw new IllegalArgumentException("Invalid value type - " + value.getClass().getName() + " should be " + old.getClass().getName());
// }
// }
// }
// Object prev = environment.get(key);
// if ((value != null && !value.equals(prev)) || (value == null && prev != null)) {
// setChanged();
// }
// notifyObservers(new UpdateEnvironmentEvent(key, prev, value));
// environment.put(key, value);
// }
//
// public MBeanServerConnection getServer() {
// return serverConnection;
// }
//
// public void setServer(MBeanServerConnection serverConnection, String url) {
// this.serverConnection = serverConnection;
// this.serverURL = url;
// this.objectName = null;
// }
//
// public ObjectName getObjectName() {
// return objectName;
// }
//
// public void setObjectName(ObjectName objectName) {
// this.objectName = objectName;
// }
//
// public boolean isConnected() {
// return serverConnection != null;
// }
//
// public List<MBeanAttributeInfo> getAttributes() throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException {
// if (serverConnection == null || objectName == null) {
// return Collections.emptyList();
// }
// MBeanInfo beanInfo = serverConnection.getMBeanInfo(objectName);
// return Arrays.asList(beanInfo.getAttributes());
// }
//
// public boolean isBeanSelected() {
// return objectName != null;
// }
//
//
// public Object getServerURL() {
// return serverURL;
// }
//
// public void fail(CommandAction action, int code) {
// if (exitCode == 0) {
// exitCode = code;
// }
// }
//
// public int getExitCode() {
// return exitCode;
// }
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/command/CommandAction.java
// public interface CommandAction {
//
// void doAction(TJContext tjContext, Output output) throws Exception;
//
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/console/Output.java
// public class Output implements Closeable {
// private final Pattern ansiRemovePattern = Pattern.compile("(@\\|\\w* )|( ?\\|@)");
// private final PrintStream out;
// private boolean useColors = true, ansiInstalled, filterInfo;
//
// public Output(PrintStream out, boolean useColors) {
// this.out = out;
// setUseColors(useColors);
// }
//
// public void setFilterInfo(boolean filterInfo) {
// this.filterInfo = filterInfo;
// }
//
// public boolean isUseColors() {
// return useColors;
// }
//
//
// public void setUseColors(boolean useColors) {
// this.useColors = useColors;
// if (useColors) {
// AnsiConsole.systemInstall();
// ansiInstalled = true;
// } else {
// AnsiConsole.systemUninstall();
// ansiInstalled = false;
// }
// }
//
//
// public void print(String text) {
// if (useColors) {
// out.print(ansi().render(text));
// } else {
// String s = ansiRemovePattern.matcher(text).replaceAll("");
// out.print(s);
// }
// out.flush();
// }
//
//
// public void println(String text) {
// print(text);
// out.println();
// out.flush();
// }
//
//
// @Override
// public void close() throws IOException {
// if (ansiInstalled) {
// AnsiConsole.systemUninstall();
// }
// out.close();
// }
//
// public void outError(String text) {
// println("@|red " + text + "|@");
// }
//
// public void outInfo(String text) {
// if (! filterInfo) {
// println("@|cyan " + text + "|@");
// }
// }
// }
// Path: src/main/java/org/jsoftware/tjconsole/command/definition/SetAttributeCommandDefinition.java
import jline.console.completer.Completer;
import org.jsoftware.tjconsole.TJContext;
import org.jsoftware.tjconsole.command.CommandAction;
import org.jsoftware.tjconsole.console.Output;
import javax.management.Attribute;
import javax.management.MBeanAttributeInfo;
package org.jsoftware.tjconsole.command.definition;
/**
* Operation to set mxBean attribute value
*
* @author szalik
*/
public class SetAttributeCommandDefinition extends AbstractCommandDefinition {
public SetAttributeCommandDefinition() {
super("Set attribute value.", "set <attributeName>=<newValue>", "set", true);
}
@Override
public CommandAction action(String input) {
String[] data = input.substring(prefix.length()).trim().split("=", 2);
final String attribute = data[0].trim();
final String valueStr = data[1].trim();
return new CommandAction() {
@Override | public void doAction(TJContext ctx, Output output) throws Exception { |
m-szalik/tjconsole | src/main/java/org/jsoftware/tjconsole/command/definition/SetAttributeCommandDefinition.java | // Path: src/main/java/org/jsoftware/tjconsole/TJContext.java
// public class TJContext extends Observable {
// private MBeanServerConnection serverConnection;
// private ObjectName objectName;
// private final Map<String, Object> environment;
// private Object serverURL;
// private int exitCode = 0;
//
// public TJContext() {
// environment = new LinkedHashMap<String, Object>();
// }
//
// public Map<String, Object> getEnvironment() {
// return Collections.unmodifiableMap(environment);
// }
//
// public void setEnvironmentVariable(String key, Object value, boolean check) {
// if (check) {
// if (!environment.containsKey(key)) {
// throw new IllegalArgumentException("Invalid key - " + key);
// }
// Object old = environment.get(key);
// if (!old.getClass().equals(value.getClass())) {
// value = ConvertUtils.convert(value, old.getClass());
// if (!old.getClass().equals(value.getClass())) {
// throw new IllegalArgumentException("Invalid value type - " + value.getClass().getName() + " should be " + old.getClass().getName());
// }
// }
// }
// Object prev = environment.get(key);
// if ((value != null && !value.equals(prev)) || (value == null && prev != null)) {
// setChanged();
// }
// notifyObservers(new UpdateEnvironmentEvent(key, prev, value));
// environment.put(key, value);
// }
//
// public MBeanServerConnection getServer() {
// return serverConnection;
// }
//
// public void setServer(MBeanServerConnection serverConnection, String url) {
// this.serverConnection = serverConnection;
// this.serverURL = url;
// this.objectName = null;
// }
//
// public ObjectName getObjectName() {
// return objectName;
// }
//
// public void setObjectName(ObjectName objectName) {
// this.objectName = objectName;
// }
//
// public boolean isConnected() {
// return serverConnection != null;
// }
//
// public List<MBeanAttributeInfo> getAttributes() throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException {
// if (serverConnection == null || objectName == null) {
// return Collections.emptyList();
// }
// MBeanInfo beanInfo = serverConnection.getMBeanInfo(objectName);
// return Arrays.asList(beanInfo.getAttributes());
// }
//
// public boolean isBeanSelected() {
// return objectName != null;
// }
//
//
// public Object getServerURL() {
// return serverURL;
// }
//
// public void fail(CommandAction action, int code) {
// if (exitCode == 0) {
// exitCode = code;
// }
// }
//
// public int getExitCode() {
// return exitCode;
// }
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/command/CommandAction.java
// public interface CommandAction {
//
// void doAction(TJContext tjContext, Output output) throws Exception;
//
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/console/Output.java
// public class Output implements Closeable {
// private final Pattern ansiRemovePattern = Pattern.compile("(@\\|\\w* )|( ?\\|@)");
// private final PrintStream out;
// private boolean useColors = true, ansiInstalled, filterInfo;
//
// public Output(PrintStream out, boolean useColors) {
// this.out = out;
// setUseColors(useColors);
// }
//
// public void setFilterInfo(boolean filterInfo) {
// this.filterInfo = filterInfo;
// }
//
// public boolean isUseColors() {
// return useColors;
// }
//
//
// public void setUseColors(boolean useColors) {
// this.useColors = useColors;
// if (useColors) {
// AnsiConsole.systemInstall();
// ansiInstalled = true;
// } else {
// AnsiConsole.systemUninstall();
// ansiInstalled = false;
// }
// }
//
//
// public void print(String text) {
// if (useColors) {
// out.print(ansi().render(text));
// } else {
// String s = ansiRemovePattern.matcher(text).replaceAll("");
// out.print(s);
// }
// out.flush();
// }
//
//
// public void println(String text) {
// print(text);
// out.println();
// out.flush();
// }
//
//
// @Override
// public void close() throws IOException {
// if (ansiInstalled) {
// AnsiConsole.systemUninstall();
// }
// out.close();
// }
//
// public void outError(String text) {
// println("@|red " + text + "|@");
// }
//
// public void outInfo(String text) {
// if (! filterInfo) {
// println("@|cyan " + text + "|@");
// }
// }
// }
| import jline.console.completer.Completer;
import org.jsoftware.tjconsole.TJContext;
import org.jsoftware.tjconsole.command.CommandAction;
import org.jsoftware.tjconsole.console.Output;
import javax.management.Attribute;
import javax.management.MBeanAttributeInfo; | package org.jsoftware.tjconsole.command.definition;
/**
* Operation to set mxBean attribute value
*
* @author szalik
*/
public class SetAttributeCommandDefinition extends AbstractCommandDefinition {
public SetAttributeCommandDefinition() {
super("Set attribute value.", "set <attributeName>=<newValue>", "set", true);
}
@Override
public CommandAction action(String input) {
String[] data = input.substring(prefix.length()).trim().split("=", 2);
final String attribute = data[0].trim();
final String valueStr = data[1].trim();
return new CommandAction() {
@Override | // Path: src/main/java/org/jsoftware/tjconsole/TJContext.java
// public class TJContext extends Observable {
// private MBeanServerConnection serverConnection;
// private ObjectName objectName;
// private final Map<String, Object> environment;
// private Object serverURL;
// private int exitCode = 0;
//
// public TJContext() {
// environment = new LinkedHashMap<String, Object>();
// }
//
// public Map<String, Object> getEnvironment() {
// return Collections.unmodifiableMap(environment);
// }
//
// public void setEnvironmentVariable(String key, Object value, boolean check) {
// if (check) {
// if (!environment.containsKey(key)) {
// throw new IllegalArgumentException("Invalid key - " + key);
// }
// Object old = environment.get(key);
// if (!old.getClass().equals(value.getClass())) {
// value = ConvertUtils.convert(value, old.getClass());
// if (!old.getClass().equals(value.getClass())) {
// throw new IllegalArgumentException("Invalid value type - " + value.getClass().getName() + " should be " + old.getClass().getName());
// }
// }
// }
// Object prev = environment.get(key);
// if ((value != null && !value.equals(prev)) || (value == null && prev != null)) {
// setChanged();
// }
// notifyObservers(new UpdateEnvironmentEvent(key, prev, value));
// environment.put(key, value);
// }
//
// public MBeanServerConnection getServer() {
// return serverConnection;
// }
//
// public void setServer(MBeanServerConnection serverConnection, String url) {
// this.serverConnection = serverConnection;
// this.serverURL = url;
// this.objectName = null;
// }
//
// public ObjectName getObjectName() {
// return objectName;
// }
//
// public void setObjectName(ObjectName objectName) {
// this.objectName = objectName;
// }
//
// public boolean isConnected() {
// return serverConnection != null;
// }
//
// public List<MBeanAttributeInfo> getAttributes() throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException {
// if (serverConnection == null || objectName == null) {
// return Collections.emptyList();
// }
// MBeanInfo beanInfo = serverConnection.getMBeanInfo(objectName);
// return Arrays.asList(beanInfo.getAttributes());
// }
//
// public boolean isBeanSelected() {
// return objectName != null;
// }
//
//
// public Object getServerURL() {
// return serverURL;
// }
//
// public void fail(CommandAction action, int code) {
// if (exitCode == 0) {
// exitCode = code;
// }
// }
//
// public int getExitCode() {
// return exitCode;
// }
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/command/CommandAction.java
// public interface CommandAction {
//
// void doAction(TJContext tjContext, Output output) throws Exception;
//
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/console/Output.java
// public class Output implements Closeable {
// private final Pattern ansiRemovePattern = Pattern.compile("(@\\|\\w* )|( ?\\|@)");
// private final PrintStream out;
// private boolean useColors = true, ansiInstalled, filterInfo;
//
// public Output(PrintStream out, boolean useColors) {
// this.out = out;
// setUseColors(useColors);
// }
//
// public void setFilterInfo(boolean filterInfo) {
// this.filterInfo = filterInfo;
// }
//
// public boolean isUseColors() {
// return useColors;
// }
//
//
// public void setUseColors(boolean useColors) {
// this.useColors = useColors;
// if (useColors) {
// AnsiConsole.systemInstall();
// ansiInstalled = true;
// } else {
// AnsiConsole.systemUninstall();
// ansiInstalled = false;
// }
// }
//
//
// public void print(String text) {
// if (useColors) {
// out.print(ansi().render(text));
// } else {
// String s = ansiRemovePattern.matcher(text).replaceAll("");
// out.print(s);
// }
// out.flush();
// }
//
//
// public void println(String text) {
// print(text);
// out.println();
// out.flush();
// }
//
//
// @Override
// public void close() throws IOException {
// if (ansiInstalled) {
// AnsiConsole.systemUninstall();
// }
// out.close();
// }
//
// public void outError(String text) {
// println("@|red " + text + "|@");
// }
//
// public void outInfo(String text) {
// if (! filterInfo) {
// println("@|cyan " + text + "|@");
// }
// }
// }
// Path: src/main/java/org/jsoftware/tjconsole/command/definition/SetAttributeCommandDefinition.java
import jline.console.completer.Completer;
import org.jsoftware.tjconsole.TJContext;
import org.jsoftware.tjconsole.command.CommandAction;
import org.jsoftware.tjconsole.console.Output;
import javax.management.Attribute;
import javax.management.MBeanAttributeInfo;
package org.jsoftware.tjconsole.command.definition;
/**
* Operation to set mxBean attribute value
*
* @author szalik
*/
public class SetAttributeCommandDefinition extends AbstractCommandDefinition {
public SetAttributeCommandDefinition() {
super("Set attribute value.", "set <attributeName>=<newValue>", "set", true);
}
@Override
public CommandAction action(String input) {
String[] data = input.substring(prefix.length()).trim().split("=", 2);
final String attribute = data[0].trim();
final String valueStr = data[1].trim();
return new CommandAction() {
@Override | public void doAction(TJContext ctx, Output output) throws Exception { |
m-szalik/tjconsole | src/main/java/org/jsoftware/tjconsole/command/definition/EnvCommandDefinition.java | // Path: src/main/java/org/jsoftware/tjconsole/TJContext.java
// public class TJContext extends Observable {
// private MBeanServerConnection serverConnection;
// private ObjectName objectName;
// private final Map<String, Object> environment;
// private Object serverURL;
// private int exitCode = 0;
//
// public TJContext() {
// environment = new LinkedHashMap<String, Object>();
// }
//
// public Map<String, Object> getEnvironment() {
// return Collections.unmodifiableMap(environment);
// }
//
// public void setEnvironmentVariable(String key, Object value, boolean check) {
// if (check) {
// if (!environment.containsKey(key)) {
// throw new IllegalArgumentException("Invalid key - " + key);
// }
// Object old = environment.get(key);
// if (!old.getClass().equals(value.getClass())) {
// value = ConvertUtils.convert(value, old.getClass());
// if (!old.getClass().equals(value.getClass())) {
// throw new IllegalArgumentException("Invalid value type - " + value.getClass().getName() + " should be " + old.getClass().getName());
// }
// }
// }
// Object prev = environment.get(key);
// if ((value != null && !value.equals(prev)) || (value == null && prev != null)) {
// setChanged();
// }
// notifyObservers(new UpdateEnvironmentEvent(key, prev, value));
// environment.put(key, value);
// }
//
// public MBeanServerConnection getServer() {
// return serverConnection;
// }
//
// public void setServer(MBeanServerConnection serverConnection, String url) {
// this.serverConnection = serverConnection;
// this.serverURL = url;
// this.objectName = null;
// }
//
// public ObjectName getObjectName() {
// return objectName;
// }
//
// public void setObjectName(ObjectName objectName) {
// this.objectName = objectName;
// }
//
// public boolean isConnected() {
// return serverConnection != null;
// }
//
// public List<MBeanAttributeInfo> getAttributes() throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException {
// if (serverConnection == null || objectName == null) {
// return Collections.emptyList();
// }
// MBeanInfo beanInfo = serverConnection.getMBeanInfo(objectName);
// return Arrays.asList(beanInfo.getAttributes());
// }
//
// public boolean isBeanSelected() {
// return objectName != null;
// }
//
//
// public Object getServerURL() {
// return serverURL;
// }
//
// public void fail(CommandAction action, int code) {
// if (exitCode == 0) {
// exitCode = code;
// }
// }
//
// public int getExitCode() {
// return exitCode;
// }
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/command/CommandAction.java
// public interface CommandAction {
//
// void doAction(TJContext tjContext, Output output) throws Exception;
//
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/console/Output.java
// public class Output implements Closeable {
// private final Pattern ansiRemovePattern = Pattern.compile("(@\\|\\w* )|( ?\\|@)");
// private final PrintStream out;
// private boolean useColors = true, ansiInstalled, filterInfo;
//
// public Output(PrintStream out, boolean useColors) {
// this.out = out;
// setUseColors(useColors);
// }
//
// public void setFilterInfo(boolean filterInfo) {
// this.filterInfo = filterInfo;
// }
//
// public boolean isUseColors() {
// return useColors;
// }
//
//
// public void setUseColors(boolean useColors) {
// this.useColors = useColors;
// if (useColors) {
// AnsiConsole.systemInstall();
// ansiInstalled = true;
// } else {
// AnsiConsole.systemUninstall();
// ansiInstalled = false;
// }
// }
//
//
// public void print(String text) {
// if (useColors) {
// out.print(ansi().render(text));
// } else {
// String s = ansiRemovePattern.matcher(text).replaceAll("");
// out.print(s);
// }
// out.flush();
// }
//
//
// public void println(String text) {
// print(text);
// out.println();
// out.flush();
// }
//
//
// @Override
// public void close() throws IOException {
// if (ansiInstalled) {
// AnsiConsole.systemUninstall();
// }
// out.close();
// }
//
// public void outError(String text) {
// println("@|red " + text + "|@");
// }
//
// public void outInfo(String text) {
// if (! filterInfo) {
// println("@|cyan " + text + "|@");
// }
// }
// }
| import jline.console.completer.Completer;
import org.jsoftware.tjconsole.TJContext;
import org.jsoftware.tjconsole.command.CommandAction;
import org.jsoftware.tjconsole.console.Output;
import java.util.List;
import java.util.Map; | package org.jsoftware.tjconsole.command.definition;
/**
* Set environment variable like username or password
*
* @author szalik
*/
public class EnvCommandDefinition extends AbstractCommandDefinition {
public EnvCommandDefinition() {
super("Set environment variable like username or password", "env <variableName>=<newValue>", "env", false);
}
| // Path: src/main/java/org/jsoftware/tjconsole/TJContext.java
// public class TJContext extends Observable {
// private MBeanServerConnection serverConnection;
// private ObjectName objectName;
// private final Map<String, Object> environment;
// private Object serverURL;
// private int exitCode = 0;
//
// public TJContext() {
// environment = new LinkedHashMap<String, Object>();
// }
//
// public Map<String, Object> getEnvironment() {
// return Collections.unmodifiableMap(environment);
// }
//
// public void setEnvironmentVariable(String key, Object value, boolean check) {
// if (check) {
// if (!environment.containsKey(key)) {
// throw new IllegalArgumentException("Invalid key - " + key);
// }
// Object old = environment.get(key);
// if (!old.getClass().equals(value.getClass())) {
// value = ConvertUtils.convert(value, old.getClass());
// if (!old.getClass().equals(value.getClass())) {
// throw new IllegalArgumentException("Invalid value type - " + value.getClass().getName() + " should be " + old.getClass().getName());
// }
// }
// }
// Object prev = environment.get(key);
// if ((value != null && !value.equals(prev)) || (value == null && prev != null)) {
// setChanged();
// }
// notifyObservers(new UpdateEnvironmentEvent(key, prev, value));
// environment.put(key, value);
// }
//
// public MBeanServerConnection getServer() {
// return serverConnection;
// }
//
// public void setServer(MBeanServerConnection serverConnection, String url) {
// this.serverConnection = serverConnection;
// this.serverURL = url;
// this.objectName = null;
// }
//
// public ObjectName getObjectName() {
// return objectName;
// }
//
// public void setObjectName(ObjectName objectName) {
// this.objectName = objectName;
// }
//
// public boolean isConnected() {
// return serverConnection != null;
// }
//
// public List<MBeanAttributeInfo> getAttributes() throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException {
// if (serverConnection == null || objectName == null) {
// return Collections.emptyList();
// }
// MBeanInfo beanInfo = serverConnection.getMBeanInfo(objectName);
// return Arrays.asList(beanInfo.getAttributes());
// }
//
// public boolean isBeanSelected() {
// return objectName != null;
// }
//
//
// public Object getServerURL() {
// return serverURL;
// }
//
// public void fail(CommandAction action, int code) {
// if (exitCode == 0) {
// exitCode = code;
// }
// }
//
// public int getExitCode() {
// return exitCode;
// }
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/command/CommandAction.java
// public interface CommandAction {
//
// void doAction(TJContext tjContext, Output output) throws Exception;
//
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/console/Output.java
// public class Output implements Closeable {
// private final Pattern ansiRemovePattern = Pattern.compile("(@\\|\\w* )|( ?\\|@)");
// private final PrintStream out;
// private boolean useColors = true, ansiInstalled, filterInfo;
//
// public Output(PrintStream out, boolean useColors) {
// this.out = out;
// setUseColors(useColors);
// }
//
// public void setFilterInfo(boolean filterInfo) {
// this.filterInfo = filterInfo;
// }
//
// public boolean isUseColors() {
// return useColors;
// }
//
//
// public void setUseColors(boolean useColors) {
// this.useColors = useColors;
// if (useColors) {
// AnsiConsole.systemInstall();
// ansiInstalled = true;
// } else {
// AnsiConsole.systemUninstall();
// ansiInstalled = false;
// }
// }
//
//
// public void print(String text) {
// if (useColors) {
// out.print(ansi().render(text));
// } else {
// String s = ansiRemovePattern.matcher(text).replaceAll("");
// out.print(s);
// }
// out.flush();
// }
//
//
// public void println(String text) {
// print(text);
// out.println();
// out.flush();
// }
//
//
// @Override
// public void close() throws IOException {
// if (ansiInstalled) {
// AnsiConsole.systemUninstall();
// }
// out.close();
// }
//
// public void outError(String text) {
// println("@|red " + text + "|@");
// }
//
// public void outInfo(String text) {
// if (! filterInfo) {
// println("@|cyan " + text + "|@");
// }
// }
// }
// Path: src/main/java/org/jsoftware/tjconsole/command/definition/EnvCommandDefinition.java
import jline.console.completer.Completer;
import org.jsoftware.tjconsole.TJContext;
import org.jsoftware.tjconsole.command.CommandAction;
import org.jsoftware.tjconsole.console.Output;
import java.util.List;
import java.util.Map;
package org.jsoftware.tjconsole.command.definition;
/**
* Set environment variable like username or password
*
* @author szalik
*/
public class EnvCommandDefinition extends AbstractCommandDefinition {
public EnvCommandDefinition() {
super("Set environment variable like username or password", "env <variableName>=<newValue>", "env", false);
}
| public CommandAction action(String input) { |
m-szalik/tjconsole | src/main/java/org/jsoftware/tjconsole/command/definition/EnvCommandDefinition.java | // Path: src/main/java/org/jsoftware/tjconsole/TJContext.java
// public class TJContext extends Observable {
// private MBeanServerConnection serverConnection;
// private ObjectName objectName;
// private final Map<String, Object> environment;
// private Object serverURL;
// private int exitCode = 0;
//
// public TJContext() {
// environment = new LinkedHashMap<String, Object>();
// }
//
// public Map<String, Object> getEnvironment() {
// return Collections.unmodifiableMap(environment);
// }
//
// public void setEnvironmentVariable(String key, Object value, boolean check) {
// if (check) {
// if (!environment.containsKey(key)) {
// throw new IllegalArgumentException("Invalid key - " + key);
// }
// Object old = environment.get(key);
// if (!old.getClass().equals(value.getClass())) {
// value = ConvertUtils.convert(value, old.getClass());
// if (!old.getClass().equals(value.getClass())) {
// throw new IllegalArgumentException("Invalid value type - " + value.getClass().getName() + " should be " + old.getClass().getName());
// }
// }
// }
// Object prev = environment.get(key);
// if ((value != null && !value.equals(prev)) || (value == null && prev != null)) {
// setChanged();
// }
// notifyObservers(new UpdateEnvironmentEvent(key, prev, value));
// environment.put(key, value);
// }
//
// public MBeanServerConnection getServer() {
// return serverConnection;
// }
//
// public void setServer(MBeanServerConnection serverConnection, String url) {
// this.serverConnection = serverConnection;
// this.serverURL = url;
// this.objectName = null;
// }
//
// public ObjectName getObjectName() {
// return objectName;
// }
//
// public void setObjectName(ObjectName objectName) {
// this.objectName = objectName;
// }
//
// public boolean isConnected() {
// return serverConnection != null;
// }
//
// public List<MBeanAttributeInfo> getAttributes() throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException {
// if (serverConnection == null || objectName == null) {
// return Collections.emptyList();
// }
// MBeanInfo beanInfo = serverConnection.getMBeanInfo(objectName);
// return Arrays.asList(beanInfo.getAttributes());
// }
//
// public boolean isBeanSelected() {
// return objectName != null;
// }
//
//
// public Object getServerURL() {
// return serverURL;
// }
//
// public void fail(CommandAction action, int code) {
// if (exitCode == 0) {
// exitCode = code;
// }
// }
//
// public int getExitCode() {
// return exitCode;
// }
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/command/CommandAction.java
// public interface CommandAction {
//
// void doAction(TJContext tjContext, Output output) throws Exception;
//
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/console/Output.java
// public class Output implements Closeable {
// private final Pattern ansiRemovePattern = Pattern.compile("(@\\|\\w* )|( ?\\|@)");
// private final PrintStream out;
// private boolean useColors = true, ansiInstalled, filterInfo;
//
// public Output(PrintStream out, boolean useColors) {
// this.out = out;
// setUseColors(useColors);
// }
//
// public void setFilterInfo(boolean filterInfo) {
// this.filterInfo = filterInfo;
// }
//
// public boolean isUseColors() {
// return useColors;
// }
//
//
// public void setUseColors(boolean useColors) {
// this.useColors = useColors;
// if (useColors) {
// AnsiConsole.systemInstall();
// ansiInstalled = true;
// } else {
// AnsiConsole.systemUninstall();
// ansiInstalled = false;
// }
// }
//
//
// public void print(String text) {
// if (useColors) {
// out.print(ansi().render(text));
// } else {
// String s = ansiRemovePattern.matcher(text).replaceAll("");
// out.print(s);
// }
// out.flush();
// }
//
//
// public void println(String text) {
// print(text);
// out.println();
// out.flush();
// }
//
//
// @Override
// public void close() throws IOException {
// if (ansiInstalled) {
// AnsiConsole.systemUninstall();
// }
// out.close();
// }
//
// public void outError(String text) {
// println("@|red " + text + "|@");
// }
//
// public void outInfo(String text) {
// if (! filterInfo) {
// println("@|cyan " + text + "|@");
// }
// }
// }
| import jline.console.completer.Completer;
import org.jsoftware.tjconsole.TJContext;
import org.jsoftware.tjconsole.command.CommandAction;
import org.jsoftware.tjconsole.console.Output;
import java.util.List;
import java.util.Map; | package org.jsoftware.tjconsole.command.definition;
/**
* Set environment variable like username or password
*
* @author szalik
*/
public class EnvCommandDefinition extends AbstractCommandDefinition {
public EnvCommandDefinition() {
super("Set environment variable like username or password", "env <variableName>=<newValue>", "env", false);
}
public CommandAction action(String input) {
String[] data = input.substring(prefix.length()).trim().split("=", 2);
if (data.length < 2) {
return new CommandAction() {
@Override | // Path: src/main/java/org/jsoftware/tjconsole/TJContext.java
// public class TJContext extends Observable {
// private MBeanServerConnection serverConnection;
// private ObjectName objectName;
// private final Map<String, Object> environment;
// private Object serverURL;
// private int exitCode = 0;
//
// public TJContext() {
// environment = new LinkedHashMap<String, Object>();
// }
//
// public Map<String, Object> getEnvironment() {
// return Collections.unmodifiableMap(environment);
// }
//
// public void setEnvironmentVariable(String key, Object value, boolean check) {
// if (check) {
// if (!environment.containsKey(key)) {
// throw new IllegalArgumentException("Invalid key - " + key);
// }
// Object old = environment.get(key);
// if (!old.getClass().equals(value.getClass())) {
// value = ConvertUtils.convert(value, old.getClass());
// if (!old.getClass().equals(value.getClass())) {
// throw new IllegalArgumentException("Invalid value type - " + value.getClass().getName() + " should be " + old.getClass().getName());
// }
// }
// }
// Object prev = environment.get(key);
// if ((value != null && !value.equals(prev)) || (value == null && prev != null)) {
// setChanged();
// }
// notifyObservers(new UpdateEnvironmentEvent(key, prev, value));
// environment.put(key, value);
// }
//
// public MBeanServerConnection getServer() {
// return serverConnection;
// }
//
// public void setServer(MBeanServerConnection serverConnection, String url) {
// this.serverConnection = serverConnection;
// this.serverURL = url;
// this.objectName = null;
// }
//
// public ObjectName getObjectName() {
// return objectName;
// }
//
// public void setObjectName(ObjectName objectName) {
// this.objectName = objectName;
// }
//
// public boolean isConnected() {
// return serverConnection != null;
// }
//
// public List<MBeanAttributeInfo> getAttributes() throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException {
// if (serverConnection == null || objectName == null) {
// return Collections.emptyList();
// }
// MBeanInfo beanInfo = serverConnection.getMBeanInfo(objectName);
// return Arrays.asList(beanInfo.getAttributes());
// }
//
// public boolean isBeanSelected() {
// return objectName != null;
// }
//
//
// public Object getServerURL() {
// return serverURL;
// }
//
// public void fail(CommandAction action, int code) {
// if (exitCode == 0) {
// exitCode = code;
// }
// }
//
// public int getExitCode() {
// return exitCode;
// }
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/command/CommandAction.java
// public interface CommandAction {
//
// void doAction(TJContext tjContext, Output output) throws Exception;
//
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/console/Output.java
// public class Output implements Closeable {
// private final Pattern ansiRemovePattern = Pattern.compile("(@\\|\\w* )|( ?\\|@)");
// private final PrintStream out;
// private boolean useColors = true, ansiInstalled, filterInfo;
//
// public Output(PrintStream out, boolean useColors) {
// this.out = out;
// setUseColors(useColors);
// }
//
// public void setFilterInfo(boolean filterInfo) {
// this.filterInfo = filterInfo;
// }
//
// public boolean isUseColors() {
// return useColors;
// }
//
//
// public void setUseColors(boolean useColors) {
// this.useColors = useColors;
// if (useColors) {
// AnsiConsole.systemInstall();
// ansiInstalled = true;
// } else {
// AnsiConsole.systemUninstall();
// ansiInstalled = false;
// }
// }
//
//
// public void print(String text) {
// if (useColors) {
// out.print(ansi().render(text));
// } else {
// String s = ansiRemovePattern.matcher(text).replaceAll("");
// out.print(s);
// }
// out.flush();
// }
//
//
// public void println(String text) {
// print(text);
// out.println();
// out.flush();
// }
//
//
// @Override
// public void close() throws IOException {
// if (ansiInstalled) {
// AnsiConsole.systemUninstall();
// }
// out.close();
// }
//
// public void outError(String text) {
// println("@|red " + text + "|@");
// }
//
// public void outInfo(String text) {
// if (! filterInfo) {
// println("@|cyan " + text + "|@");
// }
// }
// }
// Path: src/main/java/org/jsoftware/tjconsole/command/definition/EnvCommandDefinition.java
import jline.console.completer.Completer;
import org.jsoftware.tjconsole.TJContext;
import org.jsoftware.tjconsole.command.CommandAction;
import org.jsoftware.tjconsole.console.Output;
import java.util.List;
import java.util.Map;
package org.jsoftware.tjconsole.command.definition;
/**
* Set environment variable like username or password
*
* @author szalik
*/
public class EnvCommandDefinition extends AbstractCommandDefinition {
public EnvCommandDefinition() {
super("Set environment variable like username or password", "env <variableName>=<newValue>", "env", false);
}
public CommandAction action(String input) {
String[] data = input.substring(prefix.length()).trim().split("=", 2);
if (data.length < 2) {
return new CommandAction() {
@Override | public void doAction(TJContext tjContext, Output output) { |
m-szalik/tjconsole | src/main/java/org/jsoftware/tjconsole/command/definition/EnvCommandDefinition.java | // Path: src/main/java/org/jsoftware/tjconsole/TJContext.java
// public class TJContext extends Observable {
// private MBeanServerConnection serverConnection;
// private ObjectName objectName;
// private final Map<String, Object> environment;
// private Object serverURL;
// private int exitCode = 0;
//
// public TJContext() {
// environment = new LinkedHashMap<String, Object>();
// }
//
// public Map<String, Object> getEnvironment() {
// return Collections.unmodifiableMap(environment);
// }
//
// public void setEnvironmentVariable(String key, Object value, boolean check) {
// if (check) {
// if (!environment.containsKey(key)) {
// throw new IllegalArgumentException("Invalid key - " + key);
// }
// Object old = environment.get(key);
// if (!old.getClass().equals(value.getClass())) {
// value = ConvertUtils.convert(value, old.getClass());
// if (!old.getClass().equals(value.getClass())) {
// throw new IllegalArgumentException("Invalid value type - " + value.getClass().getName() + " should be " + old.getClass().getName());
// }
// }
// }
// Object prev = environment.get(key);
// if ((value != null && !value.equals(prev)) || (value == null && prev != null)) {
// setChanged();
// }
// notifyObservers(new UpdateEnvironmentEvent(key, prev, value));
// environment.put(key, value);
// }
//
// public MBeanServerConnection getServer() {
// return serverConnection;
// }
//
// public void setServer(MBeanServerConnection serverConnection, String url) {
// this.serverConnection = serverConnection;
// this.serverURL = url;
// this.objectName = null;
// }
//
// public ObjectName getObjectName() {
// return objectName;
// }
//
// public void setObjectName(ObjectName objectName) {
// this.objectName = objectName;
// }
//
// public boolean isConnected() {
// return serverConnection != null;
// }
//
// public List<MBeanAttributeInfo> getAttributes() throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException {
// if (serverConnection == null || objectName == null) {
// return Collections.emptyList();
// }
// MBeanInfo beanInfo = serverConnection.getMBeanInfo(objectName);
// return Arrays.asList(beanInfo.getAttributes());
// }
//
// public boolean isBeanSelected() {
// return objectName != null;
// }
//
//
// public Object getServerURL() {
// return serverURL;
// }
//
// public void fail(CommandAction action, int code) {
// if (exitCode == 0) {
// exitCode = code;
// }
// }
//
// public int getExitCode() {
// return exitCode;
// }
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/command/CommandAction.java
// public interface CommandAction {
//
// void doAction(TJContext tjContext, Output output) throws Exception;
//
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/console/Output.java
// public class Output implements Closeable {
// private final Pattern ansiRemovePattern = Pattern.compile("(@\\|\\w* )|( ?\\|@)");
// private final PrintStream out;
// private boolean useColors = true, ansiInstalled, filterInfo;
//
// public Output(PrintStream out, boolean useColors) {
// this.out = out;
// setUseColors(useColors);
// }
//
// public void setFilterInfo(boolean filterInfo) {
// this.filterInfo = filterInfo;
// }
//
// public boolean isUseColors() {
// return useColors;
// }
//
//
// public void setUseColors(boolean useColors) {
// this.useColors = useColors;
// if (useColors) {
// AnsiConsole.systemInstall();
// ansiInstalled = true;
// } else {
// AnsiConsole.systemUninstall();
// ansiInstalled = false;
// }
// }
//
//
// public void print(String text) {
// if (useColors) {
// out.print(ansi().render(text));
// } else {
// String s = ansiRemovePattern.matcher(text).replaceAll("");
// out.print(s);
// }
// out.flush();
// }
//
//
// public void println(String text) {
// print(text);
// out.println();
// out.flush();
// }
//
//
// @Override
// public void close() throws IOException {
// if (ansiInstalled) {
// AnsiConsole.systemUninstall();
// }
// out.close();
// }
//
// public void outError(String text) {
// println("@|red " + text + "|@");
// }
//
// public void outInfo(String text) {
// if (! filterInfo) {
// println("@|cyan " + text + "|@");
// }
// }
// }
| import jline.console.completer.Completer;
import org.jsoftware.tjconsole.TJContext;
import org.jsoftware.tjconsole.command.CommandAction;
import org.jsoftware.tjconsole.console.Output;
import java.util.List;
import java.util.Map; | package org.jsoftware.tjconsole.command.definition;
/**
* Set environment variable like username or password
*
* @author szalik
*/
public class EnvCommandDefinition extends AbstractCommandDefinition {
public EnvCommandDefinition() {
super("Set environment variable like username or password", "env <variableName>=<newValue>", "env", false);
}
public CommandAction action(String input) {
String[] data = input.substring(prefix.length()).trim().split("=", 2);
if (data.length < 2) {
return new CommandAction() {
@Override | // Path: src/main/java/org/jsoftware/tjconsole/TJContext.java
// public class TJContext extends Observable {
// private MBeanServerConnection serverConnection;
// private ObjectName objectName;
// private final Map<String, Object> environment;
// private Object serverURL;
// private int exitCode = 0;
//
// public TJContext() {
// environment = new LinkedHashMap<String, Object>();
// }
//
// public Map<String, Object> getEnvironment() {
// return Collections.unmodifiableMap(environment);
// }
//
// public void setEnvironmentVariable(String key, Object value, boolean check) {
// if (check) {
// if (!environment.containsKey(key)) {
// throw new IllegalArgumentException("Invalid key - " + key);
// }
// Object old = environment.get(key);
// if (!old.getClass().equals(value.getClass())) {
// value = ConvertUtils.convert(value, old.getClass());
// if (!old.getClass().equals(value.getClass())) {
// throw new IllegalArgumentException("Invalid value type - " + value.getClass().getName() + " should be " + old.getClass().getName());
// }
// }
// }
// Object prev = environment.get(key);
// if ((value != null && !value.equals(prev)) || (value == null && prev != null)) {
// setChanged();
// }
// notifyObservers(new UpdateEnvironmentEvent(key, prev, value));
// environment.put(key, value);
// }
//
// public MBeanServerConnection getServer() {
// return serverConnection;
// }
//
// public void setServer(MBeanServerConnection serverConnection, String url) {
// this.serverConnection = serverConnection;
// this.serverURL = url;
// this.objectName = null;
// }
//
// public ObjectName getObjectName() {
// return objectName;
// }
//
// public void setObjectName(ObjectName objectName) {
// this.objectName = objectName;
// }
//
// public boolean isConnected() {
// return serverConnection != null;
// }
//
// public List<MBeanAttributeInfo> getAttributes() throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException {
// if (serverConnection == null || objectName == null) {
// return Collections.emptyList();
// }
// MBeanInfo beanInfo = serverConnection.getMBeanInfo(objectName);
// return Arrays.asList(beanInfo.getAttributes());
// }
//
// public boolean isBeanSelected() {
// return objectName != null;
// }
//
//
// public Object getServerURL() {
// return serverURL;
// }
//
// public void fail(CommandAction action, int code) {
// if (exitCode == 0) {
// exitCode = code;
// }
// }
//
// public int getExitCode() {
// return exitCode;
// }
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/command/CommandAction.java
// public interface CommandAction {
//
// void doAction(TJContext tjContext, Output output) throws Exception;
//
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/console/Output.java
// public class Output implements Closeable {
// private final Pattern ansiRemovePattern = Pattern.compile("(@\\|\\w* )|( ?\\|@)");
// private final PrintStream out;
// private boolean useColors = true, ansiInstalled, filterInfo;
//
// public Output(PrintStream out, boolean useColors) {
// this.out = out;
// setUseColors(useColors);
// }
//
// public void setFilterInfo(boolean filterInfo) {
// this.filterInfo = filterInfo;
// }
//
// public boolean isUseColors() {
// return useColors;
// }
//
//
// public void setUseColors(boolean useColors) {
// this.useColors = useColors;
// if (useColors) {
// AnsiConsole.systemInstall();
// ansiInstalled = true;
// } else {
// AnsiConsole.systemUninstall();
// ansiInstalled = false;
// }
// }
//
//
// public void print(String text) {
// if (useColors) {
// out.print(ansi().render(text));
// } else {
// String s = ansiRemovePattern.matcher(text).replaceAll("");
// out.print(s);
// }
// out.flush();
// }
//
//
// public void println(String text) {
// print(text);
// out.println();
// out.flush();
// }
//
//
// @Override
// public void close() throws IOException {
// if (ansiInstalled) {
// AnsiConsole.systemUninstall();
// }
// out.close();
// }
//
// public void outError(String text) {
// println("@|red " + text + "|@");
// }
//
// public void outInfo(String text) {
// if (! filterInfo) {
// println("@|cyan " + text + "|@");
// }
// }
// }
// Path: src/main/java/org/jsoftware/tjconsole/command/definition/EnvCommandDefinition.java
import jline.console.completer.Completer;
import org.jsoftware.tjconsole.TJContext;
import org.jsoftware.tjconsole.command.CommandAction;
import org.jsoftware.tjconsole.console.Output;
import java.util.List;
import java.util.Map;
package org.jsoftware.tjconsole.command.definition;
/**
* Set environment variable like username or password
*
* @author szalik
*/
public class EnvCommandDefinition extends AbstractCommandDefinition {
public EnvCommandDefinition() {
super("Set environment variable like username or password", "env <variableName>=<newValue>", "env", false);
}
public CommandAction action(String input) {
String[] data = input.substring(prefix.length()).trim().split("=", 2);
if (data.length < 2) {
return new CommandAction() {
@Override | public void doAction(TJContext tjContext, Output output) { |
m-szalik/tjconsole | src/main/java/org/jsoftware/tjconsole/command/definition/DescribeCommandDefinition.java | // Path: src/main/java/org/jsoftware/tjconsole/TJContext.java
// public class TJContext extends Observable {
// private MBeanServerConnection serverConnection;
// private ObjectName objectName;
// private final Map<String, Object> environment;
// private Object serverURL;
// private int exitCode = 0;
//
// public TJContext() {
// environment = new LinkedHashMap<String, Object>();
// }
//
// public Map<String, Object> getEnvironment() {
// return Collections.unmodifiableMap(environment);
// }
//
// public void setEnvironmentVariable(String key, Object value, boolean check) {
// if (check) {
// if (!environment.containsKey(key)) {
// throw new IllegalArgumentException("Invalid key - " + key);
// }
// Object old = environment.get(key);
// if (!old.getClass().equals(value.getClass())) {
// value = ConvertUtils.convert(value, old.getClass());
// if (!old.getClass().equals(value.getClass())) {
// throw new IllegalArgumentException("Invalid value type - " + value.getClass().getName() + " should be " + old.getClass().getName());
// }
// }
// }
// Object prev = environment.get(key);
// if ((value != null && !value.equals(prev)) || (value == null && prev != null)) {
// setChanged();
// }
// notifyObservers(new UpdateEnvironmentEvent(key, prev, value));
// environment.put(key, value);
// }
//
// public MBeanServerConnection getServer() {
// return serverConnection;
// }
//
// public void setServer(MBeanServerConnection serverConnection, String url) {
// this.serverConnection = serverConnection;
// this.serverURL = url;
// this.objectName = null;
// }
//
// public ObjectName getObjectName() {
// return objectName;
// }
//
// public void setObjectName(ObjectName objectName) {
// this.objectName = objectName;
// }
//
// public boolean isConnected() {
// return serverConnection != null;
// }
//
// public List<MBeanAttributeInfo> getAttributes() throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException {
// if (serverConnection == null || objectName == null) {
// return Collections.emptyList();
// }
// MBeanInfo beanInfo = serverConnection.getMBeanInfo(objectName);
// return Arrays.asList(beanInfo.getAttributes());
// }
//
// public boolean isBeanSelected() {
// return objectName != null;
// }
//
//
// public Object getServerURL() {
// return serverURL;
// }
//
// public void fail(CommandAction action, int code) {
// if (exitCode == 0) {
// exitCode = code;
// }
// }
//
// public int getExitCode() {
// return exitCode;
// }
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/command/CommandAction.java
// public interface CommandAction {
//
// void doAction(TJContext tjContext, Output output) throws Exception;
//
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/console/Output.java
// public class Output implements Closeable {
// private final Pattern ansiRemovePattern = Pattern.compile("(@\\|\\w* )|( ?\\|@)");
// private final PrintStream out;
// private boolean useColors = true, ansiInstalled, filterInfo;
//
// public Output(PrintStream out, boolean useColors) {
// this.out = out;
// setUseColors(useColors);
// }
//
// public void setFilterInfo(boolean filterInfo) {
// this.filterInfo = filterInfo;
// }
//
// public boolean isUseColors() {
// return useColors;
// }
//
//
// public void setUseColors(boolean useColors) {
// this.useColors = useColors;
// if (useColors) {
// AnsiConsole.systemInstall();
// ansiInstalled = true;
// } else {
// AnsiConsole.systemUninstall();
// ansiInstalled = false;
// }
// }
//
//
// public void print(String text) {
// if (useColors) {
// out.print(ansi().render(text));
// } else {
// String s = ansiRemovePattern.matcher(text).replaceAll("");
// out.print(s);
// }
// out.flush();
// }
//
//
// public void println(String text) {
// print(text);
// out.println();
// out.flush();
// }
//
//
// @Override
// public void close() throws IOException {
// if (ansiInstalled) {
// AnsiConsole.systemUninstall();
// }
// out.close();
// }
//
// public void outError(String text) {
// println("@|red " + text + "|@");
// }
//
// public void outInfo(String text) {
// if (! filterInfo) {
// println("@|cyan " + text + "|@");
// }
// }
// }
| import org.jsoftware.tjconsole.TJContext;
import org.jsoftware.tjconsole.command.CommandAction;
import org.jsoftware.tjconsole.console.Output;
import javax.management.*;
import javax.management.openmbean.*;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List; | package org.jsoftware.tjconsole.command.definition;
/**
* Get mxBean attribute information (name, if it is read-only or read-write)
*
* @author szalik
*/
public class DescribeCommandDefinition extends AbstractCommandDefinition {
private static final int SPACE = 18;
public DescribeCommandDefinition() {
super("Describe attributes and operations of current bean.", "describe", "describe", true);
}
@Override | // Path: src/main/java/org/jsoftware/tjconsole/TJContext.java
// public class TJContext extends Observable {
// private MBeanServerConnection serverConnection;
// private ObjectName objectName;
// private final Map<String, Object> environment;
// private Object serverURL;
// private int exitCode = 0;
//
// public TJContext() {
// environment = new LinkedHashMap<String, Object>();
// }
//
// public Map<String, Object> getEnvironment() {
// return Collections.unmodifiableMap(environment);
// }
//
// public void setEnvironmentVariable(String key, Object value, boolean check) {
// if (check) {
// if (!environment.containsKey(key)) {
// throw new IllegalArgumentException("Invalid key - " + key);
// }
// Object old = environment.get(key);
// if (!old.getClass().equals(value.getClass())) {
// value = ConvertUtils.convert(value, old.getClass());
// if (!old.getClass().equals(value.getClass())) {
// throw new IllegalArgumentException("Invalid value type - " + value.getClass().getName() + " should be " + old.getClass().getName());
// }
// }
// }
// Object prev = environment.get(key);
// if ((value != null && !value.equals(prev)) || (value == null && prev != null)) {
// setChanged();
// }
// notifyObservers(new UpdateEnvironmentEvent(key, prev, value));
// environment.put(key, value);
// }
//
// public MBeanServerConnection getServer() {
// return serverConnection;
// }
//
// public void setServer(MBeanServerConnection serverConnection, String url) {
// this.serverConnection = serverConnection;
// this.serverURL = url;
// this.objectName = null;
// }
//
// public ObjectName getObjectName() {
// return objectName;
// }
//
// public void setObjectName(ObjectName objectName) {
// this.objectName = objectName;
// }
//
// public boolean isConnected() {
// return serverConnection != null;
// }
//
// public List<MBeanAttributeInfo> getAttributes() throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException {
// if (serverConnection == null || objectName == null) {
// return Collections.emptyList();
// }
// MBeanInfo beanInfo = serverConnection.getMBeanInfo(objectName);
// return Arrays.asList(beanInfo.getAttributes());
// }
//
// public boolean isBeanSelected() {
// return objectName != null;
// }
//
//
// public Object getServerURL() {
// return serverURL;
// }
//
// public void fail(CommandAction action, int code) {
// if (exitCode == 0) {
// exitCode = code;
// }
// }
//
// public int getExitCode() {
// return exitCode;
// }
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/command/CommandAction.java
// public interface CommandAction {
//
// void doAction(TJContext tjContext, Output output) throws Exception;
//
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/console/Output.java
// public class Output implements Closeable {
// private final Pattern ansiRemovePattern = Pattern.compile("(@\\|\\w* )|( ?\\|@)");
// private final PrintStream out;
// private boolean useColors = true, ansiInstalled, filterInfo;
//
// public Output(PrintStream out, boolean useColors) {
// this.out = out;
// setUseColors(useColors);
// }
//
// public void setFilterInfo(boolean filterInfo) {
// this.filterInfo = filterInfo;
// }
//
// public boolean isUseColors() {
// return useColors;
// }
//
//
// public void setUseColors(boolean useColors) {
// this.useColors = useColors;
// if (useColors) {
// AnsiConsole.systemInstall();
// ansiInstalled = true;
// } else {
// AnsiConsole.systemUninstall();
// ansiInstalled = false;
// }
// }
//
//
// public void print(String text) {
// if (useColors) {
// out.print(ansi().render(text));
// } else {
// String s = ansiRemovePattern.matcher(text).replaceAll("");
// out.print(s);
// }
// out.flush();
// }
//
//
// public void println(String text) {
// print(text);
// out.println();
// out.flush();
// }
//
//
// @Override
// public void close() throws IOException {
// if (ansiInstalled) {
// AnsiConsole.systemUninstall();
// }
// out.close();
// }
//
// public void outError(String text) {
// println("@|red " + text + "|@");
// }
//
// public void outInfo(String text) {
// if (! filterInfo) {
// println("@|cyan " + text + "|@");
// }
// }
// }
// Path: src/main/java/org/jsoftware/tjconsole/command/definition/DescribeCommandDefinition.java
import org.jsoftware.tjconsole.TJContext;
import org.jsoftware.tjconsole.command.CommandAction;
import org.jsoftware.tjconsole.console.Output;
import javax.management.*;
import javax.management.openmbean.*;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
package org.jsoftware.tjconsole.command.definition;
/**
* Get mxBean attribute information (name, if it is read-only or read-write)
*
* @author szalik
*/
public class DescribeCommandDefinition extends AbstractCommandDefinition {
private static final int SPACE = 18;
public DescribeCommandDefinition() {
super("Describe attributes and operations of current bean.", "describe", "describe", true);
}
@Override | public CommandAction action(String input) { |
m-szalik/tjconsole | src/main/java/org/jsoftware/tjconsole/command/definition/DescribeCommandDefinition.java | // Path: src/main/java/org/jsoftware/tjconsole/TJContext.java
// public class TJContext extends Observable {
// private MBeanServerConnection serverConnection;
// private ObjectName objectName;
// private final Map<String, Object> environment;
// private Object serverURL;
// private int exitCode = 0;
//
// public TJContext() {
// environment = new LinkedHashMap<String, Object>();
// }
//
// public Map<String, Object> getEnvironment() {
// return Collections.unmodifiableMap(environment);
// }
//
// public void setEnvironmentVariable(String key, Object value, boolean check) {
// if (check) {
// if (!environment.containsKey(key)) {
// throw new IllegalArgumentException("Invalid key - " + key);
// }
// Object old = environment.get(key);
// if (!old.getClass().equals(value.getClass())) {
// value = ConvertUtils.convert(value, old.getClass());
// if (!old.getClass().equals(value.getClass())) {
// throw new IllegalArgumentException("Invalid value type - " + value.getClass().getName() + " should be " + old.getClass().getName());
// }
// }
// }
// Object prev = environment.get(key);
// if ((value != null && !value.equals(prev)) || (value == null && prev != null)) {
// setChanged();
// }
// notifyObservers(new UpdateEnvironmentEvent(key, prev, value));
// environment.put(key, value);
// }
//
// public MBeanServerConnection getServer() {
// return serverConnection;
// }
//
// public void setServer(MBeanServerConnection serverConnection, String url) {
// this.serverConnection = serverConnection;
// this.serverURL = url;
// this.objectName = null;
// }
//
// public ObjectName getObjectName() {
// return objectName;
// }
//
// public void setObjectName(ObjectName objectName) {
// this.objectName = objectName;
// }
//
// public boolean isConnected() {
// return serverConnection != null;
// }
//
// public List<MBeanAttributeInfo> getAttributes() throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException {
// if (serverConnection == null || objectName == null) {
// return Collections.emptyList();
// }
// MBeanInfo beanInfo = serverConnection.getMBeanInfo(objectName);
// return Arrays.asList(beanInfo.getAttributes());
// }
//
// public boolean isBeanSelected() {
// return objectName != null;
// }
//
//
// public Object getServerURL() {
// return serverURL;
// }
//
// public void fail(CommandAction action, int code) {
// if (exitCode == 0) {
// exitCode = code;
// }
// }
//
// public int getExitCode() {
// return exitCode;
// }
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/command/CommandAction.java
// public interface CommandAction {
//
// void doAction(TJContext tjContext, Output output) throws Exception;
//
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/console/Output.java
// public class Output implements Closeable {
// private final Pattern ansiRemovePattern = Pattern.compile("(@\\|\\w* )|( ?\\|@)");
// private final PrintStream out;
// private boolean useColors = true, ansiInstalled, filterInfo;
//
// public Output(PrintStream out, boolean useColors) {
// this.out = out;
// setUseColors(useColors);
// }
//
// public void setFilterInfo(boolean filterInfo) {
// this.filterInfo = filterInfo;
// }
//
// public boolean isUseColors() {
// return useColors;
// }
//
//
// public void setUseColors(boolean useColors) {
// this.useColors = useColors;
// if (useColors) {
// AnsiConsole.systemInstall();
// ansiInstalled = true;
// } else {
// AnsiConsole.systemUninstall();
// ansiInstalled = false;
// }
// }
//
//
// public void print(String text) {
// if (useColors) {
// out.print(ansi().render(text));
// } else {
// String s = ansiRemovePattern.matcher(text).replaceAll("");
// out.print(s);
// }
// out.flush();
// }
//
//
// public void println(String text) {
// print(text);
// out.println();
// out.flush();
// }
//
//
// @Override
// public void close() throws IOException {
// if (ansiInstalled) {
// AnsiConsole.systemUninstall();
// }
// out.close();
// }
//
// public void outError(String text) {
// println("@|red " + text + "|@");
// }
//
// public void outInfo(String text) {
// if (! filterInfo) {
// println("@|cyan " + text + "|@");
// }
// }
// }
| import org.jsoftware.tjconsole.TJContext;
import org.jsoftware.tjconsole.command.CommandAction;
import org.jsoftware.tjconsole.console.Output;
import javax.management.*;
import javax.management.openmbean.*;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List; | package org.jsoftware.tjconsole.command.definition;
/**
* Get mxBean attribute information (name, if it is read-only or read-write)
*
* @author szalik
*/
public class DescribeCommandDefinition extends AbstractCommandDefinition {
private static final int SPACE = 18;
public DescribeCommandDefinition() {
super("Describe attributes and operations of current bean.", "describe", "describe", true);
}
@Override
public CommandAction action(String input) {
return new CommandAction() {
@Override | // Path: src/main/java/org/jsoftware/tjconsole/TJContext.java
// public class TJContext extends Observable {
// private MBeanServerConnection serverConnection;
// private ObjectName objectName;
// private final Map<String, Object> environment;
// private Object serverURL;
// private int exitCode = 0;
//
// public TJContext() {
// environment = new LinkedHashMap<String, Object>();
// }
//
// public Map<String, Object> getEnvironment() {
// return Collections.unmodifiableMap(environment);
// }
//
// public void setEnvironmentVariable(String key, Object value, boolean check) {
// if (check) {
// if (!environment.containsKey(key)) {
// throw new IllegalArgumentException("Invalid key - " + key);
// }
// Object old = environment.get(key);
// if (!old.getClass().equals(value.getClass())) {
// value = ConvertUtils.convert(value, old.getClass());
// if (!old.getClass().equals(value.getClass())) {
// throw new IllegalArgumentException("Invalid value type - " + value.getClass().getName() + " should be " + old.getClass().getName());
// }
// }
// }
// Object prev = environment.get(key);
// if ((value != null && !value.equals(prev)) || (value == null && prev != null)) {
// setChanged();
// }
// notifyObservers(new UpdateEnvironmentEvent(key, prev, value));
// environment.put(key, value);
// }
//
// public MBeanServerConnection getServer() {
// return serverConnection;
// }
//
// public void setServer(MBeanServerConnection serverConnection, String url) {
// this.serverConnection = serverConnection;
// this.serverURL = url;
// this.objectName = null;
// }
//
// public ObjectName getObjectName() {
// return objectName;
// }
//
// public void setObjectName(ObjectName objectName) {
// this.objectName = objectName;
// }
//
// public boolean isConnected() {
// return serverConnection != null;
// }
//
// public List<MBeanAttributeInfo> getAttributes() throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException {
// if (serverConnection == null || objectName == null) {
// return Collections.emptyList();
// }
// MBeanInfo beanInfo = serverConnection.getMBeanInfo(objectName);
// return Arrays.asList(beanInfo.getAttributes());
// }
//
// public boolean isBeanSelected() {
// return objectName != null;
// }
//
//
// public Object getServerURL() {
// return serverURL;
// }
//
// public void fail(CommandAction action, int code) {
// if (exitCode == 0) {
// exitCode = code;
// }
// }
//
// public int getExitCode() {
// return exitCode;
// }
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/command/CommandAction.java
// public interface CommandAction {
//
// void doAction(TJContext tjContext, Output output) throws Exception;
//
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/console/Output.java
// public class Output implements Closeable {
// private final Pattern ansiRemovePattern = Pattern.compile("(@\\|\\w* )|( ?\\|@)");
// private final PrintStream out;
// private boolean useColors = true, ansiInstalled, filterInfo;
//
// public Output(PrintStream out, boolean useColors) {
// this.out = out;
// setUseColors(useColors);
// }
//
// public void setFilterInfo(boolean filterInfo) {
// this.filterInfo = filterInfo;
// }
//
// public boolean isUseColors() {
// return useColors;
// }
//
//
// public void setUseColors(boolean useColors) {
// this.useColors = useColors;
// if (useColors) {
// AnsiConsole.systemInstall();
// ansiInstalled = true;
// } else {
// AnsiConsole.systemUninstall();
// ansiInstalled = false;
// }
// }
//
//
// public void print(String text) {
// if (useColors) {
// out.print(ansi().render(text));
// } else {
// String s = ansiRemovePattern.matcher(text).replaceAll("");
// out.print(s);
// }
// out.flush();
// }
//
//
// public void println(String text) {
// print(text);
// out.println();
// out.flush();
// }
//
//
// @Override
// public void close() throws IOException {
// if (ansiInstalled) {
// AnsiConsole.systemUninstall();
// }
// out.close();
// }
//
// public void outError(String text) {
// println("@|red " + text + "|@");
// }
//
// public void outInfo(String text) {
// if (! filterInfo) {
// println("@|cyan " + text + "|@");
// }
// }
// }
// Path: src/main/java/org/jsoftware/tjconsole/command/definition/DescribeCommandDefinition.java
import org.jsoftware.tjconsole.TJContext;
import org.jsoftware.tjconsole.command.CommandAction;
import org.jsoftware.tjconsole.console.Output;
import javax.management.*;
import javax.management.openmbean.*;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
package org.jsoftware.tjconsole.command.definition;
/**
* Get mxBean attribute information (name, if it is read-only or read-write)
*
* @author szalik
*/
public class DescribeCommandDefinition extends AbstractCommandDefinition {
private static final int SPACE = 18;
public DescribeCommandDefinition() {
super("Describe attributes and operations of current bean.", "describe", "describe", true);
}
@Override
public CommandAction action(String input) {
return new CommandAction() {
@Override | public void doAction(TJContext ctx, Output output) throws Exception { |
m-szalik/tjconsole | src/main/java/org/jsoftware/tjconsole/command/definition/DescribeCommandDefinition.java | // Path: src/main/java/org/jsoftware/tjconsole/TJContext.java
// public class TJContext extends Observable {
// private MBeanServerConnection serverConnection;
// private ObjectName objectName;
// private final Map<String, Object> environment;
// private Object serverURL;
// private int exitCode = 0;
//
// public TJContext() {
// environment = new LinkedHashMap<String, Object>();
// }
//
// public Map<String, Object> getEnvironment() {
// return Collections.unmodifiableMap(environment);
// }
//
// public void setEnvironmentVariable(String key, Object value, boolean check) {
// if (check) {
// if (!environment.containsKey(key)) {
// throw new IllegalArgumentException("Invalid key - " + key);
// }
// Object old = environment.get(key);
// if (!old.getClass().equals(value.getClass())) {
// value = ConvertUtils.convert(value, old.getClass());
// if (!old.getClass().equals(value.getClass())) {
// throw new IllegalArgumentException("Invalid value type - " + value.getClass().getName() + " should be " + old.getClass().getName());
// }
// }
// }
// Object prev = environment.get(key);
// if ((value != null && !value.equals(prev)) || (value == null && prev != null)) {
// setChanged();
// }
// notifyObservers(new UpdateEnvironmentEvent(key, prev, value));
// environment.put(key, value);
// }
//
// public MBeanServerConnection getServer() {
// return serverConnection;
// }
//
// public void setServer(MBeanServerConnection serverConnection, String url) {
// this.serverConnection = serverConnection;
// this.serverURL = url;
// this.objectName = null;
// }
//
// public ObjectName getObjectName() {
// return objectName;
// }
//
// public void setObjectName(ObjectName objectName) {
// this.objectName = objectName;
// }
//
// public boolean isConnected() {
// return serverConnection != null;
// }
//
// public List<MBeanAttributeInfo> getAttributes() throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException {
// if (serverConnection == null || objectName == null) {
// return Collections.emptyList();
// }
// MBeanInfo beanInfo = serverConnection.getMBeanInfo(objectName);
// return Arrays.asList(beanInfo.getAttributes());
// }
//
// public boolean isBeanSelected() {
// return objectName != null;
// }
//
//
// public Object getServerURL() {
// return serverURL;
// }
//
// public void fail(CommandAction action, int code) {
// if (exitCode == 0) {
// exitCode = code;
// }
// }
//
// public int getExitCode() {
// return exitCode;
// }
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/command/CommandAction.java
// public interface CommandAction {
//
// void doAction(TJContext tjContext, Output output) throws Exception;
//
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/console/Output.java
// public class Output implements Closeable {
// private final Pattern ansiRemovePattern = Pattern.compile("(@\\|\\w* )|( ?\\|@)");
// private final PrintStream out;
// private boolean useColors = true, ansiInstalled, filterInfo;
//
// public Output(PrintStream out, boolean useColors) {
// this.out = out;
// setUseColors(useColors);
// }
//
// public void setFilterInfo(boolean filterInfo) {
// this.filterInfo = filterInfo;
// }
//
// public boolean isUseColors() {
// return useColors;
// }
//
//
// public void setUseColors(boolean useColors) {
// this.useColors = useColors;
// if (useColors) {
// AnsiConsole.systemInstall();
// ansiInstalled = true;
// } else {
// AnsiConsole.systemUninstall();
// ansiInstalled = false;
// }
// }
//
//
// public void print(String text) {
// if (useColors) {
// out.print(ansi().render(text));
// } else {
// String s = ansiRemovePattern.matcher(text).replaceAll("");
// out.print(s);
// }
// out.flush();
// }
//
//
// public void println(String text) {
// print(text);
// out.println();
// out.flush();
// }
//
//
// @Override
// public void close() throws IOException {
// if (ansiInstalled) {
// AnsiConsole.systemUninstall();
// }
// out.close();
// }
//
// public void outError(String text) {
// println("@|red " + text + "|@");
// }
//
// public void outInfo(String text) {
// if (! filterInfo) {
// println("@|cyan " + text + "|@");
// }
// }
// }
| import org.jsoftware.tjconsole.TJContext;
import org.jsoftware.tjconsole.command.CommandAction;
import org.jsoftware.tjconsole.console.Output;
import javax.management.*;
import javax.management.openmbean.*;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List; | package org.jsoftware.tjconsole.command.definition;
/**
* Get mxBean attribute information (name, if it is read-only or read-write)
*
* @author szalik
*/
public class DescribeCommandDefinition extends AbstractCommandDefinition {
private static final int SPACE = 18;
public DescribeCommandDefinition() {
super("Describe attributes and operations of current bean.", "describe", "describe", true);
}
@Override
public CommandAction action(String input) {
return new CommandAction() {
@Override | // Path: src/main/java/org/jsoftware/tjconsole/TJContext.java
// public class TJContext extends Observable {
// private MBeanServerConnection serverConnection;
// private ObjectName objectName;
// private final Map<String, Object> environment;
// private Object serverURL;
// private int exitCode = 0;
//
// public TJContext() {
// environment = new LinkedHashMap<String, Object>();
// }
//
// public Map<String, Object> getEnvironment() {
// return Collections.unmodifiableMap(environment);
// }
//
// public void setEnvironmentVariable(String key, Object value, boolean check) {
// if (check) {
// if (!environment.containsKey(key)) {
// throw new IllegalArgumentException("Invalid key - " + key);
// }
// Object old = environment.get(key);
// if (!old.getClass().equals(value.getClass())) {
// value = ConvertUtils.convert(value, old.getClass());
// if (!old.getClass().equals(value.getClass())) {
// throw new IllegalArgumentException("Invalid value type - " + value.getClass().getName() + " should be " + old.getClass().getName());
// }
// }
// }
// Object prev = environment.get(key);
// if ((value != null && !value.equals(prev)) || (value == null && prev != null)) {
// setChanged();
// }
// notifyObservers(new UpdateEnvironmentEvent(key, prev, value));
// environment.put(key, value);
// }
//
// public MBeanServerConnection getServer() {
// return serverConnection;
// }
//
// public void setServer(MBeanServerConnection serverConnection, String url) {
// this.serverConnection = serverConnection;
// this.serverURL = url;
// this.objectName = null;
// }
//
// public ObjectName getObjectName() {
// return objectName;
// }
//
// public void setObjectName(ObjectName objectName) {
// this.objectName = objectName;
// }
//
// public boolean isConnected() {
// return serverConnection != null;
// }
//
// public List<MBeanAttributeInfo> getAttributes() throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException {
// if (serverConnection == null || objectName == null) {
// return Collections.emptyList();
// }
// MBeanInfo beanInfo = serverConnection.getMBeanInfo(objectName);
// return Arrays.asList(beanInfo.getAttributes());
// }
//
// public boolean isBeanSelected() {
// return objectName != null;
// }
//
//
// public Object getServerURL() {
// return serverURL;
// }
//
// public void fail(CommandAction action, int code) {
// if (exitCode == 0) {
// exitCode = code;
// }
// }
//
// public int getExitCode() {
// return exitCode;
// }
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/command/CommandAction.java
// public interface CommandAction {
//
// void doAction(TJContext tjContext, Output output) throws Exception;
//
// }
//
// Path: src/main/java/org/jsoftware/tjconsole/console/Output.java
// public class Output implements Closeable {
// private final Pattern ansiRemovePattern = Pattern.compile("(@\\|\\w* )|( ?\\|@)");
// private final PrintStream out;
// private boolean useColors = true, ansiInstalled, filterInfo;
//
// public Output(PrintStream out, boolean useColors) {
// this.out = out;
// setUseColors(useColors);
// }
//
// public void setFilterInfo(boolean filterInfo) {
// this.filterInfo = filterInfo;
// }
//
// public boolean isUseColors() {
// return useColors;
// }
//
//
// public void setUseColors(boolean useColors) {
// this.useColors = useColors;
// if (useColors) {
// AnsiConsole.systemInstall();
// ansiInstalled = true;
// } else {
// AnsiConsole.systemUninstall();
// ansiInstalled = false;
// }
// }
//
//
// public void print(String text) {
// if (useColors) {
// out.print(ansi().render(text));
// } else {
// String s = ansiRemovePattern.matcher(text).replaceAll("");
// out.print(s);
// }
// out.flush();
// }
//
//
// public void println(String text) {
// print(text);
// out.println();
// out.flush();
// }
//
//
// @Override
// public void close() throws IOException {
// if (ansiInstalled) {
// AnsiConsole.systemUninstall();
// }
// out.close();
// }
//
// public void outError(String text) {
// println("@|red " + text + "|@");
// }
//
// public void outInfo(String text) {
// if (! filterInfo) {
// println("@|cyan " + text + "|@");
// }
// }
// }
// Path: src/main/java/org/jsoftware/tjconsole/command/definition/DescribeCommandDefinition.java
import org.jsoftware.tjconsole.TJContext;
import org.jsoftware.tjconsole.command.CommandAction;
import org.jsoftware.tjconsole.console.Output;
import javax.management.*;
import javax.management.openmbean.*;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
package org.jsoftware.tjconsole.command.definition;
/**
* Get mxBean attribute information (name, if it is read-only or read-write)
*
* @author szalik
*/
public class DescribeCommandDefinition extends AbstractCommandDefinition {
private static final int SPACE = 18;
public DescribeCommandDefinition() {
super("Describe attributes and operations of current bean.", "describe", "describe", true);
}
@Override
public CommandAction action(String input) {
return new CommandAction() {
@Override | public void doAction(TJContext ctx, Output output) throws Exception { |
neo4j/docker-neo4j | src/test/java/com/neo4j/docker/neo4jadmin/TestAdminBasic.java | // Path: src/test/java/com/neo4j/docker/utils/TestSettings.java
// public class TestSettings
// {
// public static final Neo4jVersion NEO4J_VERSION = Neo4jVersion.fromVersionString( getVersionFromPropertyOrEnv() );
// public static final String IMAGE_ID = getImageFromPropertyOrEnv();
// public static final String ADMIN_IMAGE_ID = getNeo4jAdminImageFromPropertyOrEnv();
// public static final Path TEST_TMP_FOLDER = Paths.get("local-mounts" );
// public static final Edition EDITION = getEditionFromPropertyOrEnv();
//
// public enum Edition
// {
// COMMUNITY,
// ENTERPRISE;
// }
//
// private static String getVersionFromPropertyOrEnv()
// {
// String verStr = System.getProperty( "version" );
// if(verStr == null)
// {
// verStr = System.getenv( "NEO4JVERSION" );
// }
// Assert.assertNotNull("Neo4j version has not been specified, either use mvn argument -Dversion or set env NEO4JVERSION", verStr);
// return verStr;
// }
//
// private static String getImageFromPropertyOrEnv()
// {
// String image = System.getProperty( "image" );
// if(image == null)
// {
// image = System.getenv( "NEO4J_IMAGE" );
// }
// Assert.assertNotNull("Neo4j image has not been specified, either use mvn argument -Dimage or set env NEO4J_IMAGE", image);
// return image;
// }
//
// private static String getNeo4jAdminImageFromPropertyOrEnv()
// {
// String image = System.getProperty( "adminimage" );
// if(image == null)
// {
// image = System.getenv( "NEO4JADMIN_IMAGE" );
// }
// Assert.assertNotNull("Neo4j image has not been specified, either use mvn argument -Dadminimage or set env NEO4JADMIN_IMAGE", image);
// return image;
// }
//
// private static Edition getEditionFromPropertyOrEnv()
// {
// String edition = System.getProperty( "edition" );
// if(edition == null)
// {
// edition = System.getenv( "NEO4J_EDITION" );
// }
// switch ( edition.toLowerCase() )
// {
// case "community":
// return Edition.COMMUNITY;
// case "enterprise":
// return Edition.ENTERPRISE;
// default:
// Assert.fail( "Neo4j edition has not been specified, either use mvn argument -Dedition or set env NEO4J_EDITION" );
// }
// return null;
// }
// }
| import com.neo4j.docker.utils.TestSettings;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testcontainers.containers.ContainerLaunchException;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.output.Slf4jLogConsumer;
import org.testcontainers.containers.startupcheck.OneShotStartupCheckStrategy;
import org.testcontainers.containers.wait.strategy.HttpWaitStrategy;
import java.time.Duration; | package com.neo4j.docker.neo4jadmin;
public class TestAdminBasic
{
private static final Logger log = LoggerFactory.getLogger( TestAdminBasic.class );
@Test
void testCannotRunNeo4j()
{ | // Path: src/test/java/com/neo4j/docker/utils/TestSettings.java
// public class TestSettings
// {
// public static final Neo4jVersion NEO4J_VERSION = Neo4jVersion.fromVersionString( getVersionFromPropertyOrEnv() );
// public static final String IMAGE_ID = getImageFromPropertyOrEnv();
// public static final String ADMIN_IMAGE_ID = getNeo4jAdminImageFromPropertyOrEnv();
// public static final Path TEST_TMP_FOLDER = Paths.get("local-mounts" );
// public static final Edition EDITION = getEditionFromPropertyOrEnv();
//
// public enum Edition
// {
// COMMUNITY,
// ENTERPRISE;
// }
//
// private static String getVersionFromPropertyOrEnv()
// {
// String verStr = System.getProperty( "version" );
// if(verStr == null)
// {
// verStr = System.getenv( "NEO4JVERSION" );
// }
// Assert.assertNotNull("Neo4j version has not been specified, either use mvn argument -Dversion or set env NEO4JVERSION", verStr);
// return verStr;
// }
//
// private static String getImageFromPropertyOrEnv()
// {
// String image = System.getProperty( "image" );
// if(image == null)
// {
// image = System.getenv( "NEO4J_IMAGE" );
// }
// Assert.assertNotNull("Neo4j image has not been specified, either use mvn argument -Dimage or set env NEO4J_IMAGE", image);
// return image;
// }
//
// private static String getNeo4jAdminImageFromPropertyOrEnv()
// {
// String image = System.getProperty( "adminimage" );
// if(image == null)
// {
// image = System.getenv( "NEO4JADMIN_IMAGE" );
// }
// Assert.assertNotNull("Neo4j image has not been specified, either use mvn argument -Dadminimage or set env NEO4JADMIN_IMAGE", image);
// return image;
// }
//
// private static Edition getEditionFromPropertyOrEnv()
// {
// String edition = System.getProperty( "edition" );
// if(edition == null)
// {
// edition = System.getenv( "NEO4J_EDITION" );
// }
// switch ( edition.toLowerCase() )
// {
// case "community":
// return Edition.COMMUNITY;
// case "enterprise":
// return Edition.ENTERPRISE;
// default:
// Assert.fail( "Neo4j edition has not been specified, either use mvn argument -Dedition or set env NEO4J_EDITION" );
// }
// return null;
// }
// }
// Path: src/test/java/com/neo4j/docker/neo4jadmin/TestAdminBasic.java
import com.neo4j.docker.utils.TestSettings;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testcontainers.containers.ContainerLaunchException;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.output.Slf4jLogConsumer;
import org.testcontainers.containers.startupcheck.OneShotStartupCheckStrategy;
import org.testcontainers.containers.wait.strategy.HttpWaitStrategy;
import java.time.Duration;
package com.neo4j.docker.neo4jadmin;
public class TestAdminBasic
{
private static final Logger log = LoggerFactory.getLogger( TestAdminBasic.class );
@Test
void testCannotRunNeo4j()
{ | GenericContainer admin = new GenericContainer( TestSettings.ADMIN_IMAGE_ID ); |
neo4j/docker-neo4j | src/test/java/com/neo4j/docker/neo4jserver/TestPluginInstallation.java | // Path: src/test/java/com/neo4j/docker/neo4jserver/plugins/ExampleNeo4jPlugin.java
// public class ExampleNeo4jPlugin
// {
// // Output data class containing primitive types
// public static class PrimitiveOutput
// {
// public String string;
// public long integer;
// public double aFloat;
// public boolean aBoolean;
//
// public PrimitiveOutput( String string, long integer, double aFloat, boolean aBoolean )
// {
// this.string = string;
// this.integer = integer;
// this.aFloat = aFloat;
// this.aBoolean = aBoolean;
// }
// }
// // @ServiceProvider
// // public static class ExampleConfigurationSetting implements SettingsDeclaration
// // {
// // public static final String CONF_NAME = "com.neo4j.docker.neo4jserver.plugins.loaded_verison";
// //
// // @Description("Unique setting to identify which semver field was matched")
// // public static final Setting<String> loadedVersionValue = SettingImpl.newBuilder(
// // CONF_NAME,
// // SettingValueParsers.STRING,
// // "unset"
// // ).build();
// // }
//
// @Context
// public GraphDatabaseService db;
//
// @Context
// public Log log;
//
// // A Neo4j procedure that always returns fixed values
// @Procedure
// public Stream<PrimitiveOutput> defaultValues( @Name( value = "string", defaultValue = "a string" ) String string,
// @Name( value = "integer", defaultValue = "42" ) long integer,
// @Name( value = "float", defaultValue = "3.14" ) double aFloat,
// @Name( value = "boolean", defaultValue = "true" ) boolean aBoolean )
// {
// return Stream.of( new PrimitiveOutput( string, integer, aFloat, aBoolean ) );
// }
// }
//
// Path: src/test/java/com/neo4j/docker/neo4jserver/plugins/JarBuilder.java
// public class JarBuilder
// {
// public URL createJarFor( File f, Class<?>... classesToInclude ) throws IOException
// {
// try ( FileOutputStream fout = new FileOutputStream( f ); JarOutputStream jarOut = new JarOutputStream( fout ) )
// {
// for ( Class<?> target : classesToInclude )
// {
// String fileName = target.getName().replace( ".", "/" ) + ".class";
// jarOut.putNextEntry( new ZipEntry( fileName ) );
// jarOut.write( classCompiledBytes( fileName ) );
// jarOut.closeEntry();
// }
// }
// return f.toURI().toURL();
// }
//
// private byte[] classCompiledBytes( String fileName ) throws IOException
// {
// try ( InputStream in = getClass().getClassLoader().getResourceAsStream( fileName ) )
// {
// ByteArrayOutputStream out = new ByteArrayOutputStream();
// while ( in.available() > 0 )
// {
// out.write( in.read() );
// }
//
// return out.toByteArray();
// }
// }
// }
//
// Path: src/test/java/com/neo4j/docker/utils/TestSettings.java
// public static final Neo4jVersion NEO4J_VERSION = Neo4jVersion.fromVersionString( getVersionFromPropertyOrEnv() );
| import com.github.dockerjava.api.command.CreateContainerCmd;
import com.google.gson.Gson;
import com.neo4j.docker.neo4jserver.plugins.ExampleNeo4jPlugin;
import com.neo4j.docker.utils.*;
import com.neo4j.docker.neo4jserver.plugins.JarBuilder;
import org.junit.Rule;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable;
import org.junit.jupiter.migrationsupport.rules.EnableRuleMigrationSupport;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testcontainers.Testcontainers;
import org.testcontainers.containers.Container;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.output.Slf4jLogConsumer;
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.shaded.com.google.common.io.Files;
import java.io.File;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import org.neo4j.driver.Record;
import static com.neo4j.docker.utils.TestSettings.NEO4J_VERSION; |
container.withEnv( "NEO4J_AUTH", DB_USER+"/"+ DB_PASSWORD)
.withEnv( "NEO4J_ACCEPT_LICENSE_AGREEMENT", "yes" )
.withEnv( "NEO4JLABS_PLUGINS", "[\"_testing\"]" )
.withExposedPorts( 7474, 7687 )
.withLogConsumer( new Slf4jLogConsumer( log ) )
.waitingFor( Wait.forHttp( "/" )
.forPort( 7474 )
.forStatusCode( 200 ) );
SetContainerUser.nonRootUser( container );
return container;
}
private File createTestVersionsJson(Path destinationFolder, String... versions) throws Exception
{
List<VersionsJsonEntry> entryList = Arrays.stream( versions )
.map( VersionsJsonEntry::new )
.collect( Collectors.toList() );
Gson jsonBuilder = new Gson();
String jsonStr = jsonBuilder.toJson( entryList );
File outputJsonFile = destinationFolder.resolve( "versions.json" ).toFile();
Files.write( jsonStr, outputJsonFile, StandardCharsets.UTF_8 );
return outputJsonFile;
}
private void setupTestPlugin( Path pluginsDir, File versionsJson ) throws Exception
{
File myPluginJar = pluginsDir.resolve( PLUGIN_JAR ).toFile(); | // Path: src/test/java/com/neo4j/docker/neo4jserver/plugins/ExampleNeo4jPlugin.java
// public class ExampleNeo4jPlugin
// {
// // Output data class containing primitive types
// public static class PrimitiveOutput
// {
// public String string;
// public long integer;
// public double aFloat;
// public boolean aBoolean;
//
// public PrimitiveOutput( String string, long integer, double aFloat, boolean aBoolean )
// {
// this.string = string;
// this.integer = integer;
// this.aFloat = aFloat;
// this.aBoolean = aBoolean;
// }
// }
// // @ServiceProvider
// // public static class ExampleConfigurationSetting implements SettingsDeclaration
// // {
// // public static final String CONF_NAME = "com.neo4j.docker.neo4jserver.plugins.loaded_verison";
// //
// // @Description("Unique setting to identify which semver field was matched")
// // public static final Setting<String> loadedVersionValue = SettingImpl.newBuilder(
// // CONF_NAME,
// // SettingValueParsers.STRING,
// // "unset"
// // ).build();
// // }
//
// @Context
// public GraphDatabaseService db;
//
// @Context
// public Log log;
//
// // A Neo4j procedure that always returns fixed values
// @Procedure
// public Stream<PrimitiveOutput> defaultValues( @Name( value = "string", defaultValue = "a string" ) String string,
// @Name( value = "integer", defaultValue = "42" ) long integer,
// @Name( value = "float", defaultValue = "3.14" ) double aFloat,
// @Name( value = "boolean", defaultValue = "true" ) boolean aBoolean )
// {
// return Stream.of( new PrimitiveOutput( string, integer, aFloat, aBoolean ) );
// }
// }
//
// Path: src/test/java/com/neo4j/docker/neo4jserver/plugins/JarBuilder.java
// public class JarBuilder
// {
// public URL createJarFor( File f, Class<?>... classesToInclude ) throws IOException
// {
// try ( FileOutputStream fout = new FileOutputStream( f ); JarOutputStream jarOut = new JarOutputStream( fout ) )
// {
// for ( Class<?> target : classesToInclude )
// {
// String fileName = target.getName().replace( ".", "/" ) + ".class";
// jarOut.putNextEntry( new ZipEntry( fileName ) );
// jarOut.write( classCompiledBytes( fileName ) );
// jarOut.closeEntry();
// }
// }
// return f.toURI().toURL();
// }
//
// private byte[] classCompiledBytes( String fileName ) throws IOException
// {
// try ( InputStream in = getClass().getClassLoader().getResourceAsStream( fileName ) )
// {
// ByteArrayOutputStream out = new ByteArrayOutputStream();
// while ( in.available() > 0 )
// {
// out.write( in.read() );
// }
//
// return out.toByteArray();
// }
// }
// }
//
// Path: src/test/java/com/neo4j/docker/utils/TestSettings.java
// public static final Neo4jVersion NEO4J_VERSION = Neo4jVersion.fromVersionString( getVersionFromPropertyOrEnv() );
// Path: src/test/java/com/neo4j/docker/neo4jserver/TestPluginInstallation.java
import com.github.dockerjava.api.command.CreateContainerCmd;
import com.google.gson.Gson;
import com.neo4j.docker.neo4jserver.plugins.ExampleNeo4jPlugin;
import com.neo4j.docker.utils.*;
import com.neo4j.docker.neo4jserver.plugins.JarBuilder;
import org.junit.Rule;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable;
import org.junit.jupiter.migrationsupport.rules.EnableRuleMigrationSupport;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testcontainers.Testcontainers;
import org.testcontainers.containers.Container;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.output.Slf4jLogConsumer;
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.shaded.com.google.common.io.Files;
import java.io.File;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import org.neo4j.driver.Record;
import static com.neo4j.docker.utils.TestSettings.NEO4J_VERSION;
container.withEnv( "NEO4J_AUTH", DB_USER+"/"+ DB_PASSWORD)
.withEnv( "NEO4J_ACCEPT_LICENSE_AGREEMENT", "yes" )
.withEnv( "NEO4JLABS_PLUGINS", "[\"_testing\"]" )
.withExposedPorts( 7474, 7687 )
.withLogConsumer( new Slf4jLogConsumer( log ) )
.waitingFor( Wait.forHttp( "/" )
.forPort( 7474 )
.forStatusCode( 200 ) );
SetContainerUser.nonRootUser( container );
return container;
}
private File createTestVersionsJson(Path destinationFolder, String... versions) throws Exception
{
List<VersionsJsonEntry> entryList = Arrays.stream( versions )
.map( VersionsJsonEntry::new )
.collect( Collectors.toList() );
Gson jsonBuilder = new Gson();
String jsonStr = jsonBuilder.toJson( entryList );
File outputJsonFile = destinationFolder.resolve( "versions.json" ).toFile();
Files.write( jsonStr, outputJsonFile, StandardCharsets.UTF_8 );
return outputJsonFile;
}
private void setupTestPlugin( Path pluginsDir, File versionsJson ) throws Exception
{
File myPluginJar = pluginsDir.resolve( PLUGIN_JAR ).toFile(); | new JarBuilder().createJarFor( myPluginJar, ExampleNeo4jPlugin.class, ExampleNeo4jPlugin.PrimitiveOutput.class ); |
neo4j/docker-neo4j | src/test/java/com/neo4j/docker/neo4jserver/TestPluginInstallation.java | // Path: src/test/java/com/neo4j/docker/neo4jserver/plugins/ExampleNeo4jPlugin.java
// public class ExampleNeo4jPlugin
// {
// // Output data class containing primitive types
// public static class PrimitiveOutput
// {
// public String string;
// public long integer;
// public double aFloat;
// public boolean aBoolean;
//
// public PrimitiveOutput( String string, long integer, double aFloat, boolean aBoolean )
// {
// this.string = string;
// this.integer = integer;
// this.aFloat = aFloat;
// this.aBoolean = aBoolean;
// }
// }
// // @ServiceProvider
// // public static class ExampleConfigurationSetting implements SettingsDeclaration
// // {
// // public static final String CONF_NAME = "com.neo4j.docker.neo4jserver.plugins.loaded_verison";
// //
// // @Description("Unique setting to identify which semver field was matched")
// // public static final Setting<String> loadedVersionValue = SettingImpl.newBuilder(
// // CONF_NAME,
// // SettingValueParsers.STRING,
// // "unset"
// // ).build();
// // }
//
// @Context
// public GraphDatabaseService db;
//
// @Context
// public Log log;
//
// // A Neo4j procedure that always returns fixed values
// @Procedure
// public Stream<PrimitiveOutput> defaultValues( @Name( value = "string", defaultValue = "a string" ) String string,
// @Name( value = "integer", defaultValue = "42" ) long integer,
// @Name( value = "float", defaultValue = "3.14" ) double aFloat,
// @Name( value = "boolean", defaultValue = "true" ) boolean aBoolean )
// {
// return Stream.of( new PrimitiveOutput( string, integer, aFloat, aBoolean ) );
// }
// }
//
// Path: src/test/java/com/neo4j/docker/neo4jserver/plugins/JarBuilder.java
// public class JarBuilder
// {
// public URL createJarFor( File f, Class<?>... classesToInclude ) throws IOException
// {
// try ( FileOutputStream fout = new FileOutputStream( f ); JarOutputStream jarOut = new JarOutputStream( fout ) )
// {
// for ( Class<?> target : classesToInclude )
// {
// String fileName = target.getName().replace( ".", "/" ) + ".class";
// jarOut.putNextEntry( new ZipEntry( fileName ) );
// jarOut.write( classCompiledBytes( fileName ) );
// jarOut.closeEntry();
// }
// }
// return f.toURI().toURL();
// }
//
// private byte[] classCompiledBytes( String fileName ) throws IOException
// {
// try ( InputStream in = getClass().getClassLoader().getResourceAsStream( fileName ) )
// {
// ByteArrayOutputStream out = new ByteArrayOutputStream();
// while ( in.available() > 0 )
// {
// out.write( in.read() );
// }
//
// return out.toByteArray();
// }
// }
// }
//
// Path: src/test/java/com/neo4j/docker/utils/TestSettings.java
// public static final Neo4jVersion NEO4J_VERSION = Neo4jVersion.fromVersionString( getVersionFromPropertyOrEnv() );
| import com.github.dockerjava.api.command.CreateContainerCmd;
import com.google.gson.Gson;
import com.neo4j.docker.neo4jserver.plugins.ExampleNeo4jPlugin;
import com.neo4j.docker.utils.*;
import com.neo4j.docker.neo4jserver.plugins.JarBuilder;
import org.junit.Rule;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable;
import org.junit.jupiter.migrationsupport.rules.EnableRuleMigrationSupport;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testcontainers.Testcontainers;
import org.testcontainers.containers.Container;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.output.Slf4jLogConsumer;
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.shaded.com.google.common.io.Files;
import java.io.File;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import org.neo4j.driver.Record;
import static com.neo4j.docker.utils.TestSettings.NEO4J_VERSION; |
container.withEnv( "NEO4J_AUTH", DB_USER+"/"+ DB_PASSWORD)
.withEnv( "NEO4J_ACCEPT_LICENSE_AGREEMENT", "yes" )
.withEnv( "NEO4JLABS_PLUGINS", "[\"_testing\"]" )
.withExposedPorts( 7474, 7687 )
.withLogConsumer( new Slf4jLogConsumer( log ) )
.waitingFor( Wait.forHttp( "/" )
.forPort( 7474 )
.forStatusCode( 200 ) );
SetContainerUser.nonRootUser( container );
return container;
}
private File createTestVersionsJson(Path destinationFolder, String... versions) throws Exception
{
List<VersionsJsonEntry> entryList = Arrays.stream( versions )
.map( VersionsJsonEntry::new )
.collect( Collectors.toList() );
Gson jsonBuilder = new Gson();
String jsonStr = jsonBuilder.toJson( entryList );
File outputJsonFile = destinationFolder.resolve( "versions.json" ).toFile();
Files.write( jsonStr, outputJsonFile, StandardCharsets.UTF_8 );
return outputJsonFile;
}
private void setupTestPlugin( Path pluginsDir, File versionsJson ) throws Exception
{
File myPluginJar = pluginsDir.resolve( PLUGIN_JAR ).toFile(); | // Path: src/test/java/com/neo4j/docker/neo4jserver/plugins/ExampleNeo4jPlugin.java
// public class ExampleNeo4jPlugin
// {
// // Output data class containing primitive types
// public static class PrimitiveOutput
// {
// public String string;
// public long integer;
// public double aFloat;
// public boolean aBoolean;
//
// public PrimitiveOutput( String string, long integer, double aFloat, boolean aBoolean )
// {
// this.string = string;
// this.integer = integer;
// this.aFloat = aFloat;
// this.aBoolean = aBoolean;
// }
// }
// // @ServiceProvider
// // public static class ExampleConfigurationSetting implements SettingsDeclaration
// // {
// // public static final String CONF_NAME = "com.neo4j.docker.neo4jserver.plugins.loaded_verison";
// //
// // @Description("Unique setting to identify which semver field was matched")
// // public static final Setting<String> loadedVersionValue = SettingImpl.newBuilder(
// // CONF_NAME,
// // SettingValueParsers.STRING,
// // "unset"
// // ).build();
// // }
//
// @Context
// public GraphDatabaseService db;
//
// @Context
// public Log log;
//
// // A Neo4j procedure that always returns fixed values
// @Procedure
// public Stream<PrimitiveOutput> defaultValues( @Name( value = "string", defaultValue = "a string" ) String string,
// @Name( value = "integer", defaultValue = "42" ) long integer,
// @Name( value = "float", defaultValue = "3.14" ) double aFloat,
// @Name( value = "boolean", defaultValue = "true" ) boolean aBoolean )
// {
// return Stream.of( new PrimitiveOutput( string, integer, aFloat, aBoolean ) );
// }
// }
//
// Path: src/test/java/com/neo4j/docker/neo4jserver/plugins/JarBuilder.java
// public class JarBuilder
// {
// public URL createJarFor( File f, Class<?>... classesToInclude ) throws IOException
// {
// try ( FileOutputStream fout = new FileOutputStream( f ); JarOutputStream jarOut = new JarOutputStream( fout ) )
// {
// for ( Class<?> target : classesToInclude )
// {
// String fileName = target.getName().replace( ".", "/" ) + ".class";
// jarOut.putNextEntry( new ZipEntry( fileName ) );
// jarOut.write( classCompiledBytes( fileName ) );
// jarOut.closeEntry();
// }
// }
// return f.toURI().toURL();
// }
//
// private byte[] classCompiledBytes( String fileName ) throws IOException
// {
// try ( InputStream in = getClass().getClassLoader().getResourceAsStream( fileName ) )
// {
// ByteArrayOutputStream out = new ByteArrayOutputStream();
// while ( in.available() > 0 )
// {
// out.write( in.read() );
// }
//
// return out.toByteArray();
// }
// }
// }
//
// Path: src/test/java/com/neo4j/docker/utils/TestSettings.java
// public static final Neo4jVersion NEO4J_VERSION = Neo4jVersion.fromVersionString( getVersionFromPropertyOrEnv() );
// Path: src/test/java/com/neo4j/docker/neo4jserver/TestPluginInstallation.java
import com.github.dockerjava.api.command.CreateContainerCmd;
import com.google.gson.Gson;
import com.neo4j.docker.neo4jserver.plugins.ExampleNeo4jPlugin;
import com.neo4j.docker.utils.*;
import com.neo4j.docker.neo4jserver.plugins.JarBuilder;
import org.junit.Rule;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable;
import org.junit.jupiter.migrationsupport.rules.EnableRuleMigrationSupport;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testcontainers.Testcontainers;
import org.testcontainers.containers.Container;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.output.Slf4jLogConsumer;
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.shaded.com.google.common.io.Files;
import java.io.File;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import org.neo4j.driver.Record;
import static com.neo4j.docker.utils.TestSettings.NEO4J_VERSION;
container.withEnv( "NEO4J_AUTH", DB_USER+"/"+ DB_PASSWORD)
.withEnv( "NEO4J_ACCEPT_LICENSE_AGREEMENT", "yes" )
.withEnv( "NEO4JLABS_PLUGINS", "[\"_testing\"]" )
.withExposedPorts( 7474, 7687 )
.withLogConsumer( new Slf4jLogConsumer( log ) )
.waitingFor( Wait.forHttp( "/" )
.forPort( 7474 )
.forStatusCode( 200 ) );
SetContainerUser.nonRootUser( container );
return container;
}
private File createTestVersionsJson(Path destinationFolder, String... versions) throws Exception
{
List<VersionsJsonEntry> entryList = Arrays.stream( versions )
.map( VersionsJsonEntry::new )
.collect( Collectors.toList() );
Gson jsonBuilder = new Gson();
String jsonStr = jsonBuilder.toJson( entryList );
File outputJsonFile = destinationFolder.resolve( "versions.json" ).toFile();
Files.write( jsonStr, outputJsonFile, StandardCharsets.UTF_8 );
return outputJsonFile;
}
private void setupTestPlugin( Path pluginsDir, File versionsJson ) throws Exception
{
File myPluginJar = pluginsDir.resolve( PLUGIN_JAR ).toFile(); | new JarBuilder().createJarFor( myPluginJar, ExampleNeo4jPlugin.class, ExampleNeo4jPlugin.PrimitiveOutput.class ); |
neo4j/docker-neo4j | src/test/java/com/neo4j/docker/neo4jserver/TestPluginInstallation.java | // Path: src/test/java/com/neo4j/docker/neo4jserver/plugins/ExampleNeo4jPlugin.java
// public class ExampleNeo4jPlugin
// {
// // Output data class containing primitive types
// public static class PrimitiveOutput
// {
// public String string;
// public long integer;
// public double aFloat;
// public boolean aBoolean;
//
// public PrimitiveOutput( String string, long integer, double aFloat, boolean aBoolean )
// {
// this.string = string;
// this.integer = integer;
// this.aFloat = aFloat;
// this.aBoolean = aBoolean;
// }
// }
// // @ServiceProvider
// // public static class ExampleConfigurationSetting implements SettingsDeclaration
// // {
// // public static final String CONF_NAME = "com.neo4j.docker.neo4jserver.plugins.loaded_verison";
// //
// // @Description("Unique setting to identify which semver field was matched")
// // public static final Setting<String> loadedVersionValue = SettingImpl.newBuilder(
// // CONF_NAME,
// // SettingValueParsers.STRING,
// // "unset"
// // ).build();
// // }
//
// @Context
// public GraphDatabaseService db;
//
// @Context
// public Log log;
//
// // A Neo4j procedure that always returns fixed values
// @Procedure
// public Stream<PrimitiveOutput> defaultValues( @Name( value = "string", defaultValue = "a string" ) String string,
// @Name( value = "integer", defaultValue = "42" ) long integer,
// @Name( value = "float", defaultValue = "3.14" ) double aFloat,
// @Name( value = "boolean", defaultValue = "true" ) boolean aBoolean )
// {
// return Stream.of( new PrimitiveOutput( string, integer, aFloat, aBoolean ) );
// }
// }
//
// Path: src/test/java/com/neo4j/docker/neo4jserver/plugins/JarBuilder.java
// public class JarBuilder
// {
// public URL createJarFor( File f, Class<?>... classesToInclude ) throws IOException
// {
// try ( FileOutputStream fout = new FileOutputStream( f ); JarOutputStream jarOut = new JarOutputStream( fout ) )
// {
// for ( Class<?> target : classesToInclude )
// {
// String fileName = target.getName().replace( ".", "/" ) + ".class";
// jarOut.putNextEntry( new ZipEntry( fileName ) );
// jarOut.write( classCompiledBytes( fileName ) );
// jarOut.closeEntry();
// }
// }
// return f.toURI().toURL();
// }
//
// private byte[] classCompiledBytes( String fileName ) throws IOException
// {
// try ( InputStream in = getClass().getClassLoader().getResourceAsStream( fileName ) )
// {
// ByteArrayOutputStream out = new ByteArrayOutputStream();
// while ( in.available() > 0 )
// {
// out.write( in.read() );
// }
//
// return out.toByteArray();
// }
// }
// }
//
// Path: src/test/java/com/neo4j/docker/utils/TestSettings.java
// public static final Neo4jVersion NEO4J_VERSION = Neo4jVersion.fromVersionString( getVersionFromPropertyOrEnv() );
| import com.github.dockerjava.api.command.CreateContainerCmd;
import com.google.gson.Gson;
import com.neo4j.docker.neo4jserver.plugins.ExampleNeo4jPlugin;
import com.neo4j.docker.utils.*;
import com.neo4j.docker.neo4jserver.plugins.JarBuilder;
import org.junit.Rule;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable;
import org.junit.jupiter.migrationsupport.rules.EnableRuleMigrationSupport;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testcontainers.Testcontainers;
import org.testcontainers.containers.Container;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.output.Slf4jLogConsumer;
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.shaded.com.google.common.io.Files;
import java.io.File;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import org.neo4j.driver.Record;
import static com.neo4j.docker.utils.TestSettings.NEO4J_VERSION; |
SetContainerUser.nonRootUser( container );
return container;
}
private File createTestVersionsJson(Path destinationFolder, String... versions) throws Exception
{
List<VersionsJsonEntry> entryList = Arrays.stream( versions )
.map( VersionsJsonEntry::new )
.collect( Collectors.toList() );
Gson jsonBuilder = new Gson();
String jsonStr = jsonBuilder.toJson( entryList );
File outputJsonFile = destinationFolder.resolve( "versions.json" ).toFile();
Files.write( jsonStr, outputJsonFile, StandardCharsets.UTF_8 );
return outputJsonFile;
}
private void setupTestPlugin( Path pluginsDir, File versionsJson ) throws Exception
{
File myPluginJar = pluginsDir.resolve( PLUGIN_JAR ).toFile();
new JarBuilder().createJarFor( myPluginJar, ExampleNeo4jPlugin.class, ExampleNeo4jPlugin.PrimitiveOutput.class );
httpServer.registerHandler( versionsJson.getName(), new HostFileHttpHandler( versionsJson, "application/json" ) );
httpServer.registerHandler( PLUGIN_JAR, new HostFileHttpHandler( myPluginJar, "application/java-archive" ) );
}
private void verifyTestPluginLoaded(DatabaseIO db)
{
// when we check the list of installed procedures... | // Path: src/test/java/com/neo4j/docker/neo4jserver/plugins/ExampleNeo4jPlugin.java
// public class ExampleNeo4jPlugin
// {
// // Output data class containing primitive types
// public static class PrimitiveOutput
// {
// public String string;
// public long integer;
// public double aFloat;
// public boolean aBoolean;
//
// public PrimitiveOutput( String string, long integer, double aFloat, boolean aBoolean )
// {
// this.string = string;
// this.integer = integer;
// this.aFloat = aFloat;
// this.aBoolean = aBoolean;
// }
// }
// // @ServiceProvider
// // public static class ExampleConfigurationSetting implements SettingsDeclaration
// // {
// // public static final String CONF_NAME = "com.neo4j.docker.neo4jserver.plugins.loaded_verison";
// //
// // @Description("Unique setting to identify which semver field was matched")
// // public static final Setting<String> loadedVersionValue = SettingImpl.newBuilder(
// // CONF_NAME,
// // SettingValueParsers.STRING,
// // "unset"
// // ).build();
// // }
//
// @Context
// public GraphDatabaseService db;
//
// @Context
// public Log log;
//
// // A Neo4j procedure that always returns fixed values
// @Procedure
// public Stream<PrimitiveOutput> defaultValues( @Name( value = "string", defaultValue = "a string" ) String string,
// @Name( value = "integer", defaultValue = "42" ) long integer,
// @Name( value = "float", defaultValue = "3.14" ) double aFloat,
// @Name( value = "boolean", defaultValue = "true" ) boolean aBoolean )
// {
// return Stream.of( new PrimitiveOutput( string, integer, aFloat, aBoolean ) );
// }
// }
//
// Path: src/test/java/com/neo4j/docker/neo4jserver/plugins/JarBuilder.java
// public class JarBuilder
// {
// public URL createJarFor( File f, Class<?>... classesToInclude ) throws IOException
// {
// try ( FileOutputStream fout = new FileOutputStream( f ); JarOutputStream jarOut = new JarOutputStream( fout ) )
// {
// for ( Class<?> target : classesToInclude )
// {
// String fileName = target.getName().replace( ".", "/" ) + ".class";
// jarOut.putNextEntry( new ZipEntry( fileName ) );
// jarOut.write( classCompiledBytes( fileName ) );
// jarOut.closeEntry();
// }
// }
// return f.toURI().toURL();
// }
//
// private byte[] classCompiledBytes( String fileName ) throws IOException
// {
// try ( InputStream in = getClass().getClassLoader().getResourceAsStream( fileName ) )
// {
// ByteArrayOutputStream out = new ByteArrayOutputStream();
// while ( in.available() > 0 )
// {
// out.write( in.read() );
// }
//
// return out.toByteArray();
// }
// }
// }
//
// Path: src/test/java/com/neo4j/docker/utils/TestSettings.java
// public static final Neo4jVersion NEO4J_VERSION = Neo4jVersion.fromVersionString( getVersionFromPropertyOrEnv() );
// Path: src/test/java/com/neo4j/docker/neo4jserver/TestPluginInstallation.java
import com.github.dockerjava.api.command.CreateContainerCmd;
import com.google.gson.Gson;
import com.neo4j.docker.neo4jserver.plugins.ExampleNeo4jPlugin;
import com.neo4j.docker.utils.*;
import com.neo4j.docker.neo4jserver.plugins.JarBuilder;
import org.junit.Rule;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable;
import org.junit.jupiter.migrationsupport.rules.EnableRuleMigrationSupport;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testcontainers.Testcontainers;
import org.testcontainers.containers.Container;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.output.Slf4jLogConsumer;
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.shaded.com.google.common.io.Files;
import java.io.File;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import org.neo4j.driver.Record;
import static com.neo4j.docker.utils.TestSettings.NEO4J_VERSION;
SetContainerUser.nonRootUser( container );
return container;
}
private File createTestVersionsJson(Path destinationFolder, String... versions) throws Exception
{
List<VersionsJsonEntry> entryList = Arrays.stream( versions )
.map( VersionsJsonEntry::new )
.collect( Collectors.toList() );
Gson jsonBuilder = new Gson();
String jsonStr = jsonBuilder.toJson( entryList );
File outputJsonFile = destinationFolder.resolve( "versions.json" ).toFile();
Files.write( jsonStr, outputJsonFile, StandardCharsets.UTF_8 );
return outputJsonFile;
}
private void setupTestPlugin( Path pluginsDir, File versionsJson ) throws Exception
{
File myPluginJar = pluginsDir.resolve( PLUGIN_JAR ).toFile();
new JarBuilder().createJarFor( myPluginJar, ExampleNeo4jPlugin.class, ExampleNeo4jPlugin.PrimitiveOutput.class );
httpServer.registerHandler( versionsJson.getName(), new HostFileHttpHandler( versionsJson, "application/json" ) );
httpServer.registerHandler( PLUGIN_JAR, new HostFileHttpHandler( myPluginJar, "application/java-archive" ) );
}
private void verifyTestPluginLoaded(DatabaseIO db)
{
// when we check the list of installed procedures... | String listProceduresCypherQuery = NEO4J_VERSION.isAtLeastVersion( new Neo4jVersion( 4, 3, 0 ) ) ? |
jksiezni/xpra-client | xpra-client-android/src/main/java/com/github/jksiezni/xpra/XpraApplication.java | // Path: xpra-client-android/src/main/java/com/github/jksiezni/xpra/config/ConfigDatabase.java
// @Database(entities = {ServerDetails.class}, version = 2, exportSchema = false)
// @TypeConverters(ConvertersKt.class)
// public abstract class ConfigDatabase extends RoomDatabase {
//
// public abstract ConnectionDao getConfigs();
//
// private static ConfigDatabase instance;
//
// public static void setup(Application app) {
// if (instance == null) {
// instance = Room.databaseBuilder(app, ConfigDatabase.class, "config.db")
// .fallbackToDestructiveMigration()
// .build();
// }
// }
//
// public static ConfigDatabase getInstance() {
// return instance;
// }
// }
| import timber.log.Timber;
import android.app.Application;
import android.content.Context;
import com.github.jksiezni.xpra.config.ConfigDatabase; | /*
* Copyright (C) 2020 Jakub Ksiezniak
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.github.jksiezni.xpra;
public class XpraApplication extends Application {
@Override
public void onCreate() {
super.onCreate(); | // Path: xpra-client-android/src/main/java/com/github/jksiezni/xpra/config/ConfigDatabase.java
// @Database(entities = {ServerDetails.class}, version = 2, exportSchema = false)
// @TypeConverters(ConvertersKt.class)
// public abstract class ConfigDatabase extends RoomDatabase {
//
// public abstract ConnectionDao getConfigs();
//
// private static ConfigDatabase instance;
//
// public static void setup(Application app) {
// if (instance == null) {
// instance = Room.databaseBuilder(app, ConfigDatabase.class, "config.db")
// .fallbackToDestructiveMigration()
// .build();
// }
// }
//
// public static ConfigDatabase getInstance() {
// return instance;
// }
// }
// Path: xpra-client-android/src/main/java/com/github/jksiezni/xpra/XpraApplication.java
import timber.log.Timber;
import android.app.Application;
import android.content.Context;
import com.github.jksiezni.xpra.config.ConfigDatabase;
/*
* Copyright (C) 2020 Jakub Ksiezniak
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.github.jksiezni.xpra;
public class XpraApplication extends Application {
@Override
public void onCreate() {
super.onCreate(); | ConfigDatabase.setup(this); |
jksiezni/xpra-client | xpra-common/src/main/java/xpra/protocol/packets/WindowMetadata.java | // Path: xpra-common/src/main/java/xpra/protocol/data/SizeConstraints.java
// public class SizeConstraints {
//
// public final int gravity;
// public final int minimumWidth;
// public final int minimumHeight;
//
// public SizeConstraints(int gravity, int minimumWidth, int minimumHeight) {
// this.gravity = gravity;
// this.minimumWidth = minimumWidth;
// this.minimumHeight = minimumHeight;
// }
// }
| import xpra.protocol.data.SizeConstraints;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeMap; | public int getParentId() {
final Object value = meta.get("transient-for");
if (value != null) {
return asInt(value);
}
return NO_PARENT;
}
public Integer getAsInt(String key) {
final Object value = meta.get(key);
if (value != null) {
return asInt(value);
}
return null;
}
public Set<String> getWindowTypes() {
final Object value = meta.get(META_WINDOW_TYPE);
if (value != null) {
List<String> list = asStringList(value);
return Collections.unmodifiableSet(new HashSet<>(list));
}
return Collections.emptySet();
}
public String getTitle() {
return getAsString(META_TITLE);
}
@Nullable | // Path: xpra-common/src/main/java/xpra/protocol/data/SizeConstraints.java
// public class SizeConstraints {
//
// public final int gravity;
// public final int minimumWidth;
// public final int minimumHeight;
//
// public SizeConstraints(int gravity, int minimumWidth, int minimumHeight) {
// this.gravity = gravity;
// this.minimumWidth = minimumWidth;
// this.minimumHeight = minimumHeight;
// }
// }
// Path: xpra-common/src/main/java/xpra/protocol/packets/WindowMetadata.java
import xpra.protocol.data.SizeConstraints;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeMap;
public int getParentId() {
final Object value = meta.get("transient-for");
if (value != null) {
return asInt(value);
}
return NO_PARENT;
}
public Integer getAsInt(String key) {
final Object value = meta.get(key);
if (value != null) {
return asInt(value);
}
return null;
}
public Set<String> getWindowTypes() {
final Object value = meta.get(META_WINDOW_TYPE);
if (value != null) {
List<String> list = asStringList(value);
return Collections.unmodifiableSet(new HashSet<>(list));
}
return Collections.emptySet();
}
public String getTitle() {
return getAsString(META_TITLE);
}
@Nullable | public SizeConstraints getSizeConstraints() { |
jksiezni/xpra-client | xpra-common/src/main/java/xpra/protocol/XpraSender.java | // Path: xpra-common/src/main/java/xpra/network/HeaderChunk.java
// public class HeaderChunk {
// public static final int FLAG_ZLIB = 0x0;
// public static final int FLAG_RENCODE = 0x1;
// public static final int FLAG_CIPHER = 0x2;
// public static final int FLAG_YAML = 0x4;
// // 0x8 is free
// public static final int FLAG_LZ4 = 0x10;
// public static final int FLAG_LZO = 0x20;
// public static final int FLAGS_NOHEADER = 0x40;
// // 0x80 is free
//
// private static final int HEADER_SIZE = 8;
// private static final byte MAGIC_BYTE = 'P';
//
// private final byte[] header = new byte[HEADER_SIZE];
//
//
// public HeaderChunk() {
// header[0] = MAGIC_BYTE;
// }
//
// void readHeader(InputStream is) throws IOException {
// int headerRead = 0;
// while (headerRead < HEADER_SIZE) {
// final int bytesRead = is.read(header, headerRead, HEADER_SIZE - headerRead);
// if (bytesRead < 0) {
// throw new EOFException("Failed to read header.");
// }
// headerRead += bytesRead;
// }
// if (header[0] != MAGIC_BYTE) {
// throw new IOException("Bad header. expected=80, received=" + header[0]);
// }
// if (hasFlags(FLAG_CIPHER | FLAG_YAML | FLAG_LZ4 | FLAG_LZO | FLAGS_NOHEADER)) {
// throw new IOException("unsupported flags detected");
// }
// }
//
// public void writeHeader(OutputStream outputStream) throws IOException {
// outputStream.write(header);
// }
//
// byte getFlags() {
// return header[1];
// }
//
// public void setFlags(int flags) {
// header[1] = (byte) flags;
// }
//
// boolean hasFlags(int flags) {
// return (getFlags() & flags) > 0;
// }
//
// byte getCompressionLevel() {
// return header[2];
// }
//
// void setCompressionLevel(int level) {
// header[2] = (byte) level;
// }
//
// boolean isDataCompressed() {
// return getCompressionLevel() > 0;
// }
//
// int getPacketIndex() {
// return header[3];
// }
//
// void setPacketIndex(int packetIndex) {
// header[3] = (byte) packetIndex;
// }
//
// int getPacketSize() {
// return (header[4] & 0xFF) << 24 | (header[5] & 0xFF) << 16 | (header[6] & 0xFF) << 8 | (header[7] & 0xFF);
// }
//
// public void setPacketSize(int packetSize) {
// header[4] = (byte) ((packetSize >>> 24) & 0xFF);
// header[5] = (byte) ((packetSize >>> 16) & 0xFF);
// header[6] = (byte) ((packetSize >>> 8) & 0xFF);
// header[7] = (byte) (packetSize & 0xFF);
// }
//
// @Override
// public String toString() {
// return getClass().getSimpleName() + Arrays.toString(header);
// }
// }
| import com.github.jksiezni.rencode.RencodeOutputStream;
import java.io.Closeable;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import org.ardverk.coding.BencodingOutputStream;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import xpra.network.HeaderChunk; | if (!sendWorker.isAlive()) {
logger.warn("Stream closed! Failed to send packet: " + packet.type);
return;
}
final ArrayList<Object> list = new ArrayList<>();
list.add(packet.type);
packet.serialize(list);
sendWorker.queue.offer(list);
}
public void useRencode(boolean enabled) {
this.useRencode = enabled;
}
public void setCompressionLevel(int compressionLevel) {
this.compressionLevel = compressionLevel;
}
@Override
public void close() throws IOException {
sendWorker.interrupt();
try {
sendWorker.join();
} catch (InterruptedException e) {
// unused
}
}
private class SendWorker extends Thread {
| // Path: xpra-common/src/main/java/xpra/network/HeaderChunk.java
// public class HeaderChunk {
// public static final int FLAG_ZLIB = 0x0;
// public static final int FLAG_RENCODE = 0x1;
// public static final int FLAG_CIPHER = 0x2;
// public static final int FLAG_YAML = 0x4;
// // 0x8 is free
// public static final int FLAG_LZ4 = 0x10;
// public static final int FLAG_LZO = 0x20;
// public static final int FLAGS_NOHEADER = 0x40;
// // 0x80 is free
//
// private static final int HEADER_SIZE = 8;
// private static final byte MAGIC_BYTE = 'P';
//
// private final byte[] header = new byte[HEADER_SIZE];
//
//
// public HeaderChunk() {
// header[0] = MAGIC_BYTE;
// }
//
// void readHeader(InputStream is) throws IOException {
// int headerRead = 0;
// while (headerRead < HEADER_SIZE) {
// final int bytesRead = is.read(header, headerRead, HEADER_SIZE - headerRead);
// if (bytesRead < 0) {
// throw new EOFException("Failed to read header.");
// }
// headerRead += bytesRead;
// }
// if (header[0] != MAGIC_BYTE) {
// throw new IOException("Bad header. expected=80, received=" + header[0]);
// }
// if (hasFlags(FLAG_CIPHER | FLAG_YAML | FLAG_LZ4 | FLAG_LZO | FLAGS_NOHEADER)) {
// throw new IOException("unsupported flags detected");
// }
// }
//
// public void writeHeader(OutputStream outputStream) throws IOException {
// outputStream.write(header);
// }
//
// byte getFlags() {
// return header[1];
// }
//
// public void setFlags(int flags) {
// header[1] = (byte) flags;
// }
//
// boolean hasFlags(int flags) {
// return (getFlags() & flags) > 0;
// }
//
// byte getCompressionLevel() {
// return header[2];
// }
//
// void setCompressionLevel(int level) {
// header[2] = (byte) level;
// }
//
// boolean isDataCompressed() {
// return getCompressionLevel() > 0;
// }
//
// int getPacketIndex() {
// return header[3];
// }
//
// void setPacketIndex(int packetIndex) {
// header[3] = (byte) packetIndex;
// }
//
// int getPacketSize() {
// return (header[4] & 0xFF) << 24 | (header[5] & 0xFF) << 16 | (header[6] & 0xFF) << 8 | (header[7] & 0xFF);
// }
//
// public void setPacketSize(int packetSize) {
// header[4] = (byte) ((packetSize >>> 24) & 0xFF);
// header[5] = (byte) ((packetSize >>> 16) & 0xFF);
// header[6] = (byte) ((packetSize >>> 8) & 0xFF);
// header[7] = (byte) (packetSize & 0xFF);
// }
//
// @Override
// public String toString() {
// return getClass().getSimpleName() + Arrays.toString(header);
// }
// }
// Path: xpra-common/src/main/java/xpra/protocol/XpraSender.java
import com.github.jksiezni.rencode.RencodeOutputStream;
import java.io.Closeable;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import org.ardverk.coding.BencodingOutputStream;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import xpra.network.HeaderChunk;
if (!sendWorker.isAlive()) {
logger.warn("Stream closed! Failed to send packet: " + packet.type);
return;
}
final ArrayList<Object> list = new ArrayList<>();
list.add(packet.type);
packet.serialize(list);
sendWorker.queue.offer(list);
}
public void useRencode(boolean enabled) {
this.useRencode = enabled;
}
public void setCompressionLevel(int compressionLevel) {
this.compressionLevel = compressionLevel;
}
@Override
public void close() throws IOException {
sendWorker.interrupt();
try {
sendWorker.join();
} catch (InterruptedException e) {
// unused
}
}
private class SendWorker extends Thread {
| private final HeaderChunk headerChunk = new HeaderChunk(); |
jksiezni/xpra-client | xpra-common/src/main/java/xpra/protocol/packets/WindowIcon.java | // Path: xpra-common/src/main/java/xpra/protocol/PictureEncoding.java
// public enum PictureEncoding {
// rgb24,
// rgb32,
// premult_argb32,
// jpeg,
// png,
// pngP("png/P"),
// pngL("png/L");
//
// private static final PictureEncoding[] values = values();
// private final String code;
//
// PictureEncoding() {
// code = name();
// }
//
// PictureEncoding(String code) {
// this.code = code;
// }
//
// @Override
// public String toString() {
// return code;
// }
//
// public static PictureEncoding decode(String code) {
// for (PictureEncoding encoding : values) {
// if (encoding.code.equals(code)) {
// return encoding;
// }
// }
// throw new IllegalArgumentException("Unsupported picture encoding: " + code);
// }
//
// public static String[] toString(PictureEncoding[] encodings) {
// final String[] array = new String[encodings.length];
// for (int i = 0; i < encodings.length; ++i) {
// array[i] = encodings[i].toString();
// }
// return array;
// }
//
// }
| import java.util.Iterator;
import xpra.protocol.PictureEncoding; | /*
* Copyright (C) 2020 Jakub Ksiezniak
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package xpra.protocol.packets;
/**
* @author Jakub Księżniak
*
*/
public class WindowIcon extends WindowPacket {
public int width;
public int height; | // Path: xpra-common/src/main/java/xpra/protocol/PictureEncoding.java
// public enum PictureEncoding {
// rgb24,
// rgb32,
// premult_argb32,
// jpeg,
// png,
// pngP("png/P"),
// pngL("png/L");
//
// private static final PictureEncoding[] values = values();
// private final String code;
//
// PictureEncoding() {
// code = name();
// }
//
// PictureEncoding(String code) {
// this.code = code;
// }
//
// @Override
// public String toString() {
// return code;
// }
//
// public static PictureEncoding decode(String code) {
// for (PictureEncoding encoding : values) {
// if (encoding.code.equals(code)) {
// return encoding;
// }
// }
// throw new IllegalArgumentException("Unsupported picture encoding: " + code);
// }
//
// public static String[] toString(PictureEncoding[] encodings) {
// final String[] array = new String[encodings.length];
// for (int i = 0; i < encodings.length; ++i) {
// array[i] = encodings[i].toString();
// }
// return array;
// }
//
// }
// Path: xpra-common/src/main/java/xpra/protocol/packets/WindowIcon.java
import java.util.Iterator;
import xpra.protocol.PictureEncoding;
/*
* Copyright (C) 2020 Jakub Ksiezniak
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package xpra.protocol.packets;
/**
* @author Jakub Księżniak
*
*/
public class WindowIcon extends WindowPacket {
public int width;
public int height; | public PictureEncoding encoding; |
jksiezni/xpra-client | xpra-client-android/src/main/java/com/github/jksiezni/xpra/client/XpraAPI.java | // Path: xpra-client-android/src/main/java/com/github/jksiezni/xpra/ssh/SshUserInfoHandler.java
// public class SshUserInfoHandler implements UserInfo, UIKeyboardInteractive {
//
// private final Activity activity;
//
// private CredentialsAskTask passwordTask;
//
// public SshUserInfoHandler(Activity activity) {
// this.activity = activity;
// }
//
// @Override
// public boolean promptPassphrase(String message) {
// try {
// passwordTask = new CredentialsAskTask(activity, message);
// return passwordTask.execute().get();
// } catch (InterruptedException e) {
// e.printStackTrace();
// return false;
// }
// }
//
// @Override
// public String getPassphrase() {
// return passwordTask.getPassword();
// }
//
// @Override
// public boolean promptPassword(String message) {
// try {
// passwordTask = new CredentialsAskTask(activity, message);
// return passwordTask.execute().get();
// } catch (InterruptedException e) {
// e.printStackTrace();
// return false;
// }
// }
//
// @Override
// public String getPassword() {
// return passwordTask.getPassword();
// }
//
// @Override
// public String[] promptKeyboardInteractive(String destination, String name, String instruction, String[] prompt,
// boolean[] echo) {
// try {
// passwordTask = new CredentialsAskTask(activity, prompt, echo);
// boolean success = passwordTask.execute().get();
// if(success) {
// return passwordTask.getAnswers();
// }
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// return null;
// }
//
// @Override
// public boolean promptYesNo(String message) {
// try {
// return new YesNoAskTask(activity)
// .execute(message)
// .get();
// } catch (InterruptedException e) {
// e.printStackTrace();
// return false;
// }
// }
//
// @Override
// public void showMessage(String message) {
// Toast.makeText(activity, message, Toast.LENGTH_LONG).show();
// }
//
// }
| import com.github.jksiezni.xpra.config.ServerDetails;
import com.github.jksiezni.xpra.ssh.SshUserInfoHandler;
import java.io.IOException;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable; | /*
* Copyright (C) 2020 Jakub Ksiezniak
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.github.jksiezni.xpra.client;
/**
*
*/
public interface XpraAPI {
@NonNull
AndroidXpraClient getXpraClient();
@Nullable
ServerDetails getConnectionDetails();
| // Path: xpra-client-android/src/main/java/com/github/jksiezni/xpra/ssh/SshUserInfoHandler.java
// public class SshUserInfoHandler implements UserInfo, UIKeyboardInteractive {
//
// private final Activity activity;
//
// private CredentialsAskTask passwordTask;
//
// public SshUserInfoHandler(Activity activity) {
// this.activity = activity;
// }
//
// @Override
// public boolean promptPassphrase(String message) {
// try {
// passwordTask = new CredentialsAskTask(activity, message);
// return passwordTask.execute().get();
// } catch (InterruptedException e) {
// e.printStackTrace();
// return false;
// }
// }
//
// @Override
// public String getPassphrase() {
// return passwordTask.getPassword();
// }
//
// @Override
// public boolean promptPassword(String message) {
// try {
// passwordTask = new CredentialsAskTask(activity, message);
// return passwordTask.execute().get();
// } catch (InterruptedException e) {
// e.printStackTrace();
// return false;
// }
// }
//
// @Override
// public String getPassword() {
// return passwordTask.getPassword();
// }
//
// @Override
// public String[] promptKeyboardInteractive(String destination, String name, String instruction, String[] prompt,
// boolean[] echo) {
// try {
// passwordTask = new CredentialsAskTask(activity, prompt, echo);
// boolean success = passwordTask.execute().get();
// if(success) {
// return passwordTask.getAnswers();
// }
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// return null;
// }
//
// @Override
// public boolean promptYesNo(String message) {
// try {
// return new YesNoAskTask(activity)
// .execute(message)
// .get();
// } catch (InterruptedException e) {
// e.printStackTrace();
// return false;
// }
// }
//
// @Override
// public void showMessage(String message) {
// Toast.makeText(activity, message, Toast.LENGTH_LONG).show();
// }
//
// }
// Path: xpra-client-android/src/main/java/com/github/jksiezni/xpra/client/XpraAPI.java
import com.github.jksiezni.xpra.config.ServerDetails;
import com.github.jksiezni.xpra.ssh.SshUserInfoHandler;
import java.io.IOException;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
/*
* Copyright (C) 2020 Jakub Ksiezniak
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package com.github.jksiezni.xpra.client;
/**
*
*/
public interface XpraAPI {
@NonNull
AndroidXpraClient getXpraClient();
@Nullable
ServerDetails getConnectionDetails();
| void connect(@NonNull ServerDetails serverDetails, @NonNull SshUserInfoHandler userInfoHandler) throws IOException; |
jksiezni/xpra-client | xpra-common/src/main/java/xpra/protocol/packets/HelloRequest.java | // Path: xpra-common/src/main/java/xpra/client/XpraKeyboard.java
// public interface XpraKeyboard {
//
// Locale getLocale();
//
// List<KeyDesc> getKeycodes();
//
// /**
// * Key descriptor.
// */
// class KeyDesc {
//
// int keyval;
// String keyname = "";
// int keycode;
// int group;
// int level;
//
// public KeyDesc(int keycode, String keyname) {
// this.keyval = keycode;
// this.keycode = keycode;
// this.keyname = keyname;
// }
//
// public List<Object> toList() {
// final List<Object> list = new ArrayList<>(5);
// list.add(keyval);
// list.add(keyname);
// list.add(keycode);
// list.add(group);
// list.add(level);
// return list;
// }
//
// @Override
// public String toString() {
// return getClass().getSimpleName() + "( " + keycode + ", " + keyname + ")";
// }
// }
// }
//
// Path: xpra-common/src/main/java/xpra/client/XpraKeyboard.java
// class KeyDesc {
//
// int keyval;
// String keyname = "";
// int keycode;
// int group;
// int level;
//
// public KeyDesc(int keycode, String keyname) {
// this.keyval = keycode;
// this.keycode = keycode;
// this.keyname = keyname;
// }
//
// public List<Object> toList() {
// final List<Object> list = new ArrayList<>(5);
// list.add(keyval);
// list.add(keyname);
// list.add(keycode);
// list.add(group);
// list.add(level);
// return list;
// }
//
// @Override
// public String toString() {
// return getClass().getSimpleName() + "( " + keycode + ", " + keyname + ")";
// }
// }
//
// Path: xpra-common/src/main/java/xpra/protocol/PictureEncoding.java
// public enum PictureEncoding {
// rgb24,
// rgb32,
// premult_argb32,
// jpeg,
// png,
// pngP("png/P"),
// pngL("png/L");
//
// private static final PictureEncoding[] values = values();
// private final String code;
//
// PictureEncoding() {
// code = name();
// }
//
// PictureEncoding(String code) {
// this.code = code;
// }
//
// @Override
// public String toString() {
// return code;
// }
//
// public static PictureEncoding decode(String code) {
// for (PictureEncoding encoding : values) {
// if (encoding.code.equals(code)) {
// return encoding;
// }
// }
// throw new IllegalArgumentException("Unsupported picture encoding: " + code);
// }
//
// public static String[] toString(PictureEncoding[] encodings) {
// final String[] array = new String[encodings.length];
// for (int i = 0; i < encodings.length; ++i) {
// array[i] = encodings[i].toString();
// }
// return array;
// }
//
// }
//
// Path: xpra-common/src/main/java/xpra/protocol/ProtocolConstants.java
// public class ProtocolConstants {
//
// public static final String VERSION = "0.15.0";
// public static final String MIN_VERSION = "0.5";
// }
| import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import xpra.client.XpraKeyboard;
import xpra.client.XpraKeyboard.KeyDesc;
import xpra.protocol.PictureEncoding;
import xpra.protocol.ProtocolConstants; | /*
* Copyright (C) 2020 Jakub Ksiezniak
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package xpra.protocol.packets;
public class HelloRequest extends xpra.protocol.IOPacket {
private static final int[] CAPS_MAX_ICON_SIZE = {128, 128};
private final Map<String, Object> caps = new LinkedHashMap<>();
| // Path: xpra-common/src/main/java/xpra/client/XpraKeyboard.java
// public interface XpraKeyboard {
//
// Locale getLocale();
//
// List<KeyDesc> getKeycodes();
//
// /**
// * Key descriptor.
// */
// class KeyDesc {
//
// int keyval;
// String keyname = "";
// int keycode;
// int group;
// int level;
//
// public KeyDesc(int keycode, String keyname) {
// this.keyval = keycode;
// this.keycode = keycode;
// this.keyname = keyname;
// }
//
// public List<Object> toList() {
// final List<Object> list = new ArrayList<>(5);
// list.add(keyval);
// list.add(keyname);
// list.add(keycode);
// list.add(group);
// list.add(level);
// return list;
// }
//
// @Override
// public String toString() {
// return getClass().getSimpleName() + "( " + keycode + ", " + keyname + ")";
// }
// }
// }
//
// Path: xpra-common/src/main/java/xpra/client/XpraKeyboard.java
// class KeyDesc {
//
// int keyval;
// String keyname = "";
// int keycode;
// int group;
// int level;
//
// public KeyDesc(int keycode, String keyname) {
// this.keyval = keycode;
// this.keycode = keycode;
// this.keyname = keyname;
// }
//
// public List<Object> toList() {
// final List<Object> list = new ArrayList<>(5);
// list.add(keyval);
// list.add(keyname);
// list.add(keycode);
// list.add(group);
// list.add(level);
// return list;
// }
//
// @Override
// public String toString() {
// return getClass().getSimpleName() + "( " + keycode + ", " + keyname + ")";
// }
// }
//
// Path: xpra-common/src/main/java/xpra/protocol/PictureEncoding.java
// public enum PictureEncoding {
// rgb24,
// rgb32,
// premult_argb32,
// jpeg,
// png,
// pngP("png/P"),
// pngL("png/L");
//
// private static final PictureEncoding[] values = values();
// private final String code;
//
// PictureEncoding() {
// code = name();
// }
//
// PictureEncoding(String code) {
// this.code = code;
// }
//
// @Override
// public String toString() {
// return code;
// }
//
// public static PictureEncoding decode(String code) {
// for (PictureEncoding encoding : values) {
// if (encoding.code.equals(code)) {
// return encoding;
// }
// }
// throw new IllegalArgumentException("Unsupported picture encoding: " + code);
// }
//
// public static String[] toString(PictureEncoding[] encodings) {
// final String[] array = new String[encodings.length];
// for (int i = 0; i < encodings.length; ++i) {
// array[i] = encodings[i].toString();
// }
// return array;
// }
//
// }
//
// Path: xpra-common/src/main/java/xpra/protocol/ProtocolConstants.java
// public class ProtocolConstants {
//
// public static final String VERSION = "0.15.0";
// public static final String MIN_VERSION = "0.5";
// }
// Path: xpra-common/src/main/java/xpra/protocol/packets/HelloRequest.java
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import xpra.client.XpraKeyboard;
import xpra.client.XpraKeyboard.KeyDesc;
import xpra.protocol.PictureEncoding;
import xpra.protocol.ProtocolConstants;
/*
* Copyright (C) 2020 Jakub Ksiezniak
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package xpra.protocol.packets;
public class HelloRequest extends xpra.protocol.IOPacket {
private static final int[] CAPS_MAX_ICON_SIZE = {128, 128};
private final Map<String, Object> caps = new LinkedHashMap<>();
| public HelloRequest(int screenWidth, int screenHeight, XpraKeyboard keyboard, PictureEncoding defaultEncoding, PictureEncoding[] encodings) { |
jksiezni/xpra-client | xpra-common/src/main/java/xpra/protocol/packets/HelloRequest.java | // Path: xpra-common/src/main/java/xpra/client/XpraKeyboard.java
// public interface XpraKeyboard {
//
// Locale getLocale();
//
// List<KeyDesc> getKeycodes();
//
// /**
// * Key descriptor.
// */
// class KeyDesc {
//
// int keyval;
// String keyname = "";
// int keycode;
// int group;
// int level;
//
// public KeyDesc(int keycode, String keyname) {
// this.keyval = keycode;
// this.keycode = keycode;
// this.keyname = keyname;
// }
//
// public List<Object> toList() {
// final List<Object> list = new ArrayList<>(5);
// list.add(keyval);
// list.add(keyname);
// list.add(keycode);
// list.add(group);
// list.add(level);
// return list;
// }
//
// @Override
// public String toString() {
// return getClass().getSimpleName() + "( " + keycode + ", " + keyname + ")";
// }
// }
// }
//
// Path: xpra-common/src/main/java/xpra/client/XpraKeyboard.java
// class KeyDesc {
//
// int keyval;
// String keyname = "";
// int keycode;
// int group;
// int level;
//
// public KeyDesc(int keycode, String keyname) {
// this.keyval = keycode;
// this.keycode = keycode;
// this.keyname = keyname;
// }
//
// public List<Object> toList() {
// final List<Object> list = new ArrayList<>(5);
// list.add(keyval);
// list.add(keyname);
// list.add(keycode);
// list.add(group);
// list.add(level);
// return list;
// }
//
// @Override
// public String toString() {
// return getClass().getSimpleName() + "( " + keycode + ", " + keyname + ")";
// }
// }
//
// Path: xpra-common/src/main/java/xpra/protocol/PictureEncoding.java
// public enum PictureEncoding {
// rgb24,
// rgb32,
// premult_argb32,
// jpeg,
// png,
// pngP("png/P"),
// pngL("png/L");
//
// private static final PictureEncoding[] values = values();
// private final String code;
//
// PictureEncoding() {
// code = name();
// }
//
// PictureEncoding(String code) {
// this.code = code;
// }
//
// @Override
// public String toString() {
// return code;
// }
//
// public static PictureEncoding decode(String code) {
// for (PictureEncoding encoding : values) {
// if (encoding.code.equals(code)) {
// return encoding;
// }
// }
// throw new IllegalArgumentException("Unsupported picture encoding: " + code);
// }
//
// public static String[] toString(PictureEncoding[] encodings) {
// final String[] array = new String[encodings.length];
// for (int i = 0; i < encodings.length; ++i) {
// array[i] = encodings[i].toString();
// }
// return array;
// }
//
// }
//
// Path: xpra-common/src/main/java/xpra/protocol/ProtocolConstants.java
// public class ProtocolConstants {
//
// public static final String VERSION = "0.15.0";
// public static final String MIN_VERSION = "0.5";
// }
| import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import xpra.client.XpraKeyboard;
import xpra.client.XpraKeyboard.KeyDesc;
import xpra.protocol.PictureEncoding;
import xpra.protocol.ProtocolConstants; | /*
* Copyright (C) 2020 Jakub Ksiezniak
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package xpra.protocol.packets;
public class HelloRequest extends xpra.protocol.IOPacket {
private static final int[] CAPS_MAX_ICON_SIZE = {128, 128};
private final Map<String, Object> caps = new LinkedHashMap<>();
| // Path: xpra-common/src/main/java/xpra/client/XpraKeyboard.java
// public interface XpraKeyboard {
//
// Locale getLocale();
//
// List<KeyDesc> getKeycodes();
//
// /**
// * Key descriptor.
// */
// class KeyDesc {
//
// int keyval;
// String keyname = "";
// int keycode;
// int group;
// int level;
//
// public KeyDesc(int keycode, String keyname) {
// this.keyval = keycode;
// this.keycode = keycode;
// this.keyname = keyname;
// }
//
// public List<Object> toList() {
// final List<Object> list = new ArrayList<>(5);
// list.add(keyval);
// list.add(keyname);
// list.add(keycode);
// list.add(group);
// list.add(level);
// return list;
// }
//
// @Override
// public String toString() {
// return getClass().getSimpleName() + "( " + keycode + ", " + keyname + ")";
// }
// }
// }
//
// Path: xpra-common/src/main/java/xpra/client/XpraKeyboard.java
// class KeyDesc {
//
// int keyval;
// String keyname = "";
// int keycode;
// int group;
// int level;
//
// public KeyDesc(int keycode, String keyname) {
// this.keyval = keycode;
// this.keycode = keycode;
// this.keyname = keyname;
// }
//
// public List<Object> toList() {
// final List<Object> list = new ArrayList<>(5);
// list.add(keyval);
// list.add(keyname);
// list.add(keycode);
// list.add(group);
// list.add(level);
// return list;
// }
//
// @Override
// public String toString() {
// return getClass().getSimpleName() + "( " + keycode + ", " + keyname + ")";
// }
// }
//
// Path: xpra-common/src/main/java/xpra/protocol/PictureEncoding.java
// public enum PictureEncoding {
// rgb24,
// rgb32,
// premult_argb32,
// jpeg,
// png,
// pngP("png/P"),
// pngL("png/L");
//
// private static final PictureEncoding[] values = values();
// private final String code;
//
// PictureEncoding() {
// code = name();
// }
//
// PictureEncoding(String code) {
// this.code = code;
// }
//
// @Override
// public String toString() {
// return code;
// }
//
// public static PictureEncoding decode(String code) {
// for (PictureEncoding encoding : values) {
// if (encoding.code.equals(code)) {
// return encoding;
// }
// }
// throw new IllegalArgumentException("Unsupported picture encoding: " + code);
// }
//
// public static String[] toString(PictureEncoding[] encodings) {
// final String[] array = new String[encodings.length];
// for (int i = 0; i < encodings.length; ++i) {
// array[i] = encodings[i].toString();
// }
// return array;
// }
//
// }
//
// Path: xpra-common/src/main/java/xpra/protocol/ProtocolConstants.java
// public class ProtocolConstants {
//
// public static final String VERSION = "0.15.0";
// public static final String MIN_VERSION = "0.5";
// }
// Path: xpra-common/src/main/java/xpra/protocol/packets/HelloRequest.java
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import xpra.client.XpraKeyboard;
import xpra.client.XpraKeyboard.KeyDesc;
import xpra.protocol.PictureEncoding;
import xpra.protocol.ProtocolConstants;
/*
* Copyright (C) 2020 Jakub Ksiezniak
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package xpra.protocol.packets;
public class HelloRequest extends xpra.protocol.IOPacket {
private static final int[] CAPS_MAX_ICON_SIZE = {128, 128};
private final Map<String, Object> caps = new LinkedHashMap<>();
| public HelloRequest(int screenWidth, int screenHeight, XpraKeyboard keyboard, PictureEncoding defaultEncoding, PictureEncoding[] encodings) { |
jksiezni/xpra-client | xpra-common/src/main/java/xpra/protocol/packets/HelloRequest.java | // Path: xpra-common/src/main/java/xpra/client/XpraKeyboard.java
// public interface XpraKeyboard {
//
// Locale getLocale();
//
// List<KeyDesc> getKeycodes();
//
// /**
// * Key descriptor.
// */
// class KeyDesc {
//
// int keyval;
// String keyname = "";
// int keycode;
// int group;
// int level;
//
// public KeyDesc(int keycode, String keyname) {
// this.keyval = keycode;
// this.keycode = keycode;
// this.keyname = keyname;
// }
//
// public List<Object> toList() {
// final List<Object> list = new ArrayList<>(5);
// list.add(keyval);
// list.add(keyname);
// list.add(keycode);
// list.add(group);
// list.add(level);
// return list;
// }
//
// @Override
// public String toString() {
// return getClass().getSimpleName() + "( " + keycode + ", " + keyname + ")";
// }
// }
// }
//
// Path: xpra-common/src/main/java/xpra/client/XpraKeyboard.java
// class KeyDesc {
//
// int keyval;
// String keyname = "";
// int keycode;
// int group;
// int level;
//
// public KeyDesc(int keycode, String keyname) {
// this.keyval = keycode;
// this.keycode = keycode;
// this.keyname = keyname;
// }
//
// public List<Object> toList() {
// final List<Object> list = new ArrayList<>(5);
// list.add(keyval);
// list.add(keyname);
// list.add(keycode);
// list.add(group);
// list.add(level);
// return list;
// }
//
// @Override
// public String toString() {
// return getClass().getSimpleName() + "( " + keycode + ", " + keyname + ")";
// }
// }
//
// Path: xpra-common/src/main/java/xpra/protocol/PictureEncoding.java
// public enum PictureEncoding {
// rgb24,
// rgb32,
// premult_argb32,
// jpeg,
// png,
// pngP("png/P"),
// pngL("png/L");
//
// private static final PictureEncoding[] values = values();
// private final String code;
//
// PictureEncoding() {
// code = name();
// }
//
// PictureEncoding(String code) {
// this.code = code;
// }
//
// @Override
// public String toString() {
// return code;
// }
//
// public static PictureEncoding decode(String code) {
// for (PictureEncoding encoding : values) {
// if (encoding.code.equals(code)) {
// return encoding;
// }
// }
// throw new IllegalArgumentException("Unsupported picture encoding: " + code);
// }
//
// public static String[] toString(PictureEncoding[] encodings) {
// final String[] array = new String[encodings.length];
// for (int i = 0; i < encodings.length; ++i) {
// array[i] = encodings[i].toString();
// }
// return array;
// }
//
// }
//
// Path: xpra-common/src/main/java/xpra/protocol/ProtocolConstants.java
// public class ProtocolConstants {
//
// public static final String VERSION = "0.15.0";
// public static final String MIN_VERSION = "0.5";
// }
| import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import xpra.client.XpraKeyboard;
import xpra.client.XpraKeyboard.KeyDesc;
import xpra.protocol.PictureEncoding;
import xpra.protocol.ProtocolConstants; | /*
* Copyright (C) 2020 Jakub Ksiezniak
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package xpra.protocol.packets;
public class HelloRequest extends xpra.protocol.IOPacket {
private static final int[] CAPS_MAX_ICON_SIZE = {128, 128};
private final Map<String, Object> caps = new LinkedHashMap<>();
public HelloRequest(int screenWidth, int screenHeight, XpraKeyboard keyboard, PictureEncoding defaultEncoding, PictureEncoding[] encodings) {
super("hello"); | // Path: xpra-common/src/main/java/xpra/client/XpraKeyboard.java
// public interface XpraKeyboard {
//
// Locale getLocale();
//
// List<KeyDesc> getKeycodes();
//
// /**
// * Key descriptor.
// */
// class KeyDesc {
//
// int keyval;
// String keyname = "";
// int keycode;
// int group;
// int level;
//
// public KeyDesc(int keycode, String keyname) {
// this.keyval = keycode;
// this.keycode = keycode;
// this.keyname = keyname;
// }
//
// public List<Object> toList() {
// final List<Object> list = new ArrayList<>(5);
// list.add(keyval);
// list.add(keyname);
// list.add(keycode);
// list.add(group);
// list.add(level);
// return list;
// }
//
// @Override
// public String toString() {
// return getClass().getSimpleName() + "( " + keycode + ", " + keyname + ")";
// }
// }
// }
//
// Path: xpra-common/src/main/java/xpra/client/XpraKeyboard.java
// class KeyDesc {
//
// int keyval;
// String keyname = "";
// int keycode;
// int group;
// int level;
//
// public KeyDesc(int keycode, String keyname) {
// this.keyval = keycode;
// this.keycode = keycode;
// this.keyname = keyname;
// }
//
// public List<Object> toList() {
// final List<Object> list = new ArrayList<>(5);
// list.add(keyval);
// list.add(keyname);
// list.add(keycode);
// list.add(group);
// list.add(level);
// return list;
// }
//
// @Override
// public String toString() {
// return getClass().getSimpleName() + "( " + keycode + ", " + keyname + ")";
// }
// }
//
// Path: xpra-common/src/main/java/xpra/protocol/PictureEncoding.java
// public enum PictureEncoding {
// rgb24,
// rgb32,
// premult_argb32,
// jpeg,
// png,
// pngP("png/P"),
// pngL("png/L");
//
// private static final PictureEncoding[] values = values();
// private final String code;
//
// PictureEncoding() {
// code = name();
// }
//
// PictureEncoding(String code) {
// this.code = code;
// }
//
// @Override
// public String toString() {
// return code;
// }
//
// public static PictureEncoding decode(String code) {
// for (PictureEncoding encoding : values) {
// if (encoding.code.equals(code)) {
// return encoding;
// }
// }
// throw new IllegalArgumentException("Unsupported picture encoding: " + code);
// }
//
// public static String[] toString(PictureEncoding[] encodings) {
// final String[] array = new String[encodings.length];
// for (int i = 0; i < encodings.length; ++i) {
// array[i] = encodings[i].toString();
// }
// return array;
// }
//
// }
//
// Path: xpra-common/src/main/java/xpra/protocol/ProtocolConstants.java
// public class ProtocolConstants {
//
// public static final String VERSION = "0.15.0";
// public static final String MIN_VERSION = "0.5";
// }
// Path: xpra-common/src/main/java/xpra/protocol/packets/HelloRequest.java
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import xpra.client.XpraKeyboard;
import xpra.client.XpraKeyboard.KeyDesc;
import xpra.protocol.PictureEncoding;
import xpra.protocol.ProtocolConstants;
/*
* Copyright (C) 2020 Jakub Ksiezniak
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package xpra.protocol.packets;
public class HelloRequest extends xpra.protocol.IOPacket {
private static final int[] CAPS_MAX_ICON_SIZE = {128, 128};
private final Map<String, Object> caps = new LinkedHashMap<>();
public HelloRequest(int screenWidth, int screenHeight, XpraKeyboard keyboard, PictureEncoding defaultEncoding, PictureEncoding[] encodings) {
super("hello"); | caps.put("version", ProtocolConstants.VERSION); |
jksiezni/xpra-client | xpra-common/src/main/java/xpra/protocol/packets/HelloRequest.java | // Path: xpra-common/src/main/java/xpra/client/XpraKeyboard.java
// public interface XpraKeyboard {
//
// Locale getLocale();
//
// List<KeyDesc> getKeycodes();
//
// /**
// * Key descriptor.
// */
// class KeyDesc {
//
// int keyval;
// String keyname = "";
// int keycode;
// int group;
// int level;
//
// public KeyDesc(int keycode, String keyname) {
// this.keyval = keycode;
// this.keycode = keycode;
// this.keyname = keyname;
// }
//
// public List<Object> toList() {
// final List<Object> list = new ArrayList<>(5);
// list.add(keyval);
// list.add(keyname);
// list.add(keycode);
// list.add(group);
// list.add(level);
// return list;
// }
//
// @Override
// public String toString() {
// return getClass().getSimpleName() + "( " + keycode + ", " + keyname + ")";
// }
// }
// }
//
// Path: xpra-common/src/main/java/xpra/client/XpraKeyboard.java
// class KeyDesc {
//
// int keyval;
// String keyname = "";
// int keycode;
// int group;
// int level;
//
// public KeyDesc(int keycode, String keyname) {
// this.keyval = keycode;
// this.keycode = keycode;
// this.keyname = keyname;
// }
//
// public List<Object> toList() {
// final List<Object> list = new ArrayList<>(5);
// list.add(keyval);
// list.add(keyname);
// list.add(keycode);
// list.add(group);
// list.add(level);
// return list;
// }
//
// @Override
// public String toString() {
// return getClass().getSimpleName() + "( " + keycode + ", " + keyname + ")";
// }
// }
//
// Path: xpra-common/src/main/java/xpra/protocol/PictureEncoding.java
// public enum PictureEncoding {
// rgb24,
// rgb32,
// premult_argb32,
// jpeg,
// png,
// pngP("png/P"),
// pngL("png/L");
//
// private static final PictureEncoding[] values = values();
// private final String code;
//
// PictureEncoding() {
// code = name();
// }
//
// PictureEncoding(String code) {
// this.code = code;
// }
//
// @Override
// public String toString() {
// return code;
// }
//
// public static PictureEncoding decode(String code) {
// for (PictureEncoding encoding : values) {
// if (encoding.code.equals(code)) {
// return encoding;
// }
// }
// throw new IllegalArgumentException("Unsupported picture encoding: " + code);
// }
//
// public static String[] toString(PictureEncoding[] encodings) {
// final String[] array = new String[encodings.length];
// for (int i = 0; i < encodings.length; ++i) {
// array[i] = encodings[i].toString();
// }
// return array;
// }
//
// }
//
// Path: xpra-common/src/main/java/xpra/protocol/ProtocolConstants.java
// public class ProtocolConstants {
//
// public static final String VERSION = "0.15.0";
// public static final String MIN_VERSION = "0.5";
// }
| import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import xpra.client.XpraKeyboard;
import xpra.client.XpraKeyboard.KeyDesc;
import xpra.protocol.PictureEncoding;
import xpra.protocol.ProtocolConstants; | }
}
caps.put("platform", System.getProperty("os.name").toLowerCase());
caps.put("uuid", UUID.randomUUID().toString().replace("-", ""));
// it is required, if client wants to display windows (since 4.x)
caps.put("windows", true);
setKeyboard(keyboard);
}
public void setDpi(int dpi, int xdpi, int ydpi) {
caps.put("dpi", dpi);
// caps.put("dpi.x", xdpi);
// caps.put("dpi.y", ydpi);
}
private void setKeyboard(XpraKeyboard keyboard) {
if (keyboard != null) {
caps.put("keyboard", true);
caps.put("keyboard_sync", false);
caps.put("xkbmap_layout", keyboard.getLocale().getLanguage());
caps.put("xkbmap_variant", keyboard.getLocale().getVariant());
caps.put("xkbmap_keycodes", buildKeycodes(keyboard.getKeycodes()));
} else {
caps.put("keyboard", false);
caps.put("keyboard_sync", false);
}
}
| // Path: xpra-common/src/main/java/xpra/client/XpraKeyboard.java
// public interface XpraKeyboard {
//
// Locale getLocale();
//
// List<KeyDesc> getKeycodes();
//
// /**
// * Key descriptor.
// */
// class KeyDesc {
//
// int keyval;
// String keyname = "";
// int keycode;
// int group;
// int level;
//
// public KeyDesc(int keycode, String keyname) {
// this.keyval = keycode;
// this.keycode = keycode;
// this.keyname = keyname;
// }
//
// public List<Object> toList() {
// final List<Object> list = new ArrayList<>(5);
// list.add(keyval);
// list.add(keyname);
// list.add(keycode);
// list.add(group);
// list.add(level);
// return list;
// }
//
// @Override
// public String toString() {
// return getClass().getSimpleName() + "( " + keycode + ", " + keyname + ")";
// }
// }
// }
//
// Path: xpra-common/src/main/java/xpra/client/XpraKeyboard.java
// class KeyDesc {
//
// int keyval;
// String keyname = "";
// int keycode;
// int group;
// int level;
//
// public KeyDesc(int keycode, String keyname) {
// this.keyval = keycode;
// this.keycode = keycode;
// this.keyname = keyname;
// }
//
// public List<Object> toList() {
// final List<Object> list = new ArrayList<>(5);
// list.add(keyval);
// list.add(keyname);
// list.add(keycode);
// list.add(group);
// list.add(level);
// return list;
// }
//
// @Override
// public String toString() {
// return getClass().getSimpleName() + "( " + keycode + ", " + keyname + ")";
// }
// }
//
// Path: xpra-common/src/main/java/xpra/protocol/PictureEncoding.java
// public enum PictureEncoding {
// rgb24,
// rgb32,
// premult_argb32,
// jpeg,
// png,
// pngP("png/P"),
// pngL("png/L");
//
// private static final PictureEncoding[] values = values();
// private final String code;
//
// PictureEncoding() {
// code = name();
// }
//
// PictureEncoding(String code) {
// this.code = code;
// }
//
// @Override
// public String toString() {
// return code;
// }
//
// public static PictureEncoding decode(String code) {
// for (PictureEncoding encoding : values) {
// if (encoding.code.equals(code)) {
// return encoding;
// }
// }
// throw new IllegalArgumentException("Unsupported picture encoding: " + code);
// }
//
// public static String[] toString(PictureEncoding[] encodings) {
// final String[] array = new String[encodings.length];
// for (int i = 0; i < encodings.length; ++i) {
// array[i] = encodings[i].toString();
// }
// return array;
// }
//
// }
//
// Path: xpra-common/src/main/java/xpra/protocol/ProtocolConstants.java
// public class ProtocolConstants {
//
// public static final String VERSION = "0.15.0";
// public static final String MIN_VERSION = "0.5";
// }
// Path: xpra-common/src/main/java/xpra/protocol/packets/HelloRequest.java
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import xpra.client.XpraKeyboard;
import xpra.client.XpraKeyboard.KeyDesc;
import xpra.protocol.PictureEncoding;
import xpra.protocol.ProtocolConstants;
}
}
caps.put("platform", System.getProperty("os.name").toLowerCase());
caps.put("uuid", UUID.randomUUID().toString().replace("-", ""));
// it is required, if client wants to display windows (since 4.x)
caps.put("windows", true);
setKeyboard(keyboard);
}
public void setDpi(int dpi, int xdpi, int ydpi) {
caps.put("dpi", dpi);
// caps.put("dpi.x", xdpi);
// caps.put("dpi.y", ydpi);
}
private void setKeyboard(XpraKeyboard keyboard) {
if (keyboard != null) {
caps.put("keyboard", true);
caps.put("keyboard_sync", false);
caps.put("xkbmap_layout", keyboard.getLocale().getLanguage());
caps.put("xkbmap_variant", keyboard.getLocale().getVariant());
caps.put("xkbmap_keycodes", buildKeycodes(keyboard.getKeycodes()));
} else {
caps.put("keyboard", false);
caps.put("keyboard_sync", false);
}
}
| private Object buildKeycodes(List<KeyDesc> keycodes) { |
jksiezni/xpra-client | xpra-common/src/main/java/xpra/protocol/packets/DrawPacket.java | // Path: xpra-common/src/main/java/xpra/compression/CompressionException.java
// public class CompressionException extends IOException {
//
// public CompressionException(String s) {
// super(s);
// }
//
// public CompressionException(String s, Throwable throwable) {
// super(s, throwable);
// }
// }
//
// Path: xpra-common/src/main/java/xpra/compression/Decompressor.java
// public interface Decompressor {
//
// boolean decompress(byte[] inputData, byte[] outputData) throws CompressionException;
// }
//
// Path: xpra-common/src/main/java/xpra/compression/Decompressors.java
// public class Decompressors {
//
// public static final String COMP_ZLIB = "zlib";
//
// public static Decompressor zlib() {
// return new ZLib();
// }
//
// public static Decompressor getByName(String compressionName) {
// switch (compressionName) {
// case COMP_ZLIB: return zlib();
// default:
// throw new UnsupportedOperationException("Unsupported compressor used: " + compressionName);
// }
// }
// }
//
// Path: xpra-common/src/main/java/xpra/protocol/PictureEncoding.java
// public enum PictureEncoding {
// rgb24,
// rgb32,
// premult_argb32,
// jpeg,
// png,
// pngP("png/P"),
// pngL("png/L");
//
// private static final PictureEncoding[] values = values();
// private final String code;
//
// PictureEncoding() {
// code = name();
// }
//
// PictureEncoding(String code) {
// this.code = code;
// }
//
// @Override
// public String toString() {
// return code;
// }
//
// public static PictureEncoding decode(String code) {
// for (PictureEncoding encoding : values) {
// if (encoding.code.equals(code)) {
// return encoding;
// }
// }
// throw new IllegalArgumentException("Unsupported picture encoding: " + code);
// }
//
// public static String[] toString(PictureEncoding[] encodings) {
// final String[] array = new String[encodings.length];
// for (int i = 0; i < encodings.length; ++i) {
// array[i] = encodings[i].toString();
// }
// return array;
// }
//
// }
| import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import xpra.compression.CompressionException;
import xpra.compression.Decompressor;
import xpra.compression.Decompressors;
import xpra.protocol.PictureEncoding; | /*
* Copyright (C) 2020 Jakub Ksiezniak
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package xpra.protocol.packets;
public class DrawPacket extends WindowPacket {
public int x;
public int y;
public int w;
public int h; | // Path: xpra-common/src/main/java/xpra/compression/CompressionException.java
// public class CompressionException extends IOException {
//
// public CompressionException(String s) {
// super(s);
// }
//
// public CompressionException(String s, Throwable throwable) {
// super(s, throwable);
// }
// }
//
// Path: xpra-common/src/main/java/xpra/compression/Decompressor.java
// public interface Decompressor {
//
// boolean decompress(byte[] inputData, byte[] outputData) throws CompressionException;
// }
//
// Path: xpra-common/src/main/java/xpra/compression/Decompressors.java
// public class Decompressors {
//
// public static final String COMP_ZLIB = "zlib";
//
// public static Decompressor zlib() {
// return new ZLib();
// }
//
// public static Decompressor getByName(String compressionName) {
// switch (compressionName) {
// case COMP_ZLIB: return zlib();
// default:
// throw new UnsupportedOperationException("Unsupported compressor used: " + compressionName);
// }
// }
// }
//
// Path: xpra-common/src/main/java/xpra/protocol/PictureEncoding.java
// public enum PictureEncoding {
// rgb24,
// rgb32,
// premult_argb32,
// jpeg,
// png,
// pngP("png/P"),
// pngL("png/L");
//
// private static final PictureEncoding[] values = values();
// private final String code;
//
// PictureEncoding() {
// code = name();
// }
//
// PictureEncoding(String code) {
// this.code = code;
// }
//
// @Override
// public String toString() {
// return code;
// }
//
// public static PictureEncoding decode(String code) {
// for (PictureEncoding encoding : values) {
// if (encoding.code.equals(code)) {
// return encoding;
// }
// }
// throw new IllegalArgumentException("Unsupported picture encoding: " + code);
// }
//
// public static String[] toString(PictureEncoding[] encodings) {
// final String[] array = new String[encodings.length];
// for (int i = 0; i < encodings.length; ++i) {
// array[i] = encodings[i].toString();
// }
// return array;
// }
//
// }
// Path: xpra-common/src/main/java/xpra/protocol/packets/DrawPacket.java
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import xpra.compression.CompressionException;
import xpra.compression.Decompressor;
import xpra.compression.Decompressors;
import xpra.protocol.PictureEncoding;
/*
* Copyright (C) 2020 Jakub Ksiezniak
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package xpra.protocol.packets;
public class DrawPacket extends WindowPacket {
public int x;
public int y;
public int w;
public int h; | public PictureEncoding encoding; |
jksiezni/xpra-client | xpra-common/src/main/java/xpra/protocol/packets/DrawPacket.java | // Path: xpra-common/src/main/java/xpra/compression/CompressionException.java
// public class CompressionException extends IOException {
//
// public CompressionException(String s) {
// super(s);
// }
//
// public CompressionException(String s, Throwable throwable) {
// super(s, throwable);
// }
// }
//
// Path: xpra-common/src/main/java/xpra/compression/Decompressor.java
// public interface Decompressor {
//
// boolean decompress(byte[] inputData, byte[] outputData) throws CompressionException;
// }
//
// Path: xpra-common/src/main/java/xpra/compression/Decompressors.java
// public class Decompressors {
//
// public static final String COMP_ZLIB = "zlib";
//
// public static Decompressor zlib() {
// return new ZLib();
// }
//
// public static Decompressor getByName(String compressionName) {
// switch (compressionName) {
// case COMP_ZLIB: return zlib();
// default:
// throw new UnsupportedOperationException("Unsupported compressor used: " + compressionName);
// }
// }
// }
//
// Path: xpra-common/src/main/java/xpra/protocol/PictureEncoding.java
// public enum PictureEncoding {
// rgb24,
// rgb32,
// premult_argb32,
// jpeg,
// png,
// pngP("png/P"),
// pngL("png/L");
//
// private static final PictureEncoding[] values = values();
// private final String code;
//
// PictureEncoding() {
// code = name();
// }
//
// PictureEncoding(String code) {
// this.code = code;
// }
//
// @Override
// public String toString() {
// return code;
// }
//
// public static PictureEncoding decode(String code) {
// for (PictureEncoding encoding : values) {
// if (encoding.code.equals(code)) {
// return encoding;
// }
// }
// throw new IllegalArgumentException("Unsupported picture encoding: " + code);
// }
//
// public static String[] toString(PictureEncoding[] encodings) {
// final String[] array = new String[encodings.length];
// for (int i = 0; i < encodings.length; ++i) {
// array[i] = encodings[i].toString();
// }
// return array;
// }
//
// }
| import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import xpra.compression.CompressionException;
import xpra.compression.Decompressor;
import xpra.compression.Decompressors;
import xpra.protocol.PictureEncoding; | /*
* Copyright (C) 2020 Jakub Ksiezniak
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package xpra.protocol.packets;
public class DrawPacket extends WindowPacket {
public int x;
public int y;
public int w;
public int h;
public PictureEncoding encoding;
public byte[] data;
public int packet_sequence;
public int rowstride;
public Map<String, Object> options = new HashMap<>();
public DrawPacket() {
super("draw");
}
@Override
public void deserialize(Iterator<Object> iter) {
super.deserialize(iter);
x = asInt(iter.next());
y = asInt(iter.next());
w = asInt(iter.next());
h = asInt(iter.next());
encoding = PictureEncoding.decode(asString(iter.next()));
data = asByteArray(iter.next());
packet_sequence = asInt(iter.next());
rowstride = asInt(iter.next());
if (iter.hasNext()) {
options = asMap(iter.next());
}
}
| // Path: xpra-common/src/main/java/xpra/compression/CompressionException.java
// public class CompressionException extends IOException {
//
// public CompressionException(String s) {
// super(s);
// }
//
// public CompressionException(String s, Throwable throwable) {
// super(s, throwable);
// }
// }
//
// Path: xpra-common/src/main/java/xpra/compression/Decompressor.java
// public interface Decompressor {
//
// boolean decompress(byte[] inputData, byte[] outputData) throws CompressionException;
// }
//
// Path: xpra-common/src/main/java/xpra/compression/Decompressors.java
// public class Decompressors {
//
// public static final String COMP_ZLIB = "zlib";
//
// public static Decompressor zlib() {
// return new ZLib();
// }
//
// public static Decompressor getByName(String compressionName) {
// switch (compressionName) {
// case COMP_ZLIB: return zlib();
// default:
// throw new UnsupportedOperationException("Unsupported compressor used: " + compressionName);
// }
// }
// }
//
// Path: xpra-common/src/main/java/xpra/protocol/PictureEncoding.java
// public enum PictureEncoding {
// rgb24,
// rgb32,
// premult_argb32,
// jpeg,
// png,
// pngP("png/P"),
// pngL("png/L");
//
// private static final PictureEncoding[] values = values();
// private final String code;
//
// PictureEncoding() {
// code = name();
// }
//
// PictureEncoding(String code) {
// this.code = code;
// }
//
// @Override
// public String toString() {
// return code;
// }
//
// public static PictureEncoding decode(String code) {
// for (PictureEncoding encoding : values) {
// if (encoding.code.equals(code)) {
// return encoding;
// }
// }
// throw new IllegalArgumentException("Unsupported picture encoding: " + code);
// }
//
// public static String[] toString(PictureEncoding[] encodings) {
// final String[] array = new String[encodings.length];
// for (int i = 0; i < encodings.length; ++i) {
// array[i] = encodings[i].toString();
// }
// return array;
// }
//
// }
// Path: xpra-common/src/main/java/xpra/protocol/packets/DrawPacket.java
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import xpra.compression.CompressionException;
import xpra.compression.Decompressor;
import xpra.compression.Decompressors;
import xpra.protocol.PictureEncoding;
/*
* Copyright (C) 2020 Jakub Ksiezniak
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package xpra.protocol.packets;
public class DrawPacket extends WindowPacket {
public int x;
public int y;
public int w;
public int h;
public PictureEncoding encoding;
public byte[] data;
public int packet_sequence;
public int rowstride;
public Map<String, Object> options = new HashMap<>();
public DrawPacket() {
super("draw");
}
@Override
public void deserialize(Iterator<Object> iter) {
super.deserialize(iter);
x = asInt(iter.next());
y = asInt(iter.next());
w = asInt(iter.next());
h = asInt(iter.next());
encoding = PictureEncoding.decode(asString(iter.next()));
data = asByteArray(iter.next());
packet_sequence = asInt(iter.next());
rowstride = asInt(iter.next());
if (iter.hasNext()) {
options = asMap(iter.next());
}
}
| public byte[] readPixels() throws CompressionException { |
jksiezni/xpra-client | xpra-common/src/main/java/xpra/protocol/packets/DrawPacket.java | // Path: xpra-common/src/main/java/xpra/compression/CompressionException.java
// public class CompressionException extends IOException {
//
// public CompressionException(String s) {
// super(s);
// }
//
// public CompressionException(String s, Throwable throwable) {
// super(s, throwable);
// }
// }
//
// Path: xpra-common/src/main/java/xpra/compression/Decompressor.java
// public interface Decompressor {
//
// boolean decompress(byte[] inputData, byte[] outputData) throws CompressionException;
// }
//
// Path: xpra-common/src/main/java/xpra/compression/Decompressors.java
// public class Decompressors {
//
// public static final String COMP_ZLIB = "zlib";
//
// public static Decompressor zlib() {
// return new ZLib();
// }
//
// public static Decompressor getByName(String compressionName) {
// switch (compressionName) {
// case COMP_ZLIB: return zlib();
// default:
// throw new UnsupportedOperationException("Unsupported compressor used: " + compressionName);
// }
// }
// }
//
// Path: xpra-common/src/main/java/xpra/protocol/PictureEncoding.java
// public enum PictureEncoding {
// rgb24,
// rgb32,
// premult_argb32,
// jpeg,
// png,
// pngP("png/P"),
// pngL("png/L");
//
// private static final PictureEncoding[] values = values();
// private final String code;
//
// PictureEncoding() {
// code = name();
// }
//
// PictureEncoding(String code) {
// this.code = code;
// }
//
// @Override
// public String toString() {
// return code;
// }
//
// public static PictureEncoding decode(String code) {
// for (PictureEncoding encoding : values) {
// if (encoding.code.equals(code)) {
// return encoding;
// }
// }
// throw new IllegalArgumentException("Unsupported picture encoding: " + code);
// }
//
// public static String[] toString(PictureEncoding[] encodings) {
// final String[] array = new String[encodings.length];
// for (int i = 0; i < encodings.length; ++i) {
// array[i] = encodings[i].toString();
// }
// return array;
// }
//
// }
| import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import xpra.compression.CompressionException;
import xpra.compression.Decompressor;
import xpra.compression.Decompressors;
import xpra.protocol.PictureEncoding; | /*
* Copyright (C) 2020 Jakub Ksiezniak
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package xpra.protocol.packets;
public class DrawPacket extends WindowPacket {
public int x;
public int y;
public int w;
public int h;
public PictureEncoding encoding;
public byte[] data;
public int packet_sequence;
public int rowstride;
public Map<String, Object> options = new HashMap<>();
public DrawPacket() {
super("draw");
}
@Override
public void deserialize(Iterator<Object> iter) {
super.deserialize(iter);
x = asInt(iter.next());
y = asInt(iter.next());
w = asInt(iter.next());
h = asInt(iter.next());
encoding = PictureEncoding.decode(asString(iter.next()));
data = asByteArray(iter.next());
packet_sequence = asInt(iter.next());
rowstride = asInt(iter.next());
if (iter.hasNext()) {
options = asMap(iter.next());
}
}
public byte[] readPixels() throws CompressionException { | // Path: xpra-common/src/main/java/xpra/compression/CompressionException.java
// public class CompressionException extends IOException {
//
// public CompressionException(String s) {
// super(s);
// }
//
// public CompressionException(String s, Throwable throwable) {
// super(s, throwable);
// }
// }
//
// Path: xpra-common/src/main/java/xpra/compression/Decompressor.java
// public interface Decompressor {
//
// boolean decompress(byte[] inputData, byte[] outputData) throws CompressionException;
// }
//
// Path: xpra-common/src/main/java/xpra/compression/Decompressors.java
// public class Decompressors {
//
// public static final String COMP_ZLIB = "zlib";
//
// public static Decompressor zlib() {
// return new ZLib();
// }
//
// public static Decompressor getByName(String compressionName) {
// switch (compressionName) {
// case COMP_ZLIB: return zlib();
// default:
// throw new UnsupportedOperationException("Unsupported compressor used: " + compressionName);
// }
// }
// }
//
// Path: xpra-common/src/main/java/xpra/protocol/PictureEncoding.java
// public enum PictureEncoding {
// rgb24,
// rgb32,
// premult_argb32,
// jpeg,
// png,
// pngP("png/P"),
// pngL("png/L");
//
// private static final PictureEncoding[] values = values();
// private final String code;
//
// PictureEncoding() {
// code = name();
// }
//
// PictureEncoding(String code) {
// this.code = code;
// }
//
// @Override
// public String toString() {
// return code;
// }
//
// public static PictureEncoding decode(String code) {
// for (PictureEncoding encoding : values) {
// if (encoding.code.equals(code)) {
// return encoding;
// }
// }
// throw new IllegalArgumentException("Unsupported picture encoding: " + code);
// }
//
// public static String[] toString(PictureEncoding[] encodings) {
// final String[] array = new String[encodings.length];
// for (int i = 0; i < encodings.length; ++i) {
// array[i] = encodings[i].toString();
// }
// return array;
// }
//
// }
// Path: xpra-common/src/main/java/xpra/protocol/packets/DrawPacket.java
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import xpra.compression.CompressionException;
import xpra.compression.Decompressor;
import xpra.compression.Decompressors;
import xpra.protocol.PictureEncoding;
/*
* Copyright (C) 2020 Jakub Ksiezniak
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package xpra.protocol.packets;
public class DrawPacket extends WindowPacket {
public int x;
public int y;
public int w;
public int h;
public PictureEncoding encoding;
public byte[] data;
public int packet_sequence;
public int rowstride;
public Map<String, Object> options = new HashMap<>();
public DrawPacket() {
super("draw");
}
@Override
public void deserialize(Iterator<Object> iter) {
super.deserialize(iter);
x = asInt(iter.next());
y = asInt(iter.next());
w = asInt(iter.next());
h = asInt(iter.next());
encoding = PictureEncoding.decode(asString(iter.next()));
data = asByteArray(iter.next());
packet_sequence = asInt(iter.next());
rowstride = asInt(iter.next());
if (iter.hasNext()) {
options = asMap(iter.next());
}
}
public byte[] readPixels() throws CompressionException { | if (options.containsKey(Decompressors.COMP_ZLIB)) { |
jksiezni/xpra-client | xpra-common/src/main/java/xpra/protocol/packets/DrawPacket.java | // Path: xpra-common/src/main/java/xpra/compression/CompressionException.java
// public class CompressionException extends IOException {
//
// public CompressionException(String s) {
// super(s);
// }
//
// public CompressionException(String s, Throwable throwable) {
// super(s, throwable);
// }
// }
//
// Path: xpra-common/src/main/java/xpra/compression/Decompressor.java
// public interface Decompressor {
//
// boolean decompress(byte[] inputData, byte[] outputData) throws CompressionException;
// }
//
// Path: xpra-common/src/main/java/xpra/compression/Decompressors.java
// public class Decompressors {
//
// public static final String COMP_ZLIB = "zlib";
//
// public static Decompressor zlib() {
// return new ZLib();
// }
//
// public static Decompressor getByName(String compressionName) {
// switch (compressionName) {
// case COMP_ZLIB: return zlib();
// default:
// throw new UnsupportedOperationException("Unsupported compressor used: " + compressionName);
// }
// }
// }
//
// Path: xpra-common/src/main/java/xpra/protocol/PictureEncoding.java
// public enum PictureEncoding {
// rgb24,
// rgb32,
// premult_argb32,
// jpeg,
// png,
// pngP("png/P"),
// pngL("png/L");
//
// private static final PictureEncoding[] values = values();
// private final String code;
//
// PictureEncoding() {
// code = name();
// }
//
// PictureEncoding(String code) {
// this.code = code;
// }
//
// @Override
// public String toString() {
// return code;
// }
//
// public static PictureEncoding decode(String code) {
// for (PictureEncoding encoding : values) {
// if (encoding.code.equals(code)) {
// return encoding;
// }
// }
// throw new IllegalArgumentException("Unsupported picture encoding: " + code);
// }
//
// public static String[] toString(PictureEncoding[] encodings) {
// final String[] array = new String[encodings.length];
// for (int i = 0; i < encodings.length; ++i) {
// array[i] = encodings[i].toString();
// }
// return array;
// }
//
// }
| import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import xpra.compression.CompressionException;
import xpra.compression.Decompressor;
import xpra.compression.Decompressors;
import xpra.protocol.PictureEncoding; | public int h;
public PictureEncoding encoding;
public byte[] data;
public int packet_sequence;
public int rowstride;
public Map<String, Object> options = new HashMap<>();
public DrawPacket() {
super("draw");
}
@Override
public void deserialize(Iterator<Object> iter) {
super.deserialize(iter);
x = asInt(iter.next());
y = asInt(iter.next());
w = asInt(iter.next());
h = asInt(iter.next());
encoding = PictureEncoding.decode(asString(iter.next()));
data = asByteArray(iter.next());
packet_sequence = asInt(iter.next());
rowstride = asInt(iter.next());
if (iter.hasNext()) {
options = asMap(iter.next());
}
}
public byte[] readPixels() throws CompressionException {
if (options.containsKey(Decompressors.COMP_ZLIB)) { | // Path: xpra-common/src/main/java/xpra/compression/CompressionException.java
// public class CompressionException extends IOException {
//
// public CompressionException(String s) {
// super(s);
// }
//
// public CompressionException(String s, Throwable throwable) {
// super(s, throwable);
// }
// }
//
// Path: xpra-common/src/main/java/xpra/compression/Decompressor.java
// public interface Decompressor {
//
// boolean decompress(byte[] inputData, byte[] outputData) throws CompressionException;
// }
//
// Path: xpra-common/src/main/java/xpra/compression/Decompressors.java
// public class Decompressors {
//
// public static final String COMP_ZLIB = "zlib";
//
// public static Decompressor zlib() {
// return new ZLib();
// }
//
// public static Decompressor getByName(String compressionName) {
// switch (compressionName) {
// case COMP_ZLIB: return zlib();
// default:
// throw new UnsupportedOperationException("Unsupported compressor used: " + compressionName);
// }
// }
// }
//
// Path: xpra-common/src/main/java/xpra/protocol/PictureEncoding.java
// public enum PictureEncoding {
// rgb24,
// rgb32,
// premult_argb32,
// jpeg,
// png,
// pngP("png/P"),
// pngL("png/L");
//
// private static final PictureEncoding[] values = values();
// private final String code;
//
// PictureEncoding() {
// code = name();
// }
//
// PictureEncoding(String code) {
// this.code = code;
// }
//
// @Override
// public String toString() {
// return code;
// }
//
// public static PictureEncoding decode(String code) {
// for (PictureEncoding encoding : values) {
// if (encoding.code.equals(code)) {
// return encoding;
// }
// }
// throw new IllegalArgumentException("Unsupported picture encoding: " + code);
// }
//
// public static String[] toString(PictureEncoding[] encodings) {
// final String[] array = new String[encodings.length];
// for (int i = 0; i < encodings.length; ++i) {
// array[i] = encodings[i].toString();
// }
// return array;
// }
//
// }
// Path: xpra-common/src/main/java/xpra/protocol/packets/DrawPacket.java
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import xpra.compression.CompressionException;
import xpra.compression.Decompressor;
import xpra.compression.Decompressors;
import xpra.protocol.PictureEncoding;
public int h;
public PictureEncoding encoding;
public byte[] data;
public int packet_sequence;
public int rowstride;
public Map<String, Object> options = new HashMap<>();
public DrawPacket() {
super("draw");
}
@Override
public void deserialize(Iterator<Object> iter) {
super.deserialize(iter);
x = asInt(iter.next());
y = asInt(iter.next());
w = asInt(iter.next());
h = asInt(iter.next());
encoding = PictureEncoding.decode(asString(iter.next()));
data = asByteArray(iter.next());
packet_sequence = asInt(iter.next());
rowstride = asInt(iter.next());
if (iter.hasNext()) {
options = asMap(iter.next());
}
}
public byte[] readPixels() throws CompressionException {
if (options.containsKey(Decompressors.COMP_ZLIB)) { | Decompressor d = Decompressors.getByName(Decompressors.COMP_ZLIB); |
warmsheep/HuobiRobot | code/wp-huobi-robot-task/src/main/java/org/warmsheep/huobi/HuobiService.java | // Path: code/wp-huobi-robot-task/src/main/java/org/warmsheep/enums/CoinType.java
// public enum CoinType {
// /**
// * 1、比特币
// */
// BTC(1, "比特币"),
// /**
// * 2、莱特币
// */
// LTC(2, "莱特币");
//
//
// private String value;
// private int key;
//
// private CoinType(int key, String value) {
// this.key = key;
// this.value = value;
// }
//
// /**
// * 通过下标获得枚举
// */
// public static CoinType getByIndex(Integer index) {
// if (null == index)
// return null;
// for (CoinType at : CoinType.values()) {
// if (at.key == index)
// return at;
// }
// return null;
// }
//
// /**
// * 通过名称获得枚举
// */
// public static CoinType getByValue(String value) {
// if (StringUtils.isBlank(value))
// return null;
// for (CoinType at : CoinType.values()) {
// if (at.value.equals(value))
// return at;
// }
// return null;
// }
//
// @Override
// public String toString() {
// return this.key + ":" + this.value;
// }
//
// public String getValue() {
// return value;
// }
// public void setValue(String value) {
// this.value = value;
// }
//
// public int getKey() {
// return key;
// }
// public void setKey(int key) {
// this.key = key;
// }
// }
| import java.util.TreeMap;
import org.apache.commons.lang.StringUtils;
import org.warmsheep.enums.CoinType; | * @return
* @throws Exception
*/
public String sellMarket(int coinType, String amount, String tradePassword, Integer tradeid, String method)
throws Exception {
TreeMap<String, Object> paraMap = new TreeMap<String, Object>();
paraMap.put("method", method);
paraMap.put("created", getTimestamp());
paraMap.put("access_key", huobiAccessKey);
paraMap.put("secret_key", huobiSecretKey);
paraMap.put("coin_type", coinType);
paraMap.put("amount", amount);
String md5 = sign(paraMap);
paraMap.remove("secret_key");
paraMap.put("sign", md5);
if (StringUtils.isNotEmpty(tradePassword)) {
paraMap.put("trade_password", tradePassword);
}
if (null != tradeid) {
paraMap.put("trade_id", tradeid);
}
return post(paraMap, huobiApiUrl);
}
/**
* 获取一分钟线
* @return
* @throws Exception
*/
public String getMinuteData(int coinType)throws Exception { | // Path: code/wp-huobi-robot-task/src/main/java/org/warmsheep/enums/CoinType.java
// public enum CoinType {
// /**
// * 1、比特币
// */
// BTC(1, "比特币"),
// /**
// * 2、莱特币
// */
// LTC(2, "莱特币");
//
//
// private String value;
// private int key;
//
// private CoinType(int key, String value) {
// this.key = key;
// this.value = value;
// }
//
// /**
// * 通过下标获得枚举
// */
// public static CoinType getByIndex(Integer index) {
// if (null == index)
// return null;
// for (CoinType at : CoinType.values()) {
// if (at.key == index)
// return at;
// }
// return null;
// }
//
// /**
// * 通过名称获得枚举
// */
// public static CoinType getByValue(String value) {
// if (StringUtils.isBlank(value))
// return null;
// for (CoinType at : CoinType.values()) {
// if (at.value.equals(value))
// return at;
// }
// return null;
// }
//
// @Override
// public String toString() {
// return this.key + ":" + this.value;
// }
//
// public String getValue() {
// return value;
// }
// public void setValue(String value) {
// this.value = value;
// }
//
// public int getKey() {
// return key;
// }
// public void setKey(int key) {
// this.key = key;
// }
// }
// Path: code/wp-huobi-robot-task/src/main/java/org/warmsheep/huobi/HuobiService.java
import java.util.TreeMap;
import org.apache.commons.lang.StringUtils;
import org.warmsheep.enums.CoinType;
* @return
* @throws Exception
*/
public String sellMarket(int coinType, String amount, String tradePassword, Integer tradeid, String method)
throws Exception {
TreeMap<String, Object> paraMap = new TreeMap<String, Object>();
paraMap.put("method", method);
paraMap.put("created", getTimestamp());
paraMap.put("access_key", huobiAccessKey);
paraMap.put("secret_key", huobiSecretKey);
paraMap.put("coin_type", coinType);
paraMap.put("amount", amount);
String md5 = sign(paraMap);
paraMap.remove("secret_key");
paraMap.put("sign", md5);
if (StringUtils.isNotEmpty(tradePassword)) {
paraMap.put("trade_password", tradePassword);
}
if (null != tradeid) {
paraMap.put("trade_id", tradeid);
}
return post(paraMap, huobiApiUrl);
}
/**
* 获取一分钟线
* @return
* @throws Exception
*/
public String getMinuteData(int coinType)throws Exception { | if(coinType == CoinType.BTC.getKey()){ |
ccm-innovation/react-native-twilio-ip-messaging | Example/android/app/src/main/java/com/reactnativetwilioipmessagingexample/MainActivity.java | // Path: android/src/main/java/com/bradbumbalough/RCTTwilioIPMessaging/RCTTwilioIPMessagingPackage.java
// public class RCTTwilioIPMessagingPackage implements ReactPackage {
// @Override
// public List<Class<? extends JavaScriptModule>> createJSModules() {
// return Collections.emptyList();
// }
//
// @Override
// public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
// return Collections.emptyList();
// }
//
// @Override
// public List<NativeModule> createNativeModules(
// ReactApplicationContext reactContext) {
// List<NativeModule> modules = new ArrayList<>();
//
// modules.add(new RCTTwilioAccessManager(reactContext));
// modules.add(new RCTTwilioIPMessagingClient(reactContext));
// modules.add(new RCTTwilioIPMessagingChannels(reactContext));
// modules.add(new RCTTwilioIPMessagingMembers(reactContext));
// modules.add(new RCTTwilioIPMessagingMessages(reactContext));
//
// return modules;
// }
// }
| import com.facebook.react.ReactActivity;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import ca.jaysoo.extradimensions.ExtraDimensionsPackage;
import com.bradbumbalough.RCTTwilioIPMessaging.RCTTwilioIPMessagingPackage;
import java.util.Arrays;
import java.util.List; | package com.reactnativetwilioipmessagingexample;
public class MainActivity extends ReactActivity {
/**
* Returns the name of the main component registered from JavaScript.
* This is used to schedule rendering of the component.
*/
@Override
protected String getMainComponentName() {
return "ReactNativeTwilioIPMessagingExample";
}
/**
* Returns whether dev mode should be enabled.
* This enables e.g. the dev menu.
*/
@Override
protected boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
/**
* A list of packages used by the app. If the app uses additional views
* or modules besides the default ones, add more packages here.
*/
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(), | // Path: android/src/main/java/com/bradbumbalough/RCTTwilioIPMessaging/RCTTwilioIPMessagingPackage.java
// public class RCTTwilioIPMessagingPackage implements ReactPackage {
// @Override
// public List<Class<? extends JavaScriptModule>> createJSModules() {
// return Collections.emptyList();
// }
//
// @Override
// public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
// return Collections.emptyList();
// }
//
// @Override
// public List<NativeModule> createNativeModules(
// ReactApplicationContext reactContext) {
// List<NativeModule> modules = new ArrayList<>();
//
// modules.add(new RCTTwilioAccessManager(reactContext));
// modules.add(new RCTTwilioIPMessagingClient(reactContext));
// modules.add(new RCTTwilioIPMessagingChannels(reactContext));
// modules.add(new RCTTwilioIPMessagingMembers(reactContext));
// modules.add(new RCTTwilioIPMessagingMessages(reactContext));
//
// return modules;
// }
// }
// Path: Example/android/app/src/main/java/com/reactnativetwilioipmessagingexample/MainActivity.java
import com.facebook.react.ReactActivity;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import ca.jaysoo.extradimensions.ExtraDimensionsPackage;
import com.bradbumbalough.RCTTwilioIPMessaging.RCTTwilioIPMessagingPackage;
import java.util.Arrays;
import java.util.List;
package com.reactnativetwilioipmessagingexample;
public class MainActivity extends ReactActivity {
/**
* Returns the name of the main component registered from JavaScript.
* This is used to schedule rendering of the component.
*/
@Override
protected String getMainComponentName() {
return "ReactNativeTwilioIPMessagingExample";
}
/**
* Returns whether dev mode should be enabled.
* This enables e.g. the dev menu.
*/
@Override
protected boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
/**
* A list of packages used by the app. If the app uses additional views
* or modules besides the default ones, add more packages here.
*/
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(), | new RCTTwilioIPMessagingPackage(), |
interedition/collatex | collatex-core/src/test/java/eu/interedition/collatex/dekker/BeckettTest.java | // Path: collatex-core/src/main/java/eu/interedition/collatex/matching/Matches.java
// public class Matches {
//
// public final Map<Token, List<VariantGraph.Vertex>> allMatches;
// public final Set<Token> unmatchedInWitness;
// public final Set<Token> ambiguousInWitness;
// public final Set<Token> uniqueInWitness;
//
// public static Matches between(final Iterable<VariantGraph.Vertex> vertices, final Iterable<Token> witnessTokens, Comparator<Token> comparator) {
//
// final Map<Token, List<VariantGraph.Vertex>> allMatches = new HashMap<>();
//
// StreamUtil.stream(vertices).forEach(vertex ->
// vertex.tokens().stream().findFirst().ifPresent(baseToken ->
// StreamUtil.stream(witnessTokens)
// .filter(witnessToken -> comparator.compare(baseToken, witnessToken) == 0)
// .forEach(matchingToken -> allMatches.computeIfAbsent(matchingToken, t -> new ArrayList<>()).add(vertex))));
//
// final Set<Token> unmatchedInWitness = StreamUtil.stream(witnessTokens)
// .filter(t -> !allMatches.containsKey(t))
// .collect(Collectors.toCollection(LinkedHashSet::new));
//
// final Set<VariantGraph.Vertex> ambiguousInBase = allMatches.values().stream()
// .flatMap(List::stream)
// .collect(Collectors.toMap(Function.identity(), v -> 1, (a, b) -> a + b))
// .entrySet()
// .stream()
// .filter(v -> v.getValue() > 1)
// .map(Map.Entry::getKey)
// .collect(Collectors.toCollection(LinkedHashSet::new));
//
// // (have to check: base -> witness, and witness -> base)
// final Set<Token> ambiguousInWitness = Stream.concat(
// StreamUtil.stream(witnessTokens)
// .filter(t -> allMatches.getOrDefault(t, Collections.emptyList()).size() > 1),
//
// allMatches.entrySet().stream()
// .filter(match -> match.getValue().stream().anyMatch(ambiguousInBase::contains))
// .map(Map.Entry::getKey)
// ).collect(Collectors.toCollection(LinkedHashSet::new));
//
// // sure tokens
// // have to check unsure tokens because of (base -> witness && witness -> base)
// final Set<Token> uniqueInWitness = StreamUtil.stream(witnessTokens)
// .filter(t -> allMatches.getOrDefault(t, Collections.emptyList()).size() == 1 && !ambiguousInWitness.contains(t))
// .collect(Collectors.toCollection(LinkedHashSet::new));
//
// return new Matches(allMatches, unmatchedInWitness, ambiguousInWitness, uniqueInWitness);
// }
//
// private Matches(Map<Token, List<VariantGraph.Vertex>> allMatches, Set<Token> unmatchedInWitness, Set<Token> ambiguousInWitness, Set<Token> uniqueInWitness) {
// this.allMatches = Collections.unmodifiableMap(allMatches);
// this.unmatchedInWitness = Collections.unmodifiableSet(unmatchedInWitness);
// this.ambiguousInWitness = Collections.unmodifiableSet(ambiguousInWitness);
// this.uniqueInWitness = Collections.unmodifiableSet(uniqueInWitness);
// }
//
// }
| import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import eu.interedition.collatex.*;
import eu.interedition.collatex.matching.EqualityTokenComparator;
import eu.interedition.collatex.matching.Matches;
import eu.interedition.collatex.simple.SimpleToken;
import eu.interedition.collatex.simple.SimpleWitness;
import org.junit.Assert;
import org.junit.Test;
import java.util.*;
import static eu.interedition.collatex.dekker.Match.PHRASE_MATCH_TO_TOKENS; | /*
* Copyright (c) 2015 The Interedition Development Group.
*
* This file is part of CollateX.
*
* CollateX is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* CollateX 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with CollateX. If not, see <http://www.gnu.org/licenses/>.
*/
package eu.interedition.collatex.dekker;
public class BeckettTest extends AbstractTest {
/**
* The ranking of vertices in the transposition detector should only
* rank matched vertices!!!
*/
@Test
public void testBeckettStrangeTransposition() {
SimpleWitness[] w = createWitnesses("People with things, people without things, things without people, what does it matter. I'm confident I can soon scatter them.", "People with things, people without things, things without people, what does it matter, it will not take me long to scatter them.", "People with things, people without things, things without people, what does it matter, I flatter myself it will not take me long to scatter them, whenever I choose, to the winds.");
final VariantGraph graph = new VariantGraph();
InspectableCollationAlgorithm algo = (InspectableCollationAlgorithm) CollationAlgorithmFactory.dekker(new EqualityTokenComparator());
algo.collate(graph, w);
// List<List<Match>> phraseMatches = algo.getPhraseMatches();
// for (List<Match> phraseMatch: phraseMatches) {
// System.out.println(SimpleToken.toString(PHRASE_MATCH_TO_TOKENS.apply(phraseMatch)));
// }
assertEquals(0, algo.getTranspositions().size());
}
@Test
public void dirkVincent() {
final SimpleWitness[] w = createWitnesses(//
"Its soft light neither daylight nor moonlight nor starlight nor any light he could remember from the days & nights when day followed night & vice versa.",//
"Its soft changeless light unlike any light he could remember from the days and nights when day followed hard on night and vice versa.");
final VariantGraph graph = collate(w[0]); | // Path: collatex-core/src/main/java/eu/interedition/collatex/matching/Matches.java
// public class Matches {
//
// public final Map<Token, List<VariantGraph.Vertex>> allMatches;
// public final Set<Token> unmatchedInWitness;
// public final Set<Token> ambiguousInWitness;
// public final Set<Token> uniqueInWitness;
//
// public static Matches between(final Iterable<VariantGraph.Vertex> vertices, final Iterable<Token> witnessTokens, Comparator<Token> comparator) {
//
// final Map<Token, List<VariantGraph.Vertex>> allMatches = new HashMap<>();
//
// StreamUtil.stream(vertices).forEach(vertex ->
// vertex.tokens().stream().findFirst().ifPresent(baseToken ->
// StreamUtil.stream(witnessTokens)
// .filter(witnessToken -> comparator.compare(baseToken, witnessToken) == 0)
// .forEach(matchingToken -> allMatches.computeIfAbsent(matchingToken, t -> new ArrayList<>()).add(vertex))));
//
// final Set<Token> unmatchedInWitness = StreamUtil.stream(witnessTokens)
// .filter(t -> !allMatches.containsKey(t))
// .collect(Collectors.toCollection(LinkedHashSet::new));
//
// final Set<VariantGraph.Vertex> ambiguousInBase = allMatches.values().stream()
// .flatMap(List::stream)
// .collect(Collectors.toMap(Function.identity(), v -> 1, (a, b) -> a + b))
// .entrySet()
// .stream()
// .filter(v -> v.getValue() > 1)
// .map(Map.Entry::getKey)
// .collect(Collectors.toCollection(LinkedHashSet::new));
//
// // (have to check: base -> witness, and witness -> base)
// final Set<Token> ambiguousInWitness = Stream.concat(
// StreamUtil.stream(witnessTokens)
// .filter(t -> allMatches.getOrDefault(t, Collections.emptyList()).size() > 1),
//
// allMatches.entrySet().stream()
// .filter(match -> match.getValue().stream().anyMatch(ambiguousInBase::contains))
// .map(Map.Entry::getKey)
// ).collect(Collectors.toCollection(LinkedHashSet::new));
//
// // sure tokens
// // have to check unsure tokens because of (base -> witness && witness -> base)
// final Set<Token> uniqueInWitness = StreamUtil.stream(witnessTokens)
// .filter(t -> allMatches.getOrDefault(t, Collections.emptyList()).size() == 1 && !ambiguousInWitness.contains(t))
// .collect(Collectors.toCollection(LinkedHashSet::new));
//
// return new Matches(allMatches, unmatchedInWitness, ambiguousInWitness, uniqueInWitness);
// }
//
// private Matches(Map<Token, List<VariantGraph.Vertex>> allMatches, Set<Token> unmatchedInWitness, Set<Token> ambiguousInWitness, Set<Token> uniqueInWitness) {
// this.allMatches = Collections.unmodifiableMap(allMatches);
// this.unmatchedInWitness = Collections.unmodifiableSet(unmatchedInWitness);
// this.ambiguousInWitness = Collections.unmodifiableSet(ambiguousInWitness);
// this.uniqueInWitness = Collections.unmodifiableSet(uniqueInWitness);
// }
//
// }
// Path: collatex-core/src/test/java/eu/interedition/collatex/dekker/BeckettTest.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import eu.interedition.collatex.*;
import eu.interedition.collatex.matching.EqualityTokenComparator;
import eu.interedition.collatex.matching.Matches;
import eu.interedition.collatex.simple.SimpleToken;
import eu.interedition.collatex.simple.SimpleWitness;
import org.junit.Assert;
import org.junit.Test;
import java.util.*;
import static eu.interedition.collatex.dekker.Match.PHRASE_MATCH_TO_TOKENS;
/*
* Copyright (c) 2015 The Interedition Development Group.
*
* This file is part of CollateX.
*
* CollateX is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* CollateX 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with CollateX. If not, see <http://www.gnu.org/licenses/>.
*/
package eu.interedition.collatex.dekker;
public class BeckettTest extends AbstractTest {
/**
* The ranking of vertices in the transposition detector should only
* rank matched vertices!!!
*/
@Test
public void testBeckettStrangeTransposition() {
SimpleWitness[] w = createWitnesses("People with things, people without things, things without people, what does it matter. I'm confident I can soon scatter them.", "People with things, people without things, things without people, what does it matter, it will not take me long to scatter them.", "People with things, people without things, things without people, what does it matter, I flatter myself it will not take me long to scatter them, whenever I choose, to the winds.");
final VariantGraph graph = new VariantGraph();
InspectableCollationAlgorithm algo = (InspectableCollationAlgorithm) CollationAlgorithmFactory.dekker(new EqualityTokenComparator());
algo.collate(graph, w);
// List<List<Match>> phraseMatches = algo.getPhraseMatches();
// for (List<Match> phraseMatch: phraseMatches) {
// System.out.println(SimpleToken.toString(PHRASE_MATCH_TO_TOKENS.apply(phraseMatch)));
// }
assertEquals(0, algo.getTranspositions().size());
}
@Test
public void dirkVincent() {
final SimpleWitness[] w = createWitnesses(//
"Its soft light neither daylight nor moonlight nor starlight nor any light he could remember from the days & nights when day followed night & vice versa.",//
"Its soft changeless light unlike any light he could remember from the days and nights when day followed hard on night and vice versa.");
final VariantGraph graph = collate(w[0]); | final Map<Token, List<VariantGraph.Vertex>> matches = Matches.between(graph.vertices(), w[1], new EqualityTokenComparator()).allMatches; |
interedition/collatex | collatex-core/src/test/java/eu/interedition/collatex/dekker/legacy/MatchTableLinkerTest.java | // Path: collatex-core/src/main/java/eu/interedition/collatex/matching/StrictEqualityTokenComparator.java
// public class StrictEqualityTokenComparator implements Comparator<Token> {
//
// @Override
// public int compare(Token base, Token witness) {
// final String baseContent = ((SimpleToken) base).getContent();
// final String witnessContent = ((SimpleToken) witness).getContent();
// return baseContent.compareTo(witnessContent);
// }
//
// }
| import java.util.logging.Level;
import java.util.stream.Collectors;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import eu.interedition.collatex.*;
import eu.interedition.collatex.dekker.DekkerAlgorithm;
import eu.interedition.collatex.dekker.Match;
import eu.interedition.collatex.dekker.PhraseMatchDetector;
import eu.interedition.collatex.matching.EqualityTokenComparator;
import eu.interedition.collatex.matching.StrictEqualityTokenComparator;
import eu.interedition.collatex.simple.SimpleWitness;
import org.junit.Test;
import javax.xml.stream.XMLStreamException;
import java.util.*; | assertTrue(tokensAsString.contains("C:4:'voer'"));
assertTrue(tokensAsString.contains("C:5:'een'"));
assertTrue(tokensAsString.contains("C:7:'grote'"));
assertTrue(tokensAsString.contains("C:8:'stomer'"));
}
// String newLine = System.getProperty("line.separator");
@Test
public void test1() {
SimpleWitness[] sw = createWitnesses("A B C A B", "A B C A B");
VariantGraph vg = collate(sw[0]);
MatchTableLinker linker = new MatchTableLinker();
Map<Token, VariantGraph.Vertex> linkedTokens = linker.link(vg, sw[1], new EqualityTokenComparator());
Set<Token> tokens = linkedTokens.keySet();
Set<String> tokensAsString = new LinkedHashSet<>();
for (Token token : tokens) {
tokensAsString.add(token.toString());
}
assertTrue(tokensAsString.contains("B:0:'a'"));
assertTrue(tokensAsString.contains("B:1:'b'"));
assertTrue(tokensAsString.contains("B:2:'c'"));
assertTrue(tokensAsString.contains("B:3:'a'"));
assertTrue(tokensAsString.contains("B:4:'b'"));
}
@Test
public void testOverDeAtlantischeOceaan() {
int outlierTranspositionsSizeLimit = 1; | // Path: collatex-core/src/main/java/eu/interedition/collatex/matching/StrictEqualityTokenComparator.java
// public class StrictEqualityTokenComparator implements Comparator<Token> {
//
// @Override
// public int compare(Token base, Token witness) {
// final String baseContent = ((SimpleToken) base).getContent();
// final String witnessContent = ((SimpleToken) witness).getContent();
// return baseContent.compareTo(witnessContent);
// }
//
// }
// Path: collatex-core/src/test/java/eu/interedition/collatex/dekker/legacy/MatchTableLinkerTest.java
import java.util.logging.Level;
import java.util.stream.Collectors;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import eu.interedition.collatex.*;
import eu.interedition.collatex.dekker.DekkerAlgorithm;
import eu.interedition.collatex.dekker.Match;
import eu.interedition.collatex.dekker.PhraseMatchDetector;
import eu.interedition.collatex.matching.EqualityTokenComparator;
import eu.interedition.collatex.matching.StrictEqualityTokenComparator;
import eu.interedition.collatex.simple.SimpleWitness;
import org.junit.Test;
import javax.xml.stream.XMLStreamException;
import java.util.*;
assertTrue(tokensAsString.contains("C:4:'voer'"));
assertTrue(tokensAsString.contains("C:5:'een'"));
assertTrue(tokensAsString.contains("C:7:'grote'"));
assertTrue(tokensAsString.contains("C:8:'stomer'"));
}
// String newLine = System.getProperty("line.separator");
@Test
public void test1() {
SimpleWitness[] sw = createWitnesses("A B C A B", "A B C A B");
VariantGraph vg = collate(sw[0]);
MatchTableLinker linker = new MatchTableLinker();
Map<Token, VariantGraph.Vertex> linkedTokens = linker.link(vg, sw[1], new EqualityTokenComparator());
Set<Token> tokens = linkedTokens.keySet();
Set<String> tokensAsString = new LinkedHashSet<>();
for (Token token : tokens) {
tokensAsString.add(token.toString());
}
assertTrue(tokensAsString.contains("B:0:'a'"));
assertTrue(tokensAsString.contains("B:1:'b'"));
assertTrue(tokensAsString.contains("B:2:'c'"));
assertTrue(tokensAsString.contains("B:3:'a'"));
assertTrue(tokensAsString.contains("B:4:'b'"));
}
@Test
public void testOverDeAtlantischeOceaan() {
int outlierTranspositionsSizeLimit = 1; | collationAlgorithm = new DekkerAlgorithm(new StrictEqualityTokenComparator()); |
tinkerlog/PaintMachine | PrintClient/app/src/main/java/com/tinkerlog/printclient/view/CustomToggleButton.java | // Path: PrintClient/app/src/main/java/com/tinkerlog/printclient/util/FontCache.java
// public class FontCache {
//
// private static Map<String, Typeface> fontMap = new HashMap<String, Typeface>();
//
// public static Typeface getFont(Context context, String fontName){
// if (fontMap.containsKey(fontName)){
// return fontMap.get(fontName);
// }
// else {
// Typeface tf = Typeface.createFromAsset(context.getAssets(), fontName);
// fontMap.put(fontName, tf);
// return tf;
// }
// }
// }
| import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Typeface;
import android.util.AttributeSet;
import android.widget.ToggleButton;
import com.tinkerlog.printclient.R;
import com.tinkerlog.printclient.util.FontCache; | package com.tinkerlog.printclient.view;
public class CustomToggleButton extends ToggleButton {
public CustomToggleButton(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
initialize(context, attrs);
}
public CustomToggleButton(Context context, AttributeSet attrs) {
super(context, attrs);
initialize(context, attrs);
}
public CustomToggleButton(Context context) {
super(context);
initialize(context, null);
}
private void initialize(Context context, AttributeSet attrs) {
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CustomTextView);
String fontName = a.getString(R.styleable.CustomTextView_fontName);
if (fontName != null) { | // Path: PrintClient/app/src/main/java/com/tinkerlog/printclient/util/FontCache.java
// public class FontCache {
//
// private static Map<String, Typeface> fontMap = new HashMap<String, Typeface>();
//
// public static Typeface getFont(Context context, String fontName){
// if (fontMap.containsKey(fontName)){
// return fontMap.get(fontName);
// }
// else {
// Typeface tf = Typeface.createFromAsset(context.getAssets(), fontName);
// fontMap.put(fontName, tf);
// return tf;
// }
// }
// }
// Path: PrintClient/app/src/main/java/com/tinkerlog/printclient/view/CustomToggleButton.java
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Typeface;
import android.util.AttributeSet;
import android.widget.ToggleButton;
import com.tinkerlog.printclient.R;
import com.tinkerlog.printclient.util.FontCache;
package com.tinkerlog.printclient.view;
public class CustomToggleButton extends ToggleButton {
public CustomToggleButton(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
initialize(context, attrs);
}
public CustomToggleButton(Context context, AttributeSet attrs) {
super(context, attrs);
initialize(context, attrs);
}
public CustomToggleButton(Context context) {
super(context);
initialize(context, null);
}
private void initialize(Context context, AttributeSet attrs) {
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CustomTextView);
String fontName = a.getString(R.styleable.CustomTextView_fontName);
if (fontName != null) { | Typeface tf = FontCache.getFont(context, fontName); |
tinkerlog/PaintMachine | PrintClient/app/src/main/java/com/tinkerlog/printclient/view/CustomTextView.java | // Path: PrintClient/app/src/main/java/com/tinkerlog/printclient/util/FontCache.java
// public class FontCache {
//
// private static Map<String, Typeface> fontMap = new HashMap<String, Typeface>();
//
// public static Typeface getFont(Context context, String fontName){
// if (fontMap.containsKey(fontName)){
// return fontMap.get(fontName);
// }
// else {
// Typeface tf = Typeface.createFromAsset(context.getAssets(), fontName);
// fontMap.put(fontName, tf);
// return tf;
// }
// }
// }
| import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Typeface;
import android.util.AttributeSet;
import android.widget.TextView;
import com.tinkerlog.printclient.R;
import com.tinkerlog.printclient.util.FontCache; | package com.tinkerlog.printclient.view;
public class CustomTextView extends TextView {
public CustomTextView(Context context) {
super(context);
initialize(context, null);
}
public CustomTextView(Context context, AttributeSet attrs) {
super(context, attrs);
initialize(context, attrs);
}
public CustomTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
initialize(context, attrs);
}
private void initialize(Context context, AttributeSet attrs) {
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CustomTextView);
String fontName = a.getString(R.styleable.CustomTextView_fontName);
if (fontName != null) { | // Path: PrintClient/app/src/main/java/com/tinkerlog/printclient/util/FontCache.java
// public class FontCache {
//
// private static Map<String, Typeface> fontMap = new HashMap<String, Typeface>();
//
// public static Typeface getFont(Context context, String fontName){
// if (fontMap.containsKey(fontName)){
// return fontMap.get(fontName);
// }
// else {
// Typeface tf = Typeface.createFromAsset(context.getAssets(), fontName);
// fontMap.put(fontName, tf);
// return tf;
// }
// }
// }
// Path: PrintClient/app/src/main/java/com/tinkerlog/printclient/view/CustomTextView.java
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Typeface;
import android.util.AttributeSet;
import android.widget.TextView;
import com.tinkerlog.printclient.R;
import com.tinkerlog.printclient.util.FontCache;
package com.tinkerlog.printclient.view;
public class CustomTextView extends TextView {
public CustomTextView(Context context) {
super(context);
initialize(context, null);
}
public CustomTextView(Context context, AttributeSet attrs) {
super(context, attrs);
initialize(context, attrs);
}
public CustomTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
initialize(context, attrs);
}
private void initialize(Context context, AttributeSet attrs) {
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CustomTextView);
String fontName = a.getString(R.styleable.CustomTextView_fontName);
if (fontName != null) { | Typeface tf = FontCache.getFont(context, fontName); |
tinkerlog/PaintMachine | PrintClient/app/src/main/java/com/tinkerlog/printclient/network/ComThread.java | // Path: PrintClient/app/src/main/java/com/tinkerlog/printclient/model/Command.java
// public class Command {
//
// protected String request;
// protected String response;
// public ResponseHandler handler;
//
// public Command(String request, ResponseHandler handler) {
// this.request = request;
// this.handler = handler;
// }
//
// public void setResponse(String response) {
// this.response = response;
// }
//
// public String getResponse() {
// return response;
// }
//
// public String getRequest() {
// return request;
// }
//
// public byte[] getPayload() {
// return request.getBytes();
// }
// }
//
// Path: PrintClient/app/src/main/java/com/tinkerlog/printclient/util/ResponseHandler.java
// public class ResponseHandler extends Handler {
//
// private static final String TAG = "ResponseHandler";
//
// public static final int OK = 1;
// public static final int ERROR = 2;
//
// public ResponseHandler() {
// super();
// }
//
// public ResponseHandler(Callback callback) {
// super(callback);
// }
//
// public ResponseHandler(Looper looper) {
// super(looper);
// }
//
// public ResponseHandler(Looper looper, Callback callback) {
// super(looper, callback);
// }
//
// @Override
// public void handleMessage(Message msg) {
// switch (msg.what) {
// case OK:
// handleSuccess((Command)msg.obj);
// break;
// case ERROR:
// handleFailed((Command)msg.obj);
// break;
// }
// }
//
// public void handleFailed(Command cmd) {
// Log.e(TAG, "failed: " + cmd.getRequest());
// }
//
// public void handleSuccess(Command cmd) {
// Log.d(TAG, "success: " + cmd.getResponse());
// }
//
// }
| import android.os.Message;
import android.util.Log;
import com.tinkerlog.printclient.model.Command;
import com.tinkerlog.printclient.util.ResponseHandler;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit; | package com.tinkerlog.printclient.network;
public class ComThread extends Thread {
public interface ComCallback {
void closed();
void failed(String errorMsg);
}
private static final String TAG = "ComThread";
private static final String SERVER_IP = "192.168.4.1";
private static final int SERVER_PORT = 81;
private static final String MSG_PING = "ping";
private static final int MAX_BUFFER = 1024;
private static final int MAX_SOCKET_TIMEOUT = 1000;
| // Path: PrintClient/app/src/main/java/com/tinkerlog/printclient/model/Command.java
// public class Command {
//
// protected String request;
// protected String response;
// public ResponseHandler handler;
//
// public Command(String request, ResponseHandler handler) {
// this.request = request;
// this.handler = handler;
// }
//
// public void setResponse(String response) {
// this.response = response;
// }
//
// public String getResponse() {
// return response;
// }
//
// public String getRequest() {
// return request;
// }
//
// public byte[] getPayload() {
// return request.getBytes();
// }
// }
//
// Path: PrintClient/app/src/main/java/com/tinkerlog/printclient/util/ResponseHandler.java
// public class ResponseHandler extends Handler {
//
// private static final String TAG = "ResponseHandler";
//
// public static final int OK = 1;
// public static final int ERROR = 2;
//
// public ResponseHandler() {
// super();
// }
//
// public ResponseHandler(Callback callback) {
// super(callback);
// }
//
// public ResponseHandler(Looper looper) {
// super(looper);
// }
//
// public ResponseHandler(Looper looper, Callback callback) {
// super(looper, callback);
// }
//
// @Override
// public void handleMessage(Message msg) {
// switch (msg.what) {
// case OK:
// handleSuccess((Command)msg.obj);
// break;
// case ERROR:
// handleFailed((Command)msg.obj);
// break;
// }
// }
//
// public void handleFailed(Command cmd) {
// Log.e(TAG, "failed: " + cmd.getRequest());
// }
//
// public void handleSuccess(Command cmd) {
// Log.d(TAG, "success: " + cmd.getResponse());
// }
//
// }
// Path: PrintClient/app/src/main/java/com/tinkerlog/printclient/network/ComThread.java
import android.os.Message;
import android.util.Log;
import com.tinkerlog.printclient.model.Command;
import com.tinkerlog.printclient.util.ResponseHandler;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
package com.tinkerlog.printclient.network;
public class ComThread extends Thread {
public interface ComCallback {
void closed();
void failed(String errorMsg);
}
private static final String TAG = "ComThread";
private static final String SERVER_IP = "192.168.4.1";
private static final int SERVER_PORT = 81;
private static final String MSG_PING = "ping";
private static final int MAX_BUFFER = 1024;
private static final int MAX_SOCKET_TIMEOUT = 1000;
| private BlockingQueue<Command> outQueue = new LinkedBlockingQueue<>(8); |
tinkerlog/PaintMachine | PrintClient/app/src/main/java/com/tinkerlog/printclient/network/ComThread.java | // Path: PrintClient/app/src/main/java/com/tinkerlog/printclient/model/Command.java
// public class Command {
//
// protected String request;
// protected String response;
// public ResponseHandler handler;
//
// public Command(String request, ResponseHandler handler) {
// this.request = request;
// this.handler = handler;
// }
//
// public void setResponse(String response) {
// this.response = response;
// }
//
// public String getResponse() {
// return response;
// }
//
// public String getRequest() {
// return request;
// }
//
// public byte[] getPayload() {
// return request.getBytes();
// }
// }
//
// Path: PrintClient/app/src/main/java/com/tinkerlog/printclient/util/ResponseHandler.java
// public class ResponseHandler extends Handler {
//
// private static final String TAG = "ResponseHandler";
//
// public static final int OK = 1;
// public static final int ERROR = 2;
//
// public ResponseHandler() {
// super();
// }
//
// public ResponseHandler(Callback callback) {
// super(callback);
// }
//
// public ResponseHandler(Looper looper) {
// super(looper);
// }
//
// public ResponseHandler(Looper looper, Callback callback) {
// super(looper, callback);
// }
//
// @Override
// public void handleMessage(Message msg) {
// switch (msg.what) {
// case OK:
// handleSuccess((Command)msg.obj);
// break;
// case ERROR:
// handleFailed((Command)msg.obj);
// break;
// }
// }
//
// public void handleFailed(Command cmd) {
// Log.e(TAG, "failed: " + cmd.getRequest());
// }
//
// public void handleSuccess(Command cmd) {
// Log.d(TAG, "success: " + cmd.getResponse());
// }
//
// }
| import android.os.Message;
import android.util.Log;
import com.tinkerlog.printclient.model.Command;
import com.tinkerlog.printclient.util.ResponseHandler;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit; | socket.setSoTimeout(MAX_SOCKET_TIMEOUT);
socket.connect(new InetSocketAddress(SERVER_IP, SERVER_PORT), 1000);
out = new PrintWriter(new OutputStreamWriter(socket.getOutputStream()), true);
in = new BufferedInputStream(socket.getInputStream());
Log.d(TAG, "socket timeout: " + socket.getSoTimeout());
while (running) {
Command cmd = outQueue.poll(2000, TimeUnit.MILLISECONDS);
if (!running) {
break;
}
if (cmd == null) {
Log.d(TAG, "ping ...");
cmd = new Command(MSG_PING, null);
// continue;
}
else {
Log.d(TAG, "sending: " + cmd.getRequest());
}
out.write(cmd.getRequest());
out.println();
out.flush();
Thread.sleep(1);
int bytesRead = readBuffer(in, inBuffer);
if (bytesRead == -1) {
Log.d(TAG, "no response, socket closed!");
if (cmd.handler != null) { | // Path: PrintClient/app/src/main/java/com/tinkerlog/printclient/model/Command.java
// public class Command {
//
// protected String request;
// protected String response;
// public ResponseHandler handler;
//
// public Command(String request, ResponseHandler handler) {
// this.request = request;
// this.handler = handler;
// }
//
// public void setResponse(String response) {
// this.response = response;
// }
//
// public String getResponse() {
// return response;
// }
//
// public String getRequest() {
// return request;
// }
//
// public byte[] getPayload() {
// return request.getBytes();
// }
// }
//
// Path: PrintClient/app/src/main/java/com/tinkerlog/printclient/util/ResponseHandler.java
// public class ResponseHandler extends Handler {
//
// private static final String TAG = "ResponseHandler";
//
// public static final int OK = 1;
// public static final int ERROR = 2;
//
// public ResponseHandler() {
// super();
// }
//
// public ResponseHandler(Callback callback) {
// super(callback);
// }
//
// public ResponseHandler(Looper looper) {
// super(looper);
// }
//
// public ResponseHandler(Looper looper, Callback callback) {
// super(looper, callback);
// }
//
// @Override
// public void handleMessage(Message msg) {
// switch (msg.what) {
// case OK:
// handleSuccess((Command)msg.obj);
// break;
// case ERROR:
// handleFailed((Command)msg.obj);
// break;
// }
// }
//
// public void handleFailed(Command cmd) {
// Log.e(TAG, "failed: " + cmd.getRequest());
// }
//
// public void handleSuccess(Command cmd) {
// Log.d(TAG, "success: " + cmd.getResponse());
// }
//
// }
// Path: PrintClient/app/src/main/java/com/tinkerlog/printclient/network/ComThread.java
import android.os.Message;
import android.util.Log;
import com.tinkerlog.printclient.model.Command;
import com.tinkerlog.printclient.util.ResponseHandler;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
socket.setSoTimeout(MAX_SOCKET_TIMEOUT);
socket.connect(new InetSocketAddress(SERVER_IP, SERVER_PORT), 1000);
out = new PrintWriter(new OutputStreamWriter(socket.getOutputStream()), true);
in = new BufferedInputStream(socket.getInputStream());
Log.d(TAG, "socket timeout: " + socket.getSoTimeout());
while (running) {
Command cmd = outQueue.poll(2000, TimeUnit.MILLISECONDS);
if (!running) {
break;
}
if (cmd == null) {
Log.d(TAG, "ping ...");
cmd = new Command(MSG_PING, null);
// continue;
}
else {
Log.d(TAG, "sending: " + cmd.getRequest());
}
out.write(cmd.getRequest());
out.println();
out.flush();
Thread.sleep(1);
int bytesRead = readBuffer(in, inBuffer);
if (bytesRead == -1) {
Log.d(TAG, "no response, socket closed!");
if (cmd.handler != null) { | cmd.handler.sendMessage(Message.obtain(cmd.handler, ResponseHandler.ERROR, cmd)); |
tinkerlog/PaintMachine | PrintClient/app/src/main/java/com/tinkerlog/printclient/view/CustomButton.java | // Path: PrintClient/app/src/main/java/com/tinkerlog/printclient/util/FontCache.java
// public class FontCache {
//
// private static Map<String, Typeface> fontMap = new HashMap<String, Typeface>();
//
// public static Typeface getFont(Context context, String fontName){
// if (fontMap.containsKey(fontName)){
// return fontMap.get(fontName);
// }
// else {
// Typeface tf = Typeface.createFromAsset(context.getAssets(), fontName);
// fontMap.put(fontName, tf);
// return tf;
// }
// }
// }
| import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Typeface;
import android.util.AttributeSet;
import android.widget.Button;
import com.tinkerlog.printclient.R;
import com.tinkerlog.printclient.util.FontCache; | package com.tinkerlog.printclient.view;
/**
* Created by alex on 24.08.15.
*/
public class CustomButton extends Button {
public CustomButton(Context context) {
super(context);
initialize(context, null);
}
public CustomButton(Context context, AttributeSet attrs) {
super(context, attrs);
initialize(context, attrs);
}
public CustomButton(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
initialize(context, attrs);
}
private void initialize(Context context, AttributeSet attrs) {
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CustomTextView);
String fontName = a.getString(R.styleable.CustomTextView_fontName);
if (fontName != null) { | // Path: PrintClient/app/src/main/java/com/tinkerlog/printclient/util/FontCache.java
// public class FontCache {
//
// private static Map<String, Typeface> fontMap = new HashMap<String, Typeface>();
//
// public static Typeface getFont(Context context, String fontName){
// if (fontMap.containsKey(fontName)){
// return fontMap.get(fontName);
// }
// else {
// Typeface tf = Typeface.createFromAsset(context.getAssets(), fontName);
// fontMap.put(fontName, tf);
// return tf;
// }
// }
// }
// Path: PrintClient/app/src/main/java/com/tinkerlog/printclient/view/CustomButton.java
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Typeface;
import android.util.AttributeSet;
import android.widget.Button;
import com.tinkerlog.printclient.R;
import com.tinkerlog.printclient.util.FontCache;
package com.tinkerlog.printclient.view;
/**
* Created by alex on 24.08.15.
*/
public class CustomButton extends Button {
public CustomButton(Context context) {
super(context);
initialize(context, null);
}
public CustomButton(Context context, AttributeSet attrs) {
super(context, attrs);
initialize(context, attrs);
}
public CustomButton(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
initialize(context, attrs);
}
private void initialize(Context context, AttributeSet attrs) {
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CustomTextView);
String fontName = a.getString(R.styleable.CustomTextView_fontName);
if (fontName != null) { | Typeface tf = FontCache.getFont(context, fontName); |
tinkerlog/PaintMachine | PrintClient/app/src/main/java/com/tinkerlog/printclient/util/Prefs.java | // Path: PrintClient/app/src/main/java/com/tinkerlog/printclient/model/Print.java
// public class Print implements Comparable<Print> {
//
// private static final String TAG = "Print";
//
// private static final String ENC_STRING = "%d %s %s %s %s";
// private static final String DELIMITER = " ";
//
// public int id;
// public long creationDate;
// public String name;
// public String pic01FileName;
// public String pic02FileName;
// public String pic03FileName;
//
// public Print() {
// creationDate = System.currentTimeMillis();
// }
//
// public void clear() {
// pic01FileName = null;
// pic02FileName = null;
// pic03FileName = null;
// }
//
// public boolean isEmpty() {
// return pic01FileName == null;
// }
//
// public static Print decode(String src) {
// Log.d(TAG, "decoding: " + src);
// Print p = new Print();
// Scanner scanner = new Scanner(src).useDelimiter(DELIMITER);
// p.creationDate = scanner.nextLong();
// p.name = URLDecoder.decode(scanner.next());
// p.pic01FileName = scanString(scanner);
// p.pic02FileName = scanString(scanner);
// p.pic03FileName = scanString(scanner);
// return p;
// }
//
// public String encode() {
// String s = String.format(ENC_STRING,
// creationDate,
// URLEncoder.encode(name),
// pic01FileName,
// pic02FileName,
// pic03FileName
// );
// Log.d(TAG, "encoded: " + s);
// return s;
// }
//
// private static String scanString(Scanner scanner) {
// String s = scanner.next();
// if (s == null || s.equals("null")) {
// return null;
// }
// return s;
// }
//
// @Override
// public int compareTo(Print another) {
// return (creationDate > another.creationDate) ? -1 :
// (creationDate == another.creationDate) ? 0 : 1;
// }
//
// public String toString() {
// return "Print " + creationDate + ", " + name;
// }
//
// }
| import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.util.Log;
import com.tinkerlog.printclient.model.Print;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List; | package com.tinkerlog.printclient.util;
/**
*
*/
public class Prefs {
private static final String TAG = "Prefs";
private static final String PREFERENCES = "printclient";
private static final String KEY_PRINT_PREFIX = "print_";
private static final String KEY_ADDRESS = "address";
private SharedPreferences prefs;
public Prefs(Context context) {
this.prefs = context.getSharedPreferences(PREFERENCES, Context.MODE_PRIVATE);
}
public SharedPreferences getPreferences() {
return prefs;
}
| // Path: PrintClient/app/src/main/java/com/tinkerlog/printclient/model/Print.java
// public class Print implements Comparable<Print> {
//
// private static final String TAG = "Print";
//
// private static final String ENC_STRING = "%d %s %s %s %s";
// private static final String DELIMITER = " ";
//
// public int id;
// public long creationDate;
// public String name;
// public String pic01FileName;
// public String pic02FileName;
// public String pic03FileName;
//
// public Print() {
// creationDate = System.currentTimeMillis();
// }
//
// public void clear() {
// pic01FileName = null;
// pic02FileName = null;
// pic03FileName = null;
// }
//
// public boolean isEmpty() {
// return pic01FileName == null;
// }
//
// public static Print decode(String src) {
// Log.d(TAG, "decoding: " + src);
// Print p = new Print();
// Scanner scanner = new Scanner(src).useDelimiter(DELIMITER);
// p.creationDate = scanner.nextLong();
// p.name = URLDecoder.decode(scanner.next());
// p.pic01FileName = scanString(scanner);
// p.pic02FileName = scanString(scanner);
// p.pic03FileName = scanString(scanner);
// return p;
// }
//
// public String encode() {
// String s = String.format(ENC_STRING,
// creationDate,
// URLEncoder.encode(name),
// pic01FileName,
// pic02FileName,
// pic03FileName
// );
// Log.d(TAG, "encoded: " + s);
// return s;
// }
//
// private static String scanString(Scanner scanner) {
// String s = scanner.next();
// if (s == null || s.equals("null")) {
// return null;
// }
// return s;
// }
//
// @Override
// public int compareTo(Print another) {
// return (creationDate > another.creationDate) ? -1 :
// (creationDate == another.creationDate) ? 0 : 1;
// }
//
// public String toString() {
// return "Print " + creationDate + ", " + name;
// }
//
// }
// Path: PrintClient/app/src/main/java/com/tinkerlog/printclient/util/Prefs.java
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.util.Log;
import com.tinkerlog.printclient.model.Print;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
package com.tinkerlog.printclient.util;
/**
*
*/
public class Prefs {
private static final String TAG = "Prefs";
private static final String PREFERENCES = "printclient";
private static final String KEY_PRINT_PREFIX = "print_";
private static final String KEY_ADDRESS = "address";
private SharedPreferences prefs;
public Prefs(Context context) {
this.prefs = context.getSharedPreferences(PREFERENCES, Context.MODE_PRIVATE);
}
public SharedPreferences getPreferences() {
return prefs;
}
| public void storePrint(Print print) { |
tinkerlog/PaintMachine | PrintClient/app/src/main/java/com/tinkerlog/printclient/util/ResponseHandler.java | // Path: PrintClient/app/src/main/java/com/tinkerlog/printclient/model/Command.java
// public class Command {
//
// protected String request;
// protected String response;
// public ResponseHandler handler;
//
// public Command(String request, ResponseHandler handler) {
// this.request = request;
// this.handler = handler;
// }
//
// public void setResponse(String response) {
// this.response = response;
// }
//
// public String getResponse() {
// return response;
// }
//
// public String getRequest() {
// return request;
// }
//
// public byte[] getPayload() {
// return request.getBytes();
// }
// }
| import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.util.Log;
import com.tinkerlog.printclient.model.Command; | package com.tinkerlog.printclient.util;
public class ResponseHandler extends Handler {
private static final String TAG = "ResponseHandler";
public static final int OK = 1;
public static final int ERROR = 2;
public ResponseHandler() {
super();
}
public ResponseHandler(Callback callback) {
super(callback);
}
public ResponseHandler(Looper looper) {
super(looper);
}
public ResponseHandler(Looper looper, Callback callback) {
super(looper, callback);
}
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case OK: | // Path: PrintClient/app/src/main/java/com/tinkerlog/printclient/model/Command.java
// public class Command {
//
// protected String request;
// protected String response;
// public ResponseHandler handler;
//
// public Command(String request, ResponseHandler handler) {
// this.request = request;
// this.handler = handler;
// }
//
// public void setResponse(String response) {
// this.response = response;
// }
//
// public String getResponse() {
// return response;
// }
//
// public String getRequest() {
// return request;
// }
//
// public byte[] getPayload() {
// return request.getBytes();
// }
// }
// Path: PrintClient/app/src/main/java/com/tinkerlog/printclient/util/ResponseHandler.java
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.util.Log;
import com.tinkerlog.printclient.model.Command;
package com.tinkerlog.printclient.util;
public class ResponseHandler extends Handler {
private static final String TAG = "ResponseHandler";
public static final int OK = 1;
public static final int ERROR = 2;
public ResponseHandler() {
super();
}
public ResponseHandler(Callback callback) {
super(callback);
}
public ResponseHandler(Looper looper) {
super(looper);
}
public ResponseHandler(Looper looper, Callback callback) {
super(looper, callback);
}
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case OK: | handleSuccess((Command)msg.obj); |
tinkerlog/PaintMachine | PrintClient/app/src/main/java/com/tinkerlog/printclient/model/StatusCommand.java | // Path: PrintClient/app/src/main/java/com/tinkerlog/printclient/util/ResponseHandler.java
// public class ResponseHandler extends Handler {
//
// private static final String TAG = "ResponseHandler";
//
// public static final int OK = 1;
// public static final int ERROR = 2;
//
// public ResponseHandler() {
// super();
// }
//
// public ResponseHandler(Callback callback) {
// super(callback);
// }
//
// public ResponseHandler(Looper looper) {
// super(looper);
// }
//
// public ResponseHandler(Looper looper, Callback callback) {
// super(looper, callback);
// }
//
// @Override
// public void handleMessage(Message msg) {
// switch (msg.what) {
// case OK:
// handleSuccess((Command)msg.obj);
// break;
// case ERROR:
// handleFailed((Command)msg.obj);
// break;
// }
// }
//
// public void handleFailed(Command cmd) {
// Log.e(TAG, "failed: " + cmd.getRequest());
// }
//
// public void handleSuccess(Command cmd) {
// Log.d(TAG, "success: " + cmd.getResponse());
// }
//
// }
| import com.tinkerlog.printclient.util.ResponseHandler; | package com.tinkerlog.printclient.model;
public class StatusCommand extends Command {
public int leftPos;
public int headPos;
public int rightPos;
| // Path: PrintClient/app/src/main/java/com/tinkerlog/printclient/util/ResponseHandler.java
// public class ResponseHandler extends Handler {
//
// private static final String TAG = "ResponseHandler";
//
// public static final int OK = 1;
// public static final int ERROR = 2;
//
// public ResponseHandler() {
// super();
// }
//
// public ResponseHandler(Callback callback) {
// super(callback);
// }
//
// public ResponseHandler(Looper looper) {
// super(looper);
// }
//
// public ResponseHandler(Looper looper, Callback callback) {
// super(looper, callback);
// }
//
// @Override
// public void handleMessage(Message msg) {
// switch (msg.what) {
// case OK:
// handleSuccess((Command)msg.obj);
// break;
// case ERROR:
// handleFailed((Command)msg.obj);
// break;
// }
// }
//
// public void handleFailed(Command cmd) {
// Log.e(TAG, "failed: " + cmd.getRequest());
// }
//
// public void handleSuccess(Command cmd) {
// Log.d(TAG, "success: " + cmd.getResponse());
// }
//
// }
// Path: PrintClient/app/src/main/java/com/tinkerlog/printclient/model/StatusCommand.java
import com.tinkerlog.printclient.util.ResponseHandler;
package com.tinkerlog.printclient.model;
public class StatusCommand extends Command {
public int leftPos;
public int headPos;
public int rightPos;
| public StatusCommand(ResponseHandler handler) { |
tinkerlog/PaintMachine | PrintClient/app/src/main/java/com/tinkerlog/printclient/view/CustomEditText.java | // Path: PrintClient/app/src/main/java/com/tinkerlog/printclient/util/FontCache.java
// public class FontCache {
//
// private static Map<String, Typeface> fontMap = new HashMap<String, Typeface>();
//
// public static Typeface getFont(Context context, String fontName){
// if (fontMap.containsKey(fontName)){
// return fontMap.get(fontName);
// }
// else {
// Typeface tf = Typeface.createFromAsset(context.getAssets(), fontName);
// fontMap.put(fontName, tf);
// return tf;
// }
// }
// }
| import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Typeface;
import android.util.AttributeSet;
import android.widget.EditText;
import com.tinkerlog.printclient.R;
import com.tinkerlog.printclient.util.FontCache; | package com.tinkerlog.printclient.view;
/**
* Created by alex on 24.08.15.
*/
public class CustomEditText extends EditText {
public CustomEditText(Context context) {
super(context);
initialize(context, null);
}
public CustomEditText(Context context, AttributeSet attrs) {
super(context, attrs);
initialize(context, attrs);
}
public CustomEditText(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
initialize(context, attrs);
}
private void initialize(Context context, AttributeSet attrs) {
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CustomTextView);
String fontName = a.getString(R.styleable.CustomTextView_fontName);
if (fontName != null) { | // Path: PrintClient/app/src/main/java/com/tinkerlog/printclient/util/FontCache.java
// public class FontCache {
//
// private static Map<String, Typeface> fontMap = new HashMap<String, Typeface>();
//
// public static Typeface getFont(Context context, String fontName){
// if (fontMap.containsKey(fontName)){
// return fontMap.get(fontName);
// }
// else {
// Typeface tf = Typeface.createFromAsset(context.getAssets(), fontName);
// fontMap.put(fontName, tf);
// return tf;
// }
// }
// }
// Path: PrintClient/app/src/main/java/com/tinkerlog/printclient/view/CustomEditText.java
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Typeface;
import android.util.AttributeSet;
import android.widget.EditText;
import com.tinkerlog.printclient.R;
import com.tinkerlog.printclient.util.FontCache;
package com.tinkerlog.printclient.view;
/**
* Created by alex on 24.08.15.
*/
public class CustomEditText extends EditText {
public CustomEditText(Context context) {
super(context);
initialize(context, null);
}
public CustomEditText(Context context, AttributeSet attrs) {
super(context, attrs);
initialize(context, attrs);
}
public CustomEditText(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
initialize(context, attrs);
}
private void initialize(Context context, AttributeSet attrs) {
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CustomTextView);
String fontName = a.getString(R.styleable.CustomTextView_fontName);
if (fontName != null) { | Typeface tf = FontCache.getFont(context, fontName); |
tinkerlog/PaintMachine | PrintClient/app/src/main/java/com/tinkerlog/printclient/model/Command.java | // Path: PrintClient/app/src/main/java/com/tinkerlog/printclient/util/ResponseHandler.java
// public class ResponseHandler extends Handler {
//
// private static final String TAG = "ResponseHandler";
//
// public static final int OK = 1;
// public static final int ERROR = 2;
//
// public ResponseHandler() {
// super();
// }
//
// public ResponseHandler(Callback callback) {
// super(callback);
// }
//
// public ResponseHandler(Looper looper) {
// super(looper);
// }
//
// public ResponseHandler(Looper looper, Callback callback) {
// super(looper, callback);
// }
//
// @Override
// public void handleMessage(Message msg) {
// switch (msg.what) {
// case OK:
// handleSuccess((Command)msg.obj);
// break;
// case ERROR:
// handleFailed((Command)msg.obj);
// break;
// }
// }
//
// public void handleFailed(Command cmd) {
// Log.e(TAG, "failed: " + cmd.getRequest());
// }
//
// public void handleSuccess(Command cmd) {
// Log.d(TAG, "success: " + cmd.getResponse());
// }
//
// }
| import com.tinkerlog.printclient.util.ResponseHandler; | package com.tinkerlog.printclient.model;
public class Command {
protected String request;
protected String response; | // Path: PrintClient/app/src/main/java/com/tinkerlog/printclient/util/ResponseHandler.java
// public class ResponseHandler extends Handler {
//
// private static final String TAG = "ResponseHandler";
//
// public static final int OK = 1;
// public static final int ERROR = 2;
//
// public ResponseHandler() {
// super();
// }
//
// public ResponseHandler(Callback callback) {
// super(callback);
// }
//
// public ResponseHandler(Looper looper) {
// super(looper);
// }
//
// public ResponseHandler(Looper looper, Callback callback) {
// super(looper, callback);
// }
//
// @Override
// public void handleMessage(Message msg) {
// switch (msg.what) {
// case OK:
// handleSuccess((Command)msg.obj);
// break;
// case ERROR:
// handleFailed((Command)msg.obj);
// break;
// }
// }
//
// public void handleFailed(Command cmd) {
// Log.e(TAG, "failed: " + cmd.getRequest());
// }
//
// public void handleSuccess(Command cmd) {
// Log.d(TAG, "success: " + cmd.getResponse());
// }
//
// }
// Path: PrintClient/app/src/main/java/com/tinkerlog/printclient/model/Command.java
import com.tinkerlog.printclient.util.ResponseHandler;
package com.tinkerlog.printclient.model;
public class Command {
protected String request;
protected String response; | public ResponseHandler handler; |
fhissen/CrococryptFile | CrococryptFile/main/org/crococryptfile/suites/pbeserpent/PBE1SerpentMain.java | // Path: CrococryptFile/main/org/crococryptfile/suites/pbeaes/PBE1AESMain.java
// public class PBE1AESMain extends Suite {
// private int ATTRIBUTE_ITERATIONCOUNT;
// private byte[] ATTRIBUTE_SALT = new byte[CryptoCodes.STANDARD_SALTSIZE];
// private byte[] ATTRIBUTE_KEY = new byte[CryptoCodes.AES_KEYSIZE];
// private byte[] ATTRIBUTE_IV = new byte[CryptoCodes.STANDARD_IVSIZE];
//
// @Override
// public final void deinit(){
// if(key != null) key.deinit();
// key = null;
// CryptoUtils.kill(pw);
// CryptoUtils.kill(ATTRIBUTE_KEY, ATTRIBUTE_IV);
// ciph.deinint();
// System.gc();
// }
//
// @Override
// protected void finalize() throws Throwable {
// deinit();
// super.finalize();
// }
//
// private final int len = ByteUtils.sizeInBytes(ATTRIBUTE_ITERATIONCOUNT, ATTRIBUTE_SALT, ATTRIBUTE_KEY, ATTRIBUTE_IV);
// public final int headerLength(){
// return len;
// }
//
// public CipherMain getCipher(){
// return ciph;
// }
//
//
// private PBE1AESKeySet key;
// private CipherMain ciph;
// private char[] pw;
//
//
// protected BASECIPHER cipherCode = BASECIPHER.AES;
//
// @Override
// protected void _init(SuiteMODE mode, HashMap<SuitePARAM, Object> params) throws IllegalArgumentException{
// if(params == null || params.size() == 0) throw new IllegalArgumentException("PBE: no params specified");
// pw = (char[])params.get(SuitePARAM.password);
// if(pw == null) throw new IllegalArgumentException("PBE must specify a password");
//
// int itcount_ext = 0;
// if(params.containsKey(SuitePARAM.itcount)){
// try {
// itcount_ext = Integer.parseInt((String)params.get(SuitePARAM.itcount));
// } catch (Exception e) {}
// }
//
// if(mode == SuiteMODE.ENCRYPT){
// key = PBE1PwToKey.createPBE(pw, itcount_ext, getStatus());
// ciph = CipherMain.instance(cipherCode, key.plainkey);
//
// ATTRIBUTE_ITERATIONCOUNT = key.its;
// ATTRIBUTE_SALT = key.salt;
// ATTRIBUTE_KEY = key.enckey;
// ATTRIBUTE_IV = CryptoUtils.randIv16();
// }
// }
//
//
// protected void _writeTo(OutputStream out) throws IllegalStateException{
// try {
// StreamMachine.write(out,
// ATTRIBUTE_ITERATIONCOUNT,
// ATTRIBUTE_SALT,
// ATTRIBUTE_KEY,
// ciph.doEnc_ECB(ATTRIBUTE_IV)
// );
//
//
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
//
// protected void _readFrom(InputStream is) throws IllegalStateException{
// StreamMachine sm = new StreamMachine(is);
//
// ATTRIBUTE_ITERATIONCOUNT = sm.readO(ATTRIBUTE_ITERATIONCOUNT);
// sm.read(ATTRIBUTE_SALT);
// sm.read(ATTRIBUTE_KEY);
// sm.read(ATTRIBUTE_IV);
//
// if(ciph == null){
// key = new PBE1AESKeySet();
// key.enckey = ATTRIBUTE_KEY;
// key.its = ATTRIBUTE_ITERATIONCOUNT;
// key.salt = ATTRIBUTE_SALT;
//
// PBE1PwToKey.loadPBE(pw, key, getStatus());
//
// ciph = CipherMain.instance(cipherCode, key.plainkey);
// }
//
// ATTRIBUTE_IV = ciph.doDec_ECB(ATTRIBUTE_IV);
// }
//
//
// public byte[] getAttributeIV(){
// return ATTRIBUTE_IV;
// }
// }
//
// Path: CrococryptFile/common/org/fhissen/crypto/CryptoCodes.java
// public enum BASECIPHER{
// AES,
// TWOFISH ("Twofish"),
// SERPENT ("Serpent"),
// CAMELLIA ("Camellia"),
//
// ;
//
// private String cipherCode = null;
// private BASECIPHER(){}
// private BASECIPHER(String cipherCode){
// this.cipherCode = cipherCode;
// }
//
// private String getCipherCode(){
// if(cipherCode != null)
// return cipherCode;
//
// return name();
// }
//
// public String getECB(){
// return ecbCodes.get(this);
// }
//
// public String getCBCPad(){
// return cbcpadCodes.get(this);
// }
//
// public String getCBCNopad(){
// return cbcnopadCodes.get(this);
// }
// }
| import org.crococryptfile.suites.pbeaes.PBE1AESMain;
import org.fhissen.crypto.CryptoCodes.BASECIPHER;
| package org.crococryptfile.suites.pbeserpent;
public class PBE1SerpentMain extends PBE1AESMain {
{
| // Path: CrococryptFile/main/org/crococryptfile/suites/pbeaes/PBE1AESMain.java
// public class PBE1AESMain extends Suite {
// private int ATTRIBUTE_ITERATIONCOUNT;
// private byte[] ATTRIBUTE_SALT = new byte[CryptoCodes.STANDARD_SALTSIZE];
// private byte[] ATTRIBUTE_KEY = new byte[CryptoCodes.AES_KEYSIZE];
// private byte[] ATTRIBUTE_IV = new byte[CryptoCodes.STANDARD_IVSIZE];
//
// @Override
// public final void deinit(){
// if(key != null) key.deinit();
// key = null;
// CryptoUtils.kill(pw);
// CryptoUtils.kill(ATTRIBUTE_KEY, ATTRIBUTE_IV);
// ciph.deinint();
// System.gc();
// }
//
// @Override
// protected void finalize() throws Throwable {
// deinit();
// super.finalize();
// }
//
// private final int len = ByteUtils.sizeInBytes(ATTRIBUTE_ITERATIONCOUNT, ATTRIBUTE_SALT, ATTRIBUTE_KEY, ATTRIBUTE_IV);
// public final int headerLength(){
// return len;
// }
//
// public CipherMain getCipher(){
// return ciph;
// }
//
//
// private PBE1AESKeySet key;
// private CipherMain ciph;
// private char[] pw;
//
//
// protected BASECIPHER cipherCode = BASECIPHER.AES;
//
// @Override
// protected void _init(SuiteMODE mode, HashMap<SuitePARAM, Object> params) throws IllegalArgumentException{
// if(params == null || params.size() == 0) throw new IllegalArgumentException("PBE: no params specified");
// pw = (char[])params.get(SuitePARAM.password);
// if(pw == null) throw new IllegalArgumentException("PBE must specify a password");
//
// int itcount_ext = 0;
// if(params.containsKey(SuitePARAM.itcount)){
// try {
// itcount_ext = Integer.parseInt((String)params.get(SuitePARAM.itcount));
// } catch (Exception e) {}
// }
//
// if(mode == SuiteMODE.ENCRYPT){
// key = PBE1PwToKey.createPBE(pw, itcount_ext, getStatus());
// ciph = CipherMain.instance(cipherCode, key.plainkey);
//
// ATTRIBUTE_ITERATIONCOUNT = key.its;
// ATTRIBUTE_SALT = key.salt;
// ATTRIBUTE_KEY = key.enckey;
// ATTRIBUTE_IV = CryptoUtils.randIv16();
// }
// }
//
//
// protected void _writeTo(OutputStream out) throws IllegalStateException{
// try {
// StreamMachine.write(out,
// ATTRIBUTE_ITERATIONCOUNT,
// ATTRIBUTE_SALT,
// ATTRIBUTE_KEY,
// ciph.doEnc_ECB(ATTRIBUTE_IV)
// );
//
//
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
//
// protected void _readFrom(InputStream is) throws IllegalStateException{
// StreamMachine sm = new StreamMachine(is);
//
// ATTRIBUTE_ITERATIONCOUNT = sm.readO(ATTRIBUTE_ITERATIONCOUNT);
// sm.read(ATTRIBUTE_SALT);
// sm.read(ATTRIBUTE_KEY);
// sm.read(ATTRIBUTE_IV);
//
// if(ciph == null){
// key = new PBE1AESKeySet();
// key.enckey = ATTRIBUTE_KEY;
// key.its = ATTRIBUTE_ITERATIONCOUNT;
// key.salt = ATTRIBUTE_SALT;
//
// PBE1PwToKey.loadPBE(pw, key, getStatus());
//
// ciph = CipherMain.instance(cipherCode, key.plainkey);
// }
//
// ATTRIBUTE_IV = ciph.doDec_ECB(ATTRIBUTE_IV);
// }
//
//
// public byte[] getAttributeIV(){
// return ATTRIBUTE_IV;
// }
// }
//
// Path: CrococryptFile/common/org/fhissen/crypto/CryptoCodes.java
// public enum BASECIPHER{
// AES,
// TWOFISH ("Twofish"),
// SERPENT ("Serpent"),
// CAMELLIA ("Camellia"),
//
// ;
//
// private String cipherCode = null;
// private BASECIPHER(){}
// private BASECIPHER(String cipherCode){
// this.cipherCode = cipherCode;
// }
//
// private String getCipherCode(){
// if(cipherCode != null)
// return cipherCode;
//
// return name();
// }
//
// public String getECB(){
// return ecbCodes.get(this);
// }
//
// public String getCBCPad(){
// return cbcpadCodes.get(this);
// }
//
// public String getCBCNopad(){
// return cbcnopadCodes.get(this);
// }
// }
// Path: CrococryptFile/main/org/crococryptfile/suites/pbeserpent/PBE1SerpentMain.java
import org.crococryptfile.suites.pbeaes.PBE1AESMain;
import org.fhissen.crypto.CryptoCodes.BASECIPHER;
package org.crococryptfile.suites.pbeserpent;
public class PBE1SerpentMain extends PBE1AESMain {
{
| cipherCode = BASECIPHER.SERPENT;
|
fhissen/CrococryptFile | CrococryptFile/common/org/fhissen/utils/os/OSFolders.java | // Path: CrococryptFile/common/org/fhissen/utils/os/OSDetector.java
// public enum OS{
// WIN,
// LIN,
// MAC,
//
// ;
// }
| import java.io.File;
import org.fhissen.utils.os.OSDetector.OS;
| package org.fhissen.utils.os;
public class OSFolders {
public static final File getUserChooserstart(){
String tmp;
File ftmp;
switch (OSDetector.which()) {
case WIN:
tmp = System.getenv("USERPROFILE");
ftmp = new File(tmp);
if(ftmp.exists() && ftmp.isDirectory()) return ftmp;
case LIN:
case MAC:
tmp = System.getProperty("user.home");
ftmp = new File(tmp);
if(ftmp.exists() && ftmp.isDirectory()) return ftmp;
| // Path: CrococryptFile/common/org/fhissen/utils/os/OSDetector.java
// public enum OS{
// WIN,
// LIN,
// MAC,
//
// ;
// }
// Path: CrococryptFile/common/org/fhissen/utils/os/OSFolders.java
import java.io.File;
import org.fhissen.utils.os.OSDetector.OS;
package org.fhissen.utils.os;
public class OSFolders {
public static final File getUserChooserstart(){
String tmp;
File ftmp;
switch (OSDetector.which()) {
case WIN:
tmp = System.getenv("USERPROFILE");
ftmp = new File(tmp);
if(ftmp.exists() && ftmp.isDirectory()) return ftmp;
case LIN:
case MAC:
tmp = System.getProperty("user.home");
ftmp = new File(tmp);
if(ftmp.exists() && ftmp.isDirectory()) return ftmp;
| if(OSDetector.which() == OS.WIN){
|
fhissen/CrococryptFile | CrococryptFile/main/org/crococryptfile/ui/cui/PasswordInputConsole.java | // Path: CrococryptFile/main/org/crococryptfile/ui/resources/_T.java
// public enum _T {
// CAPIDNListWindow_nokeys,
// CAPIDNListWindow_title,
// CAPI_DNnotfound,
// CrocoFilereader_already,
// CrocoFilereader_decrypting,
// CrocoFilewriter_encrypting,
// DecryptWindow_already,
// DecryptWindow_cancel,
// DecryptWindow_destination,
// DecryptWindow_failedgeneral,
// DecryptWindow_failedspecific,
// DecryptWindow_folderisfile,
// DecryptWindow_folderreadonly,
// DecryptWindow_invalid,
// DecryptWindow_nofile,
// DecryptWindow_success,
// DecryptWindow_text,
// DecryptWindow_title,
// DecryptWindow_unknownfile,
// DecryptWindow_wrongversion,
// Decrypt_Start,
// EncryptListChoose,
// EncryptListChooseMulti,
// EncryptWindow_EncryptedFile,
// EncryptWindow_Multidir,
// EncryptWindow_Multifile,
// EncryptWindow_MultifileMultidir,
// EncryptWindow_MultifileSingledir,
// EncryptWindow_Singledir,
// EncryptWindow_Singlefile,
// EncryptWindow_SinglefileMultidir,
// EncryptWindow_SinglefileSingledir,
// EncryptWindow_already,
// EncryptWindow_alreadydir,
// EncryptWindow_cancel,
// EncryptWindow_createdir,
// EncryptWindow_destination,
// EncryptWindow_failedgeneral,
// EncryptWindow_failedspecific,
// EncryptWindow_folderreadonly,
// EncryptWindow_multisources,
// EncryptWindow_success,
// EncryptWindow_title,
// FileSelection_dec4cloak,
// FileSelection_dec4enc,
// FileSelection_selectbutton,
// FileSelection_title,
// FileSelection_title4cloak,
// FilepathFailure,
// General_cancel,
// General_done,
// General_empty,
// General_none,
// General_open,
// General_password,
// General_quit,
// General_synchronize,
// JCEPolicyError_title,
// JCEPolicyError_text,
// Launcher_jcepolicyerr,
// Launcher_reallyquit,
// PasswordDecrypt_title,
// PasswordEncrypt_label,
// PasswordEncrypt_len,
// PasswordEncrypt_nomatch,
// PasswordEncrypt_retype,
// PasswordEncrypt_itcount,
// PasswordEncrypt_itcountdescr,
// PasswordEncrypt_title,
// Password_caps,
// Password_PBEinProgress,
// PGP_errorNokey,
// PGP_errorSeckeyfailed,
// PGP_nokeyfile,
// PGP_novalidprivkey,
// PGP_privkey_wrongfile,
// PGP_privkeypasstitle,
// PGP_selprivkey,
// PGP_selprivkeyTitle,
// PGP_selpubkey,
// PBKDF2Interstep_start,
// PBKDF2Interstep_found,
// PBKDF2Interstep_steplong,
// Suite_CAPI_RSAAES,
// Suite_PBE1_AES,
// Suite_PBE1_TWOFISH,
// Suite_PBE1_SERPENT,
// Suite_PBE1_CAMELLIA,
// Suite_PGP_AES,
// Suite_PBECLOAKED_AESTWO,
// Suite_PBECLOAKED1MB_AESTWO,
//
// ;
//
//
// private static ResourceBundle rb;
// static{
// try {
// rb = ResourceBundle.getBundle(ResourceCenter.getTexts() + "text", ResourceCenter.getLocale());
// } catch (Exception e) {
// rb = ResourceBundle.getBundle(ResourceCenter.getTexts() + "text", Locale.ENGLISH);
// }
// }
//
//
// public String val(){
// return rb.getString(name());
// }
//
// public String msg(Object... obj){
// return MessageFormat.format(toString(), obj);
// }
//
// @Override
// public String toString() {
// return val();
// };
// }
//
// Path: CrococryptFile/common/org/fhissen/callbacks/SimpleCallback.java
// public interface SimpleCallback<T> {
// public void callbackValue(Object source, T ret);
// }
| import java.io.Console;
import org.crococryptfile.ui.resources._T;
import org.fhissen.callbacks.SimpleCallback;
| package org.crococryptfile.ui.cui;
public class PasswordInputConsole {
public void main(SimpleCallback<char[]> cb) {
Console con = System.console();
if(con == null){
System.err.println("Your system does not support an interactive console for this operation");
return;
}
| // Path: CrococryptFile/main/org/crococryptfile/ui/resources/_T.java
// public enum _T {
// CAPIDNListWindow_nokeys,
// CAPIDNListWindow_title,
// CAPI_DNnotfound,
// CrocoFilereader_already,
// CrocoFilereader_decrypting,
// CrocoFilewriter_encrypting,
// DecryptWindow_already,
// DecryptWindow_cancel,
// DecryptWindow_destination,
// DecryptWindow_failedgeneral,
// DecryptWindow_failedspecific,
// DecryptWindow_folderisfile,
// DecryptWindow_folderreadonly,
// DecryptWindow_invalid,
// DecryptWindow_nofile,
// DecryptWindow_success,
// DecryptWindow_text,
// DecryptWindow_title,
// DecryptWindow_unknownfile,
// DecryptWindow_wrongversion,
// Decrypt_Start,
// EncryptListChoose,
// EncryptListChooseMulti,
// EncryptWindow_EncryptedFile,
// EncryptWindow_Multidir,
// EncryptWindow_Multifile,
// EncryptWindow_MultifileMultidir,
// EncryptWindow_MultifileSingledir,
// EncryptWindow_Singledir,
// EncryptWindow_Singlefile,
// EncryptWindow_SinglefileMultidir,
// EncryptWindow_SinglefileSingledir,
// EncryptWindow_already,
// EncryptWindow_alreadydir,
// EncryptWindow_cancel,
// EncryptWindow_createdir,
// EncryptWindow_destination,
// EncryptWindow_failedgeneral,
// EncryptWindow_failedspecific,
// EncryptWindow_folderreadonly,
// EncryptWindow_multisources,
// EncryptWindow_success,
// EncryptWindow_title,
// FileSelection_dec4cloak,
// FileSelection_dec4enc,
// FileSelection_selectbutton,
// FileSelection_title,
// FileSelection_title4cloak,
// FilepathFailure,
// General_cancel,
// General_done,
// General_empty,
// General_none,
// General_open,
// General_password,
// General_quit,
// General_synchronize,
// JCEPolicyError_title,
// JCEPolicyError_text,
// Launcher_jcepolicyerr,
// Launcher_reallyquit,
// PasswordDecrypt_title,
// PasswordEncrypt_label,
// PasswordEncrypt_len,
// PasswordEncrypt_nomatch,
// PasswordEncrypt_retype,
// PasswordEncrypt_itcount,
// PasswordEncrypt_itcountdescr,
// PasswordEncrypt_title,
// Password_caps,
// Password_PBEinProgress,
// PGP_errorNokey,
// PGP_errorSeckeyfailed,
// PGP_nokeyfile,
// PGP_novalidprivkey,
// PGP_privkey_wrongfile,
// PGP_privkeypasstitle,
// PGP_selprivkey,
// PGP_selprivkeyTitle,
// PGP_selpubkey,
// PBKDF2Interstep_start,
// PBKDF2Interstep_found,
// PBKDF2Interstep_steplong,
// Suite_CAPI_RSAAES,
// Suite_PBE1_AES,
// Suite_PBE1_TWOFISH,
// Suite_PBE1_SERPENT,
// Suite_PBE1_CAMELLIA,
// Suite_PGP_AES,
// Suite_PBECLOAKED_AESTWO,
// Suite_PBECLOAKED1MB_AESTWO,
//
// ;
//
//
// private static ResourceBundle rb;
// static{
// try {
// rb = ResourceBundle.getBundle(ResourceCenter.getTexts() + "text", ResourceCenter.getLocale());
// } catch (Exception e) {
// rb = ResourceBundle.getBundle(ResourceCenter.getTexts() + "text", Locale.ENGLISH);
// }
// }
//
//
// public String val(){
// return rb.getString(name());
// }
//
// public String msg(Object... obj){
// return MessageFormat.format(toString(), obj);
// }
//
// @Override
// public String toString() {
// return val();
// };
// }
//
// Path: CrococryptFile/common/org/fhissen/callbacks/SimpleCallback.java
// public interface SimpleCallback<T> {
// public void callbackValue(Object source, T ret);
// }
// Path: CrococryptFile/main/org/crococryptfile/ui/cui/PasswordInputConsole.java
import java.io.Console;
import org.crococryptfile.ui.resources._T;
import org.fhissen.callbacks.SimpleCallback;
package org.crococryptfile.ui.cui;
public class PasswordInputConsole {
public void main(SimpleCallback<char[]> cb) {
Console con = System.console();
if(con == null){
System.err.println("Your system does not support an interactive console for this operation");
return;
}
| CPrint.print(_T.PasswordDecrypt_title + ": ");
|
fhissen/CrococryptFile | CrococryptFile/main/org/crococryptfile/suites/pbecamellia/PBE1CamelliaMain.java | // Path: CrococryptFile/main/org/crococryptfile/suites/pbeaes/PBE1AESMain.java
// public class PBE1AESMain extends Suite {
// private int ATTRIBUTE_ITERATIONCOUNT;
// private byte[] ATTRIBUTE_SALT = new byte[CryptoCodes.STANDARD_SALTSIZE];
// private byte[] ATTRIBUTE_KEY = new byte[CryptoCodes.AES_KEYSIZE];
// private byte[] ATTRIBUTE_IV = new byte[CryptoCodes.STANDARD_IVSIZE];
//
// @Override
// public final void deinit(){
// if(key != null) key.deinit();
// key = null;
// CryptoUtils.kill(pw);
// CryptoUtils.kill(ATTRIBUTE_KEY, ATTRIBUTE_IV);
// ciph.deinint();
// System.gc();
// }
//
// @Override
// protected void finalize() throws Throwable {
// deinit();
// super.finalize();
// }
//
// private final int len = ByteUtils.sizeInBytes(ATTRIBUTE_ITERATIONCOUNT, ATTRIBUTE_SALT, ATTRIBUTE_KEY, ATTRIBUTE_IV);
// public final int headerLength(){
// return len;
// }
//
// public CipherMain getCipher(){
// return ciph;
// }
//
//
// private PBE1AESKeySet key;
// private CipherMain ciph;
// private char[] pw;
//
//
// protected BASECIPHER cipherCode = BASECIPHER.AES;
//
// @Override
// protected void _init(SuiteMODE mode, HashMap<SuitePARAM, Object> params) throws IllegalArgumentException{
// if(params == null || params.size() == 0) throw new IllegalArgumentException("PBE: no params specified");
// pw = (char[])params.get(SuitePARAM.password);
// if(pw == null) throw new IllegalArgumentException("PBE must specify a password");
//
// int itcount_ext = 0;
// if(params.containsKey(SuitePARAM.itcount)){
// try {
// itcount_ext = Integer.parseInt((String)params.get(SuitePARAM.itcount));
// } catch (Exception e) {}
// }
//
// if(mode == SuiteMODE.ENCRYPT){
// key = PBE1PwToKey.createPBE(pw, itcount_ext, getStatus());
// ciph = CipherMain.instance(cipherCode, key.plainkey);
//
// ATTRIBUTE_ITERATIONCOUNT = key.its;
// ATTRIBUTE_SALT = key.salt;
// ATTRIBUTE_KEY = key.enckey;
// ATTRIBUTE_IV = CryptoUtils.randIv16();
// }
// }
//
//
// protected void _writeTo(OutputStream out) throws IllegalStateException{
// try {
// StreamMachine.write(out,
// ATTRIBUTE_ITERATIONCOUNT,
// ATTRIBUTE_SALT,
// ATTRIBUTE_KEY,
// ciph.doEnc_ECB(ATTRIBUTE_IV)
// );
//
//
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
//
// protected void _readFrom(InputStream is) throws IllegalStateException{
// StreamMachine sm = new StreamMachine(is);
//
// ATTRIBUTE_ITERATIONCOUNT = sm.readO(ATTRIBUTE_ITERATIONCOUNT);
// sm.read(ATTRIBUTE_SALT);
// sm.read(ATTRIBUTE_KEY);
// sm.read(ATTRIBUTE_IV);
//
// if(ciph == null){
// key = new PBE1AESKeySet();
// key.enckey = ATTRIBUTE_KEY;
// key.its = ATTRIBUTE_ITERATIONCOUNT;
// key.salt = ATTRIBUTE_SALT;
//
// PBE1PwToKey.loadPBE(pw, key, getStatus());
//
// ciph = CipherMain.instance(cipherCode, key.plainkey);
// }
//
// ATTRIBUTE_IV = ciph.doDec_ECB(ATTRIBUTE_IV);
// }
//
//
// public byte[] getAttributeIV(){
// return ATTRIBUTE_IV;
// }
// }
//
// Path: CrococryptFile/common/org/fhissen/crypto/CryptoCodes.java
// public enum BASECIPHER{
// AES,
// TWOFISH ("Twofish"),
// SERPENT ("Serpent"),
// CAMELLIA ("Camellia"),
//
// ;
//
// private String cipherCode = null;
// private BASECIPHER(){}
// private BASECIPHER(String cipherCode){
// this.cipherCode = cipherCode;
// }
//
// private String getCipherCode(){
// if(cipherCode != null)
// return cipherCode;
//
// return name();
// }
//
// public String getECB(){
// return ecbCodes.get(this);
// }
//
// public String getCBCPad(){
// return cbcpadCodes.get(this);
// }
//
// public String getCBCNopad(){
// return cbcnopadCodes.get(this);
// }
// }
| import org.crococryptfile.suites.pbeaes.PBE1AESMain;
import org.fhissen.crypto.CryptoCodes.BASECIPHER;
| package org.crococryptfile.suites.pbecamellia;
public class PBE1CamelliaMain extends PBE1AESMain {
{
| // Path: CrococryptFile/main/org/crococryptfile/suites/pbeaes/PBE1AESMain.java
// public class PBE1AESMain extends Suite {
// private int ATTRIBUTE_ITERATIONCOUNT;
// private byte[] ATTRIBUTE_SALT = new byte[CryptoCodes.STANDARD_SALTSIZE];
// private byte[] ATTRIBUTE_KEY = new byte[CryptoCodes.AES_KEYSIZE];
// private byte[] ATTRIBUTE_IV = new byte[CryptoCodes.STANDARD_IVSIZE];
//
// @Override
// public final void deinit(){
// if(key != null) key.deinit();
// key = null;
// CryptoUtils.kill(pw);
// CryptoUtils.kill(ATTRIBUTE_KEY, ATTRIBUTE_IV);
// ciph.deinint();
// System.gc();
// }
//
// @Override
// protected void finalize() throws Throwable {
// deinit();
// super.finalize();
// }
//
// private final int len = ByteUtils.sizeInBytes(ATTRIBUTE_ITERATIONCOUNT, ATTRIBUTE_SALT, ATTRIBUTE_KEY, ATTRIBUTE_IV);
// public final int headerLength(){
// return len;
// }
//
// public CipherMain getCipher(){
// return ciph;
// }
//
//
// private PBE1AESKeySet key;
// private CipherMain ciph;
// private char[] pw;
//
//
// protected BASECIPHER cipherCode = BASECIPHER.AES;
//
// @Override
// protected void _init(SuiteMODE mode, HashMap<SuitePARAM, Object> params) throws IllegalArgumentException{
// if(params == null || params.size() == 0) throw new IllegalArgumentException("PBE: no params specified");
// pw = (char[])params.get(SuitePARAM.password);
// if(pw == null) throw new IllegalArgumentException("PBE must specify a password");
//
// int itcount_ext = 0;
// if(params.containsKey(SuitePARAM.itcount)){
// try {
// itcount_ext = Integer.parseInt((String)params.get(SuitePARAM.itcount));
// } catch (Exception e) {}
// }
//
// if(mode == SuiteMODE.ENCRYPT){
// key = PBE1PwToKey.createPBE(pw, itcount_ext, getStatus());
// ciph = CipherMain.instance(cipherCode, key.plainkey);
//
// ATTRIBUTE_ITERATIONCOUNT = key.its;
// ATTRIBUTE_SALT = key.salt;
// ATTRIBUTE_KEY = key.enckey;
// ATTRIBUTE_IV = CryptoUtils.randIv16();
// }
// }
//
//
// protected void _writeTo(OutputStream out) throws IllegalStateException{
// try {
// StreamMachine.write(out,
// ATTRIBUTE_ITERATIONCOUNT,
// ATTRIBUTE_SALT,
// ATTRIBUTE_KEY,
// ciph.doEnc_ECB(ATTRIBUTE_IV)
// );
//
//
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
//
// protected void _readFrom(InputStream is) throws IllegalStateException{
// StreamMachine sm = new StreamMachine(is);
//
// ATTRIBUTE_ITERATIONCOUNT = sm.readO(ATTRIBUTE_ITERATIONCOUNT);
// sm.read(ATTRIBUTE_SALT);
// sm.read(ATTRIBUTE_KEY);
// sm.read(ATTRIBUTE_IV);
//
// if(ciph == null){
// key = new PBE1AESKeySet();
// key.enckey = ATTRIBUTE_KEY;
// key.its = ATTRIBUTE_ITERATIONCOUNT;
// key.salt = ATTRIBUTE_SALT;
//
// PBE1PwToKey.loadPBE(pw, key, getStatus());
//
// ciph = CipherMain.instance(cipherCode, key.plainkey);
// }
//
// ATTRIBUTE_IV = ciph.doDec_ECB(ATTRIBUTE_IV);
// }
//
//
// public byte[] getAttributeIV(){
// return ATTRIBUTE_IV;
// }
// }
//
// Path: CrococryptFile/common/org/fhissen/crypto/CryptoCodes.java
// public enum BASECIPHER{
// AES,
// TWOFISH ("Twofish"),
// SERPENT ("Serpent"),
// CAMELLIA ("Camellia"),
//
// ;
//
// private String cipherCode = null;
// private BASECIPHER(){}
// private BASECIPHER(String cipherCode){
// this.cipherCode = cipherCode;
// }
//
// private String getCipherCode(){
// if(cipherCode != null)
// return cipherCode;
//
// return name();
// }
//
// public String getECB(){
// return ecbCodes.get(this);
// }
//
// public String getCBCPad(){
// return cbcpadCodes.get(this);
// }
//
// public String getCBCNopad(){
// return cbcnopadCodes.get(this);
// }
// }
// Path: CrococryptFile/main/org/crococryptfile/suites/pbecamellia/PBE1CamelliaMain.java
import org.crococryptfile.suites.pbeaes.PBE1AESMain;
import org.fhissen.crypto.CryptoCodes.BASECIPHER;
package org.crococryptfile.suites.pbecamellia;
public class PBE1CamelliaMain extends PBE1AESMain {
{
| cipherCode = BASECIPHER.CAMELLIA;
|
fhissen/CrococryptFile | CrococryptFile/common/org/fhissen/utils/FileWipe.java | // Path: CrococryptFile/common/org/fhissen/crypto/CryptoUtils.java
// public class CryptoUtils {
// static{
// InitCrypto.INIT();
// }
//
// private static Random randio = new Random();
// static{
// randio.nextBoolean();
// long l = randio.nextLong();
// randio.setSeed(System.currentTimeMillis() ^ l);
// }
//
// public static final void kill(byte[] b){
// if(b == null) return;
// randio.nextBytes(b);
// }
//
// public static final void kill(byte[]... bs){
// if(bs == null) return;
//
// for(byte[]b: bs)
// kill(b);
// }
//
// public static final void kill(char[] b){
// if(b == null) return;
// for(int i=0; i<b.length; i++)
// b[i] = (char)randio.nextInt();
// }
//
//
// private static final SecureRandom sr = new KeygenUtils().makeSR();
// public static final byte[] randIv16(){
// byte[] ret = new byte[16];
// sr.nextBytes(ret);
// return ret;
// }
//
// public static final byte[] randIv(int size){
// byte[] ret = new byte[size];
// sr.nextBytes(ret);
// return ret;
// }
//
//
// public static final long makeSimpleId(){
// return UUID.randomUUID().getMostSignificantBits();
// }
//
//
// public static final String[] toArray(String... s){
// return s;
// }
//
// public static final BASECIPHER[] toArray(BASECIPHER... bc){
// return bc;
// }
//
// public static final FSecretKeySpec[] toArray(FSecretKeySpec... fs){
// return fs;
// }
//
// public static final FSecretKeySpec[] toArray(byte[]... rawkeys){
// if(rawkeys == null || rawkeys.length == 0) return null;
//
// FSecretKeySpec[] fs = new FSecretKeySpec[rawkeys.length];
//
// for(int i=0; i<rawkeys.length; i++){
// fs[i] = new FSecretKeySpec(rawkeys[i]);
// }
//
// return fs;
// }
// }
| import java.io.File;
import java.io.RandomAccessFile;
import java.util.Arrays;
import org.fhissen.crypto.CryptoUtils;
| package org.fhissen.utils;
public class FileWipe {
private static final int BUFFERSIZE = 1024 * 1024;
public static File wipe(File f){
if(!f.exists() || !f.isFile()) {
return null;
}
try {
RandomAccessFile raf = new RandomAccessFile(f, "rw");
byte[] b = new byte[BUFFERSIZE];
long l = raf.length();
while(l > 0){
| // Path: CrococryptFile/common/org/fhissen/crypto/CryptoUtils.java
// public class CryptoUtils {
// static{
// InitCrypto.INIT();
// }
//
// private static Random randio = new Random();
// static{
// randio.nextBoolean();
// long l = randio.nextLong();
// randio.setSeed(System.currentTimeMillis() ^ l);
// }
//
// public static final void kill(byte[] b){
// if(b == null) return;
// randio.nextBytes(b);
// }
//
// public static final void kill(byte[]... bs){
// if(bs == null) return;
//
// for(byte[]b: bs)
// kill(b);
// }
//
// public static final void kill(char[] b){
// if(b == null) return;
// for(int i=0; i<b.length; i++)
// b[i] = (char)randio.nextInt();
// }
//
//
// private static final SecureRandom sr = new KeygenUtils().makeSR();
// public static final byte[] randIv16(){
// byte[] ret = new byte[16];
// sr.nextBytes(ret);
// return ret;
// }
//
// public static final byte[] randIv(int size){
// byte[] ret = new byte[size];
// sr.nextBytes(ret);
// return ret;
// }
//
//
// public static final long makeSimpleId(){
// return UUID.randomUUID().getMostSignificantBits();
// }
//
//
// public static final String[] toArray(String... s){
// return s;
// }
//
// public static final BASECIPHER[] toArray(BASECIPHER... bc){
// return bc;
// }
//
// public static final FSecretKeySpec[] toArray(FSecretKeySpec... fs){
// return fs;
// }
//
// public static final FSecretKeySpec[] toArray(byte[]... rawkeys){
// if(rawkeys == null || rawkeys.length == 0) return null;
//
// FSecretKeySpec[] fs = new FSecretKeySpec[rawkeys.length];
//
// for(int i=0; i<rawkeys.length; i++){
// fs[i] = new FSecretKeySpec(rawkeys[i]);
// }
//
// return fs;
// }
// }
// Path: CrococryptFile/common/org/fhissen/utils/FileWipe.java
import java.io.File;
import java.io.RandomAccessFile;
import java.util.Arrays;
import org.fhissen.crypto.CryptoUtils;
package org.fhissen.utils;
public class FileWipe {
private static final int BUFFERSIZE = 1024 * 1024;
public static File wipe(File f){
if(!f.exists() || !f.isFile()) {
return null;
}
try {
RandomAccessFile raf = new RandomAccessFile(f, "rw");
byte[] b = new byte[BUFFERSIZE];
long l = raf.length();
while(l > 0){
| CryptoUtils.kill(b);
|
fhissen/CrococryptFile | CrococryptFile/main/org/crococryptfile/suites/pbetwofish/PBE1TwofishMain.java | // Path: CrococryptFile/main/org/crococryptfile/suites/pbeaes/PBE1AESMain.java
// public class PBE1AESMain extends Suite {
// private int ATTRIBUTE_ITERATIONCOUNT;
// private byte[] ATTRIBUTE_SALT = new byte[CryptoCodes.STANDARD_SALTSIZE];
// private byte[] ATTRIBUTE_KEY = new byte[CryptoCodes.AES_KEYSIZE];
// private byte[] ATTRIBUTE_IV = new byte[CryptoCodes.STANDARD_IVSIZE];
//
// @Override
// public final void deinit(){
// if(key != null) key.deinit();
// key = null;
// CryptoUtils.kill(pw);
// CryptoUtils.kill(ATTRIBUTE_KEY, ATTRIBUTE_IV);
// ciph.deinint();
// System.gc();
// }
//
// @Override
// protected void finalize() throws Throwable {
// deinit();
// super.finalize();
// }
//
// private final int len = ByteUtils.sizeInBytes(ATTRIBUTE_ITERATIONCOUNT, ATTRIBUTE_SALT, ATTRIBUTE_KEY, ATTRIBUTE_IV);
// public final int headerLength(){
// return len;
// }
//
// public CipherMain getCipher(){
// return ciph;
// }
//
//
// private PBE1AESKeySet key;
// private CipherMain ciph;
// private char[] pw;
//
//
// protected BASECIPHER cipherCode = BASECIPHER.AES;
//
// @Override
// protected void _init(SuiteMODE mode, HashMap<SuitePARAM, Object> params) throws IllegalArgumentException{
// if(params == null || params.size() == 0) throw new IllegalArgumentException("PBE: no params specified");
// pw = (char[])params.get(SuitePARAM.password);
// if(pw == null) throw new IllegalArgumentException("PBE must specify a password");
//
// int itcount_ext = 0;
// if(params.containsKey(SuitePARAM.itcount)){
// try {
// itcount_ext = Integer.parseInt((String)params.get(SuitePARAM.itcount));
// } catch (Exception e) {}
// }
//
// if(mode == SuiteMODE.ENCRYPT){
// key = PBE1PwToKey.createPBE(pw, itcount_ext, getStatus());
// ciph = CipherMain.instance(cipherCode, key.plainkey);
//
// ATTRIBUTE_ITERATIONCOUNT = key.its;
// ATTRIBUTE_SALT = key.salt;
// ATTRIBUTE_KEY = key.enckey;
// ATTRIBUTE_IV = CryptoUtils.randIv16();
// }
// }
//
//
// protected void _writeTo(OutputStream out) throws IllegalStateException{
// try {
// StreamMachine.write(out,
// ATTRIBUTE_ITERATIONCOUNT,
// ATTRIBUTE_SALT,
// ATTRIBUTE_KEY,
// ciph.doEnc_ECB(ATTRIBUTE_IV)
// );
//
//
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
//
// protected void _readFrom(InputStream is) throws IllegalStateException{
// StreamMachine sm = new StreamMachine(is);
//
// ATTRIBUTE_ITERATIONCOUNT = sm.readO(ATTRIBUTE_ITERATIONCOUNT);
// sm.read(ATTRIBUTE_SALT);
// sm.read(ATTRIBUTE_KEY);
// sm.read(ATTRIBUTE_IV);
//
// if(ciph == null){
// key = new PBE1AESKeySet();
// key.enckey = ATTRIBUTE_KEY;
// key.its = ATTRIBUTE_ITERATIONCOUNT;
// key.salt = ATTRIBUTE_SALT;
//
// PBE1PwToKey.loadPBE(pw, key, getStatus());
//
// ciph = CipherMain.instance(cipherCode, key.plainkey);
// }
//
// ATTRIBUTE_IV = ciph.doDec_ECB(ATTRIBUTE_IV);
// }
//
//
// public byte[] getAttributeIV(){
// return ATTRIBUTE_IV;
// }
// }
//
// Path: CrococryptFile/common/org/fhissen/crypto/CryptoCodes.java
// public enum BASECIPHER{
// AES,
// TWOFISH ("Twofish"),
// SERPENT ("Serpent"),
// CAMELLIA ("Camellia"),
//
// ;
//
// private String cipherCode = null;
// private BASECIPHER(){}
// private BASECIPHER(String cipherCode){
// this.cipherCode = cipherCode;
// }
//
// private String getCipherCode(){
// if(cipherCode != null)
// return cipherCode;
//
// return name();
// }
//
// public String getECB(){
// return ecbCodes.get(this);
// }
//
// public String getCBCPad(){
// return cbcpadCodes.get(this);
// }
//
// public String getCBCNopad(){
// return cbcnopadCodes.get(this);
// }
// }
| import org.crococryptfile.suites.pbeaes.PBE1AESMain;
import org.fhissen.crypto.CryptoCodes.BASECIPHER;
| package org.crococryptfile.suites.pbetwofish;
public class PBE1TwofishMain extends PBE1AESMain {
{
| // Path: CrococryptFile/main/org/crococryptfile/suites/pbeaes/PBE1AESMain.java
// public class PBE1AESMain extends Suite {
// private int ATTRIBUTE_ITERATIONCOUNT;
// private byte[] ATTRIBUTE_SALT = new byte[CryptoCodes.STANDARD_SALTSIZE];
// private byte[] ATTRIBUTE_KEY = new byte[CryptoCodes.AES_KEYSIZE];
// private byte[] ATTRIBUTE_IV = new byte[CryptoCodes.STANDARD_IVSIZE];
//
// @Override
// public final void deinit(){
// if(key != null) key.deinit();
// key = null;
// CryptoUtils.kill(pw);
// CryptoUtils.kill(ATTRIBUTE_KEY, ATTRIBUTE_IV);
// ciph.deinint();
// System.gc();
// }
//
// @Override
// protected void finalize() throws Throwable {
// deinit();
// super.finalize();
// }
//
// private final int len = ByteUtils.sizeInBytes(ATTRIBUTE_ITERATIONCOUNT, ATTRIBUTE_SALT, ATTRIBUTE_KEY, ATTRIBUTE_IV);
// public final int headerLength(){
// return len;
// }
//
// public CipherMain getCipher(){
// return ciph;
// }
//
//
// private PBE1AESKeySet key;
// private CipherMain ciph;
// private char[] pw;
//
//
// protected BASECIPHER cipherCode = BASECIPHER.AES;
//
// @Override
// protected void _init(SuiteMODE mode, HashMap<SuitePARAM, Object> params) throws IllegalArgumentException{
// if(params == null || params.size() == 0) throw new IllegalArgumentException("PBE: no params specified");
// pw = (char[])params.get(SuitePARAM.password);
// if(pw == null) throw new IllegalArgumentException("PBE must specify a password");
//
// int itcount_ext = 0;
// if(params.containsKey(SuitePARAM.itcount)){
// try {
// itcount_ext = Integer.parseInt((String)params.get(SuitePARAM.itcount));
// } catch (Exception e) {}
// }
//
// if(mode == SuiteMODE.ENCRYPT){
// key = PBE1PwToKey.createPBE(pw, itcount_ext, getStatus());
// ciph = CipherMain.instance(cipherCode, key.plainkey);
//
// ATTRIBUTE_ITERATIONCOUNT = key.its;
// ATTRIBUTE_SALT = key.salt;
// ATTRIBUTE_KEY = key.enckey;
// ATTRIBUTE_IV = CryptoUtils.randIv16();
// }
// }
//
//
// protected void _writeTo(OutputStream out) throws IllegalStateException{
// try {
// StreamMachine.write(out,
// ATTRIBUTE_ITERATIONCOUNT,
// ATTRIBUTE_SALT,
// ATTRIBUTE_KEY,
// ciph.doEnc_ECB(ATTRIBUTE_IV)
// );
//
//
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
//
// protected void _readFrom(InputStream is) throws IllegalStateException{
// StreamMachine sm = new StreamMachine(is);
//
// ATTRIBUTE_ITERATIONCOUNT = sm.readO(ATTRIBUTE_ITERATIONCOUNT);
// sm.read(ATTRIBUTE_SALT);
// sm.read(ATTRIBUTE_KEY);
// sm.read(ATTRIBUTE_IV);
//
// if(ciph == null){
// key = new PBE1AESKeySet();
// key.enckey = ATTRIBUTE_KEY;
// key.its = ATTRIBUTE_ITERATIONCOUNT;
// key.salt = ATTRIBUTE_SALT;
//
// PBE1PwToKey.loadPBE(pw, key, getStatus());
//
// ciph = CipherMain.instance(cipherCode, key.plainkey);
// }
//
// ATTRIBUTE_IV = ciph.doDec_ECB(ATTRIBUTE_IV);
// }
//
//
// public byte[] getAttributeIV(){
// return ATTRIBUTE_IV;
// }
// }
//
// Path: CrococryptFile/common/org/fhissen/crypto/CryptoCodes.java
// public enum BASECIPHER{
// AES,
// TWOFISH ("Twofish"),
// SERPENT ("Serpent"),
// CAMELLIA ("Camellia"),
//
// ;
//
// private String cipherCode = null;
// private BASECIPHER(){}
// private BASECIPHER(String cipherCode){
// this.cipherCode = cipherCode;
// }
//
// private String getCipherCode(){
// if(cipherCode != null)
// return cipherCode;
//
// return name();
// }
//
// public String getECB(){
// return ecbCodes.get(this);
// }
//
// public String getCBCPad(){
// return cbcpadCodes.get(this);
// }
//
// public String getCBCNopad(){
// return cbcnopadCodes.get(this);
// }
// }
// Path: CrococryptFile/main/org/crococryptfile/suites/pbetwofish/PBE1TwofishMain.java
import org.crococryptfile.suites.pbeaes.PBE1AESMain;
import org.fhissen.crypto.CryptoCodes.BASECIPHER;
package org.crococryptfile.suites.pbetwofish;
public class PBE1TwofishMain extends PBE1AESMain {
{
| cipherCode = BASECIPHER.TWOFISH;
|
fhissen/CrococryptFile | CrococryptFile/main/org/crococryptfile/suites/pbeaes/PBE1AESKeySet.java | // Path: CrococryptFile/common/org/fhissen/crypto/CryptoUtils.java
// public class CryptoUtils {
// static{
// InitCrypto.INIT();
// }
//
// private static Random randio = new Random();
// static{
// randio.nextBoolean();
// long l = randio.nextLong();
// randio.setSeed(System.currentTimeMillis() ^ l);
// }
//
// public static final void kill(byte[] b){
// if(b == null) return;
// randio.nextBytes(b);
// }
//
// public static final void kill(byte[]... bs){
// if(bs == null) return;
//
// for(byte[]b: bs)
// kill(b);
// }
//
// public static final void kill(char[] b){
// if(b == null) return;
// for(int i=0; i<b.length; i++)
// b[i] = (char)randio.nextInt();
// }
//
//
// private static final SecureRandom sr = new KeygenUtils().makeSR();
// public static final byte[] randIv16(){
// byte[] ret = new byte[16];
// sr.nextBytes(ret);
// return ret;
// }
//
// public static final byte[] randIv(int size){
// byte[] ret = new byte[size];
// sr.nextBytes(ret);
// return ret;
// }
//
//
// public static final long makeSimpleId(){
// return UUID.randomUUID().getMostSignificantBits();
// }
//
//
// public static final String[] toArray(String... s){
// return s;
// }
//
// public static final BASECIPHER[] toArray(BASECIPHER... bc){
// return bc;
// }
//
// public static final FSecretKeySpec[] toArray(FSecretKeySpec... fs){
// return fs;
// }
//
// public static final FSecretKeySpec[] toArray(byte[]... rawkeys){
// if(rawkeys == null || rawkeys.length == 0) return null;
//
// FSecretKeySpec[] fs = new FSecretKeySpec[rawkeys.length];
//
// for(int i=0; i<rawkeys.length; i++){
// fs[i] = new FSecretKeySpec(rawkeys[i]);
// }
//
// return fs;
// }
// }
| import org.fhissen.crypto.CryptoUtils;
| package org.crococryptfile.suites.pbeaes;
public class PBE1AESKeySet{
public byte[] enckey, plainkey;
public int its;
public byte[] salt;
public void deinit(){
| // Path: CrococryptFile/common/org/fhissen/crypto/CryptoUtils.java
// public class CryptoUtils {
// static{
// InitCrypto.INIT();
// }
//
// private static Random randio = new Random();
// static{
// randio.nextBoolean();
// long l = randio.nextLong();
// randio.setSeed(System.currentTimeMillis() ^ l);
// }
//
// public static final void kill(byte[] b){
// if(b == null) return;
// randio.nextBytes(b);
// }
//
// public static final void kill(byte[]... bs){
// if(bs == null) return;
//
// for(byte[]b: bs)
// kill(b);
// }
//
// public static final void kill(char[] b){
// if(b == null) return;
// for(int i=0; i<b.length; i++)
// b[i] = (char)randio.nextInt();
// }
//
//
// private static final SecureRandom sr = new KeygenUtils().makeSR();
// public static final byte[] randIv16(){
// byte[] ret = new byte[16];
// sr.nextBytes(ret);
// return ret;
// }
//
// public static final byte[] randIv(int size){
// byte[] ret = new byte[size];
// sr.nextBytes(ret);
// return ret;
// }
//
//
// public static final long makeSimpleId(){
// return UUID.randomUUID().getMostSignificantBits();
// }
//
//
// public static final String[] toArray(String... s){
// return s;
// }
//
// public static final BASECIPHER[] toArray(BASECIPHER... bc){
// return bc;
// }
//
// public static final FSecretKeySpec[] toArray(FSecretKeySpec... fs){
// return fs;
// }
//
// public static final FSecretKeySpec[] toArray(byte[]... rawkeys){
// if(rawkeys == null || rawkeys.length == 0) return null;
//
// FSecretKeySpec[] fs = new FSecretKeySpec[rawkeys.length];
//
// for(int i=0; i<rawkeys.length; i++){
// fs[i] = new FSecretKeySpec(rawkeys[i]);
// }
//
// return fs;
// }
// }
// Path: CrococryptFile/main/org/crococryptfile/suites/pbeaes/PBE1AESKeySet.java
import org.fhissen.crypto.CryptoUtils;
package org.crococryptfile.suites.pbeaes;
public class PBE1AESKeySet{
public byte[] enckey, plainkey;
public int its;
public byte[] salt;
public void deinit(){
| CryptoUtils.kill(enckey, plainkey, salt);
|
fhissen/CrococryptFile | CrococryptFile/common/org/fhissen/utils/ByteUtils.java | // Path: CrococryptFile/common/org/fhissen/crypto/CryptoUtils.java
// public class CryptoUtils {
// static{
// InitCrypto.INIT();
// }
//
// private static Random randio = new Random();
// static{
// randio.nextBoolean();
// long l = randio.nextLong();
// randio.setSeed(System.currentTimeMillis() ^ l);
// }
//
// public static final void kill(byte[] b){
// if(b == null) return;
// randio.nextBytes(b);
// }
//
// public static final void kill(byte[]... bs){
// if(bs == null) return;
//
// for(byte[]b: bs)
// kill(b);
// }
//
// public static final void kill(char[] b){
// if(b == null) return;
// for(int i=0; i<b.length; i++)
// b[i] = (char)randio.nextInt();
// }
//
//
// private static final SecureRandom sr = new KeygenUtils().makeSR();
// public static final byte[] randIv16(){
// byte[] ret = new byte[16];
// sr.nextBytes(ret);
// return ret;
// }
//
// public static final byte[] randIv(int size){
// byte[] ret = new byte[size];
// sr.nextBytes(ret);
// return ret;
// }
//
//
// public static final long makeSimpleId(){
// return UUID.randomUUID().getMostSignificantBits();
// }
//
//
// public static final String[] toArray(String... s){
// return s;
// }
//
// public static final BASECIPHER[] toArray(BASECIPHER... bc){
// return bc;
// }
//
// public static final FSecretKeySpec[] toArray(FSecretKeySpec... fs){
// return fs;
// }
//
// public static final FSecretKeySpec[] toArray(byte[]... rawkeys){
// if(rawkeys == null || rawkeys.length == 0) return null;
//
// FSecretKeySpec[] fs = new FSecretKeySpec[rawkeys.length];
//
// for(int i=0; i<rawkeys.length; i++){
// fs[i] = new FSecretKeySpec(rawkeys[i]);
// }
//
// return fs;
// }
// }
| import java.nio.ByteBuffer;
import org.fhissen.crypto.CryptoUtils;
| }
public static final byte[] copyTogetherNwipeO(Object... arr){
byte[][] b = new byte[arr.length][];
for(int i=0; i<arr.length; i++){
if(arr[i] != null)
b[i] = objToBytes(arr[i]);
else
b[i] = new byte[]{1};
}
return copyTogetherNwipeB(b);
}
public static final byte[] copyTogetherNwipeB(byte[]... arr){
int len = 0;
for(byte[] b: arr){
if(b == null) continue;
len += b.length;
}
byte[] ret = new byte[len];
int start = 0;
for(byte[] b: arr){
if(b == null) continue;
System.arraycopy(b, 0, ret, start, b.length);
start += b.length;
| // Path: CrococryptFile/common/org/fhissen/crypto/CryptoUtils.java
// public class CryptoUtils {
// static{
// InitCrypto.INIT();
// }
//
// private static Random randio = new Random();
// static{
// randio.nextBoolean();
// long l = randio.nextLong();
// randio.setSeed(System.currentTimeMillis() ^ l);
// }
//
// public static final void kill(byte[] b){
// if(b == null) return;
// randio.nextBytes(b);
// }
//
// public static final void kill(byte[]... bs){
// if(bs == null) return;
//
// for(byte[]b: bs)
// kill(b);
// }
//
// public static final void kill(char[] b){
// if(b == null) return;
// for(int i=0; i<b.length; i++)
// b[i] = (char)randio.nextInt();
// }
//
//
// private static final SecureRandom sr = new KeygenUtils().makeSR();
// public static final byte[] randIv16(){
// byte[] ret = new byte[16];
// sr.nextBytes(ret);
// return ret;
// }
//
// public static final byte[] randIv(int size){
// byte[] ret = new byte[size];
// sr.nextBytes(ret);
// return ret;
// }
//
//
// public static final long makeSimpleId(){
// return UUID.randomUUID().getMostSignificantBits();
// }
//
//
// public static final String[] toArray(String... s){
// return s;
// }
//
// public static final BASECIPHER[] toArray(BASECIPHER... bc){
// return bc;
// }
//
// public static final FSecretKeySpec[] toArray(FSecretKeySpec... fs){
// return fs;
// }
//
// public static final FSecretKeySpec[] toArray(byte[]... rawkeys){
// if(rawkeys == null || rawkeys.length == 0) return null;
//
// FSecretKeySpec[] fs = new FSecretKeySpec[rawkeys.length];
//
// for(int i=0; i<rawkeys.length; i++){
// fs[i] = new FSecretKeySpec(rawkeys[i]);
// }
//
// return fs;
// }
// }
// Path: CrococryptFile/common/org/fhissen/utils/ByteUtils.java
import java.nio.ByteBuffer;
import org.fhissen.crypto.CryptoUtils;
}
public static final byte[] copyTogetherNwipeO(Object... arr){
byte[][] b = new byte[arr.length][];
for(int i=0; i<arr.length; i++){
if(arr[i] != null)
b[i] = objToBytes(arr[i]);
else
b[i] = new byte[]{1};
}
return copyTogetherNwipeB(b);
}
public static final byte[] copyTogetherNwipeB(byte[]... arr){
int len = 0;
for(byte[] b: arr){
if(b == null) continue;
len += b.length;
}
byte[] ret = new byte[len];
int start = 0;
for(byte[] b: arr){
if(b == null) continue;
System.arraycopy(b, 0, ret, start, b.length);
start += b.length;
| CryptoUtils.kill(b);
|
fhissen/CrococryptFile | CrococryptFile/common/org/fhissen/crypto/CryptoUtils.java | // Path: CrococryptFile/common/org/fhissen/crypto/CryptoCodes.java
// public enum BASECIPHER{
// AES,
// TWOFISH ("Twofish"),
// SERPENT ("Serpent"),
// CAMELLIA ("Camellia"),
//
// ;
//
// private String cipherCode = null;
// private BASECIPHER(){}
// private BASECIPHER(String cipherCode){
// this.cipherCode = cipherCode;
// }
//
// private String getCipherCode(){
// if(cipherCode != null)
// return cipherCode;
//
// return name();
// }
//
// public String getECB(){
// return ecbCodes.get(this);
// }
//
// public String getCBCPad(){
// return cbcpadCodes.get(this);
// }
//
// public String getCBCNopad(){
// return cbcnopadCodes.get(this);
// }
// }
| import java.security.SecureRandom;
import java.util.Random;
import java.util.UUID;
import org.fhissen.crypto.CryptoCodes.BASECIPHER;
| public static final void kill(char[] b){
if(b == null) return;
for(int i=0; i<b.length; i++)
b[i] = (char)randio.nextInt();
}
private static final SecureRandom sr = new KeygenUtils().makeSR();
public static final byte[] randIv16(){
byte[] ret = new byte[16];
sr.nextBytes(ret);
return ret;
}
public static final byte[] randIv(int size){
byte[] ret = new byte[size];
sr.nextBytes(ret);
return ret;
}
public static final long makeSimpleId(){
return UUID.randomUUID().getMostSignificantBits();
}
public static final String[] toArray(String... s){
return s;
}
| // Path: CrococryptFile/common/org/fhissen/crypto/CryptoCodes.java
// public enum BASECIPHER{
// AES,
// TWOFISH ("Twofish"),
// SERPENT ("Serpent"),
// CAMELLIA ("Camellia"),
//
// ;
//
// private String cipherCode = null;
// private BASECIPHER(){}
// private BASECIPHER(String cipherCode){
// this.cipherCode = cipherCode;
// }
//
// private String getCipherCode(){
// if(cipherCode != null)
// return cipherCode;
//
// return name();
// }
//
// public String getECB(){
// return ecbCodes.get(this);
// }
//
// public String getCBCPad(){
// return cbcpadCodes.get(this);
// }
//
// public String getCBCNopad(){
// return cbcnopadCodes.get(this);
// }
// }
// Path: CrococryptFile/common/org/fhissen/crypto/CryptoUtils.java
import java.security.SecureRandom;
import java.util.Random;
import java.util.UUID;
import org.fhissen.crypto.CryptoCodes.BASECIPHER;
public static final void kill(char[] b){
if(b == null) return;
for(int i=0; i<b.length; i++)
b[i] = (char)randio.nextInt();
}
private static final SecureRandom sr = new KeygenUtils().makeSR();
public static final byte[] randIv16(){
byte[] ret = new byte[16];
sr.nextBytes(ret);
return ret;
}
public static final byte[] randIv(int size){
byte[] ret = new byte[size];
sr.nextBytes(ret);
return ret;
}
public static final long makeSimpleId(){
return UUID.randomUUID().getMostSignificantBits();
}
public static final String[] toArray(String... s){
return s;
}
| public static final BASECIPHER[] toArray(BASECIPHER... bc){
|
fhissen/CrococryptFile | CrococryptFile/main/org/crococryptfile/suites/pbecloakedaes2f/PBECloaked_AES2F_KeySet.java | // Path: CrococryptFile/common/org/fhissen/crypto/CryptoUtils.java
// public class CryptoUtils {
// static{
// InitCrypto.INIT();
// }
//
// private static Random randio = new Random();
// static{
// randio.nextBoolean();
// long l = randio.nextLong();
// randio.setSeed(System.currentTimeMillis() ^ l);
// }
//
// public static final void kill(byte[] b){
// if(b == null) return;
// randio.nextBytes(b);
// }
//
// public static final void kill(byte[]... bs){
// if(bs == null) return;
//
// for(byte[]b: bs)
// kill(b);
// }
//
// public static final void kill(char[] b){
// if(b == null) return;
// for(int i=0; i<b.length; i++)
// b[i] = (char)randio.nextInt();
// }
//
//
// private static final SecureRandom sr = new KeygenUtils().makeSR();
// public static final byte[] randIv16(){
// byte[] ret = new byte[16];
// sr.nextBytes(ret);
// return ret;
// }
//
// public static final byte[] randIv(int size){
// byte[] ret = new byte[size];
// sr.nextBytes(ret);
// return ret;
// }
//
//
// public static final long makeSimpleId(){
// return UUID.randomUUID().getMostSignificantBits();
// }
//
//
// public static final String[] toArray(String... s){
// return s;
// }
//
// public static final BASECIPHER[] toArray(BASECIPHER... bc){
// return bc;
// }
//
// public static final FSecretKeySpec[] toArray(FSecretKeySpec... fs){
// return fs;
// }
//
// public static final FSecretKeySpec[] toArray(byte[]... rawkeys){
// if(rawkeys == null || rawkeys.length == 0) return null;
//
// FSecretKeySpec[] fs = new FSecretKeySpec[rawkeys.length];
//
// for(int i=0; i<rawkeys.length; i++){
// fs[i] = new FSecretKeySpec(rawkeys[i]);
// }
//
// return fs;
// }
// }
| import org.fhissen.crypto.CryptoUtils;
| package org.crococryptfile.suites.pbecloakedaes2f;
public class PBECloaked_AES2F_KeySet{
public byte[] aes_enckey, aes_plainkey;
public byte[] two_enckey, two_plainkey;
public byte[] salt;
public void deinit(){
| // Path: CrococryptFile/common/org/fhissen/crypto/CryptoUtils.java
// public class CryptoUtils {
// static{
// InitCrypto.INIT();
// }
//
// private static Random randio = new Random();
// static{
// randio.nextBoolean();
// long l = randio.nextLong();
// randio.setSeed(System.currentTimeMillis() ^ l);
// }
//
// public static final void kill(byte[] b){
// if(b == null) return;
// randio.nextBytes(b);
// }
//
// public static final void kill(byte[]... bs){
// if(bs == null) return;
//
// for(byte[]b: bs)
// kill(b);
// }
//
// public static final void kill(char[] b){
// if(b == null) return;
// for(int i=0; i<b.length; i++)
// b[i] = (char)randio.nextInt();
// }
//
//
// private static final SecureRandom sr = new KeygenUtils().makeSR();
// public static final byte[] randIv16(){
// byte[] ret = new byte[16];
// sr.nextBytes(ret);
// return ret;
// }
//
// public static final byte[] randIv(int size){
// byte[] ret = new byte[size];
// sr.nextBytes(ret);
// return ret;
// }
//
//
// public static final long makeSimpleId(){
// return UUID.randomUUID().getMostSignificantBits();
// }
//
//
// public static final String[] toArray(String... s){
// return s;
// }
//
// public static final BASECIPHER[] toArray(BASECIPHER... bc){
// return bc;
// }
//
// public static final FSecretKeySpec[] toArray(FSecretKeySpec... fs){
// return fs;
// }
//
// public static final FSecretKeySpec[] toArray(byte[]... rawkeys){
// if(rawkeys == null || rawkeys.length == 0) return null;
//
// FSecretKeySpec[] fs = new FSecretKeySpec[rawkeys.length];
//
// for(int i=0; i<rawkeys.length; i++){
// fs[i] = new FSecretKeySpec(rawkeys[i]);
// }
//
// return fs;
// }
// }
// Path: CrococryptFile/main/org/crococryptfile/suites/pbecloakedaes2f/PBECloaked_AES2F_KeySet.java
import org.fhissen.crypto.CryptoUtils;
package org.crococryptfile.suites.pbecloakedaes2f;
public class PBECloaked_AES2F_KeySet{
public byte[] aes_enckey, aes_plainkey;
public byte[] two_enckey, two_plainkey;
public byte[] salt;
public void deinit(){
| CryptoUtils.kill(aes_enckey, aes_plainkey, two_enckey, two_plainkey, salt);
|
fhissen/CrococryptFile | CrococryptFile/common/org/fhissen/crypto/PBKDF2.java | // Path: CrococryptFile/common/org/fhissen/utils/ui/StatusUpdate.java
// public interface StatusUpdate {
// public void start();
// public void finished();
// public boolean isActive();
// public void receiveMessageSummary(String msg);
// public void receiveMessageDetails(String msg);
// public void receiveProgress(int perc);
// public void receiveDetailsProgress(int perc);
// }
| import javax.crypto.spec.SecretKeySpec;
import org.fhissen.utils.ui.StatusUpdate;
import javax.crypto.Mac; | package org.fhissen.crypto;
/*
* This class is based on the Bouncy Castle ((c) http://www.bouncycastle.org/) Java class org.bouncycastle.crypto.generators.PKCS5S2ParametersGenerator
* See http://www.bouncycastle.org/ for the license of BC
*/
public class PBKDF2 {
private Mac hMac;
private byte[] state;
private FSecretKeySpec key; | // Path: CrococryptFile/common/org/fhissen/utils/ui/StatusUpdate.java
// public interface StatusUpdate {
// public void start();
// public void finished();
// public boolean isActive();
// public void receiveMessageSummary(String msg);
// public void receiveMessageDetails(String msg);
// public void receiveProgress(int perc);
// public void receiveDetailsProgress(int perc);
// }
// Path: CrococryptFile/common/org/fhissen/crypto/PBKDF2.java
import javax.crypto.spec.SecretKeySpec;
import org.fhissen.utils.ui.StatusUpdate;
import javax.crypto.Mac;
package org.fhissen.crypto;
/*
* This class is based on the Bouncy Castle ((c) http://www.bouncycastle.org/) Java class org.bouncycastle.crypto.generators.PKCS5S2ParametersGenerator
* See http://www.bouncycastle.org/ for the license of BC
*/
public class PBKDF2 {
private Mac hMac;
private byte[] state;
private FSecretKeySpec key; | private StatusUpdate status; |
fhissen/CrococryptFile | CrococryptFile/common/org/fhissen/crypto/CipherMain.java | // Path: CrococryptFile/common/org/fhissen/crypto/CryptoCodes.java
// public enum BASECIPHER{
// AES,
// TWOFISH ("Twofish"),
// SERPENT ("Serpent"),
// CAMELLIA ("Camellia"),
//
// ;
//
// private String cipherCode = null;
// private BASECIPHER(){}
// private BASECIPHER(String cipherCode){
// this.cipherCode = cipherCode;
// }
//
// private String getCipherCode(){
// if(cipherCode != null)
// return cipherCode;
//
// return name();
// }
//
// public String getECB(){
// return ecbCodes.get(this);
// }
//
// public String getCBCPad(){
// return cbcpadCodes.get(this);
// }
//
// public String getCBCNopad(){
// return cbcnopadCodes.get(this);
// }
// }
| import java.io.InputStream;
import java.io.OutputStream;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import javax.crypto.Cipher;
import javax.crypto.CipherInputStream;
import javax.crypto.CipherOutputStream;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.spec.IvParameterSpec;
import org.fhissen.crypto.CryptoCodes.BASECIPHER;
| package org.fhissen.crypto;
public class CipherMain {
private FSecretKeySpec[] keys;
| // Path: CrococryptFile/common/org/fhissen/crypto/CryptoCodes.java
// public enum BASECIPHER{
// AES,
// TWOFISH ("Twofish"),
// SERPENT ("Serpent"),
// CAMELLIA ("Camellia"),
//
// ;
//
// private String cipherCode = null;
// private BASECIPHER(){}
// private BASECIPHER(String cipherCode){
// this.cipherCode = cipherCode;
// }
//
// private String getCipherCode(){
// if(cipherCode != null)
// return cipherCode;
//
// return name();
// }
//
// public String getECB(){
// return ecbCodes.get(this);
// }
//
// public String getCBCPad(){
// return cbcpadCodes.get(this);
// }
//
// public String getCBCNopad(){
// return cbcnopadCodes.get(this);
// }
// }
// Path: CrococryptFile/common/org/fhissen/crypto/CipherMain.java
import java.io.InputStream;
import java.io.OutputStream;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import javax.crypto.Cipher;
import javax.crypto.CipherInputStream;
import javax.crypto.CipherOutputStream;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.spec.IvParameterSpec;
import org.fhissen.crypto.CryptoCodes.BASECIPHER;
package org.fhissen.crypto;
public class CipherMain {
private FSecretKeySpec[] keys;
| private BASECIPHER[] ciphers;
|
fhissen/CrococryptFile | CrococryptFile/main/org/crococryptfile/suites/capirsaaes/CAPIRSAUtils.java | // Path: CrococryptFile/common/org/fhissen/crypto/CryptoCodes.java
// public class CryptoCodes {
// public static final String KEY_AES = "AES";
// public static final String KEY_RSA = "RSA";
//
// public static final String HMAC_SHA512 = "HmacSHA512";
// public static final String HMAC_WHIRL = "HmacWhirlpool";
//
// public static final String HASH_SHA512 = "SHA512";
//
// public static final int AES_KEYSIZE_BITS = 256;
// public static final int AES_KEYSIZE = AES_KEYSIZE_BITS / 8;
//
// public static final int STANDARD_BLOCKSIZE = 16;
// public static final int STANDARD_IVSIZE = STANDARD_BLOCKSIZE;
// public static final int STANDARD_SALTSIZE = 64;
// public static final int STANDARD_PBKDF2_ITERATIONS = 100000;
// public static final int STANDARD_PBKDF2_PWLEN = 8;
//
//
// private static HashMap<BASECIPHER, String> ecbCodes = new HashMap<>();
// private static HashMap<BASECIPHER, String> cbcpadCodes = new HashMap<>();
// private static HashMap<BASECIPHER, String> cbcnopadCodes = new HashMap<>();
//
// static{
// for(BASECIPHER b: BASECIPHER.values()){
// ecbCodes.put(b, b.getCipherCode() + "/ECB/NoPadding");
// cbcpadCodes.put(b, b.getCipherCode() + "/CBC/PKCS5Padding");
// cbcnopadCodes.put(b, b.getCipherCode() + "/CBC/NoPadding");
// }
// }
//
// public enum BASECIPHER{
// AES,
// TWOFISH ("Twofish"),
// SERPENT ("Serpent"),
// CAMELLIA ("Camellia"),
//
// ;
//
// private String cipherCode = null;
// private BASECIPHER(){}
// private BASECIPHER(String cipherCode){
// this.cipherCode = cipherCode;
// }
//
// private String getCipherCode(){
// if(cipherCode != null)
// return cipherCode;
//
// return name();
// }
//
// public String getECB(){
// return ecbCodes.get(this);
// }
//
// public String getCBCPad(){
// return cbcpadCodes.get(this);
// }
//
// public String getCBCNopad(){
// return cbcnopadCodes.get(this);
// }
// }
// }
| import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
import java.security.UnrecoverableKeyException;
import java.security.cert.Certificate;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.Enumeration;
import org.fhissen.crypto.CryptoCodes;
| package org.crococryptfile.suites.capirsaaes;
public class CAPIRSAUtils {
public static final String CAPI_KEYSTORE_USER = "Windows-MY";
public static final String CAPI_PROVIDER = "SunMSCAPI";
public static final String CAPI_RSACIPHER = "RSA/ECB/PKCS1Padding";
public static class CAPIRSAAliases{
public ArrayList<String> aliases = new ArrayList<>();
public ArrayList<String> displaytexts = new ArrayList<>();
}
private static KeyStore keystore;
static{
try {
keystore = KeyStore.getInstance(CAPI_KEYSTORE_USER, CAPI_PROVIDER);
keystore.load(null,null);
} catch (Exception e) {
e.printStackTrace();
}
}
public static final KeyStore getCAPI(){
return keystore;
}
public static final CAPIRSAAliases getPrivates() {
try {
CAPIRSAAliases ret = new CAPIRSAAliases();
Enumeration<String> en = keystore.aliases();
while(en.hasMoreElements()){
String alias = en.nextElement();
PrivateKey key = (PrivateKey)keystore.getKey(alias, null);
| // Path: CrococryptFile/common/org/fhissen/crypto/CryptoCodes.java
// public class CryptoCodes {
// public static final String KEY_AES = "AES";
// public static final String KEY_RSA = "RSA";
//
// public static final String HMAC_SHA512 = "HmacSHA512";
// public static final String HMAC_WHIRL = "HmacWhirlpool";
//
// public static final String HASH_SHA512 = "SHA512";
//
// public static final int AES_KEYSIZE_BITS = 256;
// public static final int AES_KEYSIZE = AES_KEYSIZE_BITS / 8;
//
// public static final int STANDARD_BLOCKSIZE = 16;
// public static final int STANDARD_IVSIZE = STANDARD_BLOCKSIZE;
// public static final int STANDARD_SALTSIZE = 64;
// public static final int STANDARD_PBKDF2_ITERATIONS = 100000;
// public static final int STANDARD_PBKDF2_PWLEN = 8;
//
//
// private static HashMap<BASECIPHER, String> ecbCodes = new HashMap<>();
// private static HashMap<BASECIPHER, String> cbcpadCodes = new HashMap<>();
// private static HashMap<BASECIPHER, String> cbcnopadCodes = new HashMap<>();
//
// static{
// for(BASECIPHER b: BASECIPHER.values()){
// ecbCodes.put(b, b.getCipherCode() + "/ECB/NoPadding");
// cbcpadCodes.put(b, b.getCipherCode() + "/CBC/PKCS5Padding");
// cbcnopadCodes.put(b, b.getCipherCode() + "/CBC/NoPadding");
// }
// }
//
// public enum BASECIPHER{
// AES,
// TWOFISH ("Twofish"),
// SERPENT ("Serpent"),
// CAMELLIA ("Camellia"),
//
// ;
//
// private String cipherCode = null;
// private BASECIPHER(){}
// private BASECIPHER(String cipherCode){
// this.cipherCode = cipherCode;
// }
//
// private String getCipherCode(){
// if(cipherCode != null)
// return cipherCode;
//
// return name();
// }
//
// public String getECB(){
// return ecbCodes.get(this);
// }
//
// public String getCBCPad(){
// return cbcpadCodes.get(this);
// }
//
// public String getCBCNopad(){
// return cbcnopadCodes.get(this);
// }
// }
// }
// Path: CrococryptFile/main/org/crococryptfile/suites/capirsaaes/CAPIRSAUtils.java
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
import java.security.UnrecoverableKeyException;
import java.security.cert.Certificate;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.Enumeration;
import org.fhissen.crypto.CryptoCodes;
package org.crococryptfile.suites.capirsaaes;
public class CAPIRSAUtils {
public static final String CAPI_KEYSTORE_USER = "Windows-MY";
public static final String CAPI_PROVIDER = "SunMSCAPI";
public static final String CAPI_RSACIPHER = "RSA/ECB/PKCS1Padding";
public static class CAPIRSAAliases{
public ArrayList<String> aliases = new ArrayList<>();
public ArrayList<String> displaytexts = new ArrayList<>();
}
private static KeyStore keystore;
static{
try {
keystore = KeyStore.getInstance(CAPI_KEYSTORE_USER, CAPI_PROVIDER);
keystore.load(null,null);
} catch (Exception e) {
e.printStackTrace();
}
}
public static final KeyStore getCAPI(){
return keystore;
}
public static final CAPIRSAAliases getPrivates() {
try {
CAPIRSAAliases ret = new CAPIRSAAliases();
Enumeration<String> en = keystore.aliases();
while(en.hasMoreElements()){
String alias = en.nextElement();
PrivateKey key = (PrivateKey)keystore.getKey(alias, null);
| if(key == null || !key.getAlgorithm().equalsIgnoreCase(CryptoCodes.KEY_RSA)) continue;
|
cmusatyalab/gabriel | android-client/client/src/main/java/edu/cmu/cs/gabriel/client/observer/EventObserver.java | // Path: android-client/client/src/main/java/edu/cmu/cs/gabriel/client/results/ErrorType.java
// public enum ErrorType {
// SERVER_ERROR,
// SERVER_DISCONNECTED,
// COULD_NOT_CONNECT
// }
| import android.util.Log;
import com.tinder.scarlet.Lifecycle;
import com.tinder.scarlet.ShutdownReason;
import com.tinder.scarlet.Stream.Observer;
import com.tinder.scarlet.WebSocket.Event;
import com.tinder.scarlet.lifecycle.LifecycleRegistry;
import org.jetbrains.annotations.NotNull;
import java.util.function.Consumer;
import edu.cmu.cs.gabriel.client.results.ErrorType; | package edu.cmu.cs.gabriel.client.observer;
public class EventObserver implements Observer<Event> {
private static final String TAG = "EventObserver";
private final LifecycleRegistry lifecycleRegistry; | // Path: android-client/client/src/main/java/edu/cmu/cs/gabriel/client/results/ErrorType.java
// public enum ErrorType {
// SERVER_ERROR,
// SERVER_DISCONNECTED,
// COULD_NOT_CONNECT
// }
// Path: android-client/client/src/main/java/edu/cmu/cs/gabriel/client/observer/EventObserver.java
import android.util.Log;
import com.tinder.scarlet.Lifecycle;
import com.tinder.scarlet.ShutdownReason;
import com.tinder.scarlet.Stream.Observer;
import com.tinder.scarlet.WebSocket.Event;
import com.tinder.scarlet.lifecycle.LifecycleRegistry;
import org.jetbrains.annotations.NotNull;
import java.util.function.Consumer;
import edu.cmu.cs.gabriel.client.results.ErrorType;
package edu.cmu.cs.gabriel.client.observer;
public class EventObserver implements Observer<Event> {
private static final String TAG = "EventObserver";
private final LifecycleRegistry lifecycleRegistry; | private final Consumer<ErrorType> onDisconnect; |
idugalic/micro-ecommerce | microservices-orders/src/main/java/com/idugalic/orders/order/web/OrderProjection.java | // Path: microservices-orders/src/main/java/com/idugalic/orders/order/domain/Order.java
// @Entity
// @Table(name = "WOrder")
// public class Order implements Identifiable<Long> {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// @Column(name = "id")
// private Long id;
//
// @Version
// @Column(name = "version")
// private Integer version;
//
// private Status status;
// @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTime")
// private DateTime orderedDate;
// @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
// private Set<Item> items = new HashSet<Item>();
//
// public Order(Collection<Item> items) {
// this.status = Status.PAYMENT_EXPECTED;
// this.items.addAll(items);
// this.orderedDate = new DateTime();
// }
//
// public Order(Item... items) {
// this(Arrays.asList(items));
// }
//
// public Order() {
// super();
// }
//
// public Long getId() {
// return this.id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public Integer getVersion() {
// return this.version;
// }
//
// public void setVersion(Integer version) {
// this.version = version;
// }
//
// public MonetaryAmount getPrice() {
// MonetaryAmount result = MonetaryAmount.ZERO;
//
// for (Item item : items) {
// result = result.add(item.getPrice());
// }
//
// return result;
// }
//
// public void markPaid() {
//
// if (isPaid()) {
// throw new IllegalStateException("Already paid order cannot be paid again!");
// }
//
// this.status = Status.PAID;
// }
//
// public void markInPreparation() {
//
// if (this.status != Status.PAID) {
// throw new IllegalStateException(String
// .format("Order must be in state payed to start preparation! " + "Current status: %s", this.status));
// }
//
// this.status = Status.PREPARING;
// }
//
// public void markPrepared() {
//
// if (this.status != Status.PREPARING) {
// throw new IllegalStateException(String.format(
// "Cannot mark Order prepared that is currently not " + "preparing! Current status: %s.",
// this.status));
// }
//
// this.status = Status.READY;
// }
//
// public boolean isPaid() {
// return !this.status.equals(Status.PAYMENT_EXPECTED);
// }
//
// public boolean isReady() {
// return this.status.equals(Status.READY);
// }
//
// public boolean isTaken() {
// return this.status.equals(Status.TAKEN);
// }
//
// public Status getStatus() {
// return status;
// }
//
// public void setStatus(Status status) {
// this.status = status;
// }
//
// public DateTime getOrderedDate() {
// return orderedDate;
// }
//
// public Set<Item> getItems() {
// return items;
// }
//
// public static enum Status {
//
// /**
// * Placed, but not payed yet. Still changeable.
// */
// PAYMENT_EXPECTED,
//
// /**
// * {@link Order} was payed. No changes allowed to it anymore.
// */
// PAID,
//
// /**
// * The {@link Order} is currently processed.
// */
// PREPARING,
//
// /**
// * The {@link Order} is ready to be picked up by the customer.
// */
// READY,
//
// /**
// * The {@link Order} was completed.
// */
// TAKEN;
// }
// }
//
// Path: microservices-orders/src/main/java/com/idugalic/orders/order/domain/Order.java
// public static enum Status {
//
// /**
// * Placed, but not payed yet. Still changeable.
// */
// PAYMENT_EXPECTED,
//
// /**
// * {@link Order} was payed. No changes allowed to it anymore.
// */
// PAID,
//
// /**
// * The {@link Order} is currently processed.
// */
// PREPARING,
//
// /**
// * The {@link Order} is ready to be picked up by the customer.
// */
// READY,
//
// /**
// * The {@link Order} was completed.
// */
// TAKEN;
// }
| import org.joda.time.DateTime;
import org.springframework.data.rest.core.config.Projection;
import com.idugalic.orders.order.domain.Order;
import com.idugalic.orders.order.domain.Order.Status; | package com.idugalic.orders.order.web;
/**
* Projection interface to render {@link Order} summaries.
*
*/
@Projection(name = "summary", types = Order.class)
public interface OrderProjection {
/**
* @see Order#getOrderedDate()
* @return
*/
DateTime getOrderedDate();
/**
* @see Order#getStatus()
* @return
*/ | // Path: microservices-orders/src/main/java/com/idugalic/orders/order/domain/Order.java
// @Entity
// @Table(name = "WOrder")
// public class Order implements Identifiable<Long> {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// @Column(name = "id")
// private Long id;
//
// @Version
// @Column(name = "version")
// private Integer version;
//
// private Status status;
// @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTime")
// private DateTime orderedDate;
// @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
// private Set<Item> items = new HashSet<Item>();
//
// public Order(Collection<Item> items) {
// this.status = Status.PAYMENT_EXPECTED;
// this.items.addAll(items);
// this.orderedDate = new DateTime();
// }
//
// public Order(Item... items) {
// this(Arrays.asList(items));
// }
//
// public Order() {
// super();
// }
//
// public Long getId() {
// return this.id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public Integer getVersion() {
// return this.version;
// }
//
// public void setVersion(Integer version) {
// this.version = version;
// }
//
// public MonetaryAmount getPrice() {
// MonetaryAmount result = MonetaryAmount.ZERO;
//
// for (Item item : items) {
// result = result.add(item.getPrice());
// }
//
// return result;
// }
//
// public void markPaid() {
//
// if (isPaid()) {
// throw new IllegalStateException("Already paid order cannot be paid again!");
// }
//
// this.status = Status.PAID;
// }
//
// public void markInPreparation() {
//
// if (this.status != Status.PAID) {
// throw new IllegalStateException(String
// .format("Order must be in state payed to start preparation! " + "Current status: %s", this.status));
// }
//
// this.status = Status.PREPARING;
// }
//
// public void markPrepared() {
//
// if (this.status != Status.PREPARING) {
// throw new IllegalStateException(String.format(
// "Cannot mark Order prepared that is currently not " + "preparing! Current status: %s.",
// this.status));
// }
//
// this.status = Status.READY;
// }
//
// public boolean isPaid() {
// return !this.status.equals(Status.PAYMENT_EXPECTED);
// }
//
// public boolean isReady() {
// return this.status.equals(Status.READY);
// }
//
// public boolean isTaken() {
// return this.status.equals(Status.TAKEN);
// }
//
// public Status getStatus() {
// return status;
// }
//
// public void setStatus(Status status) {
// this.status = status;
// }
//
// public DateTime getOrderedDate() {
// return orderedDate;
// }
//
// public Set<Item> getItems() {
// return items;
// }
//
// public static enum Status {
//
// /**
// * Placed, but not payed yet. Still changeable.
// */
// PAYMENT_EXPECTED,
//
// /**
// * {@link Order} was payed. No changes allowed to it anymore.
// */
// PAID,
//
// /**
// * The {@link Order} is currently processed.
// */
// PREPARING,
//
// /**
// * The {@link Order} is ready to be picked up by the customer.
// */
// READY,
//
// /**
// * The {@link Order} was completed.
// */
// TAKEN;
// }
// }
//
// Path: microservices-orders/src/main/java/com/idugalic/orders/order/domain/Order.java
// public static enum Status {
//
// /**
// * Placed, but not payed yet. Still changeable.
// */
// PAYMENT_EXPECTED,
//
// /**
// * {@link Order} was payed. No changes allowed to it anymore.
// */
// PAID,
//
// /**
// * The {@link Order} is currently processed.
// */
// PREPARING,
//
// /**
// * The {@link Order} is ready to be picked up by the customer.
// */
// READY,
//
// /**
// * The {@link Order} was completed.
// */
// TAKEN;
// }
// Path: microservices-orders/src/main/java/com/idugalic/orders/order/web/OrderProjection.java
import org.joda.time.DateTime;
import org.springframework.data.rest.core.config.Projection;
import com.idugalic.orders.order.domain.Order;
import com.idugalic.orders.order.domain.Order.Status;
package com.idugalic.orders.order.web;
/**
* Projection interface to render {@link Order} summaries.
*
*/
@Projection(name = "summary", types = Order.class)
public interface OrderProjection {
/**
* @see Order#getOrderedDate()
* @return
*/
DateTime getOrderedDate();
/**
* @see Order#getStatus()
* @return
*/ | Status getStatus(); |
idugalic/micro-ecommerce | microservices-catalog/src/main/java/com/idugalic/catalog/Application.java | // Path: microservices-catalog/src/main/java/com/idugalic/catalog/models/Category.java
// @Entity
// @Table(name = "categories")
// public class Category {
//
// @Id
// @GeneratedValue
// private Long id;
//
// @Column(nullable = false)
// private String name;
//
// @ManyToMany(mappedBy = "categories")
// @JsonIgnore
// private List<Product> products;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public List<Product> getProducts() {
// return products;
// }
//
// public void setProducts(List<Product> products) {
// this.products = products;
// }
//
// }
//
// Path: microservices-catalog/src/main/java/com/idugalic/catalog/models/Product.java
// @Entity
// @Table(name = "products")
// public class Product {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// @Column(name = "id")
// private Long id;
//
// @Version
// @Column(name = "version")
// private Integer version;
//
// private String name;
//
// private int quantity;
//
// private MonetaryAmount price;
//
// @ManyToMany(cascade = CascadeType.ALL)
// @JoinTable(name = "products_categories", joinColumns = {
// @JoinColumn(name = "product_id", referencedColumnName = "id") }, inverseJoinColumns = {
// @JoinColumn(name = "category_id", referencedColumnName = "id") })
// private List<Category> categories;
//
// public Long getId() {
// return this.id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public Integer getVersion() {
// return this.version;
// }
//
// public void setVersion(Integer version) {
// this.version = version;
// }
//
// protected Product() {
//
// }
//
// public Product(String name, MonetaryAmount price) {
// this.name = name;
// this.price = price;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public int getQuantity() {
// return quantity;
// }
//
// public void setQuantity(int quantity) {
// this.quantity = quantity;
// }
//
// public MonetaryAmount getPrice() {
// return price;
// }
//
// public void setPrice(MonetaryAmount price) {
// this.price = price;
// }
//
// public List<Category> getCategories() {
// return categories;
// }
//
// public void setCategories(List<Category> categories) {
// this.categories = categories;
// }
//
// }
| import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.data.rest.core.config.RepositoryRestConfiguration;
import org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration;
import org.springframework.http.HttpMethod;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;
import com.idugalic.catalog.models.Category;
import com.idugalic.catalog.models.Product; | package com.idugalic.catalog;
@SpringBootApplication
@EnableJpaRepositories
@EnableDiscoveryClient
public class Application
{
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@Configuration
static class RestMvc extends RepositoryRestMvcConfiguration {
@Override
protected void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) { | // Path: microservices-catalog/src/main/java/com/idugalic/catalog/models/Category.java
// @Entity
// @Table(name = "categories")
// public class Category {
//
// @Id
// @GeneratedValue
// private Long id;
//
// @Column(nullable = false)
// private String name;
//
// @ManyToMany(mappedBy = "categories")
// @JsonIgnore
// private List<Product> products;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public List<Product> getProducts() {
// return products;
// }
//
// public void setProducts(List<Product> products) {
// this.products = products;
// }
//
// }
//
// Path: microservices-catalog/src/main/java/com/idugalic/catalog/models/Product.java
// @Entity
// @Table(name = "products")
// public class Product {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// @Column(name = "id")
// private Long id;
//
// @Version
// @Column(name = "version")
// private Integer version;
//
// private String name;
//
// private int quantity;
//
// private MonetaryAmount price;
//
// @ManyToMany(cascade = CascadeType.ALL)
// @JoinTable(name = "products_categories", joinColumns = {
// @JoinColumn(name = "product_id", referencedColumnName = "id") }, inverseJoinColumns = {
// @JoinColumn(name = "category_id", referencedColumnName = "id") })
// private List<Category> categories;
//
// public Long getId() {
// return this.id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public Integer getVersion() {
// return this.version;
// }
//
// public void setVersion(Integer version) {
// this.version = version;
// }
//
// protected Product() {
//
// }
//
// public Product(String name, MonetaryAmount price) {
// this.name = name;
// this.price = price;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public int getQuantity() {
// return quantity;
// }
//
// public void setQuantity(int quantity) {
// this.quantity = quantity;
// }
//
// public MonetaryAmount getPrice() {
// return price;
// }
//
// public void setPrice(MonetaryAmount price) {
// this.price = price;
// }
//
// public List<Category> getCategories() {
// return categories;
// }
//
// public void setCategories(List<Category> categories) {
// this.categories = categories;
// }
//
// }
// Path: microservices-catalog/src/main/java/com/idugalic/catalog/Application.java
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.data.rest.core.config.RepositoryRestConfiguration;
import org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration;
import org.springframework.http.HttpMethod;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;
import com.idugalic.catalog.models.Category;
import com.idugalic.catalog.models.Product;
package com.idugalic.catalog;
@SpringBootApplication
@EnableJpaRepositories
@EnableDiscoveryClient
public class Application
{
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@Configuration
static class RestMvc extends RepositoryRestMvcConfiguration {
@Override
protected void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) { | config.exposeIdsFor(Product.class, Category.class); |
idugalic/micro-ecommerce | microservices-catalog/src/main/java/com/idugalic/catalog/Application.java | // Path: microservices-catalog/src/main/java/com/idugalic/catalog/models/Category.java
// @Entity
// @Table(name = "categories")
// public class Category {
//
// @Id
// @GeneratedValue
// private Long id;
//
// @Column(nullable = false)
// private String name;
//
// @ManyToMany(mappedBy = "categories")
// @JsonIgnore
// private List<Product> products;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public List<Product> getProducts() {
// return products;
// }
//
// public void setProducts(List<Product> products) {
// this.products = products;
// }
//
// }
//
// Path: microservices-catalog/src/main/java/com/idugalic/catalog/models/Product.java
// @Entity
// @Table(name = "products")
// public class Product {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// @Column(name = "id")
// private Long id;
//
// @Version
// @Column(name = "version")
// private Integer version;
//
// private String name;
//
// private int quantity;
//
// private MonetaryAmount price;
//
// @ManyToMany(cascade = CascadeType.ALL)
// @JoinTable(name = "products_categories", joinColumns = {
// @JoinColumn(name = "product_id", referencedColumnName = "id") }, inverseJoinColumns = {
// @JoinColumn(name = "category_id", referencedColumnName = "id") })
// private List<Category> categories;
//
// public Long getId() {
// return this.id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public Integer getVersion() {
// return this.version;
// }
//
// public void setVersion(Integer version) {
// this.version = version;
// }
//
// protected Product() {
//
// }
//
// public Product(String name, MonetaryAmount price) {
// this.name = name;
// this.price = price;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public int getQuantity() {
// return quantity;
// }
//
// public void setQuantity(int quantity) {
// this.quantity = quantity;
// }
//
// public MonetaryAmount getPrice() {
// return price;
// }
//
// public void setPrice(MonetaryAmount price) {
// this.price = price;
// }
//
// public List<Category> getCategories() {
// return categories;
// }
//
// public void setCategories(List<Category> categories) {
// this.categories = categories;
// }
//
// }
| import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.data.rest.core.config.RepositoryRestConfiguration;
import org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration;
import org.springframework.http.HttpMethod;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;
import com.idugalic.catalog.models.Category;
import com.idugalic.catalog.models.Product; | package com.idugalic.catalog;
@SpringBootApplication
@EnableJpaRepositories
@EnableDiscoveryClient
public class Application
{
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@Configuration
static class RestMvc extends RepositoryRestMvcConfiguration {
@Override
protected void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) { | // Path: microservices-catalog/src/main/java/com/idugalic/catalog/models/Category.java
// @Entity
// @Table(name = "categories")
// public class Category {
//
// @Id
// @GeneratedValue
// private Long id;
//
// @Column(nullable = false)
// private String name;
//
// @ManyToMany(mappedBy = "categories")
// @JsonIgnore
// private List<Product> products;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public List<Product> getProducts() {
// return products;
// }
//
// public void setProducts(List<Product> products) {
// this.products = products;
// }
//
// }
//
// Path: microservices-catalog/src/main/java/com/idugalic/catalog/models/Product.java
// @Entity
// @Table(name = "products")
// public class Product {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// @Column(name = "id")
// private Long id;
//
// @Version
// @Column(name = "version")
// private Integer version;
//
// private String name;
//
// private int quantity;
//
// private MonetaryAmount price;
//
// @ManyToMany(cascade = CascadeType.ALL)
// @JoinTable(name = "products_categories", joinColumns = {
// @JoinColumn(name = "product_id", referencedColumnName = "id") }, inverseJoinColumns = {
// @JoinColumn(name = "category_id", referencedColumnName = "id") })
// private List<Category> categories;
//
// public Long getId() {
// return this.id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public Integer getVersion() {
// return this.version;
// }
//
// public void setVersion(Integer version) {
// this.version = version;
// }
//
// protected Product() {
//
// }
//
// public Product(String name, MonetaryAmount price) {
// this.name = name;
// this.price = price;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public int getQuantity() {
// return quantity;
// }
//
// public void setQuantity(int quantity) {
// this.quantity = quantity;
// }
//
// public MonetaryAmount getPrice() {
// return price;
// }
//
// public void setPrice(MonetaryAmount price) {
// this.price = price;
// }
//
// public List<Category> getCategories() {
// return categories;
// }
//
// public void setCategories(List<Category> categories) {
// this.categories = categories;
// }
//
// }
// Path: microservices-catalog/src/main/java/com/idugalic/catalog/Application.java
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.data.rest.core.config.RepositoryRestConfiguration;
import org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration;
import org.springframework.http.HttpMethod;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;
import com.idugalic.catalog.models.Category;
import com.idugalic.catalog.models.Product;
package com.idugalic.catalog;
@SpringBootApplication
@EnableJpaRepositories
@EnableDiscoveryClient
public class Application
{
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@Configuration
static class RestMvc extends RepositoryRestMvcConfiguration {
@Override
protected void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) { | config.exposeIdsFor(Product.class, Category.class); |
idugalic/micro-ecommerce | microservices-orders/src/main/java/com/idugalic/orders/order/repository/OrderRepository.java | // Path: microservices-orders/src/main/java/com/idugalic/orders/order/domain/Order.java
// @Entity
// @Table(name = "WOrder")
// public class Order implements Identifiable<Long> {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// @Column(name = "id")
// private Long id;
//
// @Version
// @Column(name = "version")
// private Integer version;
//
// private Status status;
// @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTime")
// private DateTime orderedDate;
// @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
// private Set<Item> items = new HashSet<Item>();
//
// public Order(Collection<Item> items) {
// this.status = Status.PAYMENT_EXPECTED;
// this.items.addAll(items);
// this.orderedDate = new DateTime();
// }
//
// public Order(Item... items) {
// this(Arrays.asList(items));
// }
//
// public Order() {
// super();
// }
//
// public Long getId() {
// return this.id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public Integer getVersion() {
// return this.version;
// }
//
// public void setVersion(Integer version) {
// this.version = version;
// }
//
// public MonetaryAmount getPrice() {
// MonetaryAmount result = MonetaryAmount.ZERO;
//
// for (Item item : items) {
// result = result.add(item.getPrice());
// }
//
// return result;
// }
//
// public void markPaid() {
//
// if (isPaid()) {
// throw new IllegalStateException("Already paid order cannot be paid again!");
// }
//
// this.status = Status.PAID;
// }
//
// public void markInPreparation() {
//
// if (this.status != Status.PAID) {
// throw new IllegalStateException(String
// .format("Order must be in state payed to start preparation! " + "Current status: %s", this.status));
// }
//
// this.status = Status.PREPARING;
// }
//
// public void markPrepared() {
//
// if (this.status != Status.PREPARING) {
// throw new IllegalStateException(String.format(
// "Cannot mark Order prepared that is currently not " + "preparing! Current status: %s.",
// this.status));
// }
//
// this.status = Status.READY;
// }
//
// public boolean isPaid() {
// return !this.status.equals(Status.PAYMENT_EXPECTED);
// }
//
// public boolean isReady() {
// return this.status.equals(Status.READY);
// }
//
// public boolean isTaken() {
// return this.status.equals(Status.TAKEN);
// }
//
// public Status getStatus() {
// return status;
// }
//
// public void setStatus(Status status) {
// this.status = status;
// }
//
// public DateTime getOrderedDate() {
// return orderedDate;
// }
//
// public Set<Item> getItems() {
// return items;
// }
//
// public static enum Status {
//
// /**
// * Placed, but not payed yet. Still changeable.
// */
// PAYMENT_EXPECTED,
//
// /**
// * {@link Order} was payed. No changes allowed to it anymore.
// */
// PAID,
//
// /**
// * The {@link Order} is currently processed.
// */
// PREPARING,
//
// /**
// * The {@link Order} is ready to be picked up by the customer.
// */
// READY,
//
// /**
// * The {@link Order} was completed.
// */
// TAKEN;
// }
// }
//
// Path: microservices-orders/src/main/java/com/idugalic/orders/order/domain/Order.java
// public static enum Status {
//
// /**
// * Placed, but not payed yet. Still changeable.
// */
// PAYMENT_EXPECTED,
//
// /**
// * {@link Order} was payed. No changes allowed to it anymore.
// */
// PAID,
//
// /**
// * The {@link Order} is currently processed.
// */
// PREPARING,
//
// /**
// * The {@link Order} is ready to be picked up by the customer.
// */
// READY,
//
// /**
// * The {@link Order} was completed.
// */
// TAKEN;
// }
| import java.util.List;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
import com.idugalic.orders.order.domain.Order;
import com.idugalic.orders.order.domain.Order.Status; | package com.idugalic.orders.order.repository;
@RepositoryRestResource(collectionResourceRel = "orders", path = "orders")
public interface OrderRepository extends PagingAndSortingRepository<Order, Long> {
| // Path: microservices-orders/src/main/java/com/idugalic/orders/order/domain/Order.java
// @Entity
// @Table(name = "WOrder")
// public class Order implements Identifiable<Long> {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// @Column(name = "id")
// private Long id;
//
// @Version
// @Column(name = "version")
// private Integer version;
//
// private Status status;
// @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTime")
// private DateTime orderedDate;
// @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
// private Set<Item> items = new HashSet<Item>();
//
// public Order(Collection<Item> items) {
// this.status = Status.PAYMENT_EXPECTED;
// this.items.addAll(items);
// this.orderedDate = new DateTime();
// }
//
// public Order(Item... items) {
// this(Arrays.asList(items));
// }
//
// public Order() {
// super();
// }
//
// public Long getId() {
// return this.id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public Integer getVersion() {
// return this.version;
// }
//
// public void setVersion(Integer version) {
// this.version = version;
// }
//
// public MonetaryAmount getPrice() {
// MonetaryAmount result = MonetaryAmount.ZERO;
//
// for (Item item : items) {
// result = result.add(item.getPrice());
// }
//
// return result;
// }
//
// public void markPaid() {
//
// if (isPaid()) {
// throw new IllegalStateException("Already paid order cannot be paid again!");
// }
//
// this.status = Status.PAID;
// }
//
// public void markInPreparation() {
//
// if (this.status != Status.PAID) {
// throw new IllegalStateException(String
// .format("Order must be in state payed to start preparation! " + "Current status: %s", this.status));
// }
//
// this.status = Status.PREPARING;
// }
//
// public void markPrepared() {
//
// if (this.status != Status.PREPARING) {
// throw new IllegalStateException(String.format(
// "Cannot mark Order prepared that is currently not " + "preparing! Current status: %s.",
// this.status));
// }
//
// this.status = Status.READY;
// }
//
// public boolean isPaid() {
// return !this.status.equals(Status.PAYMENT_EXPECTED);
// }
//
// public boolean isReady() {
// return this.status.equals(Status.READY);
// }
//
// public boolean isTaken() {
// return this.status.equals(Status.TAKEN);
// }
//
// public Status getStatus() {
// return status;
// }
//
// public void setStatus(Status status) {
// this.status = status;
// }
//
// public DateTime getOrderedDate() {
// return orderedDate;
// }
//
// public Set<Item> getItems() {
// return items;
// }
//
// public static enum Status {
//
// /**
// * Placed, but not payed yet. Still changeable.
// */
// PAYMENT_EXPECTED,
//
// /**
// * {@link Order} was payed. No changes allowed to it anymore.
// */
// PAID,
//
// /**
// * The {@link Order} is currently processed.
// */
// PREPARING,
//
// /**
// * The {@link Order} is ready to be picked up by the customer.
// */
// READY,
//
// /**
// * The {@link Order} was completed.
// */
// TAKEN;
// }
// }
//
// Path: microservices-orders/src/main/java/com/idugalic/orders/order/domain/Order.java
// public static enum Status {
//
// /**
// * Placed, but not payed yet. Still changeable.
// */
// PAYMENT_EXPECTED,
//
// /**
// * {@link Order} was payed. No changes allowed to it anymore.
// */
// PAID,
//
// /**
// * The {@link Order} is currently processed.
// */
// PREPARING,
//
// /**
// * The {@link Order} is ready to be picked up by the customer.
// */
// READY,
//
// /**
// * The {@link Order} was completed.
// */
// TAKEN;
// }
// Path: microservices-orders/src/main/java/com/idugalic/orders/order/repository/OrderRepository.java
import java.util.List;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
import com.idugalic.orders.order.domain.Order;
import com.idugalic.orders.order.domain.Order.Status;
package com.idugalic.orders.order.repository;
@RepositoryRestResource(collectionResourceRel = "orders", path = "orders")
public interface OrderRepository extends PagingAndSortingRepository<Order, Long> {
| List<Order> findByStatus(@Param("status") Status status); |
idugalic/micro-ecommerce | microservices-orders/src/main/java/com/idugalic/orders/payment/service/PaymentException.java | // Path: microservices-orders/src/main/java/com/idugalic/orders/order/domain/Order.java
// @Entity
// @Table(name = "WOrder")
// public class Order implements Identifiable<Long> {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// @Column(name = "id")
// private Long id;
//
// @Version
// @Column(name = "version")
// private Integer version;
//
// private Status status;
// @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTime")
// private DateTime orderedDate;
// @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
// private Set<Item> items = new HashSet<Item>();
//
// public Order(Collection<Item> items) {
// this.status = Status.PAYMENT_EXPECTED;
// this.items.addAll(items);
// this.orderedDate = new DateTime();
// }
//
// public Order(Item... items) {
// this(Arrays.asList(items));
// }
//
// public Order() {
// super();
// }
//
// public Long getId() {
// return this.id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public Integer getVersion() {
// return this.version;
// }
//
// public void setVersion(Integer version) {
// this.version = version;
// }
//
// public MonetaryAmount getPrice() {
// MonetaryAmount result = MonetaryAmount.ZERO;
//
// for (Item item : items) {
// result = result.add(item.getPrice());
// }
//
// return result;
// }
//
// public void markPaid() {
//
// if (isPaid()) {
// throw new IllegalStateException("Already paid order cannot be paid again!");
// }
//
// this.status = Status.PAID;
// }
//
// public void markInPreparation() {
//
// if (this.status != Status.PAID) {
// throw new IllegalStateException(String
// .format("Order must be in state payed to start preparation! " + "Current status: %s", this.status));
// }
//
// this.status = Status.PREPARING;
// }
//
// public void markPrepared() {
//
// if (this.status != Status.PREPARING) {
// throw new IllegalStateException(String.format(
// "Cannot mark Order prepared that is currently not " + "preparing! Current status: %s.",
// this.status));
// }
//
// this.status = Status.READY;
// }
//
// public boolean isPaid() {
// return !this.status.equals(Status.PAYMENT_EXPECTED);
// }
//
// public boolean isReady() {
// return this.status.equals(Status.READY);
// }
//
// public boolean isTaken() {
// return this.status.equals(Status.TAKEN);
// }
//
// public Status getStatus() {
// return status;
// }
//
// public void setStatus(Status status) {
// this.status = status;
// }
//
// public DateTime getOrderedDate() {
// return orderedDate;
// }
//
// public Set<Item> getItems() {
// return items;
// }
//
// public static enum Status {
//
// /**
// * Placed, but not payed yet. Still changeable.
// */
// PAYMENT_EXPECTED,
//
// /**
// * {@link Order} was payed. No changes allowed to it anymore.
// */
// PAID,
//
// /**
// * The {@link Order} is currently processed.
// */
// PREPARING,
//
// /**
// * The {@link Order} is ready to be picked up by the customer.
// */
// READY,
//
// /**
// * The {@link Order} was completed.
// */
// TAKEN;
// }
// }
| import org.springframework.util.Assert;
import com.idugalic.orders.order.domain.Order; | package com.idugalic.orders.payment.service;
/**
*/
public class PaymentException extends RuntimeException {
private static final long serialVersionUID = -4929826142920520541L; | // Path: microservices-orders/src/main/java/com/idugalic/orders/order/domain/Order.java
// @Entity
// @Table(name = "WOrder")
// public class Order implements Identifiable<Long> {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// @Column(name = "id")
// private Long id;
//
// @Version
// @Column(name = "version")
// private Integer version;
//
// private Status status;
// @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTime")
// private DateTime orderedDate;
// @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
// private Set<Item> items = new HashSet<Item>();
//
// public Order(Collection<Item> items) {
// this.status = Status.PAYMENT_EXPECTED;
// this.items.addAll(items);
// this.orderedDate = new DateTime();
// }
//
// public Order(Item... items) {
// this(Arrays.asList(items));
// }
//
// public Order() {
// super();
// }
//
// public Long getId() {
// return this.id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public Integer getVersion() {
// return this.version;
// }
//
// public void setVersion(Integer version) {
// this.version = version;
// }
//
// public MonetaryAmount getPrice() {
// MonetaryAmount result = MonetaryAmount.ZERO;
//
// for (Item item : items) {
// result = result.add(item.getPrice());
// }
//
// return result;
// }
//
// public void markPaid() {
//
// if (isPaid()) {
// throw new IllegalStateException("Already paid order cannot be paid again!");
// }
//
// this.status = Status.PAID;
// }
//
// public void markInPreparation() {
//
// if (this.status != Status.PAID) {
// throw new IllegalStateException(String
// .format("Order must be in state payed to start preparation! " + "Current status: %s", this.status));
// }
//
// this.status = Status.PREPARING;
// }
//
// public void markPrepared() {
//
// if (this.status != Status.PREPARING) {
// throw new IllegalStateException(String.format(
// "Cannot mark Order prepared that is currently not " + "preparing! Current status: %s.",
// this.status));
// }
//
// this.status = Status.READY;
// }
//
// public boolean isPaid() {
// return !this.status.equals(Status.PAYMENT_EXPECTED);
// }
//
// public boolean isReady() {
// return this.status.equals(Status.READY);
// }
//
// public boolean isTaken() {
// return this.status.equals(Status.TAKEN);
// }
//
// public Status getStatus() {
// return status;
// }
//
// public void setStatus(Status status) {
// this.status = status;
// }
//
// public DateTime getOrderedDate() {
// return orderedDate;
// }
//
// public Set<Item> getItems() {
// return items;
// }
//
// public static enum Status {
//
// /**
// * Placed, but not payed yet. Still changeable.
// */
// PAYMENT_EXPECTED,
//
// /**
// * {@link Order} was payed. No changes allowed to it anymore.
// */
// PAID,
//
// /**
// * The {@link Order} is currently processed.
// */
// PREPARING,
//
// /**
// * The {@link Order} is ready to be picked up by the customer.
// */
// READY,
//
// /**
// * The {@link Order} was completed.
// */
// TAKEN;
// }
// }
// Path: microservices-orders/src/main/java/com/idugalic/orders/payment/service/PaymentException.java
import org.springframework.util.Assert;
import com.idugalic.orders.order.domain.Order;
package com.idugalic.orders.payment.service;
/**
*/
public class PaymentException extends RuntimeException {
private static final long serialVersionUID = -4929826142920520541L; | private final Order order; |
idugalic/micro-ecommerce | microservices-orders/src/main/java/com/idugalic/orders/engine/Engine.java | // Path: microservices-orders/src/main/java/com/idugalic/orders/order/domain/Order.java
// @Entity
// @Table(name = "WOrder")
// public class Order implements Identifiable<Long> {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// @Column(name = "id")
// private Long id;
//
// @Version
// @Column(name = "version")
// private Integer version;
//
// private Status status;
// @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTime")
// private DateTime orderedDate;
// @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
// private Set<Item> items = new HashSet<Item>();
//
// public Order(Collection<Item> items) {
// this.status = Status.PAYMENT_EXPECTED;
// this.items.addAll(items);
// this.orderedDate = new DateTime();
// }
//
// public Order(Item... items) {
// this(Arrays.asList(items));
// }
//
// public Order() {
// super();
// }
//
// public Long getId() {
// return this.id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public Integer getVersion() {
// return this.version;
// }
//
// public void setVersion(Integer version) {
// this.version = version;
// }
//
// public MonetaryAmount getPrice() {
// MonetaryAmount result = MonetaryAmount.ZERO;
//
// for (Item item : items) {
// result = result.add(item.getPrice());
// }
//
// return result;
// }
//
// public void markPaid() {
//
// if (isPaid()) {
// throw new IllegalStateException("Already paid order cannot be paid again!");
// }
//
// this.status = Status.PAID;
// }
//
// public void markInPreparation() {
//
// if (this.status != Status.PAID) {
// throw new IllegalStateException(String
// .format("Order must be in state payed to start preparation! " + "Current status: %s", this.status));
// }
//
// this.status = Status.PREPARING;
// }
//
// public void markPrepared() {
//
// if (this.status != Status.PREPARING) {
// throw new IllegalStateException(String.format(
// "Cannot mark Order prepared that is currently not " + "preparing! Current status: %s.",
// this.status));
// }
//
// this.status = Status.READY;
// }
//
// public boolean isPaid() {
// return !this.status.equals(Status.PAYMENT_EXPECTED);
// }
//
// public boolean isReady() {
// return this.status.equals(Status.READY);
// }
//
// public boolean isTaken() {
// return this.status.equals(Status.TAKEN);
// }
//
// public Status getStatus() {
// return status;
// }
//
// public void setStatus(Status status) {
// this.status = status;
// }
//
// public DateTime getOrderedDate() {
// return orderedDate;
// }
//
// public Set<Item> getItems() {
// return items;
// }
//
// public static enum Status {
//
// /**
// * Placed, but not payed yet. Still changeable.
// */
// PAYMENT_EXPECTED,
//
// /**
// * {@link Order} was payed. No changes allowed to it anymore.
// */
// PAID,
//
// /**
// * The {@link Order} is currently processed.
// */
// PREPARING,
//
// /**
// * The {@link Order} is ready to be picked up by the customer.
// */
// READY,
//
// /**
// * The {@link Order} was completed.
// */
// TAKEN;
// }
// }
//
// Path: microservices-orders/src/main/java/com/idugalic/orders/order/repository/OrderRepository.java
// @RepositoryRestResource(collectionResourceRel = "orders", path = "orders")
// public interface OrderRepository extends PagingAndSortingRepository<Order, Long> {
//
// List<Order> findByStatus(@Param("status") Status status);
// }
//
// Path: microservices-orders/src/main/java/com/idugalic/orders/payment/event/OrderPaidEvent.java
// public class OrderPaidEvent extends ApplicationEvent {
//
// private static final long serialVersionUID = -6150362015056003378L;
// private final long orderId;
//
// /**
// * Creates a new {@link OrderPaidEvent}
// *
// * @param orderId
// * the id of the order that just has been payed
// * @param source
// * must not be {@literal null}.
// */
// public OrderPaidEvent(long orderId, Object source) {
//
// super(source);
// this.orderId = orderId;
// }
//
// public long getOrderId() {
// return orderId;
// }
//
// }
| import java.util.Collections;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import com.idugalic.orders.order.domain.Order;
import com.idugalic.orders.order.repository.OrderRepository;
import com.idugalic.orders.payment.event.OrderPaidEvent; | package com.idugalic.orders.engine;
/**
* Simple {@link ApplicationListener} implementation that listens to
* {@link OrderPaidEvent}s marking the according {@link Order} as in process,
* sleeping for 10 seconds and marking the order as processed right after that.
*
*/
@Service
class Engine implements ApplicationListener<OrderPaidEvent>, InProgressAware {
| // Path: microservices-orders/src/main/java/com/idugalic/orders/order/domain/Order.java
// @Entity
// @Table(name = "WOrder")
// public class Order implements Identifiable<Long> {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// @Column(name = "id")
// private Long id;
//
// @Version
// @Column(name = "version")
// private Integer version;
//
// private Status status;
// @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTime")
// private DateTime orderedDate;
// @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
// private Set<Item> items = new HashSet<Item>();
//
// public Order(Collection<Item> items) {
// this.status = Status.PAYMENT_EXPECTED;
// this.items.addAll(items);
// this.orderedDate = new DateTime();
// }
//
// public Order(Item... items) {
// this(Arrays.asList(items));
// }
//
// public Order() {
// super();
// }
//
// public Long getId() {
// return this.id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public Integer getVersion() {
// return this.version;
// }
//
// public void setVersion(Integer version) {
// this.version = version;
// }
//
// public MonetaryAmount getPrice() {
// MonetaryAmount result = MonetaryAmount.ZERO;
//
// for (Item item : items) {
// result = result.add(item.getPrice());
// }
//
// return result;
// }
//
// public void markPaid() {
//
// if (isPaid()) {
// throw new IllegalStateException("Already paid order cannot be paid again!");
// }
//
// this.status = Status.PAID;
// }
//
// public void markInPreparation() {
//
// if (this.status != Status.PAID) {
// throw new IllegalStateException(String
// .format("Order must be in state payed to start preparation! " + "Current status: %s", this.status));
// }
//
// this.status = Status.PREPARING;
// }
//
// public void markPrepared() {
//
// if (this.status != Status.PREPARING) {
// throw new IllegalStateException(String.format(
// "Cannot mark Order prepared that is currently not " + "preparing! Current status: %s.",
// this.status));
// }
//
// this.status = Status.READY;
// }
//
// public boolean isPaid() {
// return !this.status.equals(Status.PAYMENT_EXPECTED);
// }
//
// public boolean isReady() {
// return this.status.equals(Status.READY);
// }
//
// public boolean isTaken() {
// return this.status.equals(Status.TAKEN);
// }
//
// public Status getStatus() {
// return status;
// }
//
// public void setStatus(Status status) {
// this.status = status;
// }
//
// public DateTime getOrderedDate() {
// return orderedDate;
// }
//
// public Set<Item> getItems() {
// return items;
// }
//
// public static enum Status {
//
// /**
// * Placed, but not payed yet. Still changeable.
// */
// PAYMENT_EXPECTED,
//
// /**
// * {@link Order} was payed. No changes allowed to it anymore.
// */
// PAID,
//
// /**
// * The {@link Order} is currently processed.
// */
// PREPARING,
//
// /**
// * The {@link Order} is ready to be picked up by the customer.
// */
// READY,
//
// /**
// * The {@link Order} was completed.
// */
// TAKEN;
// }
// }
//
// Path: microservices-orders/src/main/java/com/idugalic/orders/order/repository/OrderRepository.java
// @RepositoryRestResource(collectionResourceRel = "orders", path = "orders")
// public interface OrderRepository extends PagingAndSortingRepository<Order, Long> {
//
// List<Order> findByStatus(@Param("status") Status status);
// }
//
// Path: microservices-orders/src/main/java/com/idugalic/orders/payment/event/OrderPaidEvent.java
// public class OrderPaidEvent extends ApplicationEvent {
//
// private static final long serialVersionUID = -6150362015056003378L;
// private final long orderId;
//
// /**
// * Creates a new {@link OrderPaidEvent}
// *
// * @param orderId
// * the id of the order that just has been payed
// * @param source
// * must not be {@literal null}.
// */
// public OrderPaidEvent(long orderId, Object source) {
//
// super(source);
// this.orderId = orderId;
// }
//
// public long getOrderId() {
// return orderId;
// }
//
// }
// Path: microservices-orders/src/main/java/com/idugalic/orders/engine/Engine.java
import java.util.Collections;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import com.idugalic.orders.order.domain.Order;
import com.idugalic.orders.order.repository.OrderRepository;
import com.idugalic.orders.payment.event.OrderPaidEvent;
package com.idugalic.orders.engine;
/**
* Simple {@link ApplicationListener} implementation that listens to
* {@link OrderPaidEvent}s marking the according {@link Order} as in process,
* sleeping for 10 seconds and marking the order as processed right after that.
*
*/
@Service
class Engine implements ApplicationListener<OrderPaidEvent>, InProgressAware {
| private final OrderRepository repository; |
idugalic/micro-ecommerce | microservices-orders/src/main/java/com/idugalic/orders/engine/Engine.java | // Path: microservices-orders/src/main/java/com/idugalic/orders/order/domain/Order.java
// @Entity
// @Table(name = "WOrder")
// public class Order implements Identifiable<Long> {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// @Column(name = "id")
// private Long id;
//
// @Version
// @Column(name = "version")
// private Integer version;
//
// private Status status;
// @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTime")
// private DateTime orderedDate;
// @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
// private Set<Item> items = new HashSet<Item>();
//
// public Order(Collection<Item> items) {
// this.status = Status.PAYMENT_EXPECTED;
// this.items.addAll(items);
// this.orderedDate = new DateTime();
// }
//
// public Order(Item... items) {
// this(Arrays.asList(items));
// }
//
// public Order() {
// super();
// }
//
// public Long getId() {
// return this.id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public Integer getVersion() {
// return this.version;
// }
//
// public void setVersion(Integer version) {
// this.version = version;
// }
//
// public MonetaryAmount getPrice() {
// MonetaryAmount result = MonetaryAmount.ZERO;
//
// for (Item item : items) {
// result = result.add(item.getPrice());
// }
//
// return result;
// }
//
// public void markPaid() {
//
// if (isPaid()) {
// throw new IllegalStateException("Already paid order cannot be paid again!");
// }
//
// this.status = Status.PAID;
// }
//
// public void markInPreparation() {
//
// if (this.status != Status.PAID) {
// throw new IllegalStateException(String
// .format("Order must be in state payed to start preparation! " + "Current status: %s", this.status));
// }
//
// this.status = Status.PREPARING;
// }
//
// public void markPrepared() {
//
// if (this.status != Status.PREPARING) {
// throw new IllegalStateException(String.format(
// "Cannot mark Order prepared that is currently not " + "preparing! Current status: %s.",
// this.status));
// }
//
// this.status = Status.READY;
// }
//
// public boolean isPaid() {
// return !this.status.equals(Status.PAYMENT_EXPECTED);
// }
//
// public boolean isReady() {
// return this.status.equals(Status.READY);
// }
//
// public boolean isTaken() {
// return this.status.equals(Status.TAKEN);
// }
//
// public Status getStatus() {
// return status;
// }
//
// public void setStatus(Status status) {
// this.status = status;
// }
//
// public DateTime getOrderedDate() {
// return orderedDate;
// }
//
// public Set<Item> getItems() {
// return items;
// }
//
// public static enum Status {
//
// /**
// * Placed, but not payed yet. Still changeable.
// */
// PAYMENT_EXPECTED,
//
// /**
// * {@link Order} was payed. No changes allowed to it anymore.
// */
// PAID,
//
// /**
// * The {@link Order} is currently processed.
// */
// PREPARING,
//
// /**
// * The {@link Order} is ready to be picked up by the customer.
// */
// READY,
//
// /**
// * The {@link Order} was completed.
// */
// TAKEN;
// }
// }
//
// Path: microservices-orders/src/main/java/com/idugalic/orders/order/repository/OrderRepository.java
// @RepositoryRestResource(collectionResourceRel = "orders", path = "orders")
// public interface OrderRepository extends PagingAndSortingRepository<Order, Long> {
//
// List<Order> findByStatus(@Param("status") Status status);
// }
//
// Path: microservices-orders/src/main/java/com/idugalic/orders/payment/event/OrderPaidEvent.java
// public class OrderPaidEvent extends ApplicationEvent {
//
// private static final long serialVersionUID = -6150362015056003378L;
// private final long orderId;
//
// /**
// * Creates a new {@link OrderPaidEvent}
// *
// * @param orderId
// * the id of the order that just has been payed
// * @param source
// * must not be {@literal null}.
// */
// public OrderPaidEvent(long orderId, Object source) {
//
// super(source);
// this.orderId = orderId;
// }
//
// public long getOrderId() {
// return orderId;
// }
//
// }
| import java.util.Collections;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import com.idugalic.orders.order.domain.Order;
import com.idugalic.orders.order.repository.OrderRepository;
import com.idugalic.orders.payment.event.OrderPaidEvent; | package com.idugalic.orders.engine;
/**
* Simple {@link ApplicationListener} implementation that listens to
* {@link OrderPaidEvent}s marking the according {@link Order} as in process,
* sleeping for 10 seconds and marking the order as processed right after that.
*
*/
@Service
class Engine implements ApplicationListener<OrderPaidEvent>, InProgressAware {
private final OrderRepository repository; | // Path: microservices-orders/src/main/java/com/idugalic/orders/order/domain/Order.java
// @Entity
// @Table(name = "WOrder")
// public class Order implements Identifiable<Long> {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// @Column(name = "id")
// private Long id;
//
// @Version
// @Column(name = "version")
// private Integer version;
//
// private Status status;
// @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTime")
// private DateTime orderedDate;
// @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
// private Set<Item> items = new HashSet<Item>();
//
// public Order(Collection<Item> items) {
// this.status = Status.PAYMENT_EXPECTED;
// this.items.addAll(items);
// this.orderedDate = new DateTime();
// }
//
// public Order(Item... items) {
// this(Arrays.asList(items));
// }
//
// public Order() {
// super();
// }
//
// public Long getId() {
// return this.id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public Integer getVersion() {
// return this.version;
// }
//
// public void setVersion(Integer version) {
// this.version = version;
// }
//
// public MonetaryAmount getPrice() {
// MonetaryAmount result = MonetaryAmount.ZERO;
//
// for (Item item : items) {
// result = result.add(item.getPrice());
// }
//
// return result;
// }
//
// public void markPaid() {
//
// if (isPaid()) {
// throw new IllegalStateException("Already paid order cannot be paid again!");
// }
//
// this.status = Status.PAID;
// }
//
// public void markInPreparation() {
//
// if (this.status != Status.PAID) {
// throw new IllegalStateException(String
// .format("Order must be in state payed to start preparation! " + "Current status: %s", this.status));
// }
//
// this.status = Status.PREPARING;
// }
//
// public void markPrepared() {
//
// if (this.status != Status.PREPARING) {
// throw new IllegalStateException(String.format(
// "Cannot mark Order prepared that is currently not " + "preparing! Current status: %s.",
// this.status));
// }
//
// this.status = Status.READY;
// }
//
// public boolean isPaid() {
// return !this.status.equals(Status.PAYMENT_EXPECTED);
// }
//
// public boolean isReady() {
// return this.status.equals(Status.READY);
// }
//
// public boolean isTaken() {
// return this.status.equals(Status.TAKEN);
// }
//
// public Status getStatus() {
// return status;
// }
//
// public void setStatus(Status status) {
// this.status = status;
// }
//
// public DateTime getOrderedDate() {
// return orderedDate;
// }
//
// public Set<Item> getItems() {
// return items;
// }
//
// public static enum Status {
//
// /**
// * Placed, but not payed yet. Still changeable.
// */
// PAYMENT_EXPECTED,
//
// /**
// * {@link Order} was payed. No changes allowed to it anymore.
// */
// PAID,
//
// /**
// * The {@link Order} is currently processed.
// */
// PREPARING,
//
// /**
// * The {@link Order} is ready to be picked up by the customer.
// */
// READY,
//
// /**
// * The {@link Order} was completed.
// */
// TAKEN;
// }
// }
//
// Path: microservices-orders/src/main/java/com/idugalic/orders/order/repository/OrderRepository.java
// @RepositoryRestResource(collectionResourceRel = "orders", path = "orders")
// public interface OrderRepository extends PagingAndSortingRepository<Order, Long> {
//
// List<Order> findByStatus(@Param("status") Status status);
// }
//
// Path: microservices-orders/src/main/java/com/idugalic/orders/payment/event/OrderPaidEvent.java
// public class OrderPaidEvent extends ApplicationEvent {
//
// private static final long serialVersionUID = -6150362015056003378L;
// private final long orderId;
//
// /**
// * Creates a new {@link OrderPaidEvent}
// *
// * @param orderId
// * the id of the order that just has been payed
// * @param source
// * must not be {@literal null}.
// */
// public OrderPaidEvent(long orderId, Object source) {
//
// super(source);
// this.orderId = orderId;
// }
//
// public long getOrderId() {
// return orderId;
// }
//
// }
// Path: microservices-orders/src/main/java/com/idugalic/orders/engine/Engine.java
import java.util.Collections;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import com.idugalic.orders.order.domain.Order;
import com.idugalic.orders.order.repository.OrderRepository;
import com.idugalic.orders.payment.event.OrderPaidEvent;
package com.idugalic.orders.engine;
/**
* Simple {@link ApplicationListener} implementation that listens to
* {@link OrderPaidEvent}s marking the according {@link Order} as in process,
* sleeping for 10 seconds and marking the order as processed right after that.
*
*/
@Service
class Engine implements ApplicationListener<OrderPaidEvent>, InProgressAware {
private final OrderRepository repository; | private final Set<Order> ordersInProgress; |
idugalic/micro-ecommerce | microservices-orders/src/main/java/com/idugalic/orders/engine/web/EngineController.java | // Path: microservices-orders/src/main/java/com/idugalic/orders/engine/InProgressAware.java
// public interface InProgressAware {
//
// /**
// * Returns all {@link Order}s that currently prepared.
// *
// * @return the {@link Order}s currently in preparation.
// */
// Set<Order> getOrders();
// }
//
// Path: microservices-orders/src/main/java/com/idugalic/orders/order/domain/Order.java
// @Entity
// @Table(name = "WOrder")
// public class Order implements Identifiable<Long> {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// @Column(name = "id")
// private Long id;
//
// @Version
// @Column(name = "version")
// private Integer version;
//
// private Status status;
// @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTime")
// private DateTime orderedDate;
// @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
// private Set<Item> items = new HashSet<Item>();
//
// public Order(Collection<Item> items) {
// this.status = Status.PAYMENT_EXPECTED;
// this.items.addAll(items);
// this.orderedDate = new DateTime();
// }
//
// public Order(Item... items) {
// this(Arrays.asList(items));
// }
//
// public Order() {
// super();
// }
//
// public Long getId() {
// return this.id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public Integer getVersion() {
// return this.version;
// }
//
// public void setVersion(Integer version) {
// this.version = version;
// }
//
// public MonetaryAmount getPrice() {
// MonetaryAmount result = MonetaryAmount.ZERO;
//
// for (Item item : items) {
// result = result.add(item.getPrice());
// }
//
// return result;
// }
//
// public void markPaid() {
//
// if (isPaid()) {
// throw new IllegalStateException("Already paid order cannot be paid again!");
// }
//
// this.status = Status.PAID;
// }
//
// public void markInPreparation() {
//
// if (this.status != Status.PAID) {
// throw new IllegalStateException(String
// .format("Order must be in state payed to start preparation! " + "Current status: %s", this.status));
// }
//
// this.status = Status.PREPARING;
// }
//
// public void markPrepared() {
//
// if (this.status != Status.PREPARING) {
// throw new IllegalStateException(String.format(
// "Cannot mark Order prepared that is currently not " + "preparing! Current status: %s.",
// this.status));
// }
//
// this.status = Status.READY;
// }
//
// public boolean isPaid() {
// return !this.status.equals(Status.PAYMENT_EXPECTED);
// }
//
// public boolean isReady() {
// return this.status.equals(Status.READY);
// }
//
// public boolean isTaken() {
// return this.status.equals(Status.TAKEN);
// }
//
// public Status getStatus() {
// return status;
// }
//
// public void setStatus(Status status) {
// this.status = status;
// }
//
// public DateTime getOrderedDate() {
// return orderedDate;
// }
//
// public Set<Item> getItems() {
// return items;
// }
//
// public static enum Status {
//
// /**
// * Placed, but not payed yet. Still changeable.
// */
// PAYMENT_EXPECTED,
//
// /**
// * {@link Order} was payed. No changes allowed to it anymore.
// */
// PAID,
//
// /**
// * The {@link Order} is currently processed.
// */
// PREPARING,
//
// /**
// * The {@link Order} is ready to be picked up by the customer.
// */
// READY,
//
// /**
// * The {@link Order} was completed.
// */
// TAKEN;
// }
// }
| import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.rest.webmvc.RepositoryLinksResource;
import org.springframework.hateoas.Resource;
import org.springframework.hateoas.ResourceProcessor;
import org.springframework.hateoas.Resources;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import com.idugalic.orders.engine.InProgressAware;
import com.idugalic.orders.order.domain.Order; | package com.idugalic.orders.engine.web;
/**
* Custom controller to show how to expose a custom resource into the root
* resource exposed by Spring Data REST.
*
*/
@Controller
class EngineController implements ResourceProcessor<RepositoryLinksResource> {
public static final String ENGINE_REL = "engine";
| // Path: microservices-orders/src/main/java/com/idugalic/orders/engine/InProgressAware.java
// public interface InProgressAware {
//
// /**
// * Returns all {@link Order}s that currently prepared.
// *
// * @return the {@link Order}s currently in preparation.
// */
// Set<Order> getOrders();
// }
//
// Path: microservices-orders/src/main/java/com/idugalic/orders/order/domain/Order.java
// @Entity
// @Table(name = "WOrder")
// public class Order implements Identifiable<Long> {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// @Column(name = "id")
// private Long id;
//
// @Version
// @Column(name = "version")
// private Integer version;
//
// private Status status;
// @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTime")
// private DateTime orderedDate;
// @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
// private Set<Item> items = new HashSet<Item>();
//
// public Order(Collection<Item> items) {
// this.status = Status.PAYMENT_EXPECTED;
// this.items.addAll(items);
// this.orderedDate = new DateTime();
// }
//
// public Order(Item... items) {
// this(Arrays.asList(items));
// }
//
// public Order() {
// super();
// }
//
// public Long getId() {
// return this.id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public Integer getVersion() {
// return this.version;
// }
//
// public void setVersion(Integer version) {
// this.version = version;
// }
//
// public MonetaryAmount getPrice() {
// MonetaryAmount result = MonetaryAmount.ZERO;
//
// for (Item item : items) {
// result = result.add(item.getPrice());
// }
//
// return result;
// }
//
// public void markPaid() {
//
// if (isPaid()) {
// throw new IllegalStateException("Already paid order cannot be paid again!");
// }
//
// this.status = Status.PAID;
// }
//
// public void markInPreparation() {
//
// if (this.status != Status.PAID) {
// throw new IllegalStateException(String
// .format("Order must be in state payed to start preparation! " + "Current status: %s", this.status));
// }
//
// this.status = Status.PREPARING;
// }
//
// public void markPrepared() {
//
// if (this.status != Status.PREPARING) {
// throw new IllegalStateException(String.format(
// "Cannot mark Order prepared that is currently not " + "preparing! Current status: %s.",
// this.status));
// }
//
// this.status = Status.READY;
// }
//
// public boolean isPaid() {
// return !this.status.equals(Status.PAYMENT_EXPECTED);
// }
//
// public boolean isReady() {
// return this.status.equals(Status.READY);
// }
//
// public boolean isTaken() {
// return this.status.equals(Status.TAKEN);
// }
//
// public Status getStatus() {
// return status;
// }
//
// public void setStatus(Status status) {
// this.status = status;
// }
//
// public DateTime getOrderedDate() {
// return orderedDate;
// }
//
// public Set<Item> getItems() {
// return items;
// }
//
// public static enum Status {
//
// /**
// * Placed, but not payed yet. Still changeable.
// */
// PAYMENT_EXPECTED,
//
// /**
// * {@link Order} was payed. No changes allowed to it anymore.
// */
// PAID,
//
// /**
// * The {@link Order} is currently processed.
// */
// PREPARING,
//
// /**
// * The {@link Order} is ready to be picked up by the customer.
// */
// READY,
//
// /**
// * The {@link Order} was completed.
// */
// TAKEN;
// }
// }
// Path: microservices-orders/src/main/java/com/idugalic/orders/engine/web/EngineController.java
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.rest.webmvc.RepositoryLinksResource;
import org.springframework.hateoas.Resource;
import org.springframework.hateoas.ResourceProcessor;
import org.springframework.hateoas.Resources;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import com.idugalic.orders.engine.InProgressAware;
import com.idugalic.orders.order.domain.Order;
package com.idugalic.orders.engine.web;
/**
* Custom controller to show how to expose a custom resource into the root
* resource exposed by Spring Data REST.
*
*/
@Controller
class EngineController implements ResourceProcessor<RepositoryLinksResource> {
public static final String ENGINE_REL = "engine";
| private InProgressAware processor; |
idugalic/micro-ecommerce | microservices-orders/src/main/java/com/idugalic/orders/engine/web/EngineController.java | // Path: microservices-orders/src/main/java/com/idugalic/orders/engine/InProgressAware.java
// public interface InProgressAware {
//
// /**
// * Returns all {@link Order}s that currently prepared.
// *
// * @return the {@link Order}s currently in preparation.
// */
// Set<Order> getOrders();
// }
//
// Path: microservices-orders/src/main/java/com/idugalic/orders/order/domain/Order.java
// @Entity
// @Table(name = "WOrder")
// public class Order implements Identifiable<Long> {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// @Column(name = "id")
// private Long id;
//
// @Version
// @Column(name = "version")
// private Integer version;
//
// private Status status;
// @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTime")
// private DateTime orderedDate;
// @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
// private Set<Item> items = new HashSet<Item>();
//
// public Order(Collection<Item> items) {
// this.status = Status.PAYMENT_EXPECTED;
// this.items.addAll(items);
// this.orderedDate = new DateTime();
// }
//
// public Order(Item... items) {
// this(Arrays.asList(items));
// }
//
// public Order() {
// super();
// }
//
// public Long getId() {
// return this.id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public Integer getVersion() {
// return this.version;
// }
//
// public void setVersion(Integer version) {
// this.version = version;
// }
//
// public MonetaryAmount getPrice() {
// MonetaryAmount result = MonetaryAmount.ZERO;
//
// for (Item item : items) {
// result = result.add(item.getPrice());
// }
//
// return result;
// }
//
// public void markPaid() {
//
// if (isPaid()) {
// throw new IllegalStateException("Already paid order cannot be paid again!");
// }
//
// this.status = Status.PAID;
// }
//
// public void markInPreparation() {
//
// if (this.status != Status.PAID) {
// throw new IllegalStateException(String
// .format("Order must be in state payed to start preparation! " + "Current status: %s", this.status));
// }
//
// this.status = Status.PREPARING;
// }
//
// public void markPrepared() {
//
// if (this.status != Status.PREPARING) {
// throw new IllegalStateException(String.format(
// "Cannot mark Order prepared that is currently not " + "preparing! Current status: %s.",
// this.status));
// }
//
// this.status = Status.READY;
// }
//
// public boolean isPaid() {
// return !this.status.equals(Status.PAYMENT_EXPECTED);
// }
//
// public boolean isReady() {
// return this.status.equals(Status.READY);
// }
//
// public boolean isTaken() {
// return this.status.equals(Status.TAKEN);
// }
//
// public Status getStatus() {
// return status;
// }
//
// public void setStatus(Status status) {
// this.status = status;
// }
//
// public DateTime getOrderedDate() {
// return orderedDate;
// }
//
// public Set<Item> getItems() {
// return items;
// }
//
// public static enum Status {
//
// /**
// * Placed, but not payed yet. Still changeable.
// */
// PAYMENT_EXPECTED,
//
// /**
// * {@link Order} was payed. No changes allowed to it anymore.
// */
// PAID,
//
// /**
// * The {@link Order} is currently processed.
// */
// PREPARING,
//
// /**
// * The {@link Order} is ready to be picked up by the customer.
// */
// READY,
//
// /**
// * The {@link Order} was completed.
// */
// TAKEN;
// }
// }
| import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.rest.webmvc.RepositoryLinksResource;
import org.springframework.hateoas.Resource;
import org.springframework.hateoas.ResourceProcessor;
import org.springframework.hateoas.Resources;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import com.idugalic.orders.engine.InProgressAware;
import com.idugalic.orders.order.domain.Order; | package com.idugalic.orders.engine.web;
/**
* Custom controller to show how to expose a custom resource into the root
* resource exposed by Spring Data REST.
*
*/
@Controller
class EngineController implements ResourceProcessor<RepositoryLinksResource> {
public static final String ENGINE_REL = "engine";
private InProgressAware processor;
@Autowired
public EngineController(InProgressAware processor) {
this.processor = processor;
}
/**
* Exposes all {@link Order}s currently in preparation.
*
* @return
*/
@RequestMapping("/engine") | // Path: microservices-orders/src/main/java/com/idugalic/orders/engine/InProgressAware.java
// public interface InProgressAware {
//
// /**
// * Returns all {@link Order}s that currently prepared.
// *
// * @return the {@link Order}s currently in preparation.
// */
// Set<Order> getOrders();
// }
//
// Path: microservices-orders/src/main/java/com/idugalic/orders/order/domain/Order.java
// @Entity
// @Table(name = "WOrder")
// public class Order implements Identifiable<Long> {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// @Column(name = "id")
// private Long id;
//
// @Version
// @Column(name = "version")
// private Integer version;
//
// private Status status;
// @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTime")
// private DateTime orderedDate;
// @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
// private Set<Item> items = new HashSet<Item>();
//
// public Order(Collection<Item> items) {
// this.status = Status.PAYMENT_EXPECTED;
// this.items.addAll(items);
// this.orderedDate = new DateTime();
// }
//
// public Order(Item... items) {
// this(Arrays.asList(items));
// }
//
// public Order() {
// super();
// }
//
// public Long getId() {
// return this.id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public Integer getVersion() {
// return this.version;
// }
//
// public void setVersion(Integer version) {
// this.version = version;
// }
//
// public MonetaryAmount getPrice() {
// MonetaryAmount result = MonetaryAmount.ZERO;
//
// for (Item item : items) {
// result = result.add(item.getPrice());
// }
//
// return result;
// }
//
// public void markPaid() {
//
// if (isPaid()) {
// throw new IllegalStateException("Already paid order cannot be paid again!");
// }
//
// this.status = Status.PAID;
// }
//
// public void markInPreparation() {
//
// if (this.status != Status.PAID) {
// throw new IllegalStateException(String
// .format("Order must be in state payed to start preparation! " + "Current status: %s", this.status));
// }
//
// this.status = Status.PREPARING;
// }
//
// public void markPrepared() {
//
// if (this.status != Status.PREPARING) {
// throw new IllegalStateException(String.format(
// "Cannot mark Order prepared that is currently not " + "preparing! Current status: %s.",
// this.status));
// }
//
// this.status = Status.READY;
// }
//
// public boolean isPaid() {
// return !this.status.equals(Status.PAYMENT_EXPECTED);
// }
//
// public boolean isReady() {
// return this.status.equals(Status.READY);
// }
//
// public boolean isTaken() {
// return this.status.equals(Status.TAKEN);
// }
//
// public Status getStatus() {
// return status;
// }
//
// public void setStatus(Status status) {
// this.status = status;
// }
//
// public DateTime getOrderedDate() {
// return orderedDate;
// }
//
// public Set<Item> getItems() {
// return items;
// }
//
// public static enum Status {
//
// /**
// * Placed, but not payed yet. Still changeable.
// */
// PAYMENT_EXPECTED,
//
// /**
// * {@link Order} was payed. No changes allowed to it anymore.
// */
// PAID,
//
// /**
// * The {@link Order} is currently processed.
// */
// PREPARING,
//
// /**
// * The {@link Order} is ready to be picked up by the customer.
// */
// READY,
//
// /**
// * The {@link Order} was completed.
// */
// TAKEN;
// }
// }
// Path: microservices-orders/src/main/java/com/idugalic/orders/engine/web/EngineController.java
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.rest.webmvc.RepositoryLinksResource;
import org.springframework.hateoas.Resource;
import org.springframework.hateoas.ResourceProcessor;
import org.springframework.hateoas.Resources;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import com.idugalic.orders.engine.InProgressAware;
import com.idugalic.orders.order.domain.Order;
package com.idugalic.orders.engine.web;
/**
* Custom controller to show how to expose a custom resource into the root
* resource exposed by Spring Data REST.
*
*/
@Controller
class EngineController implements ResourceProcessor<RepositoryLinksResource> {
public static final String ENGINE_REL = "engine";
private InProgressAware processor;
@Autowired
public EngineController(InProgressAware processor) {
this.processor = processor;
}
/**
* Exposes all {@link Order}s currently in preparation.
*
* @return
*/
@RequestMapping("/engine") | HttpEntity<Resources<Resource<Order>>> showOrdersInProgress() { |
idugalic/micro-ecommerce | microservices-orders/src/main/java/com/idugalic/orders/payment/repository/CreditCardRepository.java | // Path: microservices-orders/src/main/java/com/idugalic/orders/payment/domain/CreditCard.java
// @Entity
// @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE)
// public class CreditCard {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// @Column(name = "id")
// private Long id;
//
// @Version
// @Column(name = "version")
// private Integer version;
//
// @JsonUnwrapped
// private CreditCardNumber number;
//
// private String cardHolderName;
//
// private Months expiryMonth;
// private Years expiryYear;
//
// public CreditCard(CreditCardNumber number, String cardHolderName, Months expiryMonth, Years expiryYear) {
// super();
// this.number = number;
// this.cardHolderName = cardHolderName;
// this.expiryMonth = expiryMonth;
// this.expiryYear = expiryYear;
// }
//
// /**
// * Returns whether the {@link CreditCard} is currently valid.
// *
// * @return
// */
// @JsonIgnore
// public boolean isValid() {
// return isValid(new LocalDate());
// }
//
// /**
// * Returns whether the {@link CreditCard} is valid for the given date.
// *
// * @param date
// * @return
// */
// public boolean isValid(LocalDate date) {
// return date == null ? false : getExpirationDate().isAfter(date);
// }
//
// /**
// * Returns the {@link LocalDate} the {@link CreditCard} expires.
// *
// * @return will never be {@literal null}.
// */
// public LocalDate getExpirationDate() {
// return new LocalDate(expiryYear.getYears(), expiryMonth.getMonths(), 1);
// }
//
// /**
// * Protected setter to allow binding the expiration date.
// *
// * @param date
// */
// protected void setExpirationDate(LocalDate date) {
//
// this.expiryYear = Years.years(date.getYear());
// this.expiryMonth = Months.months(date.getMonthOfYear());
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public Integer getVersion() {
// return version;
// }
//
// public void setVersion(Integer version) {
// this.version = version;
// }
//
// public CreditCardNumber getNumber() {
// return number;
// }
//
// public void setNumber(CreditCardNumber number) {
// this.number = number;
// }
//
// public String getCardHolderName() {
// return cardHolderName;
// }
//
// public void setCardHolderName(String cardHolderName) {
// this.cardHolderName = cardHolderName;
// }
//
// }
//
// Path: microservices-orders/src/main/java/com/idugalic/orders/payment/domain/CreditCardNumber.java
// @Embeddable
// public class CreditCardNumber {
//
// private static final String regex = "[0-9]{16}";
//
// @Column(unique = true)
// private String number;
//
// /**
// * Creates a new {@link CreditCardNumber}.
// *
// * @param number
// * must not be {@literal null} and be a 16 digit numerical only
// * String.
// */
// public CreditCardNumber(String number) {
//
// if (!isValid(number)) {
// throw new IllegalArgumentException(String.format("Invalid credit card NUMBER %s!", number));
// }
//
// this.number = number;
// }
//
// public CreditCardNumber() {
// super();
// }
//
// /**
// * Returns whether the given {@link String} is a valid
// * {@link CreditCardNumber}.
// *
// * @param number
// * @return
// */
// public static boolean isValid(String number) {
// return number == null ? false : number.matches(regex);
// }
//
// public String getNumber() {
// return number;
// }
//
// public void setNumber(String number) {
// this.number = number;
// }
//
// }
| import org.springframework.data.repository.CrudRepository;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
import com.idugalic.orders.payment.domain.CreditCard;
import com.idugalic.orders.payment.domain.CreditCardNumber; | package com.idugalic.orders.payment.repository;
/**
* Repository to access {@link CreditCard} instances.
*
*/
@RepositoryRestResource(exported = false)
public interface CreditCardRepository extends CrudRepository<CreditCard, Long> {
/**
* Returns the {@link CreditCard} assicaiated with the given
* {@link CreditCardNumber}.
*
* @param number
* must not be {@literal null}.
* @return
*/ | // Path: microservices-orders/src/main/java/com/idugalic/orders/payment/domain/CreditCard.java
// @Entity
// @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE)
// public class CreditCard {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// @Column(name = "id")
// private Long id;
//
// @Version
// @Column(name = "version")
// private Integer version;
//
// @JsonUnwrapped
// private CreditCardNumber number;
//
// private String cardHolderName;
//
// private Months expiryMonth;
// private Years expiryYear;
//
// public CreditCard(CreditCardNumber number, String cardHolderName, Months expiryMonth, Years expiryYear) {
// super();
// this.number = number;
// this.cardHolderName = cardHolderName;
// this.expiryMonth = expiryMonth;
// this.expiryYear = expiryYear;
// }
//
// /**
// * Returns whether the {@link CreditCard} is currently valid.
// *
// * @return
// */
// @JsonIgnore
// public boolean isValid() {
// return isValid(new LocalDate());
// }
//
// /**
// * Returns whether the {@link CreditCard} is valid for the given date.
// *
// * @param date
// * @return
// */
// public boolean isValid(LocalDate date) {
// return date == null ? false : getExpirationDate().isAfter(date);
// }
//
// /**
// * Returns the {@link LocalDate} the {@link CreditCard} expires.
// *
// * @return will never be {@literal null}.
// */
// public LocalDate getExpirationDate() {
// return new LocalDate(expiryYear.getYears(), expiryMonth.getMonths(), 1);
// }
//
// /**
// * Protected setter to allow binding the expiration date.
// *
// * @param date
// */
// protected void setExpirationDate(LocalDate date) {
//
// this.expiryYear = Years.years(date.getYear());
// this.expiryMonth = Months.months(date.getMonthOfYear());
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public Integer getVersion() {
// return version;
// }
//
// public void setVersion(Integer version) {
// this.version = version;
// }
//
// public CreditCardNumber getNumber() {
// return number;
// }
//
// public void setNumber(CreditCardNumber number) {
// this.number = number;
// }
//
// public String getCardHolderName() {
// return cardHolderName;
// }
//
// public void setCardHolderName(String cardHolderName) {
// this.cardHolderName = cardHolderName;
// }
//
// }
//
// Path: microservices-orders/src/main/java/com/idugalic/orders/payment/domain/CreditCardNumber.java
// @Embeddable
// public class CreditCardNumber {
//
// private static final String regex = "[0-9]{16}";
//
// @Column(unique = true)
// private String number;
//
// /**
// * Creates a new {@link CreditCardNumber}.
// *
// * @param number
// * must not be {@literal null} and be a 16 digit numerical only
// * String.
// */
// public CreditCardNumber(String number) {
//
// if (!isValid(number)) {
// throw new IllegalArgumentException(String.format("Invalid credit card NUMBER %s!", number));
// }
//
// this.number = number;
// }
//
// public CreditCardNumber() {
// super();
// }
//
// /**
// * Returns whether the given {@link String} is a valid
// * {@link CreditCardNumber}.
// *
// * @param number
// * @return
// */
// public static boolean isValid(String number) {
// return number == null ? false : number.matches(regex);
// }
//
// public String getNumber() {
// return number;
// }
//
// public void setNumber(String number) {
// this.number = number;
// }
//
// }
// Path: microservices-orders/src/main/java/com/idugalic/orders/payment/repository/CreditCardRepository.java
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
import com.idugalic.orders.payment.domain.CreditCard;
import com.idugalic.orders.payment.domain.CreditCardNumber;
package com.idugalic.orders.payment.repository;
/**
* Repository to access {@link CreditCard} instances.
*
*/
@RepositoryRestResource(exported = false)
public interface CreditCardRepository extends CrudRepository<CreditCard, Long> {
/**
* Returns the {@link CreditCard} assicaiated with the given
* {@link CreditCardNumber}.
*
* @param number
* must not be {@literal null}.
* @return
*/ | CreditCard findByNumber(CreditCardNumber number); |
idugalic/micro-ecommerce | microservices-api-gateway/src/main/java/com/idugalic/apigateway/models/ProductDetails.java | // Path: microservices-api-gateway/src/main/java/com/idugalic/apigateway/services/recommendations/Product.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class Product {
// private String name;
// private String productId;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getProductId() {
// return productId;
// }
//
// public void setProductId(String productId) {
// this.productId = productId;
// }
//
// }
//
// Path: microservices-api-gateway/src/main/java/com/idugalic/apigateway/services/reviews/Review.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class Review {
// private String productId;
// private String userName;
// private String name;
// private String review;
// private int rating;
//
// public String getUserName() {
// return userName;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// public String getProductId() {
// return productId;
// }
//
// public void setProductId(String productId) {
// this.productId = productId;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getReview() {
// return review;
// }
//
// public void setReview(String review) {
// this.review = review;
// }
//
// public int getRating() {
// return rating;
// }
//
// public void setRating(int rating) {
// this.rating = rating;
// }
// }
| import java.util.ArrayList;
import java.util.Collection;
import com.idugalic.apigateway.services.recommendations.Product;
import com.idugalic.apigateway.services.reviews.Review; | package com.idugalic.apigateway.models;
public class ProductDetails {
private String name;
private String productId; | // Path: microservices-api-gateway/src/main/java/com/idugalic/apigateway/services/recommendations/Product.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class Product {
// private String name;
// private String productId;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getProductId() {
// return productId;
// }
//
// public void setProductId(String productId) {
// this.productId = productId;
// }
//
// }
//
// Path: microservices-api-gateway/src/main/java/com/idugalic/apigateway/services/reviews/Review.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class Review {
// private String productId;
// private String userName;
// private String name;
// private String review;
// private int rating;
//
// public String getUserName() {
// return userName;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// public String getProductId() {
// return productId;
// }
//
// public void setProductId(String productId) {
// this.productId = productId;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getReview() {
// return review;
// }
//
// public void setReview(String review) {
// this.review = review;
// }
//
// public int getRating() {
// return rating;
// }
//
// public void setRating(int rating) {
// this.rating = rating;
// }
// }
// Path: microservices-api-gateway/src/main/java/com/idugalic/apigateway/models/ProductDetails.java
import java.util.ArrayList;
import java.util.Collection;
import com.idugalic.apigateway.services.recommendations.Product;
import com.idugalic.apigateway.services.reviews.Review;
package com.idugalic.apigateway.models;
public class ProductDetails {
private String name;
private String productId; | private Collection<Review> reviews = new ArrayList<>(); |
idugalic/micro-ecommerce | microservices-api-gateway/src/main/java/com/idugalic/apigateway/models/ProductDetails.java | // Path: microservices-api-gateway/src/main/java/com/idugalic/apigateway/services/recommendations/Product.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class Product {
// private String name;
// private String productId;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getProductId() {
// return productId;
// }
//
// public void setProductId(String productId) {
// this.productId = productId;
// }
//
// }
//
// Path: microservices-api-gateway/src/main/java/com/idugalic/apigateway/services/reviews/Review.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class Review {
// private String productId;
// private String userName;
// private String name;
// private String review;
// private int rating;
//
// public String getUserName() {
// return userName;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// public String getProductId() {
// return productId;
// }
//
// public void setProductId(String productId) {
// this.productId = productId;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getReview() {
// return review;
// }
//
// public void setReview(String review) {
// this.review = review;
// }
//
// public int getRating() {
// return rating;
// }
//
// public void setRating(int rating) {
// this.rating = rating;
// }
// }
| import java.util.ArrayList;
import java.util.Collection;
import com.idugalic.apigateway.services.recommendations.Product;
import com.idugalic.apigateway.services.reviews.Review; | package com.idugalic.apigateway.models;
public class ProductDetails {
private String name;
private String productId;
private Collection<Review> reviews = new ArrayList<>(); | // Path: microservices-api-gateway/src/main/java/com/idugalic/apigateway/services/recommendations/Product.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class Product {
// private String name;
// private String productId;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getProductId() {
// return productId;
// }
//
// public void setProductId(String productId) {
// this.productId = productId;
// }
//
// }
//
// Path: microservices-api-gateway/src/main/java/com/idugalic/apigateway/services/reviews/Review.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// public class Review {
// private String productId;
// private String userName;
// private String name;
// private String review;
// private int rating;
//
// public String getUserName() {
// return userName;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// public String getProductId() {
// return productId;
// }
//
// public void setProductId(String productId) {
// this.productId = productId;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getReview() {
// return review;
// }
//
// public void setReview(String review) {
// this.review = review;
// }
//
// public int getRating() {
// return rating;
// }
//
// public void setRating(int rating) {
// this.rating = rating;
// }
// }
// Path: microservices-api-gateway/src/main/java/com/idugalic/apigateway/models/ProductDetails.java
import java.util.ArrayList;
import java.util.Collection;
import com.idugalic.apigateway.services.recommendations.Product;
import com.idugalic.apigateway.services.reviews.Review;
package com.idugalic.apigateway.models;
public class ProductDetails {
private String name;
private String productId;
private Collection<Review> reviews = new ArrayList<>(); | private Collection<Product> recommendations = new ArrayList<>(); |
idugalic/micro-ecommerce | microservices-orders/src/main/java/com/idugalic/orders/payment/domain/CreditCardPayment.java | // Path: microservices-orders/src/main/java/com/idugalic/orders/order/domain/Order.java
// @Entity
// @Table(name = "WOrder")
// public class Order implements Identifiable<Long> {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// @Column(name = "id")
// private Long id;
//
// @Version
// @Column(name = "version")
// private Integer version;
//
// private Status status;
// @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTime")
// private DateTime orderedDate;
// @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
// private Set<Item> items = new HashSet<Item>();
//
// public Order(Collection<Item> items) {
// this.status = Status.PAYMENT_EXPECTED;
// this.items.addAll(items);
// this.orderedDate = new DateTime();
// }
//
// public Order(Item... items) {
// this(Arrays.asList(items));
// }
//
// public Order() {
// super();
// }
//
// public Long getId() {
// return this.id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public Integer getVersion() {
// return this.version;
// }
//
// public void setVersion(Integer version) {
// this.version = version;
// }
//
// public MonetaryAmount getPrice() {
// MonetaryAmount result = MonetaryAmount.ZERO;
//
// for (Item item : items) {
// result = result.add(item.getPrice());
// }
//
// return result;
// }
//
// public void markPaid() {
//
// if (isPaid()) {
// throw new IllegalStateException("Already paid order cannot be paid again!");
// }
//
// this.status = Status.PAID;
// }
//
// public void markInPreparation() {
//
// if (this.status != Status.PAID) {
// throw new IllegalStateException(String
// .format("Order must be in state payed to start preparation! " + "Current status: %s", this.status));
// }
//
// this.status = Status.PREPARING;
// }
//
// public void markPrepared() {
//
// if (this.status != Status.PREPARING) {
// throw new IllegalStateException(String.format(
// "Cannot mark Order prepared that is currently not " + "preparing! Current status: %s.",
// this.status));
// }
//
// this.status = Status.READY;
// }
//
// public boolean isPaid() {
// return !this.status.equals(Status.PAYMENT_EXPECTED);
// }
//
// public boolean isReady() {
// return this.status.equals(Status.READY);
// }
//
// public boolean isTaken() {
// return this.status.equals(Status.TAKEN);
// }
//
// public Status getStatus() {
// return status;
// }
//
// public void setStatus(Status status) {
// this.status = status;
// }
//
// public DateTime getOrderedDate() {
// return orderedDate;
// }
//
// public Set<Item> getItems() {
// return items;
// }
//
// public static enum Status {
//
// /**
// * Placed, but not payed yet. Still changeable.
// */
// PAYMENT_EXPECTED,
//
// /**
// * {@link Order} was payed. No changes allowed to it anymore.
// */
// PAID,
//
// /**
// * The {@link Order} is currently processed.
// */
// PREPARING,
//
// /**
// * The {@link Order} is ready to be picked up by the customer.
// */
// READY,
//
// /**
// * The {@link Order} was completed.
// */
// TAKEN;
// }
// }
| import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import org.springframework.util.Assert;
import com.idugalic.orders.order.domain.Order; | package com.idugalic.orders.payment.domain;
/**
* A {@link Payment} done through a {@link CreditCard}.
*
*/
@Entity
public class CreditCardPayment extends Payment {
@ManyToOne
private CreditCard creditCard;
public CreditCardPayment() {
super();
}
/**
* Creates a new {@link CreditCardPayment} for the given {@link CreditCard}
* and {@link Order}.
*
* @param creditCard
* must not be {@literal null}.
* @param order
*/ | // Path: microservices-orders/src/main/java/com/idugalic/orders/order/domain/Order.java
// @Entity
// @Table(name = "WOrder")
// public class Order implements Identifiable<Long> {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// @Column(name = "id")
// private Long id;
//
// @Version
// @Column(name = "version")
// private Integer version;
//
// private Status status;
// @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTime")
// private DateTime orderedDate;
// @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
// private Set<Item> items = new HashSet<Item>();
//
// public Order(Collection<Item> items) {
// this.status = Status.PAYMENT_EXPECTED;
// this.items.addAll(items);
// this.orderedDate = new DateTime();
// }
//
// public Order(Item... items) {
// this(Arrays.asList(items));
// }
//
// public Order() {
// super();
// }
//
// public Long getId() {
// return this.id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public Integer getVersion() {
// return this.version;
// }
//
// public void setVersion(Integer version) {
// this.version = version;
// }
//
// public MonetaryAmount getPrice() {
// MonetaryAmount result = MonetaryAmount.ZERO;
//
// for (Item item : items) {
// result = result.add(item.getPrice());
// }
//
// return result;
// }
//
// public void markPaid() {
//
// if (isPaid()) {
// throw new IllegalStateException("Already paid order cannot be paid again!");
// }
//
// this.status = Status.PAID;
// }
//
// public void markInPreparation() {
//
// if (this.status != Status.PAID) {
// throw new IllegalStateException(String
// .format("Order must be in state payed to start preparation! " + "Current status: %s", this.status));
// }
//
// this.status = Status.PREPARING;
// }
//
// public void markPrepared() {
//
// if (this.status != Status.PREPARING) {
// throw new IllegalStateException(String.format(
// "Cannot mark Order prepared that is currently not " + "preparing! Current status: %s.",
// this.status));
// }
//
// this.status = Status.READY;
// }
//
// public boolean isPaid() {
// return !this.status.equals(Status.PAYMENT_EXPECTED);
// }
//
// public boolean isReady() {
// return this.status.equals(Status.READY);
// }
//
// public boolean isTaken() {
// return this.status.equals(Status.TAKEN);
// }
//
// public Status getStatus() {
// return status;
// }
//
// public void setStatus(Status status) {
// this.status = status;
// }
//
// public DateTime getOrderedDate() {
// return orderedDate;
// }
//
// public Set<Item> getItems() {
// return items;
// }
//
// public static enum Status {
//
// /**
// * Placed, but not payed yet. Still changeable.
// */
// PAYMENT_EXPECTED,
//
// /**
// * {@link Order} was payed. No changes allowed to it anymore.
// */
// PAID,
//
// /**
// * The {@link Order} is currently processed.
// */
// PREPARING,
//
// /**
// * The {@link Order} is ready to be picked up by the customer.
// */
// READY,
//
// /**
// * The {@link Order} was completed.
// */
// TAKEN;
// }
// }
// Path: microservices-orders/src/main/java/com/idugalic/orders/payment/domain/CreditCardPayment.java
import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import org.springframework.util.Assert;
import com.idugalic.orders.order.domain.Order;
package com.idugalic.orders.payment.domain;
/**
* A {@link Payment} done through a {@link CreditCard}.
*
*/
@Entity
public class CreditCardPayment extends Payment {
@ManyToOne
private CreditCard creditCard;
public CreditCardPayment() {
super();
}
/**
* Creates a new {@link CreditCardPayment} for the given {@link CreditCard}
* and {@link Order}.
*
* @param creditCard
* must not be {@literal null}.
* @param order
*/ | public CreditCardPayment(CreditCard creditCard, Order order) { |
idugalic/micro-ecommerce | microservices-reviews/src/main/java/com/idugalic/reviews/Application.java | // Path: microservices-reviews/src/main/java/com/idugalic/reviews/models/Review.java
// public class Review {
// @Id
// private String id;
//
// @Indexed
// private String productId;
//
// @Indexed
// private String userName;
//
// private String name;
//
// private String review;
//
// private int rating;
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getProductId() {
// return productId;
// }
//
// public void setProductId(String productId) {
// this.productId = productId;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getUserName() {
// return userName;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// public String getReview() {
// return review;
// }
//
// public void setReview(String review) {
// this.review = review;
// }
//
// public int getRating() {
// return rating;
// }
//
// public void setRating(int rating) {
// this.rating = rating;
// }
// }
| import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
import org.springframework.data.rest.core.config.RepositoryRestConfiguration;
import org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration;
import org.springframework.http.HttpMethod;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;
import com.idugalic.reviews.models.Review; | package com.idugalic.reviews;
@SpringBootApplication
@EnableMongoRepositories
@EnableDiscoveryClient
public class Application extends RepositoryRestMvcConfiguration {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@Override
protected void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) { | // Path: microservices-reviews/src/main/java/com/idugalic/reviews/models/Review.java
// public class Review {
// @Id
// private String id;
//
// @Indexed
// private String productId;
//
// @Indexed
// private String userName;
//
// private String name;
//
// private String review;
//
// private int rating;
//
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getProductId() {
// return productId;
// }
//
// public void setProductId(String productId) {
// this.productId = productId;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getUserName() {
// return userName;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// public String getReview() {
// return review;
// }
//
// public void setReview(String review) {
// this.review = review;
// }
//
// public int getRating() {
// return rating;
// }
//
// public void setRating(int rating) {
// this.rating = rating;
// }
// }
// Path: microservices-reviews/src/main/java/com/idugalic/reviews/Application.java
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
import org.springframework.data.rest.core.config.RepositoryRestConfiguration;
import org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration;
import org.springframework.http.HttpMethod;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;
import com.idugalic.reviews.models.Review;
package com.idugalic.reviews;
@SpringBootApplication
@EnableMongoRepositories
@EnableDiscoveryClient
public class Application extends RepositoryRestMvcConfiguration {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@Override
protected void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) { | config.exposeIdsFor(Review.class); |
idugalic/micro-ecommerce | microservices-recommendations/src/main/java/com/idugalic/recommendations/controllers/ApiController.java | // Path: microservices-recommendations/src/main/java/com/idugalic/recommendations/model/Likes.java
// @RelationshipEntity(type = "LIKES")
// public class Likes {
//
// @GraphId
// private Long id;
//
// @StartNode
// private Person person;
//
// @EndNode
// private Product product;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public Person getPerson() {
// return person;
// }
//
// public void setPerson(Person person) {
// this.person = person;
// }
//
// public Product getProduct() {
// return product;
// }
//
// public void setProduct(Product product) {
// this.product = product;
// }
//
// @Override
// public String toString() {
// return "Likes{" + "id=" + id + ", person=" + person + ", product=" + product + '}';
// }
// }
//
// Path: microservices-recommendations/src/main/java/com/idugalic/recommendations/model/Person.java
// @NodeEntity
// public class Person {
//
// @GraphId
// private Long id;
// private String userName;
// private String firstName;
// private String lastName;
//
// @Override
// public String toString() {
// return "Person{" + "id=" + id + ", userName='" + userName + '\'' + ", firstName='" + firstName + '\''
// + ", lastName='" + lastName + '\'' + '}';
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getUserName() {
// return userName;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public void setFirstName(String firstName) {
// this.firstName = firstName;
// }
//
// public String getLastName() {
// return lastName;
// }
//
// public void setLastName(String lastName) {
// this.lastName = lastName;
// }
// }
//
// Path: microservices-recommendations/src/main/java/com/idugalic/recommendations/model/Product.java
// @NodeEntity
// public class Product {
//
// @GraphId
// private Long id;
//
// @Override
// public String toString() {
// return "Product{" + "id=" + id + ", productId='" + productId + '\'' + ", name='" + name + '\'' + '}';
// }
//
// @Indexed(unique = true)
// private String productId;
// private String name;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getProductId() {
// return productId;
// }
//
// public void setProductId(String productId) {
// this.productId = productId;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// }
//
// Path: microservices-recommendations/src/main/java/com/idugalic/recommendations/repositories/LikesRepository.java
// @RepositoryRestResource(exported = false)
// public interface LikesRepository extends GraphRepository<Likes> {
// }
//
// Path: microservices-recommendations/src/main/java/com/idugalic/recommendations/repositories/PersonRepository.java
// public interface PersonRepository extends GraphRepository<Person> {
// @Query("MATCH (person:Person) WHERE person.userName = {userName} RETURN person")
// Person findByUserName(@Param("userName") String userName);
// }
//
// Path: microservices-recommendations/src/main/java/com/idugalic/recommendations/repositories/ProductRepository.java
// public interface ProductRepository extends GraphRepository<Product> {
// @Query("MATCH (product:Product) WHERE product.productId = {productId} RETURN product")
// Product findByProductId(@Param("productId") String productId);
//
// @Query("MATCH (p:Person) WHERE p.userName = {userName} MATCH p-[:LIKES]->product<-[:LIKES]-slm-[:LIKES]->recommendations "
// + "WHERE not(p = slm) and not (p--recommendations) return recommendations")
// Iterable<Product> recommendedProductsFor(@Param("userName") String userName);
//
// @Query("MATCH (product:Product) WHERE product.productId = {productId} MATCH product<-[:LIKES]-slm-[:LIKES]->recommendations "
// + "RETURN distinct recommendations")
// Iterable<Product> productsLikedByPeopleWhoLiked(@Param("productId") String productId);
// }
| import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.hateoas.ExposesResourceFor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.idugalic.recommendations.model.Likes;
import com.idugalic.recommendations.model.Person;
import com.idugalic.recommendations.model.Product;
import com.idugalic.recommendations.repositories.LikesRepository;
import com.idugalic.recommendations.repositories.PersonRepository;
import com.idugalic.recommendations.repositories.ProductRepository; | package com.idugalic.recommendations.controllers;
@RestController
@ExposesResourceFor(Likes.class)
public class ApiController {
@Autowired | // Path: microservices-recommendations/src/main/java/com/idugalic/recommendations/model/Likes.java
// @RelationshipEntity(type = "LIKES")
// public class Likes {
//
// @GraphId
// private Long id;
//
// @StartNode
// private Person person;
//
// @EndNode
// private Product product;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public Person getPerson() {
// return person;
// }
//
// public void setPerson(Person person) {
// this.person = person;
// }
//
// public Product getProduct() {
// return product;
// }
//
// public void setProduct(Product product) {
// this.product = product;
// }
//
// @Override
// public String toString() {
// return "Likes{" + "id=" + id + ", person=" + person + ", product=" + product + '}';
// }
// }
//
// Path: microservices-recommendations/src/main/java/com/idugalic/recommendations/model/Person.java
// @NodeEntity
// public class Person {
//
// @GraphId
// private Long id;
// private String userName;
// private String firstName;
// private String lastName;
//
// @Override
// public String toString() {
// return "Person{" + "id=" + id + ", userName='" + userName + '\'' + ", firstName='" + firstName + '\''
// + ", lastName='" + lastName + '\'' + '}';
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getUserName() {
// return userName;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public void setFirstName(String firstName) {
// this.firstName = firstName;
// }
//
// public String getLastName() {
// return lastName;
// }
//
// public void setLastName(String lastName) {
// this.lastName = lastName;
// }
// }
//
// Path: microservices-recommendations/src/main/java/com/idugalic/recommendations/model/Product.java
// @NodeEntity
// public class Product {
//
// @GraphId
// private Long id;
//
// @Override
// public String toString() {
// return "Product{" + "id=" + id + ", productId='" + productId + '\'' + ", name='" + name + '\'' + '}';
// }
//
// @Indexed(unique = true)
// private String productId;
// private String name;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getProductId() {
// return productId;
// }
//
// public void setProductId(String productId) {
// this.productId = productId;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// }
//
// Path: microservices-recommendations/src/main/java/com/idugalic/recommendations/repositories/LikesRepository.java
// @RepositoryRestResource(exported = false)
// public interface LikesRepository extends GraphRepository<Likes> {
// }
//
// Path: microservices-recommendations/src/main/java/com/idugalic/recommendations/repositories/PersonRepository.java
// public interface PersonRepository extends GraphRepository<Person> {
// @Query("MATCH (person:Person) WHERE person.userName = {userName} RETURN person")
// Person findByUserName(@Param("userName") String userName);
// }
//
// Path: microservices-recommendations/src/main/java/com/idugalic/recommendations/repositories/ProductRepository.java
// public interface ProductRepository extends GraphRepository<Product> {
// @Query("MATCH (product:Product) WHERE product.productId = {productId} RETURN product")
// Product findByProductId(@Param("productId") String productId);
//
// @Query("MATCH (p:Person) WHERE p.userName = {userName} MATCH p-[:LIKES]->product<-[:LIKES]-slm-[:LIKES]->recommendations "
// + "WHERE not(p = slm) and not (p--recommendations) return recommendations")
// Iterable<Product> recommendedProductsFor(@Param("userName") String userName);
//
// @Query("MATCH (product:Product) WHERE product.productId = {productId} MATCH product<-[:LIKES]-slm-[:LIKES]->recommendations "
// + "RETURN distinct recommendations")
// Iterable<Product> productsLikedByPeopleWhoLiked(@Param("productId") String productId);
// }
// Path: microservices-recommendations/src/main/java/com/idugalic/recommendations/controllers/ApiController.java
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.hateoas.ExposesResourceFor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.idugalic.recommendations.model.Likes;
import com.idugalic.recommendations.model.Person;
import com.idugalic.recommendations.model.Product;
import com.idugalic.recommendations.repositories.LikesRepository;
import com.idugalic.recommendations.repositories.PersonRepository;
import com.idugalic.recommendations.repositories.ProductRepository;
package com.idugalic.recommendations.controllers;
@RestController
@ExposesResourceFor(Likes.class)
public class ApiController {
@Autowired | ProductRepository productRepository; |
idugalic/micro-ecommerce | microservices-recommendations/src/main/java/com/idugalic/recommendations/controllers/ApiController.java | // Path: microservices-recommendations/src/main/java/com/idugalic/recommendations/model/Likes.java
// @RelationshipEntity(type = "LIKES")
// public class Likes {
//
// @GraphId
// private Long id;
//
// @StartNode
// private Person person;
//
// @EndNode
// private Product product;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public Person getPerson() {
// return person;
// }
//
// public void setPerson(Person person) {
// this.person = person;
// }
//
// public Product getProduct() {
// return product;
// }
//
// public void setProduct(Product product) {
// this.product = product;
// }
//
// @Override
// public String toString() {
// return "Likes{" + "id=" + id + ", person=" + person + ", product=" + product + '}';
// }
// }
//
// Path: microservices-recommendations/src/main/java/com/idugalic/recommendations/model/Person.java
// @NodeEntity
// public class Person {
//
// @GraphId
// private Long id;
// private String userName;
// private String firstName;
// private String lastName;
//
// @Override
// public String toString() {
// return "Person{" + "id=" + id + ", userName='" + userName + '\'' + ", firstName='" + firstName + '\''
// + ", lastName='" + lastName + '\'' + '}';
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getUserName() {
// return userName;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public void setFirstName(String firstName) {
// this.firstName = firstName;
// }
//
// public String getLastName() {
// return lastName;
// }
//
// public void setLastName(String lastName) {
// this.lastName = lastName;
// }
// }
//
// Path: microservices-recommendations/src/main/java/com/idugalic/recommendations/model/Product.java
// @NodeEntity
// public class Product {
//
// @GraphId
// private Long id;
//
// @Override
// public String toString() {
// return "Product{" + "id=" + id + ", productId='" + productId + '\'' + ", name='" + name + '\'' + '}';
// }
//
// @Indexed(unique = true)
// private String productId;
// private String name;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getProductId() {
// return productId;
// }
//
// public void setProductId(String productId) {
// this.productId = productId;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// }
//
// Path: microservices-recommendations/src/main/java/com/idugalic/recommendations/repositories/LikesRepository.java
// @RepositoryRestResource(exported = false)
// public interface LikesRepository extends GraphRepository<Likes> {
// }
//
// Path: microservices-recommendations/src/main/java/com/idugalic/recommendations/repositories/PersonRepository.java
// public interface PersonRepository extends GraphRepository<Person> {
// @Query("MATCH (person:Person) WHERE person.userName = {userName} RETURN person")
// Person findByUserName(@Param("userName") String userName);
// }
//
// Path: microservices-recommendations/src/main/java/com/idugalic/recommendations/repositories/ProductRepository.java
// public interface ProductRepository extends GraphRepository<Product> {
// @Query("MATCH (product:Product) WHERE product.productId = {productId} RETURN product")
// Product findByProductId(@Param("productId") String productId);
//
// @Query("MATCH (p:Person) WHERE p.userName = {userName} MATCH p-[:LIKES]->product<-[:LIKES]-slm-[:LIKES]->recommendations "
// + "WHERE not(p = slm) and not (p--recommendations) return recommendations")
// Iterable<Product> recommendedProductsFor(@Param("userName") String userName);
//
// @Query("MATCH (product:Product) WHERE product.productId = {productId} MATCH product<-[:LIKES]-slm-[:LIKES]->recommendations "
// + "RETURN distinct recommendations")
// Iterable<Product> productsLikedByPeopleWhoLiked(@Param("productId") String productId);
// }
| import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.hateoas.ExposesResourceFor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.idugalic.recommendations.model.Likes;
import com.idugalic.recommendations.model.Person;
import com.idugalic.recommendations.model.Product;
import com.idugalic.recommendations.repositories.LikesRepository;
import com.idugalic.recommendations.repositories.PersonRepository;
import com.idugalic.recommendations.repositories.ProductRepository; | package com.idugalic.recommendations.controllers;
@RestController
@ExposesResourceFor(Likes.class)
public class ApiController {
@Autowired
ProductRepository productRepository;
@Autowired | // Path: microservices-recommendations/src/main/java/com/idugalic/recommendations/model/Likes.java
// @RelationshipEntity(type = "LIKES")
// public class Likes {
//
// @GraphId
// private Long id;
//
// @StartNode
// private Person person;
//
// @EndNode
// private Product product;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public Person getPerson() {
// return person;
// }
//
// public void setPerson(Person person) {
// this.person = person;
// }
//
// public Product getProduct() {
// return product;
// }
//
// public void setProduct(Product product) {
// this.product = product;
// }
//
// @Override
// public String toString() {
// return "Likes{" + "id=" + id + ", person=" + person + ", product=" + product + '}';
// }
// }
//
// Path: microservices-recommendations/src/main/java/com/idugalic/recommendations/model/Person.java
// @NodeEntity
// public class Person {
//
// @GraphId
// private Long id;
// private String userName;
// private String firstName;
// private String lastName;
//
// @Override
// public String toString() {
// return "Person{" + "id=" + id + ", userName='" + userName + '\'' + ", firstName='" + firstName + '\''
// + ", lastName='" + lastName + '\'' + '}';
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getUserName() {
// return userName;
// }
//
// public void setUserName(String userName) {
// this.userName = userName;
// }
//
// public String getFirstName() {
// return firstName;
// }
//
// public void setFirstName(String firstName) {
// this.firstName = firstName;
// }
//
// public String getLastName() {
// return lastName;
// }
//
// public void setLastName(String lastName) {
// this.lastName = lastName;
// }
// }
//
// Path: microservices-recommendations/src/main/java/com/idugalic/recommendations/model/Product.java
// @NodeEntity
// public class Product {
//
// @GraphId
// private Long id;
//
// @Override
// public String toString() {
// return "Product{" + "id=" + id + ", productId='" + productId + '\'' + ", name='" + name + '\'' + '}';
// }
//
// @Indexed(unique = true)
// private String productId;
// private String name;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getProductId() {
// return productId;
// }
//
// public void setProductId(String productId) {
// this.productId = productId;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// }
//
// Path: microservices-recommendations/src/main/java/com/idugalic/recommendations/repositories/LikesRepository.java
// @RepositoryRestResource(exported = false)
// public interface LikesRepository extends GraphRepository<Likes> {
// }
//
// Path: microservices-recommendations/src/main/java/com/idugalic/recommendations/repositories/PersonRepository.java
// public interface PersonRepository extends GraphRepository<Person> {
// @Query("MATCH (person:Person) WHERE person.userName = {userName} RETURN person")
// Person findByUserName(@Param("userName") String userName);
// }
//
// Path: microservices-recommendations/src/main/java/com/idugalic/recommendations/repositories/ProductRepository.java
// public interface ProductRepository extends GraphRepository<Product> {
// @Query("MATCH (product:Product) WHERE product.productId = {productId} RETURN product")
// Product findByProductId(@Param("productId") String productId);
//
// @Query("MATCH (p:Person) WHERE p.userName = {userName} MATCH p-[:LIKES]->product<-[:LIKES]-slm-[:LIKES]->recommendations "
// + "WHERE not(p = slm) and not (p--recommendations) return recommendations")
// Iterable<Product> recommendedProductsFor(@Param("userName") String userName);
//
// @Query("MATCH (product:Product) WHERE product.productId = {productId} MATCH product<-[:LIKES]-slm-[:LIKES]->recommendations "
// + "RETURN distinct recommendations")
// Iterable<Product> productsLikedByPeopleWhoLiked(@Param("productId") String productId);
// }
// Path: microservices-recommendations/src/main/java/com/idugalic/recommendations/controllers/ApiController.java
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.hateoas.ExposesResourceFor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.idugalic.recommendations.model.Likes;
import com.idugalic.recommendations.model.Person;
import com.idugalic.recommendations.model.Product;
import com.idugalic.recommendations.repositories.LikesRepository;
import com.idugalic.recommendations.repositories.PersonRepository;
import com.idugalic.recommendations.repositories.ProductRepository;
package com.idugalic.recommendations.controllers;
@RestController
@ExposesResourceFor(Likes.class)
public class ApiController {
@Autowired
ProductRepository productRepository;
@Autowired | PersonRepository personRepository; |
idugalic/micro-ecommerce | microservices-orders/src/main/java/com/idugalic/orders/payment/domain/Payment.java | // Path: microservices-orders/src/main/java/com/idugalic/orders/order/domain/Order.java
// @Entity
// @Table(name = "WOrder")
// public class Order implements Identifiable<Long> {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// @Column(name = "id")
// private Long id;
//
// @Version
// @Column(name = "version")
// private Integer version;
//
// private Status status;
// @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTime")
// private DateTime orderedDate;
// @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
// private Set<Item> items = new HashSet<Item>();
//
// public Order(Collection<Item> items) {
// this.status = Status.PAYMENT_EXPECTED;
// this.items.addAll(items);
// this.orderedDate = new DateTime();
// }
//
// public Order(Item... items) {
// this(Arrays.asList(items));
// }
//
// public Order() {
// super();
// }
//
// public Long getId() {
// return this.id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public Integer getVersion() {
// return this.version;
// }
//
// public void setVersion(Integer version) {
// this.version = version;
// }
//
// public MonetaryAmount getPrice() {
// MonetaryAmount result = MonetaryAmount.ZERO;
//
// for (Item item : items) {
// result = result.add(item.getPrice());
// }
//
// return result;
// }
//
// public void markPaid() {
//
// if (isPaid()) {
// throw new IllegalStateException("Already paid order cannot be paid again!");
// }
//
// this.status = Status.PAID;
// }
//
// public void markInPreparation() {
//
// if (this.status != Status.PAID) {
// throw new IllegalStateException(String
// .format("Order must be in state payed to start preparation! " + "Current status: %s", this.status));
// }
//
// this.status = Status.PREPARING;
// }
//
// public void markPrepared() {
//
// if (this.status != Status.PREPARING) {
// throw new IllegalStateException(String.format(
// "Cannot mark Order prepared that is currently not " + "preparing! Current status: %s.",
// this.status));
// }
//
// this.status = Status.READY;
// }
//
// public boolean isPaid() {
// return !this.status.equals(Status.PAYMENT_EXPECTED);
// }
//
// public boolean isReady() {
// return this.status.equals(Status.READY);
// }
//
// public boolean isTaken() {
// return this.status.equals(Status.TAKEN);
// }
//
// public Status getStatus() {
// return status;
// }
//
// public void setStatus(Status status) {
// this.status = status;
// }
//
// public DateTime getOrderedDate() {
// return orderedDate;
// }
//
// public Set<Item> getItems() {
// return items;
// }
//
// public static enum Status {
//
// /**
// * Placed, but not payed yet. Still changeable.
// */
// PAYMENT_EXPECTED,
//
// /**
// * {@link Order} was payed. No changes allowed to it anymore.
// */
// PAID,
//
// /**
// * The {@link Order} is currently processed.
// */
// PREPARING,
//
// /**
// * The {@link Order} is ready to be picked up by the customer.
// */
// READY,
//
// /**
// * The {@link Order} was completed.
// */
// TAKEN;
// }
// }
| import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Version;
import org.hibernate.annotations.Type;
import org.joda.time.DateTime;
import org.springframework.util.Assert;
import com.idugalic.orders.order.domain.Order; | package com.idugalic.orders.payment.domain;
/**
* Baseclass for payment implementations.
*
*/
@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
public abstract class Payment {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id")
private Long id;
@Version
@Column(name = "version")
private Integer version;
@JoinColumn(name = "rborder") //
@OneToOne(cascade = CascadeType.MERGE) // | // Path: microservices-orders/src/main/java/com/idugalic/orders/order/domain/Order.java
// @Entity
// @Table(name = "WOrder")
// public class Order implements Identifiable<Long> {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// @Column(name = "id")
// private Long id;
//
// @Version
// @Column(name = "version")
// private Integer version;
//
// private Status status;
// @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTime")
// private DateTime orderedDate;
// @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
// private Set<Item> items = new HashSet<Item>();
//
// public Order(Collection<Item> items) {
// this.status = Status.PAYMENT_EXPECTED;
// this.items.addAll(items);
// this.orderedDate = new DateTime();
// }
//
// public Order(Item... items) {
// this(Arrays.asList(items));
// }
//
// public Order() {
// super();
// }
//
// public Long getId() {
// return this.id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public Integer getVersion() {
// return this.version;
// }
//
// public void setVersion(Integer version) {
// this.version = version;
// }
//
// public MonetaryAmount getPrice() {
// MonetaryAmount result = MonetaryAmount.ZERO;
//
// for (Item item : items) {
// result = result.add(item.getPrice());
// }
//
// return result;
// }
//
// public void markPaid() {
//
// if (isPaid()) {
// throw new IllegalStateException("Already paid order cannot be paid again!");
// }
//
// this.status = Status.PAID;
// }
//
// public void markInPreparation() {
//
// if (this.status != Status.PAID) {
// throw new IllegalStateException(String
// .format("Order must be in state payed to start preparation! " + "Current status: %s", this.status));
// }
//
// this.status = Status.PREPARING;
// }
//
// public void markPrepared() {
//
// if (this.status != Status.PREPARING) {
// throw new IllegalStateException(String.format(
// "Cannot mark Order prepared that is currently not " + "preparing! Current status: %s.",
// this.status));
// }
//
// this.status = Status.READY;
// }
//
// public boolean isPaid() {
// return !this.status.equals(Status.PAYMENT_EXPECTED);
// }
//
// public boolean isReady() {
// return this.status.equals(Status.READY);
// }
//
// public boolean isTaken() {
// return this.status.equals(Status.TAKEN);
// }
//
// public Status getStatus() {
// return status;
// }
//
// public void setStatus(Status status) {
// this.status = status;
// }
//
// public DateTime getOrderedDate() {
// return orderedDate;
// }
//
// public Set<Item> getItems() {
// return items;
// }
//
// public static enum Status {
//
// /**
// * Placed, but not payed yet. Still changeable.
// */
// PAYMENT_EXPECTED,
//
// /**
// * {@link Order} was payed. No changes allowed to it anymore.
// */
// PAID,
//
// /**
// * The {@link Order} is currently processed.
// */
// PREPARING,
//
// /**
// * The {@link Order} is ready to be picked up by the customer.
// */
// READY,
//
// /**
// * The {@link Order} was completed.
// */
// TAKEN;
// }
// }
// Path: microservices-orders/src/main/java/com/idugalic/orders/payment/domain/Payment.java
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Version;
import org.hibernate.annotations.Type;
import org.joda.time.DateTime;
import org.springframework.util.Assert;
import com.idugalic.orders.order.domain.Order;
package com.idugalic.orders.payment.domain;
/**
* Baseclass for payment implementations.
*
*/
@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
public abstract class Payment {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id")
private Long id;
@Version
@Column(name = "version")
private Integer version;
@JoinColumn(name = "rborder") //
@OneToOne(cascade = CascadeType.MERGE) // | private Order order; |
pinaraf/ebics | src/main/java/org/kopi/ebics/xml/HPBRequestElement.java | // Path: src/main/java/org/kopi/ebics/exception/EbicsException.java
// public class EbicsException extends Exception {
//
// /**
// * A means to construct a server error.
// */
// public EbicsException() {}
//
// /**
// * A means to construct a server error with an additional message.
// * @param message the exception message
// */
// public EbicsException(String message) {
// super(message);
// }
// /**
// * A means to construct a server error with no additional message.
// * @param returnCode the ebics return code.
// */
// public EbicsException(ReturnCode returnCode) {
// this.returnCode = returnCode;
// }
//
// /**
// * A means to construct a server error with an additional message.
// * @param returnCode the ebics return code.
// * @param message the additional message.
// */
// public EbicsException(ReturnCode returnCode, String message) {
// super(message);
// this.returnCode = returnCode;
// }
//
// /**
// * Returns the standardized error code.
// * @return the standardized error code.
// */
// public ReturnCode getReturnCode() {
// return returnCode;
// }
//
// // --------------------------------------------------------------------
// // DATA MEMBERS
// // --------------------------------------------------------------------
//
// private ReturnCode returnCode;
// private static final long serialVersionUID = 2728820344946361669L;
// }
//
// Path: src/main/java/org/kopi/ebics/session/EbicsSession.java
// public class EbicsSession {
//
// /**
// * Constructs a new ebics session
// * @param user the ebics user
// * @param the ebics client configuration
// */
// public EbicsSession(EbicsUser user, Configuration configuration) {
// this.user = user;
// this.configuration = configuration;
// parameters = new HashMap<String, String>();
// }
//
// /**
// * Returns the banks encryption key.
// * The key will be fetched automatically form the bank if needed.
// * @return the banks encryption key.
// * @throws IOException Communication error during key retrieval.
// * @throws EbicsException Server error message generated during key retrieval.
// */
// public RSAPublicKey getBankE002Key() throws IOException, EbicsException {
// return user.getPartner().getBank().getE002Key();
// }
//
// /**
// * Returns the banks authentication key.
// * The key will be fetched automatically form the bank if needed.
// * @return the banks authentication key.
// * @throws IOException Communication error during key retrieval.
// * @throws EbicsException Server error message generated during key retrieval.
// */
// public RSAPublicKey getBankX002Key() throws IOException, EbicsException {
// return user.getPartner().getBank().getX002Key();
// }
//
// /**
// * Returns the bank id.
// * @return the bank id.
// * @throws EbicsException
// */
// public String getBankID() throws EbicsException {
// return user.getPartner().getBank().getHostId();
// }
//
// /**
// * Return the session user.
// * @return the session user.
// */
// public EbicsUser getUser() {
// return user;
// }
//
// /**
// * Returns the client application configuration.
// * @return the client application configuration.
// */
// public Configuration getConfiguration() {
// return configuration;
// }
//
// /**
// * Sets the optional product identification that will be sent to the bank during each request.
// * @param product Product description
// */
// public void setProduct(Product product) {
// this.product = product;
// }
//
// /**
// * @return the product
// */
// public Product getProduct() {
// return product;
// }
//
// /**
// * Adds a session parameter to use it in the transfer process.
// * @param key the parameter key
// * @param value the parameter value
// */
// public void addSessionParam(String key, String value) {
// parameters.put(key, value);
// }
//
// /**
// * Retrieves a session parameter using its key.
// * @param key the parameter key
// * @return the session parameter
// */
// public String getSessionParam(String key) {
// if (key == null) {
// return null;
// }
//
// return parameters.get(key);
// }
//
// // --------------------------------------------------------------------
// // DATA MEMBERS
// // --------------------------------------------------------------------
//
// private EbicsUser user;
// private Configuration configuration;
// private Product product;
// private Map<String, String> parameters;
// }
| import org.kopi.ebics.exception.EbicsException;
import org.kopi.ebics.session.EbicsSession; | /*
* Copyright (c) 1990-2012 kopiLeft Development SARL, Bizerte, Tunisia
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1 as published by the Free Software Foundation.
*
* This library 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 library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* $Id$
*/
package org.kopi.ebics.xml;
/**
* The <code>HPBRequestElement</code> is the element to be sent when
* a HPB request is needed to retrieve the bank public keys
*
* @author hachani
*
*/
public class HPBRequestElement extends DefaultEbicsRootElement {
/**
* Constructs a new HPB Request element.
* @param session the current ebics session.
*/
public HPBRequestElement(EbicsSession session) {
super(session);
}
@Override
public String getName() {
return "HPBRequest.xml";
}
@Override | // Path: src/main/java/org/kopi/ebics/exception/EbicsException.java
// public class EbicsException extends Exception {
//
// /**
// * A means to construct a server error.
// */
// public EbicsException() {}
//
// /**
// * A means to construct a server error with an additional message.
// * @param message the exception message
// */
// public EbicsException(String message) {
// super(message);
// }
// /**
// * A means to construct a server error with no additional message.
// * @param returnCode the ebics return code.
// */
// public EbicsException(ReturnCode returnCode) {
// this.returnCode = returnCode;
// }
//
// /**
// * A means to construct a server error with an additional message.
// * @param returnCode the ebics return code.
// * @param message the additional message.
// */
// public EbicsException(ReturnCode returnCode, String message) {
// super(message);
// this.returnCode = returnCode;
// }
//
// /**
// * Returns the standardized error code.
// * @return the standardized error code.
// */
// public ReturnCode getReturnCode() {
// return returnCode;
// }
//
// // --------------------------------------------------------------------
// // DATA MEMBERS
// // --------------------------------------------------------------------
//
// private ReturnCode returnCode;
// private static final long serialVersionUID = 2728820344946361669L;
// }
//
// Path: src/main/java/org/kopi/ebics/session/EbicsSession.java
// public class EbicsSession {
//
// /**
// * Constructs a new ebics session
// * @param user the ebics user
// * @param the ebics client configuration
// */
// public EbicsSession(EbicsUser user, Configuration configuration) {
// this.user = user;
// this.configuration = configuration;
// parameters = new HashMap<String, String>();
// }
//
// /**
// * Returns the banks encryption key.
// * The key will be fetched automatically form the bank if needed.
// * @return the banks encryption key.
// * @throws IOException Communication error during key retrieval.
// * @throws EbicsException Server error message generated during key retrieval.
// */
// public RSAPublicKey getBankE002Key() throws IOException, EbicsException {
// return user.getPartner().getBank().getE002Key();
// }
//
// /**
// * Returns the banks authentication key.
// * The key will be fetched automatically form the bank if needed.
// * @return the banks authentication key.
// * @throws IOException Communication error during key retrieval.
// * @throws EbicsException Server error message generated during key retrieval.
// */
// public RSAPublicKey getBankX002Key() throws IOException, EbicsException {
// return user.getPartner().getBank().getX002Key();
// }
//
// /**
// * Returns the bank id.
// * @return the bank id.
// * @throws EbicsException
// */
// public String getBankID() throws EbicsException {
// return user.getPartner().getBank().getHostId();
// }
//
// /**
// * Return the session user.
// * @return the session user.
// */
// public EbicsUser getUser() {
// return user;
// }
//
// /**
// * Returns the client application configuration.
// * @return the client application configuration.
// */
// public Configuration getConfiguration() {
// return configuration;
// }
//
// /**
// * Sets the optional product identification that will be sent to the bank during each request.
// * @param product Product description
// */
// public void setProduct(Product product) {
// this.product = product;
// }
//
// /**
// * @return the product
// */
// public Product getProduct() {
// return product;
// }
//
// /**
// * Adds a session parameter to use it in the transfer process.
// * @param key the parameter key
// * @param value the parameter value
// */
// public void addSessionParam(String key, String value) {
// parameters.put(key, value);
// }
//
// /**
// * Retrieves a session parameter using its key.
// * @param key the parameter key
// * @return the session parameter
// */
// public String getSessionParam(String key) {
// if (key == null) {
// return null;
// }
//
// return parameters.get(key);
// }
//
// // --------------------------------------------------------------------
// // DATA MEMBERS
// // --------------------------------------------------------------------
//
// private EbicsUser user;
// private Configuration configuration;
// private Product product;
// private Map<String, String> parameters;
// }
// Path: src/main/java/org/kopi/ebics/xml/HPBRequestElement.java
import org.kopi.ebics.exception.EbicsException;
import org.kopi.ebics.session.EbicsSession;
/*
* Copyright (c) 1990-2012 kopiLeft Development SARL, Bizerte, Tunisia
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1 as published by the Free Software Foundation.
*
* This library 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 library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* $Id$
*/
package org.kopi.ebics.xml;
/**
* The <code>HPBRequestElement</code> is the element to be sent when
* a HPB request is needed to retrieve the bank public keys
*
* @author hachani
*
*/
public class HPBRequestElement extends DefaultEbicsRootElement {
/**
* Constructs a new HPB Request element.
* @param session the current ebics session.
*/
public HPBRequestElement(EbicsSession session) {
super(session);
}
@Override
public String getName() {
return "HPBRequest.xml";
}
@Override | public void build() throws EbicsException { |
pinaraf/ebics | src/main/java/org/kopi/ebics/interfaces/EbicsUser.java | // Path: src/main/java/org/kopi/ebics/exception/EbicsException.java
// public class EbicsException extends Exception {
//
// /**
// * A means to construct a server error.
// */
// public EbicsException() {}
//
// /**
// * A means to construct a server error with an additional message.
// * @param message the exception message
// */
// public EbicsException(String message) {
// super(message);
// }
// /**
// * A means to construct a server error with no additional message.
// * @param returnCode the ebics return code.
// */
// public EbicsException(ReturnCode returnCode) {
// this.returnCode = returnCode;
// }
//
// /**
// * A means to construct a server error with an additional message.
// * @param returnCode the ebics return code.
// * @param message the additional message.
// */
// public EbicsException(ReturnCode returnCode, String message) {
// super(message);
// this.returnCode = returnCode;
// }
//
// /**
// * Returns the standardized error code.
// * @return the standardized error code.
// */
// public ReturnCode getReturnCode() {
// return returnCode;
// }
//
// // --------------------------------------------------------------------
// // DATA MEMBERS
// // --------------------------------------------------------------------
//
// private ReturnCode returnCode;
// private static final long serialVersionUID = 2728820344946361669L;
// }
| import java.io.IOException;
import java.security.GeneralSecurityException;
import java.security.PrivateKey;
import java.security.cert.X509Certificate;
import java.security.interfaces.RSAPublicKey;
import org.kopi.ebics.exception.EbicsException;
| /*
* Copyright (c) 1990-2012 kopiLeft Development SARL, Bizerte, Tunisia
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1 as published by the Free Software Foundation.
*
* This library 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 library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* $Id$
*/
package org.kopi.ebics.interfaces;
/**
* Things an EBICS user must be able to perform.
*
* @author Hachani
*
*/
public interface EbicsUser {
/**
* Returns the public part of the signature key.
* @return the public part of the signature key.
*/
public RSAPublicKey getA005PublicKey();
/**
* Returns the public part of the encryption key.
* @return the public part of the encryption key.
*/
public RSAPublicKey getE002PublicKey();
/**
* Return the public part of the transport authentication key.
* @return the public part of the transport authentication key.
*/
public RSAPublicKey getX002PublicKey();
/**
* Returns the signature certificate.
* @return the encryption certificate.
* @throws EbicsException
*/
| // Path: src/main/java/org/kopi/ebics/exception/EbicsException.java
// public class EbicsException extends Exception {
//
// /**
// * A means to construct a server error.
// */
// public EbicsException() {}
//
// /**
// * A means to construct a server error with an additional message.
// * @param message the exception message
// */
// public EbicsException(String message) {
// super(message);
// }
// /**
// * A means to construct a server error with no additional message.
// * @param returnCode the ebics return code.
// */
// public EbicsException(ReturnCode returnCode) {
// this.returnCode = returnCode;
// }
//
// /**
// * A means to construct a server error with an additional message.
// * @param returnCode the ebics return code.
// * @param message the additional message.
// */
// public EbicsException(ReturnCode returnCode, String message) {
// super(message);
// this.returnCode = returnCode;
// }
//
// /**
// * Returns the standardized error code.
// * @return the standardized error code.
// */
// public ReturnCode getReturnCode() {
// return returnCode;
// }
//
// // --------------------------------------------------------------------
// // DATA MEMBERS
// // --------------------------------------------------------------------
//
// private ReturnCode returnCode;
// private static final long serialVersionUID = 2728820344946361669L;
// }
// Path: src/main/java/org/kopi/ebics/interfaces/EbicsUser.java
import java.io.IOException;
import java.security.GeneralSecurityException;
import java.security.PrivateKey;
import java.security.cert.X509Certificate;
import java.security.interfaces.RSAPublicKey;
import org.kopi.ebics.exception.EbicsException;
/*
* Copyright (c) 1990-2012 kopiLeft Development SARL, Bizerte, Tunisia
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1 as published by the Free Software Foundation.
*
* This library 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 library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* $Id$
*/
package org.kopi.ebics.interfaces;
/**
* Things an EBICS user must be able to perform.
*
* @author Hachani
*
*/
public interface EbicsUser {
/**
* Returns the public part of the signature key.
* @return the public part of the signature key.
*/
public RSAPublicKey getA005PublicKey();
/**
* Returns the public part of the encryption key.
* @return the public part of the encryption key.
*/
public RSAPublicKey getE002PublicKey();
/**
* Return the public part of the transport authentication key.
* @return the public part of the transport authentication key.
*/
public RSAPublicKey getX002PublicKey();
/**
* Returns the signature certificate.
* @return the encryption certificate.
* @throws EbicsException
*/
| public byte[] getA005Certificate() throws EbicsException;
|
pinaraf/ebics | src/main/java/org/kopi/ebics/interfaces/InitLetter.java | // Path: src/main/java/org/kopi/ebics/exception/EbicsException.java
// public class EbicsException extends Exception {
//
// /**
// * A means to construct a server error.
// */
// public EbicsException() {}
//
// /**
// * A means to construct a server error with an additional message.
// * @param message the exception message
// */
// public EbicsException(String message) {
// super(message);
// }
// /**
// * A means to construct a server error with no additional message.
// * @param returnCode the ebics return code.
// */
// public EbicsException(ReturnCode returnCode) {
// this.returnCode = returnCode;
// }
//
// /**
// * A means to construct a server error with an additional message.
// * @param returnCode the ebics return code.
// * @param message the additional message.
// */
// public EbicsException(ReturnCode returnCode, String message) {
// super(message);
// this.returnCode = returnCode;
// }
//
// /**
// * Returns the standardized error code.
// * @return the standardized error code.
// */
// public ReturnCode getReturnCode() {
// return returnCode;
// }
//
// // --------------------------------------------------------------------
// // DATA MEMBERS
// // --------------------------------------------------------------------
//
// private ReturnCode returnCode;
// private static final long serialVersionUID = 2728820344946361669L;
// }
| import org.kopi.ebics.exception.EbicsException;
import java.io.IOException;
import java.io.OutputStream;
import java.security.GeneralSecurityException;
| /*
* Copyright (c) 1990-2012 kopiLeft Development SARL, Bizerte, Tunisia
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1 as published by the Free Software Foundation.
*
* This library 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 library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* $Id$
*/
package org.kopi.ebics.interfaces;
/**
* The <code>InitLetter</code> is an abstract initialization
* letter. The INI, HIA and HPB letters should be an implementation
* of the <code>InitLetter</code>
*
* @author Hachani
*
*/
public interface InitLetter {
/**
* Creates an <code>InitLetter</code> for a given <code>EbicsUser</code>
* @param user the ebics user.
* @throws EbicsException
* @throws IOException
* @throws GeneralSecurityException
*/
public void create(EbicsUser user)
| // Path: src/main/java/org/kopi/ebics/exception/EbicsException.java
// public class EbicsException extends Exception {
//
// /**
// * A means to construct a server error.
// */
// public EbicsException() {}
//
// /**
// * A means to construct a server error with an additional message.
// * @param message the exception message
// */
// public EbicsException(String message) {
// super(message);
// }
// /**
// * A means to construct a server error with no additional message.
// * @param returnCode the ebics return code.
// */
// public EbicsException(ReturnCode returnCode) {
// this.returnCode = returnCode;
// }
//
// /**
// * A means to construct a server error with an additional message.
// * @param returnCode the ebics return code.
// * @param message the additional message.
// */
// public EbicsException(ReturnCode returnCode, String message) {
// super(message);
// this.returnCode = returnCode;
// }
//
// /**
// * Returns the standardized error code.
// * @return the standardized error code.
// */
// public ReturnCode getReturnCode() {
// return returnCode;
// }
//
// // --------------------------------------------------------------------
// // DATA MEMBERS
// // --------------------------------------------------------------------
//
// private ReturnCode returnCode;
// private static final long serialVersionUID = 2728820344946361669L;
// }
// Path: src/main/java/org/kopi/ebics/interfaces/InitLetter.java
import org.kopi.ebics.exception.EbicsException;
import java.io.IOException;
import java.io.OutputStream;
import java.security.GeneralSecurityException;
/*
* Copyright (c) 1990-2012 kopiLeft Development SARL, Bizerte, Tunisia
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1 as published by the Free Software Foundation.
*
* This library 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 library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* $Id$
*/
package org.kopi.ebics.interfaces;
/**
* The <code>InitLetter</code> is an abstract initialization
* letter. The INI, HIA and HPB letters should be an implementation
* of the <code>InitLetter</code>
*
* @author Hachani
*
*/
public interface InitLetter {
/**
* Creates an <code>InitLetter</code> for a given <code>EbicsUser</code>
* @param user the ebics user.
* @throws EbicsException
* @throws IOException
* @throws GeneralSecurityException
*/
public void create(EbicsUser user)
| throws GeneralSecurityException, IOException, EbicsException;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.