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
|
---|---|---|---|---|---|---|
jmcampanini/gexf4j-core | src/test/java/com/ojn/gexf4j/core/testgraphs/HierarchyInlineBuilder.java | // Path: src/main/java/com/ojn/gexf4j/core/EdgeType.java
// public enum EdgeType {
//
// DIRECTED,
// UNDIRECTED,
// MUTUAL,
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/Gexf.java
// public interface Gexf {
//
// String getVersion();
//
// boolean hasVariant();
// Gexf clearVariant();
// String getVariant();
// Gexf setVariant(String variant);
//
// Metadata getMetadata();
//
// Graph getGraph();
//
// boolean hasVisualization();
// Gexf setVisualization(boolean viz);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/Mode.java
// public enum Mode {
//
// STATIC,
// DYNAMIC,
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/Node.java
// public interface Node extends SlicableDatum<Node>, HasNodes {
//
// String getId();
//
// String getLabel();
// Node setLabel(String label);
//
// List<Edge> getEdges();
//
// Edge connectTo(Node target);
// Edge connectTo(String id, Node target);
//
// boolean hasEdgeTo(String id);
//
// boolean hasColor();
// Node clearColor();
// Color getColor();
// Node setColor(Color color);
//
// boolean hasPosition();
// Node clearPosition();
// Position getPosition();
// Node setPosition(Position position);
//
// boolean hasSize();
// Node clearSize();
// float getSize();
// Node setSize(float size);
//
// boolean hasShape();
// Node clearShape();
// NodeShapeEntity getShapeEntity();
//
// List<Node> getParentForList();
//
// boolean hasPID();
// Node clearPID();
// String getPID();
// Node setPID(String pid);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/impl/GexfImpl.java
// public class GexfImpl implements Gexf {
// private static final String VERSION = "1.1";
//
// private String variant = null;
// private Graph graph = null;
// private Metadata meta = null;
// private boolean viz = false;
//
// public GexfImpl() {
// graph = new GraphImpl();
// meta = new MetadataImpl();
// }
//
// @Override
// public Graph getGraph() {
// return graph;
// }
//
// @Override
// public Metadata getMetadata() {
// return meta;
// }
//
// @Override
// public String getVersion() {
// return VERSION;
// }
//
// @Override
// public boolean hasVariant() {
// return (variant != null);
// }
//
// @Override
// public Gexf clearVariant() {
// variant = null;
// return this;
// }
//
// @Override
// public String getVariant() {
// checkState(hasVariant(), "Variant has not been set.");
// return variant;
// }
//
// @Override
// public Gexf setVariant(String variant) {
// checkArgument(variant != null, "Variant cannot be null.");
// checkArgument(!variant.trim().isEmpty(), "Variant cannot be empty or blank.");
// this.variant = variant;
// return this;
// }
//
// @Override
// public boolean hasVisualization() {
// return viz;
// }
//
// @Override
// public Gexf setVisualization(boolean viz) {
// this.viz = viz;
// return this;
// }
// }
| import com.ojn.gexf4j.core.EdgeType;
import com.ojn.gexf4j.core.Gexf;
import com.ojn.gexf4j.core.Mode;
import com.ojn.gexf4j.core.Node;
import com.ojn.gexf4j.core.impl.GexfImpl; | package com.ojn.gexf4j.core.testgraphs;
public class HierarchyInlineBuilder extends GexfBuilder {
@Override
public String getSuffix() {
return "hierarchyInline";
}
@Override
public Gexf buildGexf() { | // Path: src/main/java/com/ojn/gexf4j/core/EdgeType.java
// public enum EdgeType {
//
// DIRECTED,
// UNDIRECTED,
// MUTUAL,
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/Gexf.java
// public interface Gexf {
//
// String getVersion();
//
// boolean hasVariant();
// Gexf clearVariant();
// String getVariant();
// Gexf setVariant(String variant);
//
// Metadata getMetadata();
//
// Graph getGraph();
//
// boolean hasVisualization();
// Gexf setVisualization(boolean viz);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/Mode.java
// public enum Mode {
//
// STATIC,
// DYNAMIC,
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/Node.java
// public interface Node extends SlicableDatum<Node>, HasNodes {
//
// String getId();
//
// String getLabel();
// Node setLabel(String label);
//
// List<Edge> getEdges();
//
// Edge connectTo(Node target);
// Edge connectTo(String id, Node target);
//
// boolean hasEdgeTo(String id);
//
// boolean hasColor();
// Node clearColor();
// Color getColor();
// Node setColor(Color color);
//
// boolean hasPosition();
// Node clearPosition();
// Position getPosition();
// Node setPosition(Position position);
//
// boolean hasSize();
// Node clearSize();
// float getSize();
// Node setSize(float size);
//
// boolean hasShape();
// Node clearShape();
// NodeShapeEntity getShapeEntity();
//
// List<Node> getParentForList();
//
// boolean hasPID();
// Node clearPID();
// String getPID();
// Node setPID(String pid);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/impl/GexfImpl.java
// public class GexfImpl implements Gexf {
// private static final String VERSION = "1.1";
//
// private String variant = null;
// private Graph graph = null;
// private Metadata meta = null;
// private boolean viz = false;
//
// public GexfImpl() {
// graph = new GraphImpl();
// meta = new MetadataImpl();
// }
//
// @Override
// public Graph getGraph() {
// return graph;
// }
//
// @Override
// public Metadata getMetadata() {
// return meta;
// }
//
// @Override
// public String getVersion() {
// return VERSION;
// }
//
// @Override
// public boolean hasVariant() {
// return (variant != null);
// }
//
// @Override
// public Gexf clearVariant() {
// variant = null;
// return this;
// }
//
// @Override
// public String getVariant() {
// checkState(hasVariant(), "Variant has not been set.");
// return variant;
// }
//
// @Override
// public Gexf setVariant(String variant) {
// checkArgument(variant != null, "Variant cannot be null.");
// checkArgument(!variant.trim().isEmpty(), "Variant cannot be empty or blank.");
// this.variant = variant;
// return this;
// }
//
// @Override
// public boolean hasVisualization() {
// return viz;
// }
//
// @Override
// public Gexf setVisualization(boolean viz) {
// this.viz = viz;
// return this;
// }
// }
// Path: src/test/java/com/ojn/gexf4j/core/testgraphs/HierarchyInlineBuilder.java
import com.ojn.gexf4j.core.EdgeType;
import com.ojn.gexf4j.core.Gexf;
import com.ojn.gexf4j.core.Mode;
import com.ojn.gexf4j.core.Node;
import com.ojn.gexf4j.core.impl.GexfImpl;
package com.ojn.gexf4j.core.testgraphs;
public class HierarchyInlineBuilder extends GexfBuilder {
@Override
public String getSuffix() {
return "hierarchyInline";
}
@Override
public Gexf buildGexf() { | Gexf gexf = new GexfImpl(); |
jmcampanini/gexf4j-core | src/test/java/com/ojn/gexf4j/core/testgraphs/HierarchyInlineBuilder.java | // Path: src/main/java/com/ojn/gexf4j/core/EdgeType.java
// public enum EdgeType {
//
// DIRECTED,
// UNDIRECTED,
// MUTUAL,
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/Gexf.java
// public interface Gexf {
//
// String getVersion();
//
// boolean hasVariant();
// Gexf clearVariant();
// String getVariant();
// Gexf setVariant(String variant);
//
// Metadata getMetadata();
//
// Graph getGraph();
//
// boolean hasVisualization();
// Gexf setVisualization(boolean viz);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/Mode.java
// public enum Mode {
//
// STATIC,
// DYNAMIC,
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/Node.java
// public interface Node extends SlicableDatum<Node>, HasNodes {
//
// String getId();
//
// String getLabel();
// Node setLabel(String label);
//
// List<Edge> getEdges();
//
// Edge connectTo(Node target);
// Edge connectTo(String id, Node target);
//
// boolean hasEdgeTo(String id);
//
// boolean hasColor();
// Node clearColor();
// Color getColor();
// Node setColor(Color color);
//
// boolean hasPosition();
// Node clearPosition();
// Position getPosition();
// Node setPosition(Position position);
//
// boolean hasSize();
// Node clearSize();
// float getSize();
// Node setSize(float size);
//
// boolean hasShape();
// Node clearShape();
// NodeShapeEntity getShapeEntity();
//
// List<Node> getParentForList();
//
// boolean hasPID();
// Node clearPID();
// String getPID();
// Node setPID(String pid);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/impl/GexfImpl.java
// public class GexfImpl implements Gexf {
// private static final String VERSION = "1.1";
//
// private String variant = null;
// private Graph graph = null;
// private Metadata meta = null;
// private boolean viz = false;
//
// public GexfImpl() {
// graph = new GraphImpl();
// meta = new MetadataImpl();
// }
//
// @Override
// public Graph getGraph() {
// return graph;
// }
//
// @Override
// public Metadata getMetadata() {
// return meta;
// }
//
// @Override
// public String getVersion() {
// return VERSION;
// }
//
// @Override
// public boolean hasVariant() {
// return (variant != null);
// }
//
// @Override
// public Gexf clearVariant() {
// variant = null;
// return this;
// }
//
// @Override
// public String getVariant() {
// checkState(hasVariant(), "Variant has not been set.");
// return variant;
// }
//
// @Override
// public Gexf setVariant(String variant) {
// checkArgument(variant != null, "Variant cannot be null.");
// checkArgument(!variant.trim().isEmpty(), "Variant cannot be empty or blank.");
// this.variant = variant;
// return this;
// }
//
// @Override
// public boolean hasVisualization() {
// return viz;
// }
//
// @Override
// public Gexf setVisualization(boolean viz) {
// this.viz = viz;
// return this;
// }
// }
| import com.ojn.gexf4j.core.EdgeType;
import com.ojn.gexf4j.core.Gexf;
import com.ojn.gexf4j.core.Mode;
import com.ojn.gexf4j.core.Node;
import com.ojn.gexf4j.core.impl.GexfImpl; | package com.ojn.gexf4j.core.testgraphs;
public class HierarchyInlineBuilder extends GexfBuilder {
@Override
public String getSuffix() {
return "hierarchyInline";
}
@Override
public Gexf buildGexf() {
Gexf gexf = new GexfImpl();
gexf.getGraph() | // Path: src/main/java/com/ojn/gexf4j/core/EdgeType.java
// public enum EdgeType {
//
// DIRECTED,
// UNDIRECTED,
// MUTUAL,
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/Gexf.java
// public interface Gexf {
//
// String getVersion();
//
// boolean hasVariant();
// Gexf clearVariant();
// String getVariant();
// Gexf setVariant(String variant);
//
// Metadata getMetadata();
//
// Graph getGraph();
//
// boolean hasVisualization();
// Gexf setVisualization(boolean viz);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/Mode.java
// public enum Mode {
//
// STATIC,
// DYNAMIC,
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/Node.java
// public interface Node extends SlicableDatum<Node>, HasNodes {
//
// String getId();
//
// String getLabel();
// Node setLabel(String label);
//
// List<Edge> getEdges();
//
// Edge connectTo(Node target);
// Edge connectTo(String id, Node target);
//
// boolean hasEdgeTo(String id);
//
// boolean hasColor();
// Node clearColor();
// Color getColor();
// Node setColor(Color color);
//
// boolean hasPosition();
// Node clearPosition();
// Position getPosition();
// Node setPosition(Position position);
//
// boolean hasSize();
// Node clearSize();
// float getSize();
// Node setSize(float size);
//
// boolean hasShape();
// Node clearShape();
// NodeShapeEntity getShapeEntity();
//
// List<Node> getParentForList();
//
// boolean hasPID();
// Node clearPID();
// String getPID();
// Node setPID(String pid);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/impl/GexfImpl.java
// public class GexfImpl implements Gexf {
// private static final String VERSION = "1.1";
//
// private String variant = null;
// private Graph graph = null;
// private Metadata meta = null;
// private boolean viz = false;
//
// public GexfImpl() {
// graph = new GraphImpl();
// meta = new MetadataImpl();
// }
//
// @Override
// public Graph getGraph() {
// return graph;
// }
//
// @Override
// public Metadata getMetadata() {
// return meta;
// }
//
// @Override
// public String getVersion() {
// return VERSION;
// }
//
// @Override
// public boolean hasVariant() {
// return (variant != null);
// }
//
// @Override
// public Gexf clearVariant() {
// variant = null;
// return this;
// }
//
// @Override
// public String getVariant() {
// checkState(hasVariant(), "Variant has not been set.");
// return variant;
// }
//
// @Override
// public Gexf setVariant(String variant) {
// checkArgument(variant != null, "Variant cannot be null.");
// checkArgument(!variant.trim().isEmpty(), "Variant cannot be empty or blank.");
// this.variant = variant;
// return this;
// }
//
// @Override
// public boolean hasVisualization() {
// return viz;
// }
//
// @Override
// public Gexf setVisualization(boolean viz) {
// this.viz = viz;
// return this;
// }
// }
// Path: src/test/java/com/ojn/gexf4j/core/testgraphs/HierarchyInlineBuilder.java
import com.ojn.gexf4j.core.EdgeType;
import com.ojn.gexf4j.core.Gexf;
import com.ojn.gexf4j.core.Mode;
import com.ojn.gexf4j.core.Node;
import com.ojn.gexf4j.core.impl.GexfImpl;
package com.ojn.gexf4j.core.testgraphs;
public class HierarchyInlineBuilder extends GexfBuilder {
@Override
public String getSuffix() {
return "hierarchyInline";
}
@Override
public Gexf buildGexf() {
Gexf gexf = new GexfImpl();
gexf.getGraph() | .setMode(Mode.STATIC) |
jmcampanini/gexf4j-core | src/test/java/com/ojn/gexf4j/core/testgraphs/HierarchyInlineBuilder.java | // Path: src/main/java/com/ojn/gexf4j/core/EdgeType.java
// public enum EdgeType {
//
// DIRECTED,
// UNDIRECTED,
// MUTUAL,
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/Gexf.java
// public interface Gexf {
//
// String getVersion();
//
// boolean hasVariant();
// Gexf clearVariant();
// String getVariant();
// Gexf setVariant(String variant);
//
// Metadata getMetadata();
//
// Graph getGraph();
//
// boolean hasVisualization();
// Gexf setVisualization(boolean viz);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/Mode.java
// public enum Mode {
//
// STATIC,
// DYNAMIC,
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/Node.java
// public interface Node extends SlicableDatum<Node>, HasNodes {
//
// String getId();
//
// String getLabel();
// Node setLabel(String label);
//
// List<Edge> getEdges();
//
// Edge connectTo(Node target);
// Edge connectTo(String id, Node target);
//
// boolean hasEdgeTo(String id);
//
// boolean hasColor();
// Node clearColor();
// Color getColor();
// Node setColor(Color color);
//
// boolean hasPosition();
// Node clearPosition();
// Position getPosition();
// Node setPosition(Position position);
//
// boolean hasSize();
// Node clearSize();
// float getSize();
// Node setSize(float size);
//
// boolean hasShape();
// Node clearShape();
// NodeShapeEntity getShapeEntity();
//
// List<Node> getParentForList();
//
// boolean hasPID();
// Node clearPID();
// String getPID();
// Node setPID(String pid);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/impl/GexfImpl.java
// public class GexfImpl implements Gexf {
// private static final String VERSION = "1.1";
//
// private String variant = null;
// private Graph graph = null;
// private Metadata meta = null;
// private boolean viz = false;
//
// public GexfImpl() {
// graph = new GraphImpl();
// meta = new MetadataImpl();
// }
//
// @Override
// public Graph getGraph() {
// return graph;
// }
//
// @Override
// public Metadata getMetadata() {
// return meta;
// }
//
// @Override
// public String getVersion() {
// return VERSION;
// }
//
// @Override
// public boolean hasVariant() {
// return (variant != null);
// }
//
// @Override
// public Gexf clearVariant() {
// variant = null;
// return this;
// }
//
// @Override
// public String getVariant() {
// checkState(hasVariant(), "Variant has not been set.");
// return variant;
// }
//
// @Override
// public Gexf setVariant(String variant) {
// checkArgument(variant != null, "Variant cannot be null.");
// checkArgument(!variant.trim().isEmpty(), "Variant cannot be empty or blank.");
// this.variant = variant;
// return this;
// }
//
// @Override
// public boolean hasVisualization() {
// return viz;
// }
//
// @Override
// public Gexf setVisualization(boolean viz) {
// this.viz = viz;
// return this;
// }
// }
| import com.ojn.gexf4j.core.EdgeType;
import com.ojn.gexf4j.core.Gexf;
import com.ojn.gexf4j.core.Mode;
import com.ojn.gexf4j.core.Node;
import com.ojn.gexf4j.core.impl.GexfImpl; | package com.ojn.gexf4j.core.testgraphs;
public class HierarchyInlineBuilder extends GexfBuilder {
@Override
public String getSuffix() {
return "hierarchyInline";
}
@Override
public Gexf buildGexf() {
Gexf gexf = new GexfImpl();
gexf.getGraph()
.setMode(Mode.STATIC) | // Path: src/main/java/com/ojn/gexf4j/core/EdgeType.java
// public enum EdgeType {
//
// DIRECTED,
// UNDIRECTED,
// MUTUAL,
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/Gexf.java
// public interface Gexf {
//
// String getVersion();
//
// boolean hasVariant();
// Gexf clearVariant();
// String getVariant();
// Gexf setVariant(String variant);
//
// Metadata getMetadata();
//
// Graph getGraph();
//
// boolean hasVisualization();
// Gexf setVisualization(boolean viz);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/Mode.java
// public enum Mode {
//
// STATIC,
// DYNAMIC,
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/Node.java
// public interface Node extends SlicableDatum<Node>, HasNodes {
//
// String getId();
//
// String getLabel();
// Node setLabel(String label);
//
// List<Edge> getEdges();
//
// Edge connectTo(Node target);
// Edge connectTo(String id, Node target);
//
// boolean hasEdgeTo(String id);
//
// boolean hasColor();
// Node clearColor();
// Color getColor();
// Node setColor(Color color);
//
// boolean hasPosition();
// Node clearPosition();
// Position getPosition();
// Node setPosition(Position position);
//
// boolean hasSize();
// Node clearSize();
// float getSize();
// Node setSize(float size);
//
// boolean hasShape();
// Node clearShape();
// NodeShapeEntity getShapeEntity();
//
// List<Node> getParentForList();
//
// boolean hasPID();
// Node clearPID();
// String getPID();
// Node setPID(String pid);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/impl/GexfImpl.java
// public class GexfImpl implements Gexf {
// private static final String VERSION = "1.1";
//
// private String variant = null;
// private Graph graph = null;
// private Metadata meta = null;
// private boolean viz = false;
//
// public GexfImpl() {
// graph = new GraphImpl();
// meta = new MetadataImpl();
// }
//
// @Override
// public Graph getGraph() {
// return graph;
// }
//
// @Override
// public Metadata getMetadata() {
// return meta;
// }
//
// @Override
// public String getVersion() {
// return VERSION;
// }
//
// @Override
// public boolean hasVariant() {
// return (variant != null);
// }
//
// @Override
// public Gexf clearVariant() {
// variant = null;
// return this;
// }
//
// @Override
// public String getVariant() {
// checkState(hasVariant(), "Variant has not been set.");
// return variant;
// }
//
// @Override
// public Gexf setVariant(String variant) {
// checkArgument(variant != null, "Variant cannot be null.");
// checkArgument(!variant.trim().isEmpty(), "Variant cannot be empty or blank.");
// this.variant = variant;
// return this;
// }
//
// @Override
// public boolean hasVisualization() {
// return viz;
// }
//
// @Override
// public Gexf setVisualization(boolean viz) {
// this.viz = viz;
// return this;
// }
// }
// Path: src/test/java/com/ojn/gexf4j/core/testgraphs/HierarchyInlineBuilder.java
import com.ojn.gexf4j.core.EdgeType;
import com.ojn.gexf4j.core.Gexf;
import com.ojn.gexf4j.core.Mode;
import com.ojn.gexf4j.core.Node;
import com.ojn.gexf4j.core.impl.GexfImpl;
package com.ojn.gexf4j.core.testgraphs;
public class HierarchyInlineBuilder extends GexfBuilder {
@Override
public String getSuffix() {
return "hierarchyInline";
}
@Override
public Gexf buildGexf() {
Gexf gexf = new GexfImpl();
gexf.getGraph()
.setMode(Mode.STATIC) | .setDefaultEdgeType(EdgeType.DIRECTED); |
jmcampanini/gexf4j-core | src/test/java/com/ojn/gexf4j/core/testgraphs/HierarchyInlineBuilder.java | // Path: src/main/java/com/ojn/gexf4j/core/EdgeType.java
// public enum EdgeType {
//
// DIRECTED,
// UNDIRECTED,
// MUTUAL,
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/Gexf.java
// public interface Gexf {
//
// String getVersion();
//
// boolean hasVariant();
// Gexf clearVariant();
// String getVariant();
// Gexf setVariant(String variant);
//
// Metadata getMetadata();
//
// Graph getGraph();
//
// boolean hasVisualization();
// Gexf setVisualization(boolean viz);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/Mode.java
// public enum Mode {
//
// STATIC,
// DYNAMIC,
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/Node.java
// public interface Node extends SlicableDatum<Node>, HasNodes {
//
// String getId();
//
// String getLabel();
// Node setLabel(String label);
//
// List<Edge> getEdges();
//
// Edge connectTo(Node target);
// Edge connectTo(String id, Node target);
//
// boolean hasEdgeTo(String id);
//
// boolean hasColor();
// Node clearColor();
// Color getColor();
// Node setColor(Color color);
//
// boolean hasPosition();
// Node clearPosition();
// Position getPosition();
// Node setPosition(Position position);
//
// boolean hasSize();
// Node clearSize();
// float getSize();
// Node setSize(float size);
//
// boolean hasShape();
// Node clearShape();
// NodeShapeEntity getShapeEntity();
//
// List<Node> getParentForList();
//
// boolean hasPID();
// Node clearPID();
// String getPID();
// Node setPID(String pid);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/impl/GexfImpl.java
// public class GexfImpl implements Gexf {
// private static final String VERSION = "1.1";
//
// private String variant = null;
// private Graph graph = null;
// private Metadata meta = null;
// private boolean viz = false;
//
// public GexfImpl() {
// graph = new GraphImpl();
// meta = new MetadataImpl();
// }
//
// @Override
// public Graph getGraph() {
// return graph;
// }
//
// @Override
// public Metadata getMetadata() {
// return meta;
// }
//
// @Override
// public String getVersion() {
// return VERSION;
// }
//
// @Override
// public boolean hasVariant() {
// return (variant != null);
// }
//
// @Override
// public Gexf clearVariant() {
// variant = null;
// return this;
// }
//
// @Override
// public String getVariant() {
// checkState(hasVariant(), "Variant has not been set.");
// return variant;
// }
//
// @Override
// public Gexf setVariant(String variant) {
// checkArgument(variant != null, "Variant cannot be null.");
// checkArgument(!variant.trim().isEmpty(), "Variant cannot be empty or blank.");
// this.variant = variant;
// return this;
// }
//
// @Override
// public boolean hasVisualization() {
// return viz;
// }
//
// @Override
// public Gexf setVisualization(boolean viz) {
// this.viz = viz;
// return this;
// }
// }
| import com.ojn.gexf4j.core.EdgeType;
import com.ojn.gexf4j.core.Gexf;
import com.ojn.gexf4j.core.Mode;
import com.ojn.gexf4j.core.Node;
import com.ojn.gexf4j.core.impl.GexfImpl; | package com.ojn.gexf4j.core.testgraphs;
public class HierarchyInlineBuilder extends GexfBuilder {
@Override
public String getSuffix() {
return "hierarchyInline";
}
@Override
public Gexf buildGexf() {
Gexf gexf = new GexfImpl();
gexf.getGraph()
.setMode(Mode.STATIC)
.setDefaultEdgeType(EdgeType.DIRECTED);
| // Path: src/main/java/com/ojn/gexf4j/core/EdgeType.java
// public enum EdgeType {
//
// DIRECTED,
// UNDIRECTED,
// MUTUAL,
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/Gexf.java
// public interface Gexf {
//
// String getVersion();
//
// boolean hasVariant();
// Gexf clearVariant();
// String getVariant();
// Gexf setVariant(String variant);
//
// Metadata getMetadata();
//
// Graph getGraph();
//
// boolean hasVisualization();
// Gexf setVisualization(boolean viz);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/Mode.java
// public enum Mode {
//
// STATIC,
// DYNAMIC,
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/Node.java
// public interface Node extends SlicableDatum<Node>, HasNodes {
//
// String getId();
//
// String getLabel();
// Node setLabel(String label);
//
// List<Edge> getEdges();
//
// Edge connectTo(Node target);
// Edge connectTo(String id, Node target);
//
// boolean hasEdgeTo(String id);
//
// boolean hasColor();
// Node clearColor();
// Color getColor();
// Node setColor(Color color);
//
// boolean hasPosition();
// Node clearPosition();
// Position getPosition();
// Node setPosition(Position position);
//
// boolean hasSize();
// Node clearSize();
// float getSize();
// Node setSize(float size);
//
// boolean hasShape();
// Node clearShape();
// NodeShapeEntity getShapeEntity();
//
// List<Node> getParentForList();
//
// boolean hasPID();
// Node clearPID();
// String getPID();
// Node setPID(String pid);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/impl/GexfImpl.java
// public class GexfImpl implements Gexf {
// private static final String VERSION = "1.1";
//
// private String variant = null;
// private Graph graph = null;
// private Metadata meta = null;
// private boolean viz = false;
//
// public GexfImpl() {
// graph = new GraphImpl();
// meta = new MetadataImpl();
// }
//
// @Override
// public Graph getGraph() {
// return graph;
// }
//
// @Override
// public Metadata getMetadata() {
// return meta;
// }
//
// @Override
// public String getVersion() {
// return VERSION;
// }
//
// @Override
// public boolean hasVariant() {
// return (variant != null);
// }
//
// @Override
// public Gexf clearVariant() {
// variant = null;
// return this;
// }
//
// @Override
// public String getVariant() {
// checkState(hasVariant(), "Variant has not been set.");
// return variant;
// }
//
// @Override
// public Gexf setVariant(String variant) {
// checkArgument(variant != null, "Variant cannot be null.");
// checkArgument(!variant.trim().isEmpty(), "Variant cannot be empty or blank.");
// this.variant = variant;
// return this;
// }
//
// @Override
// public boolean hasVisualization() {
// return viz;
// }
//
// @Override
// public Gexf setVisualization(boolean viz) {
// this.viz = viz;
// return this;
// }
// }
// Path: src/test/java/com/ojn/gexf4j/core/testgraphs/HierarchyInlineBuilder.java
import com.ojn.gexf4j.core.EdgeType;
import com.ojn.gexf4j.core.Gexf;
import com.ojn.gexf4j.core.Mode;
import com.ojn.gexf4j.core.Node;
import com.ojn.gexf4j.core.impl.GexfImpl;
package com.ojn.gexf4j.core.testgraphs;
public class HierarchyInlineBuilder extends GexfBuilder {
@Override
public String getSuffix() {
return "hierarchyInline";
}
@Override
public Gexf buildGexf() {
Gexf gexf = new GexfImpl();
gexf.getGraph()
.setMode(Mode.STATIC)
.setDefaultEdgeType(EdgeType.DIRECTED);
| Node kb = gexf.getGraph().createNode("a"); |
jmcampanini/gexf4j-core | src/test/java/com/ojn/gexf4j/core/testgraphs/GexfBuilder.java | // Path: src/main/java/com/ojn/gexf4j/core/Gexf.java
// public interface Gexf {
//
// String getVersion();
//
// boolean hasVariant();
// Gexf clearVariant();
// String getVariant();
// Gexf setVariant(String variant);
//
// Metadata getMetadata();
//
// Graph getGraph();
//
// boolean hasVisualization();
// Gexf setVisualization(boolean viz);
// }
| import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import com.ojn.gexf4j.core.Gexf; | package com.ojn.gexf4j.core.testgraphs;
public abstract class GexfBuilder {
private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
| // Path: src/main/java/com/ojn/gexf4j/core/Gexf.java
// public interface Gexf {
//
// String getVersion();
//
// boolean hasVariant();
// Gexf clearVariant();
// String getVariant();
// Gexf setVariant(String variant);
//
// Metadata getMetadata();
//
// Graph getGraph();
//
// boolean hasVisualization();
// Gexf setVisualization(boolean viz);
// }
// Path: src/test/java/com/ojn/gexf4j/core/testgraphs/GexfBuilder.java
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import com.ojn.gexf4j.core.Gexf;
package com.ojn.gexf4j.core.testgraphs;
public abstract class GexfBuilder {
private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
| public abstract Gexf buildGexf(); |
jmcampanini/gexf4j-core | src/main/java/com/ojn/gexf4j/core/impl/StaxGraphWriter.java | // Path: src/main/java/com/ojn/gexf4j/core/Gexf.java
// public interface Gexf {
//
// String getVersion();
//
// boolean hasVariant();
// Gexf clearVariant();
// String getVariant();
// Gexf setVariant(String variant);
//
// Metadata getMetadata();
//
// Graph getGraph();
//
// boolean hasVisualization();
// Gexf setVisualization(boolean viz);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/GexfWriter.java
// public interface GexfWriter {
//
// void writeToStream(Gexf gexf, OutputStream out) throws IOException;
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/impl/writer/GexfEntityWriter.java
// public class GexfEntityWriter extends AbstractEntityWriter<Gexf> {
// private static final String ENTITY = "gexf";
// private static final String ATTRIBUTE_VERSION = "version";
// private static final String ATTRIBUTE_VARIANT = "variant";
// private static final String XMLNS_URL = "http://www.gexf.net/1.1draft";
// private static final String XMLNS_VIZ = "viz";
// private static final String XMLNS_VIZ_URL = "http://www.gexf.net/1.1draft/viz";
//
// public GexfEntityWriter(XMLStreamWriter writer, Gexf entity) {
// super(writer, entity);
// write();
// }
//
// @Override
// protected String getElementName() {
// return ENTITY;
// }
//
// @Override
// protected void writeAttributes() throws XMLStreamException {
// writer.writeAttribute(
// ATTRIBUTE_VERSION,
// entity.getVersion());
//
// if (entity.hasVariant()) {
// writer.writeAttribute(
// ATTRIBUTE_VARIANT,
// entity.getVariant());
// }
// }
//
// @Override
// protected void writeStartElement() throws XMLStreamException {
// writer.writeStartElement(getElementName());
// writer.writeDefaultNamespace(XMLNS_URL);
//
// if (entity.hasVisualization()) {
// writer.writeNamespace(XMLNS_VIZ, XMLNS_VIZ_URL);
// }
// }
//
// @Override
// protected void writeElements() throws XMLStreamException {
// new MetadataEntityWriter(writer, entity.getMetadata());
// new GraphEntityWriter(writer, entity.getGraph());
// }
// }
| import java.io.IOException;
import java.io.OutputStream;
import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
import com.ojn.gexf4j.core.Gexf;
import com.ojn.gexf4j.core.GexfWriter;
import com.ojn.gexf4j.core.impl.writer.GexfEntityWriter; | package com.ojn.gexf4j.core.impl;
public class StaxGraphWriter implements GexfWriter {
@Override | // Path: src/main/java/com/ojn/gexf4j/core/Gexf.java
// public interface Gexf {
//
// String getVersion();
//
// boolean hasVariant();
// Gexf clearVariant();
// String getVariant();
// Gexf setVariant(String variant);
//
// Metadata getMetadata();
//
// Graph getGraph();
//
// boolean hasVisualization();
// Gexf setVisualization(boolean viz);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/GexfWriter.java
// public interface GexfWriter {
//
// void writeToStream(Gexf gexf, OutputStream out) throws IOException;
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/impl/writer/GexfEntityWriter.java
// public class GexfEntityWriter extends AbstractEntityWriter<Gexf> {
// private static final String ENTITY = "gexf";
// private static final String ATTRIBUTE_VERSION = "version";
// private static final String ATTRIBUTE_VARIANT = "variant";
// private static final String XMLNS_URL = "http://www.gexf.net/1.1draft";
// private static final String XMLNS_VIZ = "viz";
// private static final String XMLNS_VIZ_URL = "http://www.gexf.net/1.1draft/viz";
//
// public GexfEntityWriter(XMLStreamWriter writer, Gexf entity) {
// super(writer, entity);
// write();
// }
//
// @Override
// protected String getElementName() {
// return ENTITY;
// }
//
// @Override
// protected void writeAttributes() throws XMLStreamException {
// writer.writeAttribute(
// ATTRIBUTE_VERSION,
// entity.getVersion());
//
// if (entity.hasVariant()) {
// writer.writeAttribute(
// ATTRIBUTE_VARIANT,
// entity.getVariant());
// }
// }
//
// @Override
// protected void writeStartElement() throws XMLStreamException {
// writer.writeStartElement(getElementName());
// writer.writeDefaultNamespace(XMLNS_URL);
//
// if (entity.hasVisualization()) {
// writer.writeNamespace(XMLNS_VIZ, XMLNS_VIZ_URL);
// }
// }
//
// @Override
// protected void writeElements() throws XMLStreamException {
// new MetadataEntityWriter(writer, entity.getMetadata());
// new GraphEntityWriter(writer, entity.getGraph());
// }
// }
// Path: src/main/java/com/ojn/gexf4j/core/impl/StaxGraphWriter.java
import java.io.IOException;
import java.io.OutputStream;
import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
import com.ojn.gexf4j.core.Gexf;
import com.ojn.gexf4j.core.GexfWriter;
import com.ojn.gexf4j.core.impl.writer.GexfEntityWriter;
package com.ojn.gexf4j.core.impl;
public class StaxGraphWriter implements GexfWriter {
@Override | public void writeToStream(Gexf gexf, OutputStream out) throws IOException { |
jmcampanini/gexf4j-core | src/main/java/com/ojn/gexf4j/core/impl/StaxGraphWriter.java | // Path: src/main/java/com/ojn/gexf4j/core/Gexf.java
// public interface Gexf {
//
// String getVersion();
//
// boolean hasVariant();
// Gexf clearVariant();
// String getVariant();
// Gexf setVariant(String variant);
//
// Metadata getMetadata();
//
// Graph getGraph();
//
// boolean hasVisualization();
// Gexf setVisualization(boolean viz);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/GexfWriter.java
// public interface GexfWriter {
//
// void writeToStream(Gexf gexf, OutputStream out) throws IOException;
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/impl/writer/GexfEntityWriter.java
// public class GexfEntityWriter extends AbstractEntityWriter<Gexf> {
// private static final String ENTITY = "gexf";
// private static final String ATTRIBUTE_VERSION = "version";
// private static final String ATTRIBUTE_VARIANT = "variant";
// private static final String XMLNS_URL = "http://www.gexf.net/1.1draft";
// private static final String XMLNS_VIZ = "viz";
// private static final String XMLNS_VIZ_URL = "http://www.gexf.net/1.1draft/viz";
//
// public GexfEntityWriter(XMLStreamWriter writer, Gexf entity) {
// super(writer, entity);
// write();
// }
//
// @Override
// protected String getElementName() {
// return ENTITY;
// }
//
// @Override
// protected void writeAttributes() throws XMLStreamException {
// writer.writeAttribute(
// ATTRIBUTE_VERSION,
// entity.getVersion());
//
// if (entity.hasVariant()) {
// writer.writeAttribute(
// ATTRIBUTE_VARIANT,
// entity.getVariant());
// }
// }
//
// @Override
// protected void writeStartElement() throws XMLStreamException {
// writer.writeStartElement(getElementName());
// writer.writeDefaultNamespace(XMLNS_URL);
//
// if (entity.hasVisualization()) {
// writer.writeNamespace(XMLNS_VIZ, XMLNS_VIZ_URL);
// }
// }
//
// @Override
// protected void writeElements() throws XMLStreamException {
// new MetadataEntityWriter(writer, entity.getMetadata());
// new GraphEntityWriter(writer, entity.getGraph());
// }
// }
| import java.io.IOException;
import java.io.OutputStream;
import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
import com.ojn.gexf4j.core.Gexf;
import com.ojn.gexf4j.core.GexfWriter;
import com.ojn.gexf4j.core.impl.writer.GexfEntityWriter; | package com.ojn.gexf4j.core.impl;
public class StaxGraphWriter implements GexfWriter {
@Override
public void writeToStream(Gexf gexf, OutputStream out) throws IOException {
try {
XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
XMLStreamWriter writer = outputFactory.createXMLStreamWriter(out);
writer.writeStartDocument("1.0");
| // Path: src/main/java/com/ojn/gexf4j/core/Gexf.java
// public interface Gexf {
//
// String getVersion();
//
// boolean hasVariant();
// Gexf clearVariant();
// String getVariant();
// Gexf setVariant(String variant);
//
// Metadata getMetadata();
//
// Graph getGraph();
//
// boolean hasVisualization();
// Gexf setVisualization(boolean viz);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/GexfWriter.java
// public interface GexfWriter {
//
// void writeToStream(Gexf gexf, OutputStream out) throws IOException;
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/impl/writer/GexfEntityWriter.java
// public class GexfEntityWriter extends AbstractEntityWriter<Gexf> {
// private static final String ENTITY = "gexf";
// private static final String ATTRIBUTE_VERSION = "version";
// private static final String ATTRIBUTE_VARIANT = "variant";
// private static final String XMLNS_URL = "http://www.gexf.net/1.1draft";
// private static final String XMLNS_VIZ = "viz";
// private static final String XMLNS_VIZ_URL = "http://www.gexf.net/1.1draft/viz";
//
// public GexfEntityWriter(XMLStreamWriter writer, Gexf entity) {
// super(writer, entity);
// write();
// }
//
// @Override
// protected String getElementName() {
// return ENTITY;
// }
//
// @Override
// protected void writeAttributes() throws XMLStreamException {
// writer.writeAttribute(
// ATTRIBUTE_VERSION,
// entity.getVersion());
//
// if (entity.hasVariant()) {
// writer.writeAttribute(
// ATTRIBUTE_VARIANT,
// entity.getVariant());
// }
// }
//
// @Override
// protected void writeStartElement() throws XMLStreamException {
// writer.writeStartElement(getElementName());
// writer.writeDefaultNamespace(XMLNS_URL);
//
// if (entity.hasVisualization()) {
// writer.writeNamespace(XMLNS_VIZ, XMLNS_VIZ_URL);
// }
// }
//
// @Override
// protected void writeElements() throws XMLStreamException {
// new MetadataEntityWriter(writer, entity.getMetadata());
// new GraphEntityWriter(writer, entity.getGraph());
// }
// }
// Path: src/main/java/com/ojn/gexf4j/core/impl/StaxGraphWriter.java
import java.io.IOException;
import java.io.OutputStream;
import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
import com.ojn.gexf4j.core.Gexf;
import com.ojn.gexf4j.core.GexfWriter;
import com.ojn.gexf4j.core.impl.writer.GexfEntityWriter;
package com.ojn.gexf4j.core.impl;
public class StaxGraphWriter implements GexfWriter {
@Override
public void writeToStream(Gexf gexf, OutputStream out) throws IOException {
try {
XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
XMLStreamWriter writer = outputFactory.createXMLStreamWriter(out);
writer.writeStartDocument("1.0");
| new GexfEntityWriter(writer, gexf); |
jmcampanini/gexf4j-core | src/test/java/com/ojn/gexf4j/core/impl/data/AttributeValueImplTest.java | // Path: src/main/java/com/ojn/gexf4j/core/data/Attribute.java
// public interface Attribute {
//
// String getId();
//
// String getTitle();
// Attribute setTitle(String title);
//
// AttributeType getAttributeType();
//
// boolean hasDefaultValue();
// Attribute clearDefaultValue();
// String getDefaultValue();
// Attribute setDefaultValue(String defaultValue);
//
// List<String> getOptions();
//
// AttributeValue createValue(String value);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/data/AttributeClass.java
// public enum AttributeClass {
//
// NODE,
// EDGE,
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/data/AttributeType.java
// public enum AttributeType {
//
// INTEGER,
// LONG,
// DOUBLE,
// FLOAT,
// BOOLEAN,
// STRING,
// LISTSTRING,
// ANYURI,
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/data/AttributeValue.java
// public interface AttributeValue extends Dynamic<AttributeValue> {
//
// Attribute getAttribute();
//
// String getValue();
// AttributeValue setValue(String value);
// }
//
// Path: src/test/java/com/ojn/gexf4j/core/data/AttributeValueTest.java
// public abstract class AttributeValueTest {
//
// protected abstract Attribute newAttribute();
// protected abstract AttributeValue newAttributeValue(Attribute attrib, String value);
//
// private String value = null;
// private Attribute attrib = null;
// private AttributeValue av = null;
//
// @Before
// public void before() {
// value = UUID.randomUUID().toString();
// attrib = newAttribute();
// av = newAttributeValue(attrib, value);
// }
//
// @Test
// public void valueFor() {
// assertThat(av.getAttribute(), is(equalTo(attrib)));
// }
//
// @Test
// public void setValueValid() {
// String newValue = UUID.randomUUID().toString();
// av.setValue(newValue);
//
// assertThat(av.getValue(), is(equalTo(newValue)));
// }
//
// @Test(expected=IllegalArgumentException.class)
// public void setValueNull() {
// av.setValue(null);
// }
// }
| import java.util.UUID;
import com.ojn.gexf4j.core.data.Attribute;
import com.ojn.gexf4j.core.data.AttributeClass;
import com.ojn.gexf4j.core.data.AttributeType;
import com.ojn.gexf4j.core.data.AttributeValue;
import com.ojn.gexf4j.core.data.AttributeValueTest; | package com.ojn.gexf4j.core.impl.data;
public class AttributeValueImplTest extends AttributeValueTest {
@Override | // Path: src/main/java/com/ojn/gexf4j/core/data/Attribute.java
// public interface Attribute {
//
// String getId();
//
// String getTitle();
// Attribute setTitle(String title);
//
// AttributeType getAttributeType();
//
// boolean hasDefaultValue();
// Attribute clearDefaultValue();
// String getDefaultValue();
// Attribute setDefaultValue(String defaultValue);
//
// List<String> getOptions();
//
// AttributeValue createValue(String value);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/data/AttributeClass.java
// public enum AttributeClass {
//
// NODE,
// EDGE,
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/data/AttributeType.java
// public enum AttributeType {
//
// INTEGER,
// LONG,
// DOUBLE,
// FLOAT,
// BOOLEAN,
// STRING,
// LISTSTRING,
// ANYURI,
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/data/AttributeValue.java
// public interface AttributeValue extends Dynamic<AttributeValue> {
//
// Attribute getAttribute();
//
// String getValue();
// AttributeValue setValue(String value);
// }
//
// Path: src/test/java/com/ojn/gexf4j/core/data/AttributeValueTest.java
// public abstract class AttributeValueTest {
//
// protected abstract Attribute newAttribute();
// protected abstract AttributeValue newAttributeValue(Attribute attrib, String value);
//
// private String value = null;
// private Attribute attrib = null;
// private AttributeValue av = null;
//
// @Before
// public void before() {
// value = UUID.randomUUID().toString();
// attrib = newAttribute();
// av = newAttributeValue(attrib, value);
// }
//
// @Test
// public void valueFor() {
// assertThat(av.getAttribute(), is(equalTo(attrib)));
// }
//
// @Test
// public void setValueValid() {
// String newValue = UUID.randomUUID().toString();
// av.setValue(newValue);
//
// assertThat(av.getValue(), is(equalTo(newValue)));
// }
//
// @Test(expected=IllegalArgumentException.class)
// public void setValueNull() {
// av.setValue(null);
// }
// }
// Path: src/test/java/com/ojn/gexf4j/core/impl/data/AttributeValueImplTest.java
import java.util.UUID;
import com.ojn.gexf4j.core.data.Attribute;
import com.ojn.gexf4j.core.data.AttributeClass;
import com.ojn.gexf4j.core.data.AttributeType;
import com.ojn.gexf4j.core.data.AttributeValue;
import com.ojn.gexf4j.core.data.AttributeValueTest;
package com.ojn.gexf4j.core.impl.data;
public class AttributeValueImplTest extends AttributeValueTest {
@Override | protected Attribute newAttribute() { |
jmcampanini/gexf4j-core | src/test/java/com/ojn/gexf4j/core/impl/data/AttributeValueImplTest.java | // Path: src/main/java/com/ojn/gexf4j/core/data/Attribute.java
// public interface Attribute {
//
// String getId();
//
// String getTitle();
// Attribute setTitle(String title);
//
// AttributeType getAttributeType();
//
// boolean hasDefaultValue();
// Attribute clearDefaultValue();
// String getDefaultValue();
// Attribute setDefaultValue(String defaultValue);
//
// List<String> getOptions();
//
// AttributeValue createValue(String value);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/data/AttributeClass.java
// public enum AttributeClass {
//
// NODE,
// EDGE,
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/data/AttributeType.java
// public enum AttributeType {
//
// INTEGER,
// LONG,
// DOUBLE,
// FLOAT,
// BOOLEAN,
// STRING,
// LISTSTRING,
// ANYURI,
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/data/AttributeValue.java
// public interface AttributeValue extends Dynamic<AttributeValue> {
//
// Attribute getAttribute();
//
// String getValue();
// AttributeValue setValue(String value);
// }
//
// Path: src/test/java/com/ojn/gexf4j/core/data/AttributeValueTest.java
// public abstract class AttributeValueTest {
//
// protected abstract Attribute newAttribute();
// protected abstract AttributeValue newAttributeValue(Attribute attrib, String value);
//
// private String value = null;
// private Attribute attrib = null;
// private AttributeValue av = null;
//
// @Before
// public void before() {
// value = UUID.randomUUID().toString();
// attrib = newAttribute();
// av = newAttributeValue(attrib, value);
// }
//
// @Test
// public void valueFor() {
// assertThat(av.getAttribute(), is(equalTo(attrib)));
// }
//
// @Test
// public void setValueValid() {
// String newValue = UUID.randomUUID().toString();
// av.setValue(newValue);
//
// assertThat(av.getValue(), is(equalTo(newValue)));
// }
//
// @Test(expected=IllegalArgumentException.class)
// public void setValueNull() {
// av.setValue(null);
// }
// }
| import java.util.UUID;
import com.ojn.gexf4j.core.data.Attribute;
import com.ojn.gexf4j.core.data.AttributeClass;
import com.ojn.gexf4j.core.data.AttributeType;
import com.ojn.gexf4j.core.data.AttributeValue;
import com.ojn.gexf4j.core.data.AttributeValueTest; | package com.ojn.gexf4j.core.impl.data;
public class AttributeValueImplTest extends AttributeValueTest {
@Override
protected Attribute newAttribute() { | // Path: src/main/java/com/ojn/gexf4j/core/data/Attribute.java
// public interface Attribute {
//
// String getId();
//
// String getTitle();
// Attribute setTitle(String title);
//
// AttributeType getAttributeType();
//
// boolean hasDefaultValue();
// Attribute clearDefaultValue();
// String getDefaultValue();
// Attribute setDefaultValue(String defaultValue);
//
// List<String> getOptions();
//
// AttributeValue createValue(String value);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/data/AttributeClass.java
// public enum AttributeClass {
//
// NODE,
// EDGE,
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/data/AttributeType.java
// public enum AttributeType {
//
// INTEGER,
// LONG,
// DOUBLE,
// FLOAT,
// BOOLEAN,
// STRING,
// LISTSTRING,
// ANYURI,
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/data/AttributeValue.java
// public interface AttributeValue extends Dynamic<AttributeValue> {
//
// Attribute getAttribute();
//
// String getValue();
// AttributeValue setValue(String value);
// }
//
// Path: src/test/java/com/ojn/gexf4j/core/data/AttributeValueTest.java
// public abstract class AttributeValueTest {
//
// protected abstract Attribute newAttribute();
// protected abstract AttributeValue newAttributeValue(Attribute attrib, String value);
//
// private String value = null;
// private Attribute attrib = null;
// private AttributeValue av = null;
//
// @Before
// public void before() {
// value = UUID.randomUUID().toString();
// attrib = newAttribute();
// av = newAttributeValue(attrib, value);
// }
//
// @Test
// public void valueFor() {
// assertThat(av.getAttribute(), is(equalTo(attrib)));
// }
//
// @Test
// public void setValueValid() {
// String newValue = UUID.randomUUID().toString();
// av.setValue(newValue);
//
// assertThat(av.getValue(), is(equalTo(newValue)));
// }
//
// @Test(expected=IllegalArgumentException.class)
// public void setValueNull() {
// av.setValue(null);
// }
// }
// Path: src/test/java/com/ojn/gexf4j/core/impl/data/AttributeValueImplTest.java
import java.util.UUID;
import com.ojn.gexf4j.core.data.Attribute;
import com.ojn.gexf4j.core.data.AttributeClass;
import com.ojn.gexf4j.core.data.AttributeType;
import com.ojn.gexf4j.core.data.AttributeValue;
import com.ojn.gexf4j.core.data.AttributeValueTest;
package com.ojn.gexf4j.core.impl.data;
public class AttributeValueImplTest extends AttributeValueTest {
@Override
protected Attribute newAttribute() { | return new AttributeImpl(AttributeType.STRING, UUID.randomUUID().toString(), AttributeClass.NODE); |
jmcampanini/gexf4j-core | src/test/java/com/ojn/gexf4j/core/impl/data/AttributeValueImplTest.java | // Path: src/main/java/com/ojn/gexf4j/core/data/Attribute.java
// public interface Attribute {
//
// String getId();
//
// String getTitle();
// Attribute setTitle(String title);
//
// AttributeType getAttributeType();
//
// boolean hasDefaultValue();
// Attribute clearDefaultValue();
// String getDefaultValue();
// Attribute setDefaultValue(String defaultValue);
//
// List<String> getOptions();
//
// AttributeValue createValue(String value);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/data/AttributeClass.java
// public enum AttributeClass {
//
// NODE,
// EDGE,
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/data/AttributeType.java
// public enum AttributeType {
//
// INTEGER,
// LONG,
// DOUBLE,
// FLOAT,
// BOOLEAN,
// STRING,
// LISTSTRING,
// ANYURI,
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/data/AttributeValue.java
// public interface AttributeValue extends Dynamic<AttributeValue> {
//
// Attribute getAttribute();
//
// String getValue();
// AttributeValue setValue(String value);
// }
//
// Path: src/test/java/com/ojn/gexf4j/core/data/AttributeValueTest.java
// public abstract class AttributeValueTest {
//
// protected abstract Attribute newAttribute();
// protected abstract AttributeValue newAttributeValue(Attribute attrib, String value);
//
// private String value = null;
// private Attribute attrib = null;
// private AttributeValue av = null;
//
// @Before
// public void before() {
// value = UUID.randomUUID().toString();
// attrib = newAttribute();
// av = newAttributeValue(attrib, value);
// }
//
// @Test
// public void valueFor() {
// assertThat(av.getAttribute(), is(equalTo(attrib)));
// }
//
// @Test
// public void setValueValid() {
// String newValue = UUID.randomUUID().toString();
// av.setValue(newValue);
//
// assertThat(av.getValue(), is(equalTo(newValue)));
// }
//
// @Test(expected=IllegalArgumentException.class)
// public void setValueNull() {
// av.setValue(null);
// }
// }
| import java.util.UUID;
import com.ojn.gexf4j.core.data.Attribute;
import com.ojn.gexf4j.core.data.AttributeClass;
import com.ojn.gexf4j.core.data.AttributeType;
import com.ojn.gexf4j.core.data.AttributeValue;
import com.ojn.gexf4j.core.data.AttributeValueTest; | package com.ojn.gexf4j.core.impl.data;
public class AttributeValueImplTest extends AttributeValueTest {
@Override
protected Attribute newAttribute() { | // Path: src/main/java/com/ojn/gexf4j/core/data/Attribute.java
// public interface Attribute {
//
// String getId();
//
// String getTitle();
// Attribute setTitle(String title);
//
// AttributeType getAttributeType();
//
// boolean hasDefaultValue();
// Attribute clearDefaultValue();
// String getDefaultValue();
// Attribute setDefaultValue(String defaultValue);
//
// List<String> getOptions();
//
// AttributeValue createValue(String value);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/data/AttributeClass.java
// public enum AttributeClass {
//
// NODE,
// EDGE,
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/data/AttributeType.java
// public enum AttributeType {
//
// INTEGER,
// LONG,
// DOUBLE,
// FLOAT,
// BOOLEAN,
// STRING,
// LISTSTRING,
// ANYURI,
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/data/AttributeValue.java
// public interface AttributeValue extends Dynamic<AttributeValue> {
//
// Attribute getAttribute();
//
// String getValue();
// AttributeValue setValue(String value);
// }
//
// Path: src/test/java/com/ojn/gexf4j/core/data/AttributeValueTest.java
// public abstract class AttributeValueTest {
//
// protected abstract Attribute newAttribute();
// protected abstract AttributeValue newAttributeValue(Attribute attrib, String value);
//
// private String value = null;
// private Attribute attrib = null;
// private AttributeValue av = null;
//
// @Before
// public void before() {
// value = UUID.randomUUID().toString();
// attrib = newAttribute();
// av = newAttributeValue(attrib, value);
// }
//
// @Test
// public void valueFor() {
// assertThat(av.getAttribute(), is(equalTo(attrib)));
// }
//
// @Test
// public void setValueValid() {
// String newValue = UUID.randomUUID().toString();
// av.setValue(newValue);
//
// assertThat(av.getValue(), is(equalTo(newValue)));
// }
//
// @Test(expected=IllegalArgumentException.class)
// public void setValueNull() {
// av.setValue(null);
// }
// }
// Path: src/test/java/com/ojn/gexf4j/core/impl/data/AttributeValueImplTest.java
import java.util.UUID;
import com.ojn.gexf4j.core.data.Attribute;
import com.ojn.gexf4j.core.data.AttributeClass;
import com.ojn.gexf4j.core.data.AttributeType;
import com.ojn.gexf4j.core.data.AttributeValue;
import com.ojn.gexf4j.core.data.AttributeValueTest;
package com.ojn.gexf4j.core.impl.data;
public class AttributeValueImplTest extends AttributeValueTest {
@Override
protected Attribute newAttribute() { | return new AttributeImpl(AttributeType.STRING, UUID.randomUUID().toString(), AttributeClass.NODE); |
jmcampanini/gexf4j-core | src/test/java/com/ojn/gexf4j/core/impl/data/AttributeValueImplTest.java | // Path: src/main/java/com/ojn/gexf4j/core/data/Attribute.java
// public interface Attribute {
//
// String getId();
//
// String getTitle();
// Attribute setTitle(String title);
//
// AttributeType getAttributeType();
//
// boolean hasDefaultValue();
// Attribute clearDefaultValue();
// String getDefaultValue();
// Attribute setDefaultValue(String defaultValue);
//
// List<String> getOptions();
//
// AttributeValue createValue(String value);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/data/AttributeClass.java
// public enum AttributeClass {
//
// NODE,
// EDGE,
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/data/AttributeType.java
// public enum AttributeType {
//
// INTEGER,
// LONG,
// DOUBLE,
// FLOAT,
// BOOLEAN,
// STRING,
// LISTSTRING,
// ANYURI,
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/data/AttributeValue.java
// public interface AttributeValue extends Dynamic<AttributeValue> {
//
// Attribute getAttribute();
//
// String getValue();
// AttributeValue setValue(String value);
// }
//
// Path: src/test/java/com/ojn/gexf4j/core/data/AttributeValueTest.java
// public abstract class AttributeValueTest {
//
// protected abstract Attribute newAttribute();
// protected abstract AttributeValue newAttributeValue(Attribute attrib, String value);
//
// private String value = null;
// private Attribute attrib = null;
// private AttributeValue av = null;
//
// @Before
// public void before() {
// value = UUID.randomUUID().toString();
// attrib = newAttribute();
// av = newAttributeValue(attrib, value);
// }
//
// @Test
// public void valueFor() {
// assertThat(av.getAttribute(), is(equalTo(attrib)));
// }
//
// @Test
// public void setValueValid() {
// String newValue = UUID.randomUUID().toString();
// av.setValue(newValue);
//
// assertThat(av.getValue(), is(equalTo(newValue)));
// }
//
// @Test(expected=IllegalArgumentException.class)
// public void setValueNull() {
// av.setValue(null);
// }
// }
| import java.util.UUID;
import com.ojn.gexf4j.core.data.Attribute;
import com.ojn.gexf4j.core.data.AttributeClass;
import com.ojn.gexf4j.core.data.AttributeType;
import com.ojn.gexf4j.core.data.AttributeValue;
import com.ojn.gexf4j.core.data.AttributeValueTest; | package com.ojn.gexf4j.core.impl.data;
public class AttributeValueImplTest extends AttributeValueTest {
@Override
protected Attribute newAttribute() {
return new AttributeImpl(AttributeType.STRING, UUID.randomUUID().toString(), AttributeClass.NODE);
}
@Override | // Path: src/main/java/com/ojn/gexf4j/core/data/Attribute.java
// public interface Attribute {
//
// String getId();
//
// String getTitle();
// Attribute setTitle(String title);
//
// AttributeType getAttributeType();
//
// boolean hasDefaultValue();
// Attribute clearDefaultValue();
// String getDefaultValue();
// Attribute setDefaultValue(String defaultValue);
//
// List<String> getOptions();
//
// AttributeValue createValue(String value);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/data/AttributeClass.java
// public enum AttributeClass {
//
// NODE,
// EDGE,
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/data/AttributeType.java
// public enum AttributeType {
//
// INTEGER,
// LONG,
// DOUBLE,
// FLOAT,
// BOOLEAN,
// STRING,
// LISTSTRING,
// ANYURI,
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/data/AttributeValue.java
// public interface AttributeValue extends Dynamic<AttributeValue> {
//
// Attribute getAttribute();
//
// String getValue();
// AttributeValue setValue(String value);
// }
//
// Path: src/test/java/com/ojn/gexf4j/core/data/AttributeValueTest.java
// public abstract class AttributeValueTest {
//
// protected abstract Attribute newAttribute();
// protected abstract AttributeValue newAttributeValue(Attribute attrib, String value);
//
// private String value = null;
// private Attribute attrib = null;
// private AttributeValue av = null;
//
// @Before
// public void before() {
// value = UUID.randomUUID().toString();
// attrib = newAttribute();
// av = newAttributeValue(attrib, value);
// }
//
// @Test
// public void valueFor() {
// assertThat(av.getAttribute(), is(equalTo(attrib)));
// }
//
// @Test
// public void setValueValid() {
// String newValue = UUID.randomUUID().toString();
// av.setValue(newValue);
//
// assertThat(av.getValue(), is(equalTo(newValue)));
// }
//
// @Test(expected=IllegalArgumentException.class)
// public void setValueNull() {
// av.setValue(null);
// }
// }
// Path: src/test/java/com/ojn/gexf4j/core/impl/data/AttributeValueImplTest.java
import java.util.UUID;
import com.ojn.gexf4j.core.data.Attribute;
import com.ojn.gexf4j.core.data.AttributeClass;
import com.ojn.gexf4j.core.data.AttributeType;
import com.ojn.gexf4j.core.data.AttributeValue;
import com.ojn.gexf4j.core.data.AttributeValueTest;
package com.ojn.gexf4j.core.impl.data;
public class AttributeValueImplTest extends AttributeValueTest {
@Override
protected Attribute newAttribute() {
return new AttributeImpl(AttributeType.STRING, UUID.randomUUID().toString(), AttributeClass.NODE);
}
@Override | protected AttributeValue newAttributeValue(Attribute attrib, String value) { |
jmcampanini/gexf4j-core | src/main/java/com/ojn/gexf4j/core/Node.java | // Path: src/main/java/com/ojn/gexf4j/core/viz/Color.java
// public interface Color {
//
// int getR();
// Color setR(int r);
//
// int getG();
// Color setG(int g);
//
// int getB();
// Color setB(int b);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/viz/NodeShapeEntity.java
// public interface NodeShapeEntity {
//
// NodeShape getNodeShape();
// NodeShapeEntity setNodeShape(NodeShape shape);
//
// boolean hasUri();
// NodeShapeEntity clearUri();
// String getUri();
// NodeShapeEntity setUri(String uri);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/viz/Position.java
// public interface Position {
//
// float getX();
// Position setX(float x);
//
// float getY();
// Position setY(float y);
//
// float getZ();
// Position setZ(float z);
// }
| import java.util.List;
import com.ojn.gexf4j.core.viz.Color;
import com.ojn.gexf4j.core.viz.NodeShapeEntity;
import com.ojn.gexf4j.core.viz.Position; | package com.ojn.gexf4j.core;
public interface Node extends SlicableDatum<Node>, HasNodes {
String getId();
String getLabel();
Node setLabel(String label);
List<Edge> getEdges();
Edge connectTo(Node target);
Edge connectTo(String id, Node target);
boolean hasEdgeTo(String id);
boolean hasColor();
Node clearColor(); | // Path: src/main/java/com/ojn/gexf4j/core/viz/Color.java
// public interface Color {
//
// int getR();
// Color setR(int r);
//
// int getG();
// Color setG(int g);
//
// int getB();
// Color setB(int b);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/viz/NodeShapeEntity.java
// public interface NodeShapeEntity {
//
// NodeShape getNodeShape();
// NodeShapeEntity setNodeShape(NodeShape shape);
//
// boolean hasUri();
// NodeShapeEntity clearUri();
// String getUri();
// NodeShapeEntity setUri(String uri);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/viz/Position.java
// public interface Position {
//
// float getX();
// Position setX(float x);
//
// float getY();
// Position setY(float y);
//
// float getZ();
// Position setZ(float z);
// }
// Path: src/main/java/com/ojn/gexf4j/core/Node.java
import java.util.List;
import com.ojn.gexf4j.core.viz.Color;
import com.ojn.gexf4j.core.viz.NodeShapeEntity;
import com.ojn.gexf4j.core.viz.Position;
package com.ojn.gexf4j.core;
public interface Node extends SlicableDatum<Node>, HasNodes {
String getId();
String getLabel();
Node setLabel(String label);
List<Edge> getEdges();
Edge connectTo(Node target);
Edge connectTo(String id, Node target);
boolean hasEdgeTo(String id);
boolean hasColor();
Node clearColor(); | Color getColor(); |
jmcampanini/gexf4j-core | src/main/java/com/ojn/gexf4j/core/Node.java | // Path: src/main/java/com/ojn/gexf4j/core/viz/Color.java
// public interface Color {
//
// int getR();
// Color setR(int r);
//
// int getG();
// Color setG(int g);
//
// int getB();
// Color setB(int b);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/viz/NodeShapeEntity.java
// public interface NodeShapeEntity {
//
// NodeShape getNodeShape();
// NodeShapeEntity setNodeShape(NodeShape shape);
//
// boolean hasUri();
// NodeShapeEntity clearUri();
// String getUri();
// NodeShapeEntity setUri(String uri);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/viz/Position.java
// public interface Position {
//
// float getX();
// Position setX(float x);
//
// float getY();
// Position setY(float y);
//
// float getZ();
// Position setZ(float z);
// }
| import java.util.List;
import com.ojn.gexf4j.core.viz.Color;
import com.ojn.gexf4j.core.viz.NodeShapeEntity;
import com.ojn.gexf4j.core.viz.Position; | package com.ojn.gexf4j.core;
public interface Node extends SlicableDatum<Node>, HasNodes {
String getId();
String getLabel();
Node setLabel(String label);
List<Edge> getEdges();
Edge connectTo(Node target);
Edge connectTo(String id, Node target);
boolean hasEdgeTo(String id);
boolean hasColor();
Node clearColor();
Color getColor();
Node setColor(Color color);
boolean hasPosition();
Node clearPosition(); | // Path: src/main/java/com/ojn/gexf4j/core/viz/Color.java
// public interface Color {
//
// int getR();
// Color setR(int r);
//
// int getG();
// Color setG(int g);
//
// int getB();
// Color setB(int b);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/viz/NodeShapeEntity.java
// public interface NodeShapeEntity {
//
// NodeShape getNodeShape();
// NodeShapeEntity setNodeShape(NodeShape shape);
//
// boolean hasUri();
// NodeShapeEntity clearUri();
// String getUri();
// NodeShapeEntity setUri(String uri);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/viz/Position.java
// public interface Position {
//
// float getX();
// Position setX(float x);
//
// float getY();
// Position setY(float y);
//
// float getZ();
// Position setZ(float z);
// }
// Path: src/main/java/com/ojn/gexf4j/core/Node.java
import java.util.List;
import com.ojn.gexf4j.core.viz.Color;
import com.ojn.gexf4j.core.viz.NodeShapeEntity;
import com.ojn.gexf4j.core.viz.Position;
package com.ojn.gexf4j.core;
public interface Node extends SlicableDatum<Node>, HasNodes {
String getId();
String getLabel();
Node setLabel(String label);
List<Edge> getEdges();
Edge connectTo(Node target);
Edge connectTo(String id, Node target);
boolean hasEdgeTo(String id);
boolean hasColor();
Node clearColor();
Color getColor();
Node setColor(Color color);
boolean hasPosition();
Node clearPosition(); | Position getPosition(); |
jmcampanini/gexf4j-core | src/main/java/com/ojn/gexf4j/core/Node.java | // Path: src/main/java/com/ojn/gexf4j/core/viz/Color.java
// public interface Color {
//
// int getR();
// Color setR(int r);
//
// int getG();
// Color setG(int g);
//
// int getB();
// Color setB(int b);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/viz/NodeShapeEntity.java
// public interface NodeShapeEntity {
//
// NodeShape getNodeShape();
// NodeShapeEntity setNodeShape(NodeShape shape);
//
// boolean hasUri();
// NodeShapeEntity clearUri();
// String getUri();
// NodeShapeEntity setUri(String uri);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/viz/Position.java
// public interface Position {
//
// float getX();
// Position setX(float x);
//
// float getY();
// Position setY(float y);
//
// float getZ();
// Position setZ(float z);
// }
| import java.util.List;
import com.ojn.gexf4j.core.viz.Color;
import com.ojn.gexf4j.core.viz.NodeShapeEntity;
import com.ojn.gexf4j.core.viz.Position; | package com.ojn.gexf4j.core;
public interface Node extends SlicableDatum<Node>, HasNodes {
String getId();
String getLabel();
Node setLabel(String label);
List<Edge> getEdges();
Edge connectTo(Node target);
Edge connectTo(String id, Node target);
boolean hasEdgeTo(String id);
boolean hasColor();
Node clearColor();
Color getColor();
Node setColor(Color color);
boolean hasPosition();
Node clearPosition();
Position getPosition();
Node setPosition(Position position);
boolean hasSize();
Node clearSize();
float getSize();
Node setSize(float size);
boolean hasShape();
Node clearShape(); | // Path: src/main/java/com/ojn/gexf4j/core/viz/Color.java
// public interface Color {
//
// int getR();
// Color setR(int r);
//
// int getG();
// Color setG(int g);
//
// int getB();
// Color setB(int b);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/viz/NodeShapeEntity.java
// public interface NodeShapeEntity {
//
// NodeShape getNodeShape();
// NodeShapeEntity setNodeShape(NodeShape shape);
//
// boolean hasUri();
// NodeShapeEntity clearUri();
// String getUri();
// NodeShapeEntity setUri(String uri);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/viz/Position.java
// public interface Position {
//
// float getX();
// Position setX(float x);
//
// float getY();
// Position setY(float y);
//
// float getZ();
// Position setZ(float z);
// }
// Path: src/main/java/com/ojn/gexf4j/core/Node.java
import java.util.List;
import com.ojn.gexf4j.core.viz.Color;
import com.ojn.gexf4j.core.viz.NodeShapeEntity;
import com.ojn.gexf4j.core.viz.Position;
package com.ojn.gexf4j.core;
public interface Node extends SlicableDatum<Node>, HasNodes {
String getId();
String getLabel();
Node setLabel(String label);
List<Edge> getEdges();
Edge connectTo(Node target);
Edge connectTo(String id, Node target);
boolean hasEdgeTo(String id);
boolean hasColor();
Node clearColor();
Color getColor();
Node setColor(Color color);
boolean hasPosition();
Node clearPosition();
Position getPosition();
Node setPosition(Position position);
boolean hasSize();
Node clearSize();
float getSize();
Node setSize(float size);
boolean hasShape();
Node clearShape(); | NodeShapeEntity getShapeEntity(); |
jmcampanini/gexf4j-core | src/main/java/com/ojn/gexf4j/core/impl/writer/AttributesEntityWriter.java | // Path: src/main/java/com/ojn/gexf4j/core/data/Attribute.java
// public interface Attribute {
//
// String getId();
//
// String getTitle();
// Attribute setTitle(String title);
//
// AttributeType getAttributeType();
//
// boolean hasDefaultValue();
// Attribute clearDefaultValue();
// String getDefaultValue();
// Attribute setDefaultValue(String defaultValue);
//
// List<String> getOptions();
//
// AttributeValue createValue(String value);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/data/AttributeList.java
// public interface AttributeList extends List<Attribute>, Dynamic<AttributeList> {
//
// AttributeClass getAttributeClass();
//
// Mode getMode();
// AttributeList setMode(Mode mode);
//
// Attribute createAttribute(AttributeType type, String title);
// Attribute createAttribute(String id, AttributeType type, String title);
//
// AttributeList addAttribute(AttributeType type, String title);
// AttributeList addAttribute(String id, AttributeType type, String title);
// }
| import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
import com.ojn.gexf4j.core.data.Attribute;
import com.ojn.gexf4j.core.data.AttributeList; | package com.ojn.gexf4j.core.impl.writer;
public class AttributesEntityWriter extends DynamicEntityWriter<AttributeList> {
private static final String ENTITY = "attributes";
private static final String ATTRIB_CLASS = "class";
private static final String ATTRIB_MODE = "mode";
public AttributesEntityWriter(XMLStreamWriter writer, AttributeList entity) {
super(writer, entity);
if (!entity.isEmpty()) {
write();
}
}
@Override
protected String getElementName() {
return ENTITY;
}
@Override
protected void writeAttributes() throws XMLStreamException {
writer.writeAttribute(
ATTRIB_CLASS,
entity.getAttributeClass().toString().toLowerCase());
writer.writeAttribute(
ATTRIB_MODE,
entity.getMode().toString().toLowerCase());
}
@Override
protected void writeElements() throws XMLStreamException { | // Path: src/main/java/com/ojn/gexf4j/core/data/Attribute.java
// public interface Attribute {
//
// String getId();
//
// String getTitle();
// Attribute setTitle(String title);
//
// AttributeType getAttributeType();
//
// boolean hasDefaultValue();
// Attribute clearDefaultValue();
// String getDefaultValue();
// Attribute setDefaultValue(String defaultValue);
//
// List<String> getOptions();
//
// AttributeValue createValue(String value);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/data/AttributeList.java
// public interface AttributeList extends List<Attribute>, Dynamic<AttributeList> {
//
// AttributeClass getAttributeClass();
//
// Mode getMode();
// AttributeList setMode(Mode mode);
//
// Attribute createAttribute(AttributeType type, String title);
// Attribute createAttribute(String id, AttributeType type, String title);
//
// AttributeList addAttribute(AttributeType type, String title);
// AttributeList addAttribute(String id, AttributeType type, String title);
// }
// Path: src/main/java/com/ojn/gexf4j/core/impl/writer/AttributesEntityWriter.java
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
import com.ojn.gexf4j.core.data.Attribute;
import com.ojn.gexf4j.core.data.AttributeList;
package com.ojn.gexf4j.core.impl.writer;
public class AttributesEntityWriter extends DynamicEntityWriter<AttributeList> {
private static final String ENTITY = "attributes";
private static final String ATTRIB_CLASS = "class";
private static final String ATTRIB_MODE = "mode";
public AttributesEntityWriter(XMLStreamWriter writer, AttributeList entity) {
super(writer, entity);
if (!entity.isEmpty()) {
write();
}
}
@Override
protected String getElementName() {
return ENTITY;
}
@Override
protected void writeAttributes() throws XMLStreamException {
writer.writeAttribute(
ATTRIB_CLASS,
entity.getAttributeClass().toString().toLowerCase());
writer.writeAttribute(
ATTRIB_MODE,
entity.getMode().toString().toLowerCase());
}
@Override
protected void writeElements() throws XMLStreamException { | for (Attribute attrib : entity) { |
jmcampanini/gexf4j-core | src/main/java/com/ojn/gexf4j/core/impl/reader/NodeEntityParser.java | // Path: src/main/java/com/ojn/gexf4j/core/Graph.java
// public interface Graph extends Dynamic<Graph>, HasNodes {
//
// EdgeType getDefaultEdgeType();
// Graph setDefaultEdgeType(EdgeType edgeType);
//
// IDType getIDType();
// Graph setIDType(IDType idType);
//
// Mode getMode();
// Graph setMode(Mode graphMode);
//
// TimeType getTimeType();
// Graph setTimeType(TimeType timeType);
//
// List<AttributeList> getAttributeLists();
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/Node.java
// public interface Node extends SlicableDatum<Node>, HasNodes {
//
// String getId();
//
// String getLabel();
// Node setLabel(String label);
//
// List<Edge> getEdges();
//
// Edge connectTo(Node target);
// Edge connectTo(String id, Node target);
//
// boolean hasEdgeTo(String id);
//
// boolean hasColor();
// Node clearColor();
// Color getColor();
// Node setColor(Color color);
//
// boolean hasPosition();
// Node clearPosition();
// Position getPosition();
// Node setPosition(Position position);
//
// boolean hasSize();
// Node clearSize();
// float getSize();
// Node setSize(float size);
//
// boolean hasShape();
// Node clearShape();
// NodeShapeEntity getShapeEntity();
//
// List<Node> getParentForList();
//
// boolean hasPID();
// Node clearPID();
// String getPID();
// Node setPID(String pid);
// }
| import javax.xml.stream.XMLStreamReader;
import com.ojn.gexf4j.core.Graph;
import com.ojn.gexf4j.core.Node; | package com.ojn.gexf4j.core.impl.reader;
public class NodeEntityParser extends AbstractEntityParser<Node> {
private static final String ATTRIB_ID = "id";
private static final String ATTRIB_LABEL = "label";
// private static final String ENTITY_ATTVALUES = "attvalues";
private String id = "";
private String label = "";
// private List<AttributeValue> attributeValues = null; | // Path: src/main/java/com/ojn/gexf4j/core/Graph.java
// public interface Graph extends Dynamic<Graph>, HasNodes {
//
// EdgeType getDefaultEdgeType();
// Graph setDefaultEdgeType(EdgeType edgeType);
//
// IDType getIDType();
// Graph setIDType(IDType idType);
//
// Mode getMode();
// Graph setMode(Mode graphMode);
//
// TimeType getTimeType();
// Graph setTimeType(TimeType timeType);
//
// List<AttributeList> getAttributeLists();
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/Node.java
// public interface Node extends SlicableDatum<Node>, HasNodes {
//
// String getId();
//
// String getLabel();
// Node setLabel(String label);
//
// List<Edge> getEdges();
//
// Edge connectTo(Node target);
// Edge connectTo(String id, Node target);
//
// boolean hasEdgeTo(String id);
//
// boolean hasColor();
// Node clearColor();
// Color getColor();
// Node setColor(Color color);
//
// boolean hasPosition();
// Node clearPosition();
// Position getPosition();
// Node setPosition(Position position);
//
// boolean hasSize();
// Node clearSize();
// float getSize();
// Node setSize(float size);
//
// boolean hasShape();
// Node clearShape();
// NodeShapeEntity getShapeEntity();
//
// List<Node> getParentForList();
//
// boolean hasPID();
// Node clearPID();
// String getPID();
// Node setPID(String pid);
// }
// Path: src/main/java/com/ojn/gexf4j/core/impl/reader/NodeEntityParser.java
import javax.xml.stream.XMLStreamReader;
import com.ojn.gexf4j.core.Graph;
import com.ojn.gexf4j.core.Node;
package com.ojn.gexf4j.core.impl.reader;
public class NodeEntityParser extends AbstractEntityParser<Node> {
private static final String ATTRIB_ID = "id";
private static final String ATTRIB_LABEL = "label";
// private static final String ENTITY_ATTVALUES = "attvalues";
private String id = "";
private String label = "";
// private List<AttributeValue> attributeValues = null; | private Graph graph = null; |
jmcampanini/gexf4j-core | src/test/java/com/ojn/gexf4j/core/testgraphs/PhylogenyBuilder.java | // Path: src/main/java/com/ojn/gexf4j/core/Gexf.java
// public interface Gexf {
//
// String getVersion();
//
// boolean hasVariant();
// Gexf clearVariant();
// String getVariant();
// Gexf setVariant(String variant);
//
// Metadata getMetadata();
//
// Graph getGraph();
//
// boolean hasVisualization();
// Gexf setVisualization(boolean viz);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/Node.java
// public interface Node extends SlicableDatum<Node>, HasNodes {
//
// String getId();
//
// String getLabel();
// Node setLabel(String label);
//
// List<Edge> getEdges();
//
// Edge connectTo(Node target);
// Edge connectTo(String id, Node target);
//
// boolean hasEdgeTo(String id);
//
// boolean hasColor();
// Node clearColor();
// Color getColor();
// Node setColor(Color color);
//
// boolean hasPosition();
// Node clearPosition();
// Position getPosition();
// Node setPosition(Position position);
//
// boolean hasSize();
// Node clearSize();
// float getSize();
// Node setSize(float size);
//
// boolean hasShape();
// Node clearShape();
// NodeShapeEntity getShapeEntity();
//
// List<Node> getParentForList();
//
// boolean hasPID();
// Node clearPID();
// String getPID();
// Node setPID(String pid);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/impl/GexfImpl.java
// public class GexfImpl implements Gexf {
// private static final String VERSION = "1.1";
//
// private String variant = null;
// private Graph graph = null;
// private Metadata meta = null;
// private boolean viz = false;
//
// public GexfImpl() {
// graph = new GraphImpl();
// meta = new MetadataImpl();
// }
//
// @Override
// public Graph getGraph() {
// return graph;
// }
//
// @Override
// public Metadata getMetadata() {
// return meta;
// }
//
// @Override
// public String getVersion() {
// return VERSION;
// }
//
// @Override
// public boolean hasVariant() {
// return (variant != null);
// }
//
// @Override
// public Gexf clearVariant() {
// variant = null;
// return this;
// }
//
// @Override
// public String getVariant() {
// checkState(hasVariant(), "Variant has not been set.");
// return variant;
// }
//
// @Override
// public Gexf setVariant(String variant) {
// checkArgument(variant != null, "Variant cannot be null.");
// checkArgument(!variant.trim().isEmpty(), "Variant cannot be empty or blank.");
// this.variant = variant;
// return this;
// }
//
// @Override
// public boolean hasVisualization() {
// return viz;
// }
//
// @Override
// public Gexf setVisualization(boolean viz) {
// this.viz = viz;
// return this;
// }
// }
| import com.ojn.gexf4j.core.Gexf;
import com.ojn.gexf4j.core.Node;
import com.ojn.gexf4j.core.impl.GexfImpl; | package com.ojn.gexf4j.core.testgraphs;
public class PhylogenyBuilder extends GexfBuilder {
@Override
public String getSuffix() {
return "phylogeny";
}
@Override | // Path: src/main/java/com/ojn/gexf4j/core/Gexf.java
// public interface Gexf {
//
// String getVersion();
//
// boolean hasVariant();
// Gexf clearVariant();
// String getVariant();
// Gexf setVariant(String variant);
//
// Metadata getMetadata();
//
// Graph getGraph();
//
// boolean hasVisualization();
// Gexf setVisualization(boolean viz);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/Node.java
// public interface Node extends SlicableDatum<Node>, HasNodes {
//
// String getId();
//
// String getLabel();
// Node setLabel(String label);
//
// List<Edge> getEdges();
//
// Edge connectTo(Node target);
// Edge connectTo(String id, Node target);
//
// boolean hasEdgeTo(String id);
//
// boolean hasColor();
// Node clearColor();
// Color getColor();
// Node setColor(Color color);
//
// boolean hasPosition();
// Node clearPosition();
// Position getPosition();
// Node setPosition(Position position);
//
// boolean hasSize();
// Node clearSize();
// float getSize();
// Node setSize(float size);
//
// boolean hasShape();
// Node clearShape();
// NodeShapeEntity getShapeEntity();
//
// List<Node> getParentForList();
//
// boolean hasPID();
// Node clearPID();
// String getPID();
// Node setPID(String pid);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/impl/GexfImpl.java
// public class GexfImpl implements Gexf {
// private static final String VERSION = "1.1";
//
// private String variant = null;
// private Graph graph = null;
// private Metadata meta = null;
// private boolean viz = false;
//
// public GexfImpl() {
// graph = new GraphImpl();
// meta = new MetadataImpl();
// }
//
// @Override
// public Graph getGraph() {
// return graph;
// }
//
// @Override
// public Metadata getMetadata() {
// return meta;
// }
//
// @Override
// public String getVersion() {
// return VERSION;
// }
//
// @Override
// public boolean hasVariant() {
// return (variant != null);
// }
//
// @Override
// public Gexf clearVariant() {
// variant = null;
// return this;
// }
//
// @Override
// public String getVariant() {
// checkState(hasVariant(), "Variant has not been set.");
// return variant;
// }
//
// @Override
// public Gexf setVariant(String variant) {
// checkArgument(variant != null, "Variant cannot be null.");
// checkArgument(!variant.trim().isEmpty(), "Variant cannot be empty or blank.");
// this.variant = variant;
// return this;
// }
//
// @Override
// public boolean hasVisualization() {
// return viz;
// }
//
// @Override
// public Gexf setVisualization(boolean viz) {
// this.viz = viz;
// return this;
// }
// }
// Path: src/test/java/com/ojn/gexf4j/core/testgraphs/PhylogenyBuilder.java
import com.ojn.gexf4j.core.Gexf;
import com.ojn.gexf4j.core.Node;
import com.ojn.gexf4j.core.impl.GexfImpl;
package com.ojn.gexf4j.core.testgraphs;
public class PhylogenyBuilder extends GexfBuilder {
@Override
public String getSuffix() {
return "phylogeny";
}
@Override | public Gexf buildGexf() { |
jmcampanini/gexf4j-core | src/test/java/com/ojn/gexf4j/core/testgraphs/PhylogenyBuilder.java | // Path: src/main/java/com/ojn/gexf4j/core/Gexf.java
// public interface Gexf {
//
// String getVersion();
//
// boolean hasVariant();
// Gexf clearVariant();
// String getVariant();
// Gexf setVariant(String variant);
//
// Metadata getMetadata();
//
// Graph getGraph();
//
// boolean hasVisualization();
// Gexf setVisualization(boolean viz);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/Node.java
// public interface Node extends SlicableDatum<Node>, HasNodes {
//
// String getId();
//
// String getLabel();
// Node setLabel(String label);
//
// List<Edge> getEdges();
//
// Edge connectTo(Node target);
// Edge connectTo(String id, Node target);
//
// boolean hasEdgeTo(String id);
//
// boolean hasColor();
// Node clearColor();
// Color getColor();
// Node setColor(Color color);
//
// boolean hasPosition();
// Node clearPosition();
// Position getPosition();
// Node setPosition(Position position);
//
// boolean hasSize();
// Node clearSize();
// float getSize();
// Node setSize(float size);
//
// boolean hasShape();
// Node clearShape();
// NodeShapeEntity getShapeEntity();
//
// List<Node> getParentForList();
//
// boolean hasPID();
// Node clearPID();
// String getPID();
// Node setPID(String pid);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/impl/GexfImpl.java
// public class GexfImpl implements Gexf {
// private static final String VERSION = "1.1";
//
// private String variant = null;
// private Graph graph = null;
// private Metadata meta = null;
// private boolean viz = false;
//
// public GexfImpl() {
// graph = new GraphImpl();
// meta = new MetadataImpl();
// }
//
// @Override
// public Graph getGraph() {
// return graph;
// }
//
// @Override
// public Metadata getMetadata() {
// return meta;
// }
//
// @Override
// public String getVersion() {
// return VERSION;
// }
//
// @Override
// public boolean hasVariant() {
// return (variant != null);
// }
//
// @Override
// public Gexf clearVariant() {
// variant = null;
// return this;
// }
//
// @Override
// public String getVariant() {
// checkState(hasVariant(), "Variant has not been set.");
// return variant;
// }
//
// @Override
// public Gexf setVariant(String variant) {
// checkArgument(variant != null, "Variant cannot be null.");
// checkArgument(!variant.trim().isEmpty(), "Variant cannot be empty or blank.");
// this.variant = variant;
// return this;
// }
//
// @Override
// public boolean hasVisualization() {
// return viz;
// }
//
// @Override
// public Gexf setVisualization(boolean viz) {
// this.viz = viz;
// return this;
// }
// }
| import com.ojn.gexf4j.core.Gexf;
import com.ojn.gexf4j.core.Node;
import com.ojn.gexf4j.core.impl.GexfImpl; | package com.ojn.gexf4j.core.testgraphs;
public class PhylogenyBuilder extends GexfBuilder {
@Override
public String getSuffix() {
return "phylogeny";
}
@Override
public Gexf buildGexf() { | // Path: src/main/java/com/ojn/gexf4j/core/Gexf.java
// public interface Gexf {
//
// String getVersion();
//
// boolean hasVariant();
// Gexf clearVariant();
// String getVariant();
// Gexf setVariant(String variant);
//
// Metadata getMetadata();
//
// Graph getGraph();
//
// boolean hasVisualization();
// Gexf setVisualization(boolean viz);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/Node.java
// public interface Node extends SlicableDatum<Node>, HasNodes {
//
// String getId();
//
// String getLabel();
// Node setLabel(String label);
//
// List<Edge> getEdges();
//
// Edge connectTo(Node target);
// Edge connectTo(String id, Node target);
//
// boolean hasEdgeTo(String id);
//
// boolean hasColor();
// Node clearColor();
// Color getColor();
// Node setColor(Color color);
//
// boolean hasPosition();
// Node clearPosition();
// Position getPosition();
// Node setPosition(Position position);
//
// boolean hasSize();
// Node clearSize();
// float getSize();
// Node setSize(float size);
//
// boolean hasShape();
// Node clearShape();
// NodeShapeEntity getShapeEntity();
//
// List<Node> getParentForList();
//
// boolean hasPID();
// Node clearPID();
// String getPID();
// Node setPID(String pid);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/impl/GexfImpl.java
// public class GexfImpl implements Gexf {
// private static final String VERSION = "1.1";
//
// private String variant = null;
// private Graph graph = null;
// private Metadata meta = null;
// private boolean viz = false;
//
// public GexfImpl() {
// graph = new GraphImpl();
// meta = new MetadataImpl();
// }
//
// @Override
// public Graph getGraph() {
// return graph;
// }
//
// @Override
// public Metadata getMetadata() {
// return meta;
// }
//
// @Override
// public String getVersion() {
// return VERSION;
// }
//
// @Override
// public boolean hasVariant() {
// return (variant != null);
// }
//
// @Override
// public Gexf clearVariant() {
// variant = null;
// return this;
// }
//
// @Override
// public String getVariant() {
// checkState(hasVariant(), "Variant has not been set.");
// return variant;
// }
//
// @Override
// public Gexf setVariant(String variant) {
// checkArgument(variant != null, "Variant cannot be null.");
// checkArgument(!variant.trim().isEmpty(), "Variant cannot be empty or blank.");
// this.variant = variant;
// return this;
// }
//
// @Override
// public boolean hasVisualization() {
// return viz;
// }
//
// @Override
// public Gexf setVisualization(boolean viz) {
// this.viz = viz;
// return this;
// }
// }
// Path: src/test/java/com/ojn/gexf4j/core/testgraphs/PhylogenyBuilder.java
import com.ojn.gexf4j.core.Gexf;
import com.ojn.gexf4j.core.Node;
import com.ojn.gexf4j.core.impl.GexfImpl;
package com.ojn.gexf4j.core.testgraphs;
public class PhylogenyBuilder extends GexfBuilder {
@Override
public String getSuffix() {
return "phylogeny";
}
@Override
public Gexf buildGexf() { | Gexf gexf = new GexfImpl(); |
jmcampanini/gexf4j-core | src/test/java/com/ojn/gexf4j/core/testgraphs/PhylogenyBuilder.java | // Path: src/main/java/com/ojn/gexf4j/core/Gexf.java
// public interface Gexf {
//
// String getVersion();
//
// boolean hasVariant();
// Gexf clearVariant();
// String getVariant();
// Gexf setVariant(String variant);
//
// Metadata getMetadata();
//
// Graph getGraph();
//
// boolean hasVisualization();
// Gexf setVisualization(boolean viz);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/Node.java
// public interface Node extends SlicableDatum<Node>, HasNodes {
//
// String getId();
//
// String getLabel();
// Node setLabel(String label);
//
// List<Edge> getEdges();
//
// Edge connectTo(Node target);
// Edge connectTo(String id, Node target);
//
// boolean hasEdgeTo(String id);
//
// boolean hasColor();
// Node clearColor();
// Color getColor();
// Node setColor(Color color);
//
// boolean hasPosition();
// Node clearPosition();
// Position getPosition();
// Node setPosition(Position position);
//
// boolean hasSize();
// Node clearSize();
// float getSize();
// Node setSize(float size);
//
// boolean hasShape();
// Node clearShape();
// NodeShapeEntity getShapeEntity();
//
// List<Node> getParentForList();
//
// boolean hasPID();
// Node clearPID();
// String getPID();
// Node setPID(String pid);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/impl/GexfImpl.java
// public class GexfImpl implements Gexf {
// private static final String VERSION = "1.1";
//
// private String variant = null;
// private Graph graph = null;
// private Metadata meta = null;
// private boolean viz = false;
//
// public GexfImpl() {
// graph = new GraphImpl();
// meta = new MetadataImpl();
// }
//
// @Override
// public Graph getGraph() {
// return graph;
// }
//
// @Override
// public Metadata getMetadata() {
// return meta;
// }
//
// @Override
// public String getVersion() {
// return VERSION;
// }
//
// @Override
// public boolean hasVariant() {
// return (variant != null);
// }
//
// @Override
// public Gexf clearVariant() {
// variant = null;
// return this;
// }
//
// @Override
// public String getVariant() {
// checkState(hasVariant(), "Variant has not been set.");
// return variant;
// }
//
// @Override
// public Gexf setVariant(String variant) {
// checkArgument(variant != null, "Variant cannot be null.");
// checkArgument(!variant.trim().isEmpty(), "Variant cannot be empty or blank.");
// this.variant = variant;
// return this;
// }
//
// @Override
// public boolean hasVisualization() {
// return viz;
// }
//
// @Override
// public Gexf setVisualization(boolean viz) {
// this.viz = viz;
// return this;
// }
// }
| import com.ojn.gexf4j.core.Gexf;
import com.ojn.gexf4j.core.Node;
import com.ojn.gexf4j.core.impl.GexfImpl; | package com.ojn.gexf4j.core.testgraphs;
public class PhylogenyBuilder extends GexfBuilder {
@Override
public String getSuffix() {
return "phylogeny";
}
@Override
public Gexf buildGexf() {
Gexf gexf = new GexfImpl();
| // Path: src/main/java/com/ojn/gexf4j/core/Gexf.java
// public interface Gexf {
//
// String getVersion();
//
// boolean hasVariant();
// Gexf clearVariant();
// String getVariant();
// Gexf setVariant(String variant);
//
// Metadata getMetadata();
//
// Graph getGraph();
//
// boolean hasVisualization();
// Gexf setVisualization(boolean viz);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/Node.java
// public interface Node extends SlicableDatum<Node>, HasNodes {
//
// String getId();
//
// String getLabel();
// Node setLabel(String label);
//
// List<Edge> getEdges();
//
// Edge connectTo(Node target);
// Edge connectTo(String id, Node target);
//
// boolean hasEdgeTo(String id);
//
// boolean hasColor();
// Node clearColor();
// Color getColor();
// Node setColor(Color color);
//
// boolean hasPosition();
// Node clearPosition();
// Position getPosition();
// Node setPosition(Position position);
//
// boolean hasSize();
// Node clearSize();
// float getSize();
// Node setSize(float size);
//
// boolean hasShape();
// Node clearShape();
// NodeShapeEntity getShapeEntity();
//
// List<Node> getParentForList();
//
// boolean hasPID();
// Node clearPID();
// String getPID();
// Node setPID(String pid);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/impl/GexfImpl.java
// public class GexfImpl implements Gexf {
// private static final String VERSION = "1.1";
//
// private String variant = null;
// private Graph graph = null;
// private Metadata meta = null;
// private boolean viz = false;
//
// public GexfImpl() {
// graph = new GraphImpl();
// meta = new MetadataImpl();
// }
//
// @Override
// public Graph getGraph() {
// return graph;
// }
//
// @Override
// public Metadata getMetadata() {
// return meta;
// }
//
// @Override
// public String getVersion() {
// return VERSION;
// }
//
// @Override
// public boolean hasVariant() {
// return (variant != null);
// }
//
// @Override
// public Gexf clearVariant() {
// variant = null;
// return this;
// }
//
// @Override
// public String getVariant() {
// checkState(hasVariant(), "Variant has not been set.");
// return variant;
// }
//
// @Override
// public Gexf setVariant(String variant) {
// checkArgument(variant != null, "Variant cannot be null.");
// checkArgument(!variant.trim().isEmpty(), "Variant cannot be empty or blank.");
// this.variant = variant;
// return this;
// }
//
// @Override
// public boolean hasVisualization() {
// return viz;
// }
//
// @Override
// public Gexf setVisualization(boolean viz) {
// this.viz = viz;
// return this;
// }
// }
// Path: src/test/java/com/ojn/gexf4j/core/testgraphs/PhylogenyBuilder.java
import com.ojn.gexf4j.core.Gexf;
import com.ojn.gexf4j.core.Node;
import com.ojn.gexf4j.core.impl.GexfImpl;
package com.ojn.gexf4j.core.testgraphs;
public class PhylogenyBuilder extends GexfBuilder {
@Override
public String getSuffix() {
return "phylogeny";
}
@Override
public Gexf buildGexf() {
Gexf gexf = new GexfImpl();
| Node a = gexf.getGraph().createNode("a"); |
jmcampanini/gexf4j-core | src/test/java/com/ojn/gexf4j/core/NodeTest.java | // Path: src/main/java/com/ojn/gexf4j/core/data/Attribute.java
// public interface Attribute {
//
// String getId();
//
// String getTitle();
// Attribute setTitle(String title);
//
// AttributeType getAttributeType();
//
// boolean hasDefaultValue();
// Attribute clearDefaultValue();
// String getDefaultValue();
// Attribute setDefaultValue(String defaultValue);
//
// List<String> getOptions();
//
// AttributeValue createValue(String value);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/data/AttributeClass.java
// public enum AttributeClass {
//
// NODE,
// EDGE,
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/data/AttributeType.java
// public enum AttributeType {
//
// INTEGER,
// LONG,
// DOUBLE,
// FLOAT,
// BOOLEAN,
// STRING,
// LISTSTRING,
// ANYURI,
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/data/AttributeValue.java
// public interface AttributeValue extends Dynamic<AttributeValue> {
//
// Attribute getAttribute();
//
// String getValue();
// AttributeValue setValue(String value);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/impl/data/AttributeImpl.java
// public class AttributeImpl implements Attribute {
//
// private String id = "";
// private String defaultValue = null;
// private AttributeType type = AttributeType.STRING;
// private List<String> options = null;
// private String title = "";
//
// public AttributeImpl(String id, AttributeType type, String title) {
// checkArgument(id != null, "ID cannot be null.");
// checkArgument(!id.trim().isEmpty(), "ID cannot be empty or blank.");
// checkArgument(title != null, "Title cannot be null.");
// checkArgument(!title.trim().isEmpty(), "Title cannot be null or blank.");
//
// this.id = id;
// this.type = type;
// this.options = new ArrayList<String>();
// this.title = title;
// }
//
// @Override
// public Attribute clearDefaultValue() {
// defaultValue = null;
// return this;
// }
//
// @Override
// public AttributeType getAttributeType() {
// return type;
// }
//
// @Override
// public String getDefaultValue() {
// checkState(hasDefaultValue(), "Default Value has not been set.");
// return defaultValue;
// }
//
// @Override
// public String getId() {
// return id;
// }
//
// @Override
// public List<String> getOptions() {
// return options;
// }
//
// @Override
// public String getTitle() {
// return title;
// }
//
// @Override
// public boolean hasDefaultValue() {
// return (defaultValue != null);
// }
//
// @Override
// public Attribute setDefaultValue(String defaultValue) {
// checkArgument(defaultValue != null, "Default Value cannot be null.");
// this.defaultValue = defaultValue;
// return this;
// }
//
// @Override
// public Attribute setTitle(String title) {
// checkArgument(title != null, "Title cannot be null.");
// checkArgument(title.trim().isEmpty(), "Title cannot be null or blank.");
// this.title = title;
// return this;
// }
//
// @Override
// public AttributeValue createValue(String value) {
// checkArgument(value != null, "Value cannot be null.");
// AttributeValue rv = new AttributeValueImpl(this);
// rv.setValue(value);
// return rv;
// }
// }
| import static org.hamcrest.MatcherAssert.*;
import static org.hamcrest.Matchers.*;
import java.util.UUID;
import org.junit.Test;
import com.ojn.gexf4j.core.data.Attribute;
import com.ojn.gexf4j.core.data.AttributeClass;
import com.ojn.gexf4j.core.data.AttributeType;
import com.ojn.gexf4j.core.data.AttributeValue;
import com.ojn.gexf4j.core.impl.data.AttributeImpl; | package com.ojn.gexf4j.core;
public abstract class NodeTest {
protected abstract Node newNode(String id);
@Test
public void getId() {
String id = UUID.randomUUID().toString();
Node n = newNode(id);
assertThat(n.getId(), is(equalTo(id)));
}
@Test
public void setLabelValid() {
String label= UUID.randomUUID().toString();
Node n = newNode(UUID.randomUUID().toString());
n.setLabel(label);
assertThat(n.getLabel(), is(equalTo(label)));
}
@Test(expected=IllegalArgumentException.class)
public void setLabelNull() {
Node n = newNode(UUID.randomUUID().toString());
n.setLabel(null);
}
@Test
public void getAttributeValues() { | // Path: src/main/java/com/ojn/gexf4j/core/data/Attribute.java
// public interface Attribute {
//
// String getId();
//
// String getTitle();
// Attribute setTitle(String title);
//
// AttributeType getAttributeType();
//
// boolean hasDefaultValue();
// Attribute clearDefaultValue();
// String getDefaultValue();
// Attribute setDefaultValue(String defaultValue);
//
// List<String> getOptions();
//
// AttributeValue createValue(String value);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/data/AttributeClass.java
// public enum AttributeClass {
//
// NODE,
// EDGE,
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/data/AttributeType.java
// public enum AttributeType {
//
// INTEGER,
// LONG,
// DOUBLE,
// FLOAT,
// BOOLEAN,
// STRING,
// LISTSTRING,
// ANYURI,
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/data/AttributeValue.java
// public interface AttributeValue extends Dynamic<AttributeValue> {
//
// Attribute getAttribute();
//
// String getValue();
// AttributeValue setValue(String value);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/impl/data/AttributeImpl.java
// public class AttributeImpl implements Attribute {
//
// private String id = "";
// private String defaultValue = null;
// private AttributeType type = AttributeType.STRING;
// private List<String> options = null;
// private String title = "";
//
// public AttributeImpl(String id, AttributeType type, String title) {
// checkArgument(id != null, "ID cannot be null.");
// checkArgument(!id.trim().isEmpty(), "ID cannot be empty or blank.");
// checkArgument(title != null, "Title cannot be null.");
// checkArgument(!title.trim().isEmpty(), "Title cannot be null or blank.");
//
// this.id = id;
// this.type = type;
// this.options = new ArrayList<String>();
// this.title = title;
// }
//
// @Override
// public Attribute clearDefaultValue() {
// defaultValue = null;
// return this;
// }
//
// @Override
// public AttributeType getAttributeType() {
// return type;
// }
//
// @Override
// public String getDefaultValue() {
// checkState(hasDefaultValue(), "Default Value has not been set.");
// return defaultValue;
// }
//
// @Override
// public String getId() {
// return id;
// }
//
// @Override
// public List<String> getOptions() {
// return options;
// }
//
// @Override
// public String getTitle() {
// return title;
// }
//
// @Override
// public boolean hasDefaultValue() {
// return (defaultValue != null);
// }
//
// @Override
// public Attribute setDefaultValue(String defaultValue) {
// checkArgument(defaultValue != null, "Default Value cannot be null.");
// this.defaultValue = defaultValue;
// return this;
// }
//
// @Override
// public Attribute setTitle(String title) {
// checkArgument(title != null, "Title cannot be null.");
// checkArgument(title.trim().isEmpty(), "Title cannot be null or blank.");
// this.title = title;
// return this;
// }
//
// @Override
// public AttributeValue createValue(String value) {
// checkArgument(value != null, "Value cannot be null.");
// AttributeValue rv = new AttributeValueImpl(this);
// rv.setValue(value);
// return rv;
// }
// }
// Path: src/test/java/com/ojn/gexf4j/core/NodeTest.java
import static org.hamcrest.MatcherAssert.*;
import static org.hamcrest.Matchers.*;
import java.util.UUID;
import org.junit.Test;
import com.ojn.gexf4j.core.data.Attribute;
import com.ojn.gexf4j.core.data.AttributeClass;
import com.ojn.gexf4j.core.data.AttributeType;
import com.ojn.gexf4j.core.data.AttributeValue;
import com.ojn.gexf4j.core.impl.data.AttributeImpl;
package com.ojn.gexf4j.core;
public abstract class NodeTest {
protected abstract Node newNode(String id);
@Test
public void getId() {
String id = UUID.randomUUID().toString();
Node n = newNode(id);
assertThat(n.getId(), is(equalTo(id)));
}
@Test
public void setLabelValid() {
String label= UUID.randomUUID().toString();
Node n = newNode(UUID.randomUUID().toString());
n.setLabel(label);
assertThat(n.getLabel(), is(equalTo(label)));
}
@Test(expected=IllegalArgumentException.class)
public void setLabelNull() {
Node n = newNode(UUID.randomUUID().toString());
n.setLabel(null);
}
@Test
public void getAttributeValues() { | Attribute attrib = new AttributeImpl(AttributeType.STRING, "test", AttributeClass.NODE); |
jmcampanini/gexf4j-core | src/test/java/com/ojn/gexf4j/core/NodeTest.java | // Path: src/main/java/com/ojn/gexf4j/core/data/Attribute.java
// public interface Attribute {
//
// String getId();
//
// String getTitle();
// Attribute setTitle(String title);
//
// AttributeType getAttributeType();
//
// boolean hasDefaultValue();
// Attribute clearDefaultValue();
// String getDefaultValue();
// Attribute setDefaultValue(String defaultValue);
//
// List<String> getOptions();
//
// AttributeValue createValue(String value);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/data/AttributeClass.java
// public enum AttributeClass {
//
// NODE,
// EDGE,
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/data/AttributeType.java
// public enum AttributeType {
//
// INTEGER,
// LONG,
// DOUBLE,
// FLOAT,
// BOOLEAN,
// STRING,
// LISTSTRING,
// ANYURI,
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/data/AttributeValue.java
// public interface AttributeValue extends Dynamic<AttributeValue> {
//
// Attribute getAttribute();
//
// String getValue();
// AttributeValue setValue(String value);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/impl/data/AttributeImpl.java
// public class AttributeImpl implements Attribute {
//
// private String id = "";
// private String defaultValue = null;
// private AttributeType type = AttributeType.STRING;
// private List<String> options = null;
// private String title = "";
//
// public AttributeImpl(String id, AttributeType type, String title) {
// checkArgument(id != null, "ID cannot be null.");
// checkArgument(!id.trim().isEmpty(), "ID cannot be empty or blank.");
// checkArgument(title != null, "Title cannot be null.");
// checkArgument(!title.trim().isEmpty(), "Title cannot be null or blank.");
//
// this.id = id;
// this.type = type;
// this.options = new ArrayList<String>();
// this.title = title;
// }
//
// @Override
// public Attribute clearDefaultValue() {
// defaultValue = null;
// return this;
// }
//
// @Override
// public AttributeType getAttributeType() {
// return type;
// }
//
// @Override
// public String getDefaultValue() {
// checkState(hasDefaultValue(), "Default Value has not been set.");
// return defaultValue;
// }
//
// @Override
// public String getId() {
// return id;
// }
//
// @Override
// public List<String> getOptions() {
// return options;
// }
//
// @Override
// public String getTitle() {
// return title;
// }
//
// @Override
// public boolean hasDefaultValue() {
// return (defaultValue != null);
// }
//
// @Override
// public Attribute setDefaultValue(String defaultValue) {
// checkArgument(defaultValue != null, "Default Value cannot be null.");
// this.defaultValue = defaultValue;
// return this;
// }
//
// @Override
// public Attribute setTitle(String title) {
// checkArgument(title != null, "Title cannot be null.");
// checkArgument(title.trim().isEmpty(), "Title cannot be null or blank.");
// this.title = title;
// return this;
// }
//
// @Override
// public AttributeValue createValue(String value) {
// checkArgument(value != null, "Value cannot be null.");
// AttributeValue rv = new AttributeValueImpl(this);
// rv.setValue(value);
// return rv;
// }
// }
| import static org.hamcrest.MatcherAssert.*;
import static org.hamcrest.Matchers.*;
import java.util.UUID;
import org.junit.Test;
import com.ojn.gexf4j.core.data.Attribute;
import com.ojn.gexf4j.core.data.AttributeClass;
import com.ojn.gexf4j.core.data.AttributeType;
import com.ojn.gexf4j.core.data.AttributeValue;
import com.ojn.gexf4j.core.impl.data.AttributeImpl; | package com.ojn.gexf4j.core;
public abstract class NodeTest {
protected abstract Node newNode(String id);
@Test
public void getId() {
String id = UUID.randomUUID().toString();
Node n = newNode(id);
assertThat(n.getId(), is(equalTo(id)));
}
@Test
public void setLabelValid() {
String label= UUID.randomUUID().toString();
Node n = newNode(UUID.randomUUID().toString());
n.setLabel(label);
assertThat(n.getLabel(), is(equalTo(label)));
}
@Test(expected=IllegalArgumentException.class)
public void setLabelNull() {
Node n = newNode(UUID.randomUUID().toString());
n.setLabel(null);
}
@Test
public void getAttributeValues() { | // Path: src/main/java/com/ojn/gexf4j/core/data/Attribute.java
// public interface Attribute {
//
// String getId();
//
// String getTitle();
// Attribute setTitle(String title);
//
// AttributeType getAttributeType();
//
// boolean hasDefaultValue();
// Attribute clearDefaultValue();
// String getDefaultValue();
// Attribute setDefaultValue(String defaultValue);
//
// List<String> getOptions();
//
// AttributeValue createValue(String value);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/data/AttributeClass.java
// public enum AttributeClass {
//
// NODE,
// EDGE,
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/data/AttributeType.java
// public enum AttributeType {
//
// INTEGER,
// LONG,
// DOUBLE,
// FLOAT,
// BOOLEAN,
// STRING,
// LISTSTRING,
// ANYURI,
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/data/AttributeValue.java
// public interface AttributeValue extends Dynamic<AttributeValue> {
//
// Attribute getAttribute();
//
// String getValue();
// AttributeValue setValue(String value);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/impl/data/AttributeImpl.java
// public class AttributeImpl implements Attribute {
//
// private String id = "";
// private String defaultValue = null;
// private AttributeType type = AttributeType.STRING;
// private List<String> options = null;
// private String title = "";
//
// public AttributeImpl(String id, AttributeType type, String title) {
// checkArgument(id != null, "ID cannot be null.");
// checkArgument(!id.trim().isEmpty(), "ID cannot be empty or blank.");
// checkArgument(title != null, "Title cannot be null.");
// checkArgument(!title.trim().isEmpty(), "Title cannot be null or blank.");
//
// this.id = id;
// this.type = type;
// this.options = new ArrayList<String>();
// this.title = title;
// }
//
// @Override
// public Attribute clearDefaultValue() {
// defaultValue = null;
// return this;
// }
//
// @Override
// public AttributeType getAttributeType() {
// return type;
// }
//
// @Override
// public String getDefaultValue() {
// checkState(hasDefaultValue(), "Default Value has not been set.");
// return defaultValue;
// }
//
// @Override
// public String getId() {
// return id;
// }
//
// @Override
// public List<String> getOptions() {
// return options;
// }
//
// @Override
// public String getTitle() {
// return title;
// }
//
// @Override
// public boolean hasDefaultValue() {
// return (defaultValue != null);
// }
//
// @Override
// public Attribute setDefaultValue(String defaultValue) {
// checkArgument(defaultValue != null, "Default Value cannot be null.");
// this.defaultValue = defaultValue;
// return this;
// }
//
// @Override
// public Attribute setTitle(String title) {
// checkArgument(title != null, "Title cannot be null.");
// checkArgument(title.trim().isEmpty(), "Title cannot be null or blank.");
// this.title = title;
// return this;
// }
//
// @Override
// public AttributeValue createValue(String value) {
// checkArgument(value != null, "Value cannot be null.");
// AttributeValue rv = new AttributeValueImpl(this);
// rv.setValue(value);
// return rv;
// }
// }
// Path: src/test/java/com/ojn/gexf4j/core/NodeTest.java
import static org.hamcrest.MatcherAssert.*;
import static org.hamcrest.Matchers.*;
import java.util.UUID;
import org.junit.Test;
import com.ojn.gexf4j.core.data.Attribute;
import com.ojn.gexf4j.core.data.AttributeClass;
import com.ojn.gexf4j.core.data.AttributeType;
import com.ojn.gexf4j.core.data.AttributeValue;
import com.ojn.gexf4j.core.impl.data.AttributeImpl;
package com.ojn.gexf4j.core;
public abstract class NodeTest {
protected abstract Node newNode(String id);
@Test
public void getId() {
String id = UUID.randomUUID().toString();
Node n = newNode(id);
assertThat(n.getId(), is(equalTo(id)));
}
@Test
public void setLabelValid() {
String label= UUID.randomUUID().toString();
Node n = newNode(UUID.randomUUID().toString());
n.setLabel(label);
assertThat(n.getLabel(), is(equalTo(label)));
}
@Test(expected=IllegalArgumentException.class)
public void setLabelNull() {
Node n = newNode(UUID.randomUUID().toString());
n.setLabel(null);
}
@Test
public void getAttributeValues() { | Attribute attrib = new AttributeImpl(AttributeType.STRING, "test", AttributeClass.NODE); |
jmcampanini/gexf4j-core | src/test/java/com/ojn/gexf4j/core/NodeTest.java | // Path: src/main/java/com/ojn/gexf4j/core/data/Attribute.java
// public interface Attribute {
//
// String getId();
//
// String getTitle();
// Attribute setTitle(String title);
//
// AttributeType getAttributeType();
//
// boolean hasDefaultValue();
// Attribute clearDefaultValue();
// String getDefaultValue();
// Attribute setDefaultValue(String defaultValue);
//
// List<String> getOptions();
//
// AttributeValue createValue(String value);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/data/AttributeClass.java
// public enum AttributeClass {
//
// NODE,
// EDGE,
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/data/AttributeType.java
// public enum AttributeType {
//
// INTEGER,
// LONG,
// DOUBLE,
// FLOAT,
// BOOLEAN,
// STRING,
// LISTSTRING,
// ANYURI,
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/data/AttributeValue.java
// public interface AttributeValue extends Dynamic<AttributeValue> {
//
// Attribute getAttribute();
//
// String getValue();
// AttributeValue setValue(String value);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/impl/data/AttributeImpl.java
// public class AttributeImpl implements Attribute {
//
// private String id = "";
// private String defaultValue = null;
// private AttributeType type = AttributeType.STRING;
// private List<String> options = null;
// private String title = "";
//
// public AttributeImpl(String id, AttributeType type, String title) {
// checkArgument(id != null, "ID cannot be null.");
// checkArgument(!id.trim().isEmpty(), "ID cannot be empty or blank.");
// checkArgument(title != null, "Title cannot be null.");
// checkArgument(!title.trim().isEmpty(), "Title cannot be null or blank.");
//
// this.id = id;
// this.type = type;
// this.options = new ArrayList<String>();
// this.title = title;
// }
//
// @Override
// public Attribute clearDefaultValue() {
// defaultValue = null;
// return this;
// }
//
// @Override
// public AttributeType getAttributeType() {
// return type;
// }
//
// @Override
// public String getDefaultValue() {
// checkState(hasDefaultValue(), "Default Value has not been set.");
// return defaultValue;
// }
//
// @Override
// public String getId() {
// return id;
// }
//
// @Override
// public List<String> getOptions() {
// return options;
// }
//
// @Override
// public String getTitle() {
// return title;
// }
//
// @Override
// public boolean hasDefaultValue() {
// return (defaultValue != null);
// }
//
// @Override
// public Attribute setDefaultValue(String defaultValue) {
// checkArgument(defaultValue != null, "Default Value cannot be null.");
// this.defaultValue = defaultValue;
// return this;
// }
//
// @Override
// public Attribute setTitle(String title) {
// checkArgument(title != null, "Title cannot be null.");
// checkArgument(title.trim().isEmpty(), "Title cannot be null or blank.");
// this.title = title;
// return this;
// }
//
// @Override
// public AttributeValue createValue(String value) {
// checkArgument(value != null, "Value cannot be null.");
// AttributeValue rv = new AttributeValueImpl(this);
// rv.setValue(value);
// return rv;
// }
// }
| import static org.hamcrest.MatcherAssert.*;
import static org.hamcrest.Matchers.*;
import java.util.UUID;
import org.junit.Test;
import com.ojn.gexf4j.core.data.Attribute;
import com.ojn.gexf4j.core.data.AttributeClass;
import com.ojn.gexf4j.core.data.AttributeType;
import com.ojn.gexf4j.core.data.AttributeValue;
import com.ojn.gexf4j.core.impl.data.AttributeImpl; | package com.ojn.gexf4j.core;
public abstract class NodeTest {
protected abstract Node newNode(String id);
@Test
public void getId() {
String id = UUID.randomUUID().toString();
Node n = newNode(id);
assertThat(n.getId(), is(equalTo(id)));
}
@Test
public void setLabelValid() {
String label= UUID.randomUUID().toString();
Node n = newNode(UUID.randomUUID().toString());
n.setLabel(label);
assertThat(n.getLabel(), is(equalTo(label)));
}
@Test(expected=IllegalArgumentException.class)
public void setLabelNull() {
Node n = newNode(UUID.randomUUID().toString());
n.setLabel(null);
}
@Test
public void getAttributeValues() { | // Path: src/main/java/com/ojn/gexf4j/core/data/Attribute.java
// public interface Attribute {
//
// String getId();
//
// String getTitle();
// Attribute setTitle(String title);
//
// AttributeType getAttributeType();
//
// boolean hasDefaultValue();
// Attribute clearDefaultValue();
// String getDefaultValue();
// Attribute setDefaultValue(String defaultValue);
//
// List<String> getOptions();
//
// AttributeValue createValue(String value);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/data/AttributeClass.java
// public enum AttributeClass {
//
// NODE,
// EDGE,
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/data/AttributeType.java
// public enum AttributeType {
//
// INTEGER,
// LONG,
// DOUBLE,
// FLOAT,
// BOOLEAN,
// STRING,
// LISTSTRING,
// ANYURI,
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/data/AttributeValue.java
// public interface AttributeValue extends Dynamic<AttributeValue> {
//
// Attribute getAttribute();
//
// String getValue();
// AttributeValue setValue(String value);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/impl/data/AttributeImpl.java
// public class AttributeImpl implements Attribute {
//
// private String id = "";
// private String defaultValue = null;
// private AttributeType type = AttributeType.STRING;
// private List<String> options = null;
// private String title = "";
//
// public AttributeImpl(String id, AttributeType type, String title) {
// checkArgument(id != null, "ID cannot be null.");
// checkArgument(!id.trim().isEmpty(), "ID cannot be empty or blank.");
// checkArgument(title != null, "Title cannot be null.");
// checkArgument(!title.trim().isEmpty(), "Title cannot be null or blank.");
//
// this.id = id;
// this.type = type;
// this.options = new ArrayList<String>();
// this.title = title;
// }
//
// @Override
// public Attribute clearDefaultValue() {
// defaultValue = null;
// return this;
// }
//
// @Override
// public AttributeType getAttributeType() {
// return type;
// }
//
// @Override
// public String getDefaultValue() {
// checkState(hasDefaultValue(), "Default Value has not been set.");
// return defaultValue;
// }
//
// @Override
// public String getId() {
// return id;
// }
//
// @Override
// public List<String> getOptions() {
// return options;
// }
//
// @Override
// public String getTitle() {
// return title;
// }
//
// @Override
// public boolean hasDefaultValue() {
// return (defaultValue != null);
// }
//
// @Override
// public Attribute setDefaultValue(String defaultValue) {
// checkArgument(defaultValue != null, "Default Value cannot be null.");
// this.defaultValue = defaultValue;
// return this;
// }
//
// @Override
// public Attribute setTitle(String title) {
// checkArgument(title != null, "Title cannot be null.");
// checkArgument(title.trim().isEmpty(), "Title cannot be null or blank.");
// this.title = title;
// return this;
// }
//
// @Override
// public AttributeValue createValue(String value) {
// checkArgument(value != null, "Value cannot be null.");
// AttributeValue rv = new AttributeValueImpl(this);
// rv.setValue(value);
// return rv;
// }
// }
// Path: src/test/java/com/ojn/gexf4j/core/NodeTest.java
import static org.hamcrest.MatcherAssert.*;
import static org.hamcrest.Matchers.*;
import java.util.UUID;
import org.junit.Test;
import com.ojn.gexf4j.core.data.Attribute;
import com.ojn.gexf4j.core.data.AttributeClass;
import com.ojn.gexf4j.core.data.AttributeType;
import com.ojn.gexf4j.core.data.AttributeValue;
import com.ojn.gexf4j.core.impl.data.AttributeImpl;
package com.ojn.gexf4j.core;
public abstract class NodeTest {
protected abstract Node newNode(String id);
@Test
public void getId() {
String id = UUID.randomUUID().toString();
Node n = newNode(id);
assertThat(n.getId(), is(equalTo(id)));
}
@Test
public void setLabelValid() {
String label= UUID.randomUUID().toString();
Node n = newNode(UUID.randomUUID().toString());
n.setLabel(label);
assertThat(n.getLabel(), is(equalTo(label)));
}
@Test(expected=IllegalArgumentException.class)
public void setLabelNull() {
Node n = newNode(UUID.randomUUID().toString());
n.setLabel(null);
}
@Test
public void getAttributeValues() { | Attribute attrib = new AttributeImpl(AttributeType.STRING, "test", AttributeClass.NODE); |
jmcampanini/gexf4j-core | src/test/java/com/ojn/gexf4j/core/NodeTest.java | // Path: src/main/java/com/ojn/gexf4j/core/data/Attribute.java
// public interface Attribute {
//
// String getId();
//
// String getTitle();
// Attribute setTitle(String title);
//
// AttributeType getAttributeType();
//
// boolean hasDefaultValue();
// Attribute clearDefaultValue();
// String getDefaultValue();
// Attribute setDefaultValue(String defaultValue);
//
// List<String> getOptions();
//
// AttributeValue createValue(String value);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/data/AttributeClass.java
// public enum AttributeClass {
//
// NODE,
// EDGE,
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/data/AttributeType.java
// public enum AttributeType {
//
// INTEGER,
// LONG,
// DOUBLE,
// FLOAT,
// BOOLEAN,
// STRING,
// LISTSTRING,
// ANYURI,
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/data/AttributeValue.java
// public interface AttributeValue extends Dynamic<AttributeValue> {
//
// Attribute getAttribute();
//
// String getValue();
// AttributeValue setValue(String value);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/impl/data/AttributeImpl.java
// public class AttributeImpl implements Attribute {
//
// private String id = "";
// private String defaultValue = null;
// private AttributeType type = AttributeType.STRING;
// private List<String> options = null;
// private String title = "";
//
// public AttributeImpl(String id, AttributeType type, String title) {
// checkArgument(id != null, "ID cannot be null.");
// checkArgument(!id.trim().isEmpty(), "ID cannot be empty or blank.");
// checkArgument(title != null, "Title cannot be null.");
// checkArgument(!title.trim().isEmpty(), "Title cannot be null or blank.");
//
// this.id = id;
// this.type = type;
// this.options = new ArrayList<String>();
// this.title = title;
// }
//
// @Override
// public Attribute clearDefaultValue() {
// defaultValue = null;
// return this;
// }
//
// @Override
// public AttributeType getAttributeType() {
// return type;
// }
//
// @Override
// public String getDefaultValue() {
// checkState(hasDefaultValue(), "Default Value has not been set.");
// return defaultValue;
// }
//
// @Override
// public String getId() {
// return id;
// }
//
// @Override
// public List<String> getOptions() {
// return options;
// }
//
// @Override
// public String getTitle() {
// return title;
// }
//
// @Override
// public boolean hasDefaultValue() {
// return (defaultValue != null);
// }
//
// @Override
// public Attribute setDefaultValue(String defaultValue) {
// checkArgument(defaultValue != null, "Default Value cannot be null.");
// this.defaultValue = defaultValue;
// return this;
// }
//
// @Override
// public Attribute setTitle(String title) {
// checkArgument(title != null, "Title cannot be null.");
// checkArgument(title.trim().isEmpty(), "Title cannot be null or blank.");
// this.title = title;
// return this;
// }
//
// @Override
// public AttributeValue createValue(String value) {
// checkArgument(value != null, "Value cannot be null.");
// AttributeValue rv = new AttributeValueImpl(this);
// rv.setValue(value);
// return rv;
// }
// }
| import static org.hamcrest.MatcherAssert.*;
import static org.hamcrest.Matchers.*;
import java.util.UUID;
import org.junit.Test;
import com.ojn.gexf4j.core.data.Attribute;
import com.ojn.gexf4j.core.data.AttributeClass;
import com.ojn.gexf4j.core.data.AttributeType;
import com.ojn.gexf4j.core.data.AttributeValue;
import com.ojn.gexf4j.core.impl.data.AttributeImpl; | package com.ojn.gexf4j.core;
public abstract class NodeTest {
protected abstract Node newNode(String id);
@Test
public void getId() {
String id = UUID.randomUUID().toString();
Node n = newNode(id);
assertThat(n.getId(), is(equalTo(id)));
}
@Test
public void setLabelValid() {
String label= UUID.randomUUID().toString();
Node n = newNode(UUID.randomUUID().toString());
n.setLabel(label);
assertThat(n.getLabel(), is(equalTo(label)));
}
@Test(expected=IllegalArgumentException.class)
public void setLabelNull() {
Node n = newNode(UUID.randomUUID().toString());
n.setLabel(null);
}
@Test
public void getAttributeValues() { | // Path: src/main/java/com/ojn/gexf4j/core/data/Attribute.java
// public interface Attribute {
//
// String getId();
//
// String getTitle();
// Attribute setTitle(String title);
//
// AttributeType getAttributeType();
//
// boolean hasDefaultValue();
// Attribute clearDefaultValue();
// String getDefaultValue();
// Attribute setDefaultValue(String defaultValue);
//
// List<String> getOptions();
//
// AttributeValue createValue(String value);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/data/AttributeClass.java
// public enum AttributeClass {
//
// NODE,
// EDGE,
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/data/AttributeType.java
// public enum AttributeType {
//
// INTEGER,
// LONG,
// DOUBLE,
// FLOAT,
// BOOLEAN,
// STRING,
// LISTSTRING,
// ANYURI,
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/data/AttributeValue.java
// public interface AttributeValue extends Dynamic<AttributeValue> {
//
// Attribute getAttribute();
//
// String getValue();
// AttributeValue setValue(String value);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/impl/data/AttributeImpl.java
// public class AttributeImpl implements Attribute {
//
// private String id = "";
// private String defaultValue = null;
// private AttributeType type = AttributeType.STRING;
// private List<String> options = null;
// private String title = "";
//
// public AttributeImpl(String id, AttributeType type, String title) {
// checkArgument(id != null, "ID cannot be null.");
// checkArgument(!id.trim().isEmpty(), "ID cannot be empty or blank.");
// checkArgument(title != null, "Title cannot be null.");
// checkArgument(!title.trim().isEmpty(), "Title cannot be null or blank.");
//
// this.id = id;
// this.type = type;
// this.options = new ArrayList<String>();
// this.title = title;
// }
//
// @Override
// public Attribute clearDefaultValue() {
// defaultValue = null;
// return this;
// }
//
// @Override
// public AttributeType getAttributeType() {
// return type;
// }
//
// @Override
// public String getDefaultValue() {
// checkState(hasDefaultValue(), "Default Value has not been set.");
// return defaultValue;
// }
//
// @Override
// public String getId() {
// return id;
// }
//
// @Override
// public List<String> getOptions() {
// return options;
// }
//
// @Override
// public String getTitle() {
// return title;
// }
//
// @Override
// public boolean hasDefaultValue() {
// return (defaultValue != null);
// }
//
// @Override
// public Attribute setDefaultValue(String defaultValue) {
// checkArgument(defaultValue != null, "Default Value cannot be null.");
// this.defaultValue = defaultValue;
// return this;
// }
//
// @Override
// public Attribute setTitle(String title) {
// checkArgument(title != null, "Title cannot be null.");
// checkArgument(title.trim().isEmpty(), "Title cannot be null or blank.");
// this.title = title;
// return this;
// }
//
// @Override
// public AttributeValue createValue(String value) {
// checkArgument(value != null, "Value cannot be null.");
// AttributeValue rv = new AttributeValueImpl(this);
// rv.setValue(value);
// return rv;
// }
// }
// Path: src/test/java/com/ojn/gexf4j/core/NodeTest.java
import static org.hamcrest.MatcherAssert.*;
import static org.hamcrest.Matchers.*;
import java.util.UUID;
import org.junit.Test;
import com.ojn.gexf4j.core.data.Attribute;
import com.ojn.gexf4j.core.data.AttributeClass;
import com.ojn.gexf4j.core.data.AttributeType;
import com.ojn.gexf4j.core.data.AttributeValue;
import com.ojn.gexf4j.core.impl.data.AttributeImpl;
package com.ojn.gexf4j.core;
public abstract class NodeTest {
protected abstract Node newNode(String id);
@Test
public void getId() {
String id = UUID.randomUUID().toString();
Node n = newNode(id);
assertThat(n.getId(), is(equalTo(id)));
}
@Test
public void setLabelValid() {
String label= UUID.randomUUID().toString();
Node n = newNode(UUID.randomUUID().toString());
n.setLabel(label);
assertThat(n.getLabel(), is(equalTo(label)));
}
@Test(expected=IllegalArgumentException.class)
public void setLabelNull() {
Node n = newNode(UUID.randomUUID().toString());
n.setLabel(null);
}
@Test
public void getAttributeValues() { | Attribute attrib = new AttributeImpl(AttributeType.STRING, "test", AttributeClass.NODE); |
jmcampanini/gexf4j-core | src/test/java/com/ojn/gexf4j/core/NodeTest.java | // Path: src/main/java/com/ojn/gexf4j/core/data/Attribute.java
// public interface Attribute {
//
// String getId();
//
// String getTitle();
// Attribute setTitle(String title);
//
// AttributeType getAttributeType();
//
// boolean hasDefaultValue();
// Attribute clearDefaultValue();
// String getDefaultValue();
// Attribute setDefaultValue(String defaultValue);
//
// List<String> getOptions();
//
// AttributeValue createValue(String value);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/data/AttributeClass.java
// public enum AttributeClass {
//
// NODE,
// EDGE,
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/data/AttributeType.java
// public enum AttributeType {
//
// INTEGER,
// LONG,
// DOUBLE,
// FLOAT,
// BOOLEAN,
// STRING,
// LISTSTRING,
// ANYURI,
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/data/AttributeValue.java
// public interface AttributeValue extends Dynamic<AttributeValue> {
//
// Attribute getAttribute();
//
// String getValue();
// AttributeValue setValue(String value);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/impl/data/AttributeImpl.java
// public class AttributeImpl implements Attribute {
//
// private String id = "";
// private String defaultValue = null;
// private AttributeType type = AttributeType.STRING;
// private List<String> options = null;
// private String title = "";
//
// public AttributeImpl(String id, AttributeType type, String title) {
// checkArgument(id != null, "ID cannot be null.");
// checkArgument(!id.trim().isEmpty(), "ID cannot be empty or blank.");
// checkArgument(title != null, "Title cannot be null.");
// checkArgument(!title.trim().isEmpty(), "Title cannot be null or blank.");
//
// this.id = id;
// this.type = type;
// this.options = new ArrayList<String>();
// this.title = title;
// }
//
// @Override
// public Attribute clearDefaultValue() {
// defaultValue = null;
// return this;
// }
//
// @Override
// public AttributeType getAttributeType() {
// return type;
// }
//
// @Override
// public String getDefaultValue() {
// checkState(hasDefaultValue(), "Default Value has not been set.");
// return defaultValue;
// }
//
// @Override
// public String getId() {
// return id;
// }
//
// @Override
// public List<String> getOptions() {
// return options;
// }
//
// @Override
// public String getTitle() {
// return title;
// }
//
// @Override
// public boolean hasDefaultValue() {
// return (defaultValue != null);
// }
//
// @Override
// public Attribute setDefaultValue(String defaultValue) {
// checkArgument(defaultValue != null, "Default Value cannot be null.");
// this.defaultValue = defaultValue;
// return this;
// }
//
// @Override
// public Attribute setTitle(String title) {
// checkArgument(title != null, "Title cannot be null.");
// checkArgument(title.trim().isEmpty(), "Title cannot be null or blank.");
// this.title = title;
// return this;
// }
//
// @Override
// public AttributeValue createValue(String value) {
// checkArgument(value != null, "Value cannot be null.");
// AttributeValue rv = new AttributeValueImpl(this);
// rv.setValue(value);
// return rv;
// }
// }
| import static org.hamcrest.MatcherAssert.*;
import static org.hamcrest.Matchers.*;
import java.util.UUID;
import org.junit.Test;
import com.ojn.gexf4j.core.data.Attribute;
import com.ojn.gexf4j.core.data.AttributeClass;
import com.ojn.gexf4j.core.data.AttributeType;
import com.ojn.gexf4j.core.data.AttributeValue;
import com.ojn.gexf4j.core.impl.data.AttributeImpl; | package com.ojn.gexf4j.core;
public abstract class NodeTest {
protected abstract Node newNode(String id);
@Test
public void getId() {
String id = UUID.randomUUID().toString();
Node n = newNode(id);
assertThat(n.getId(), is(equalTo(id)));
}
@Test
public void setLabelValid() {
String label= UUID.randomUUID().toString();
Node n = newNode(UUID.randomUUID().toString());
n.setLabel(label);
assertThat(n.getLabel(), is(equalTo(label)));
}
@Test(expected=IllegalArgumentException.class)
public void setLabelNull() {
Node n = newNode(UUID.randomUUID().toString());
n.setLabel(null);
}
@Test
public void getAttributeValues() {
Attribute attrib = new AttributeImpl(AttributeType.STRING, "test", AttributeClass.NODE); | // Path: src/main/java/com/ojn/gexf4j/core/data/Attribute.java
// public interface Attribute {
//
// String getId();
//
// String getTitle();
// Attribute setTitle(String title);
//
// AttributeType getAttributeType();
//
// boolean hasDefaultValue();
// Attribute clearDefaultValue();
// String getDefaultValue();
// Attribute setDefaultValue(String defaultValue);
//
// List<String> getOptions();
//
// AttributeValue createValue(String value);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/data/AttributeClass.java
// public enum AttributeClass {
//
// NODE,
// EDGE,
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/data/AttributeType.java
// public enum AttributeType {
//
// INTEGER,
// LONG,
// DOUBLE,
// FLOAT,
// BOOLEAN,
// STRING,
// LISTSTRING,
// ANYURI,
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/data/AttributeValue.java
// public interface AttributeValue extends Dynamic<AttributeValue> {
//
// Attribute getAttribute();
//
// String getValue();
// AttributeValue setValue(String value);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/impl/data/AttributeImpl.java
// public class AttributeImpl implements Attribute {
//
// private String id = "";
// private String defaultValue = null;
// private AttributeType type = AttributeType.STRING;
// private List<String> options = null;
// private String title = "";
//
// public AttributeImpl(String id, AttributeType type, String title) {
// checkArgument(id != null, "ID cannot be null.");
// checkArgument(!id.trim().isEmpty(), "ID cannot be empty or blank.");
// checkArgument(title != null, "Title cannot be null.");
// checkArgument(!title.trim().isEmpty(), "Title cannot be null or blank.");
//
// this.id = id;
// this.type = type;
// this.options = new ArrayList<String>();
// this.title = title;
// }
//
// @Override
// public Attribute clearDefaultValue() {
// defaultValue = null;
// return this;
// }
//
// @Override
// public AttributeType getAttributeType() {
// return type;
// }
//
// @Override
// public String getDefaultValue() {
// checkState(hasDefaultValue(), "Default Value has not been set.");
// return defaultValue;
// }
//
// @Override
// public String getId() {
// return id;
// }
//
// @Override
// public List<String> getOptions() {
// return options;
// }
//
// @Override
// public String getTitle() {
// return title;
// }
//
// @Override
// public boolean hasDefaultValue() {
// return (defaultValue != null);
// }
//
// @Override
// public Attribute setDefaultValue(String defaultValue) {
// checkArgument(defaultValue != null, "Default Value cannot be null.");
// this.defaultValue = defaultValue;
// return this;
// }
//
// @Override
// public Attribute setTitle(String title) {
// checkArgument(title != null, "Title cannot be null.");
// checkArgument(title.trim().isEmpty(), "Title cannot be null or blank.");
// this.title = title;
// return this;
// }
//
// @Override
// public AttributeValue createValue(String value) {
// checkArgument(value != null, "Value cannot be null.");
// AttributeValue rv = new AttributeValueImpl(this);
// rv.setValue(value);
// return rv;
// }
// }
// Path: src/test/java/com/ojn/gexf4j/core/NodeTest.java
import static org.hamcrest.MatcherAssert.*;
import static org.hamcrest.Matchers.*;
import java.util.UUID;
import org.junit.Test;
import com.ojn.gexf4j.core.data.Attribute;
import com.ojn.gexf4j.core.data.AttributeClass;
import com.ojn.gexf4j.core.data.AttributeType;
import com.ojn.gexf4j.core.data.AttributeValue;
import com.ojn.gexf4j.core.impl.data.AttributeImpl;
package com.ojn.gexf4j.core;
public abstract class NodeTest {
protected abstract Node newNode(String id);
@Test
public void getId() {
String id = UUID.randomUUID().toString();
Node n = newNode(id);
assertThat(n.getId(), is(equalTo(id)));
}
@Test
public void setLabelValid() {
String label= UUID.randomUUID().toString();
Node n = newNode(UUID.randomUUID().toString());
n.setLabel(label);
assertThat(n.getLabel(), is(equalTo(label)));
}
@Test(expected=IllegalArgumentException.class)
public void setLabelNull() {
Node n = newNode(UUID.randomUUID().toString());
n.setLabel(null);
}
@Test
public void getAttributeValues() {
Attribute attrib = new AttributeImpl(AttributeType.STRING, "test", AttributeClass.NODE); | AttributeValue av = attrib.createValue("testing"); |
jmcampanini/gexf4j-core | src/main/java/com/ojn/gexf4j/core/impl/SliceableDatumBase.java | // Path: src/main/java/com/ojn/gexf4j/core/SlicableDatum.java
// public interface SlicableDatum<T extends Object> extends Slicable<T>, Datum {
//
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/data/AttributeValueList.java
// public interface AttributeValueList extends List<AttributeValue> {
//
// AttributeValueList addValue(Attribute attribute, String value);
//
// AttributeValue createValue(Attribute attribute, String value);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/impl/data/AttributeValueListImpl.java
// public class AttributeValueListImpl extends ArrayList<AttributeValue> implements AttributeValueList {
// private static final long serialVersionUID = 7730475001078826140L;
//
// public AttributeValueListImpl() {
// // do nothing
// }
//
// @Override
// public AttributeValueList addValue(Attribute attribute, String value) {
// createValue(attribute, value);
// return this;
// }
//
// @Override
// public AttributeValue createValue(Attribute attribute, String value) {
// checkArgument(value != null, "Value cannot be null.");
//
// AttributeValue rv = new AttributeValueImpl(attribute);
// rv.setValue(value);
// add(rv);
//
// return rv;
// }
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/impl/dynamic/SlicableBase.java
// public abstract class SlicableBase<T extends Object> extends DynamicBase<T> implements Slicable<T> {
//
// private List<Slice> slices = null;
//
// public SlicableBase() {
// slices = new ArrayList<Slice>();
// }
//
// @Override
// public List<Slice> getSlices() {
// return slices;
// }
// }
| import com.ojn.gexf4j.core.SlicableDatum;
import com.ojn.gexf4j.core.data.AttributeValueList;
import com.ojn.gexf4j.core.impl.data.AttributeValueListImpl;
import com.ojn.gexf4j.core.impl.dynamic.SlicableBase; | package com.ojn.gexf4j.core.impl;
public abstract class SliceableDatumBase<T extends Object> extends SlicableBase<T> implements SlicableDatum<T> {
private AttributeValueList attributes = null;
public SliceableDatumBase() { | // Path: src/main/java/com/ojn/gexf4j/core/SlicableDatum.java
// public interface SlicableDatum<T extends Object> extends Slicable<T>, Datum {
//
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/data/AttributeValueList.java
// public interface AttributeValueList extends List<AttributeValue> {
//
// AttributeValueList addValue(Attribute attribute, String value);
//
// AttributeValue createValue(Attribute attribute, String value);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/impl/data/AttributeValueListImpl.java
// public class AttributeValueListImpl extends ArrayList<AttributeValue> implements AttributeValueList {
// private static final long serialVersionUID = 7730475001078826140L;
//
// public AttributeValueListImpl() {
// // do nothing
// }
//
// @Override
// public AttributeValueList addValue(Attribute attribute, String value) {
// createValue(attribute, value);
// return this;
// }
//
// @Override
// public AttributeValue createValue(Attribute attribute, String value) {
// checkArgument(value != null, "Value cannot be null.");
//
// AttributeValue rv = new AttributeValueImpl(attribute);
// rv.setValue(value);
// add(rv);
//
// return rv;
// }
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/impl/dynamic/SlicableBase.java
// public abstract class SlicableBase<T extends Object> extends DynamicBase<T> implements Slicable<T> {
//
// private List<Slice> slices = null;
//
// public SlicableBase() {
// slices = new ArrayList<Slice>();
// }
//
// @Override
// public List<Slice> getSlices() {
// return slices;
// }
// }
// Path: src/main/java/com/ojn/gexf4j/core/impl/SliceableDatumBase.java
import com.ojn.gexf4j.core.SlicableDatum;
import com.ojn.gexf4j.core.data.AttributeValueList;
import com.ojn.gexf4j.core.impl.data.AttributeValueListImpl;
import com.ojn.gexf4j.core.impl.dynamic.SlicableBase;
package com.ojn.gexf4j.core.impl;
public abstract class SliceableDatumBase<T extends Object> extends SlicableBase<T> implements SlicableDatum<T> {
private AttributeValueList attributes = null;
public SliceableDatumBase() { | attributes = new AttributeValueListImpl(); |
jmcampanini/gexf4j-core | src/main/java/com/ojn/gexf4j/core/Graph.java | // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeList.java
// public interface AttributeList extends List<Attribute>, Dynamic<AttributeList> {
//
// AttributeClass getAttributeClass();
//
// Mode getMode();
// AttributeList setMode(Mode mode);
//
// Attribute createAttribute(AttributeType type, String title);
// Attribute createAttribute(String id, AttributeType type, String title);
//
// AttributeList addAttribute(AttributeType type, String title);
// AttributeList addAttribute(String id, AttributeType type, String title);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/dynamic/Dynamic.java
// public interface Dynamic<T extends Object> {
//
// boolean hasStartDate();
// T clearStartDate();
// Date getStartDate();
// T setStartDate(Date startDate);
//
// boolean hasEndDate();
// T clearEndDate();
// Date getEndDate();
// T setEndDate(Date endDate);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/dynamic/TimeType.java
// public enum TimeType {
//
// DATE,
// FLOAT,
// }
| import java.util.List;
import com.ojn.gexf4j.core.data.AttributeList;
import com.ojn.gexf4j.core.dynamic.Dynamic;
import com.ojn.gexf4j.core.dynamic.TimeType; | package com.ojn.gexf4j.core;
public interface Graph extends Dynamic<Graph>, HasNodes {
EdgeType getDefaultEdgeType();
Graph setDefaultEdgeType(EdgeType edgeType);
IDType getIDType();
Graph setIDType(IDType idType);
Mode getMode();
Graph setMode(Mode graphMode);
| // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeList.java
// public interface AttributeList extends List<Attribute>, Dynamic<AttributeList> {
//
// AttributeClass getAttributeClass();
//
// Mode getMode();
// AttributeList setMode(Mode mode);
//
// Attribute createAttribute(AttributeType type, String title);
// Attribute createAttribute(String id, AttributeType type, String title);
//
// AttributeList addAttribute(AttributeType type, String title);
// AttributeList addAttribute(String id, AttributeType type, String title);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/dynamic/Dynamic.java
// public interface Dynamic<T extends Object> {
//
// boolean hasStartDate();
// T clearStartDate();
// Date getStartDate();
// T setStartDate(Date startDate);
//
// boolean hasEndDate();
// T clearEndDate();
// Date getEndDate();
// T setEndDate(Date endDate);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/dynamic/TimeType.java
// public enum TimeType {
//
// DATE,
// FLOAT,
// }
// Path: src/main/java/com/ojn/gexf4j/core/Graph.java
import java.util.List;
import com.ojn.gexf4j.core.data.AttributeList;
import com.ojn.gexf4j.core.dynamic.Dynamic;
import com.ojn.gexf4j.core.dynamic.TimeType;
package com.ojn.gexf4j.core;
public interface Graph extends Dynamic<Graph>, HasNodes {
EdgeType getDefaultEdgeType();
Graph setDefaultEdgeType(EdgeType edgeType);
IDType getIDType();
Graph setIDType(IDType idType);
Mode getMode();
Graph setMode(Mode graphMode);
| TimeType getTimeType(); |
jmcampanini/gexf4j-core | src/main/java/com/ojn/gexf4j/core/Graph.java | // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeList.java
// public interface AttributeList extends List<Attribute>, Dynamic<AttributeList> {
//
// AttributeClass getAttributeClass();
//
// Mode getMode();
// AttributeList setMode(Mode mode);
//
// Attribute createAttribute(AttributeType type, String title);
// Attribute createAttribute(String id, AttributeType type, String title);
//
// AttributeList addAttribute(AttributeType type, String title);
// AttributeList addAttribute(String id, AttributeType type, String title);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/dynamic/Dynamic.java
// public interface Dynamic<T extends Object> {
//
// boolean hasStartDate();
// T clearStartDate();
// Date getStartDate();
// T setStartDate(Date startDate);
//
// boolean hasEndDate();
// T clearEndDate();
// Date getEndDate();
// T setEndDate(Date endDate);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/dynamic/TimeType.java
// public enum TimeType {
//
// DATE,
// FLOAT,
// }
| import java.util.List;
import com.ojn.gexf4j.core.data.AttributeList;
import com.ojn.gexf4j.core.dynamic.Dynamic;
import com.ojn.gexf4j.core.dynamic.TimeType; | package com.ojn.gexf4j.core;
public interface Graph extends Dynamic<Graph>, HasNodes {
EdgeType getDefaultEdgeType();
Graph setDefaultEdgeType(EdgeType edgeType);
IDType getIDType();
Graph setIDType(IDType idType);
Mode getMode();
Graph setMode(Mode graphMode);
TimeType getTimeType();
Graph setTimeType(TimeType timeType);
| // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeList.java
// public interface AttributeList extends List<Attribute>, Dynamic<AttributeList> {
//
// AttributeClass getAttributeClass();
//
// Mode getMode();
// AttributeList setMode(Mode mode);
//
// Attribute createAttribute(AttributeType type, String title);
// Attribute createAttribute(String id, AttributeType type, String title);
//
// AttributeList addAttribute(AttributeType type, String title);
// AttributeList addAttribute(String id, AttributeType type, String title);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/dynamic/Dynamic.java
// public interface Dynamic<T extends Object> {
//
// boolean hasStartDate();
// T clearStartDate();
// Date getStartDate();
// T setStartDate(Date startDate);
//
// boolean hasEndDate();
// T clearEndDate();
// Date getEndDate();
// T setEndDate(Date endDate);
// }
//
// Path: src/main/java/com/ojn/gexf4j/core/dynamic/TimeType.java
// public enum TimeType {
//
// DATE,
// FLOAT,
// }
// Path: src/main/java/com/ojn/gexf4j/core/Graph.java
import java.util.List;
import com.ojn.gexf4j.core.data.AttributeList;
import com.ojn.gexf4j.core.dynamic.Dynamic;
import com.ojn.gexf4j.core.dynamic.TimeType;
package com.ojn.gexf4j.core;
public interface Graph extends Dynamic<Graph>, HasNodes {
EdgeType getDefaultEdgeType();
Graph setDefaultEdgeType(EdgeType edgeType);
IDType getIDType();
Graph setIDType(IDType idType);
Mode getMode();
Graph setMode(Mode graphMode);
TimeType getTimeType();
Graph setTimeType(TimeType timeType);
| List<AttributeList> getAttributeLists(); |
deniotokiari/training-epam-2016 | MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/db/Contract.java | // Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/model/contract/User.java
// @Table(name = "USER")
// public final class User {
//
// @dbInteger
// public static final String ID = "id";
//
// @dbString
// public static final String TITLE = "title";
//
// @dbLong
// public static final String DATE = "date";
//
// }
| import com.example.mikhail_sianko.myapplication.model.contract.User; | package com.example.mikhail_sianko.myapplication.db;
public final class Contract {
public static final Class<?>[] MODELS =
{ | // Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/model/contract/User.java
// @Table(name = "USER")
// public final class User {
//
// @dbInteger
// public static final String ID = "id";
//
// @dbString
// public static final String TITLE = "title";
//
// @dbLong
// public static final String DATE = "date";
//
// }
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/db/Contract.java
import com.example.mikhail_sianko.myapplication.model.contract.User;
package com.example.mikhail_sianko.myapplication.db;
public final class Contract {
public static final Class<?>[] MODELS =
{ | User.class, |
deniotokiari/training-epam-2016 | MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/threads/operation/DBOperation.java | // Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/threads/Operation.java
// public interface Operation<Params, Progress, Result> {
//
// Result doing(Params params, ProgressCallback<Progress> progressCallback) throws Exception;
//
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/threads/ProgressCallback.java
// public interface ProgressCallback<Progress> {
//
// void onProgressChanged(Progress progress);
//
// }
| import android.util.Log;
import com.example.mikhail_sianko.myapplication.threads.Operation;
import com.example.mikhail_sianko.myapplication.threads.ProgressCallback; | package com.example.mikhail_sianko.myapplication.threads.operation;
public class DBOperation implements Operation<Integer, Integer, String> {
public static final String TAG = DBOperation.class.getSimpleName();
@Override | // Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/threads/Operation.java
// public interface Operation<Params, Progress, Result> {
//
// Result doing(Params params, ProgressCallback<Progress> progressCallback) throws Exception;
//
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/threads/ProgressCallback.java
// public interface ProgressCallback<Progress> {
//
// void onProgressChanged(Progress progress);
//
// }
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/threads/operation/DBOperation.java
import android.util.Log;
import com.example.mikhail_sianko.myapplication.threads.Operation;
import com.example.mikhail_sianko.myapplication.threads.ProgressCallback;
package com.example.mikhail_sianko.myapplication.threads.operation;
public class DBOperation implements Operation<Integer, Integer, String> {
public static final String TAG = DBOperation.class.getSimpleName();
@Override | public String doing(final Integer count, final ProgressCallback<Integer> progressCallback) throws Exception { |
deniotokiari/training-epam-2016 | MyApplication/app/src/test/java/com/example/mikhail_sianko/myapplication/DbTest.java | // Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/db/DbHelper.java
// public class DbHelper extends SQLiteOpenHelper implements IDbOperations {
//
// private static final String SQL_TABLE_CREATE_TEMPLATE = "CREATE TABLE IF NOT EXISTS %s (%s);";
// private static final String SQL_TABLE_CREATE_FIELD_TEMPLATE = "%s %s";
//
// public DbHelper(final Context context, final String name, final int version) {
// super(context, name, null, version);
// }
//
// @Nullable
// public static String getTableName(final AnnotatedElement clazz) {
// final Table table = clazz.getAnnotation(Table.class);
//
// if (table != null) {
// return table.name();
// } else {
// return null;
// }
// }
//
// @Nullable
// public static String getTableCreateQuery(final Class<?> clazz) {
// final Table table = clazz.getAnnotation(Table.class);
//
// if (table != null) {
// try {
// final String name = table.name();
//
// final StringBuilder builder = new StringBuilder();
// final Field[] fields = clazz.getFields();
//
// for (int i = 0; i < fields.length; i++) {
// final Field field = fields[i];
//
// final Annotation[] annotations = field.getAnnotations();
//
// String type = null;
//
// for (final Annotation annotation : annotations) {
// if (annotation instanceof dbInteger) {
// type = ((dbInteger) annotation).value();
// } else if (annotation instanceof dbLong) {
// type = ((dbLong) annotation).value();
// } else if (annotation instanceof dbString) {
// type = ((dbString) annotation).value();
// }
// }
//
// if (type == null) {
// return null;
// }
//
// final String value = (String) field.get(null);
//
// builder.append(String.format(Locale.US, SQL_TABLE_CREATE_FIELD_TEMPLATE, value, type));
//
// if (i < fields.length - 1) {
// builder.append(",");
// }
// }
//
// return String.format(Locale.US, SQL_TABLE_CREATE_TEMPLATE, name, builder);
// } catch (final Exception e) {
// return null;
// }
// } else {
// return null;
// }
// }
//
// @Override
// public void onCreate(final SQLiteDatabase db) {
// for (final Class<?> clazz : Contract.MODELS) {
// final String sql = getTableCreateQuery(clazz);
//
// if (sql != null) {
// db.execSQL(sql);
// }
// }
// }
//
// @Override
// public void onUpgrade(final SQLiteDatabase db, final int oldVersion, final int newVersion) {
//
// }
//
// @Override
// public Cursor query(final String sql, final String... args) {
// final SQLiteDatabase database = getReadableDatabase();
//
// return database.rawQuery(sql, args);
// }
//
// @Override
// public long insert(final Class<?> table, final ContentValues values) {
// final String name = getTableName(table);
//
// if (name != null) {
// final SQLiteDatabase database = getWritableDatabase();
// long id;
//
// try {
// database.beginTransaction();
//
// id = database.insert(name, null, values);
//
// database.setTransactionSuccessful();
// } finally {
// database.endTransaction();
// }
//
// return id;
// } else {
// throw new RuntimeException();
// }
// }
//
// @Override
// public int bulkInsert(final Class<?> table, final List<ContentValues> values) {
// final String name = getTableName(table);
//
// if (name != null) {
// final SQLiteDatabase database = getWritableDatabase();
// int count = 0;
//
// try {
// database.beginTransaction();
//
// for (final ContentValues value : values) {
// database.insert(name, null, value);
//
// count++;
// }
//
// database.setTransactionSuccessful();
// } finally {
// database.endTransaction();
// }
//
// return count;
// } else {
// throw new RuntimeException();
// }
// }
//
// @Override
// public int delete(final Class<?> table, final String sql, final String... args) {
// final String name = getTableName(table);
//
// if (name != null) {
// final SQLiteDatabase database = getWritableDatabase();
// int count = 0;
//
// try {
// database.beginTransaction();
//
// count = database.delete(name, sql, args);
//
// database.setTransactionSuccessful();
// } finally {
// database.endTransaction();
// }
//
// return count;
// } else {
// throw new RuntimeException();
// }
// }
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/model/contract/User.java
// @Table(name = "USER")
// public final class User {
//
// @dbInteger
// public static final String ID = "id";
//
// @dbString
// public static final String TITLE = "title";
//
// @dbLong
// public static final String DATE = "date";
//
// }
| import com.example.mikhail_sianko.myapplication.db.DbHelper;
import com.example.mikhail_sianko.myapplication.model.contract.User;
import org.junit.Assert;
import org.junit.Test; | package com.example.mikhail_sianko.myapplication;
public class DbTest {
@Test
public void testCreateTableStatement() { | // Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/db/DbHelper.java
// public class DbHelper extends SQLiteOpenHelper implements IDbOperations {
//
// private static final String SQL_TABLE_CREATE_TEMPLATE = "CREATE TABLE IF NOT EXISTS %s (%s);";
// private static final String SQL_TABLE_CREATE_FIELD_TEMPLATE = "%s %s";
//
// public DbHelper(final Context context, final String name, final int version) {
// super(context, name, null, version);
// }
//
// @Nullable
// public static String getTableName(final AnnotatedElement clazz) {
// final Table table = clazz.getAnnotation(Table.class);
//
// if (table != null) {
// return table.name();
// } else {
// return null;
// }
// }
//
// @Nullable
// public static String getTableCreateQuery(final Class<?> clazz) {
// final Table table = clazz.getAnnotation(Table.class);
//
// if (table != null) {
// try {
// final String name = table.name();
//
// final StringBuilder builder = new StringBuilder();
// final Field[] fields = clazz.getFields();
//
// for (int i = 0; i < fields.length; i++) {
// final Field field = fields[i];
//
// final Annotation[] annotations = field.getAnnotations();
//
// String type = null;
//
// for (final Annotation annotation : annotations) {
// if (annotation instanceof dbInteger) {
// type = ((dbInteger) annotation).value();
// } else if (annotation instanceof dbLong) {
// type = ((dbLong) annotation).value();
// } else if (annotation instanceof dbString) {
// type = ((dbString) annotation).value();
// }
// }
//
// if (type == null) {
// return null;
// }
//
// final String value = (String) field.get(null);
//
// builder.append(String.format(Locale.US, SQL_TABLE_CREATE_FIELD_TEMPLATE, value, type));
//
// if (i < fields.length - 1) {
// builder.append(",");
// }
// }
//
// return String.format(Locale.US, SQL_TABLE_CREATE_TEMPLATE, name, builder);
// } catch (final Exception e) {
// return null;
// }
// } else {
// return null;
// }
// }
//
// @Override
// public void onCreate(final SQLiteDatabase db) {
// for (final Class<?> clazz : Contract.MODELS) {
// final String sql = getTableCreateQuery(clazz);
//
// if (sql != null) {
// db.execSQL(sql);
// }
// }
// }
//
// @Override
// public void onUpgrade(final SQLiteDatabase db, final int oldVersion, final int newVersion) {
//
// }
//
// @Override
// public Cursor query(final String sql, final String... args) {
// final SQLiteDatabase database = getReadableDatabase();
//
// return database.rawQuery(sql, args);
// }
//
// @Override
// public long insert(final Class<?> table, final ContentValues values) {
// final String name = getTableName(table);
//
// if (name != null) {
// final SQLiteDatabase database = getWritableDatabase();
// long id;
//
// try {
// database.beginTransaction();
//
// id = database.insert(name, null, values);
//
// database.setTransactionSuccessful();
// } finally {
// database.endTransaction();
// }
//
// return id;
// } else {
// throw new RuntimeException();
// }
// }
//
// @Override
// public int bulkInsert(final Class<?> table, final List<ContentValues> values) {
// final String name = getTableName(table);
//
// if (name != null) {
// final SQLiteDatabase database = getWritableDatabase();
// int count = 0;
//
// try {
// database.beginTransaction();
//
// for (final ContentValues value : values) {
// database.insert(name, null, value);
//
// count++;
// }
//
// database.setTransactionSuccessful();
// } finally {
// database.endTransaction();
// }
//
// return count;
// } else {
// throw new RuntimeException();
// }
// }
//
// @Override
// public int delete(final Class<?> table, final String sql, final String... args) {
// final String name = getTableName(table);
//
// if (name != null) {
// final SQLiteDatabase database = getWritableDatabase();
// int count = 0;
//
// try {
// database.beginTransaction();
//
// count = database.delete(name, sql, args);
//
// database.setTransactionSuccessful();
// } finally {
// database.endTransaction();
// }
//
// return count;
// } else {
// throw new RuntimeException();
// }
// }
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/model/contract/User.java
// @Table(name = "USER")
// public final class User {
//
// @dbInteger
// public static final String ID = "id";
//
// @dbString
// public static final String TITLE = "title";
//
// @dbLong
// public static final String DATE = "date";
//
// }
// Path: MyApplication/app/src/test/java/com/example/mikhail_sianko/myapplication/DbTest.java
import com.example.mikhail_sianko.myapplication.db.DbHelper;
import com.example.mikhail_sianko.myapplication.model.contract.User;
import org.junit.Assert;
import org.junit.Test;
package com.example.mikhail_sianko.myapplication;
public class DbTest {
@Test
public void testCreateTableStatement() { | final String sql = DbHelper.getTableCreateQuery(User.class); |
deniotokiari/training-epam-2016 | MyApplication/app/src/test/java/com/example/mikhail_sianko/myapplication/DbTest.java | // Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/db/DbHelper.java
// public class DbHelper extends SQLiteOpenHelper implements IDbOperations {
//
// private static final String SQL_TABLE_CREATE_TEMPLATE = "CREATE TABLE IF NOT EXISTS %s (%s);";
// private static final String SQL_TABLE_CREATE_FIELD_TEMPLATE = "%s %s";
//
// public DbHelper(final Context context, final String name, final int version) {
// super(context, name, null, version);
// }
//
// @Nullable
// public static String getTableName(final AnnotatedElement clazz) {
// final Table table = clazz.getAnnotation(Table.class);
//
// if (table != null) {
// return table.name();
// } else {
// return null;
// }
// }
//
// @Nullable
// public static String getTableCreateQuery(final Class<?> clazz) {
// final Table table = clazz.getAnnotation(Table.class);
//
// if (table != null) {
// try {
// final String name = table.name();
//
// final StringBuilder builder = new StringBuilder();
// final Field[] fields = clazz.getFields();
//
// for (int i = 0; i < fields.length; i++) {
// final Field field = fields[i];
//
// final Annotation[] annotations = field.getAnnotations();
//
// String type = null;
//
// for (final Annotation annotation : annotations) {
// if (annotation instanceof dbInteger) {
// type = ((dbInteger) annotation).value();
// } else if (annotation instanceof dbLong) {
// type = ((dbLong) annotation).value();
// } else if (annotation instanceof dbString) {
// type = ((dbString) annotation).value();
// }
// }
//
// if (type == null) {
// return null;
// }
//
// final String value = (String) field.get(null);
//
// builder.append(String.format(Locale.US, SQL_TABLE_CREATE_FIELD_TEMPLATE, value, type));
//
// if (i < fields.length - 1) {
// builder.append(",");
// }
// }
//
// return String.format(Locale.US, SQL_TABLE_CREATE_TEMPLATE, name, builder);
// } catch (final Exception e) {
// return null;
// }
// } else {
// return null;
// }
// }
//
// @Override
// public void onCreate(final SQLiteDatabase db) {
// for (final Class<?> clazz : Contract.MODELS) {
// final String sql = getTableCreateQuery(clazz);
//
// if (sql != null) {
// db.execSQL(sql);
// }
// }
// }
//
// @Override
// public void onUpgrade(final SQLiteDatabase db, final int oldVersion, final int newVersion) {
//
// }
//
// @Override
// public Cursor query(final String sql, final String... args) {
// final SQLiteDatabase database = getReadableDatabase();
//
// return database.rawQuery(sql, args);
// }
//
// @Override
// public long insert(final Class<?> table, final ContentValues values) {
// final String name = getTableName(table);
//
// if (name != null) {
// final SQLiteDatabase database = getWritableDatabase();
// long id;
//
// try {
// database.beginTransaction();
//
// id = database.insert(name, null, values);
//
// database.setTransactionSuccessful();
// } finally {
// database.endTransaction();
// }
//
// return id;
// } else {
// throw new RuntimeException();
// }
// }
//
// @Override
// public int bulkInsert(final Class<?> table, final List<ContentValues> values) {
// final String name = getTableName(table);
//
// if (name != null) {
// final SQLiteDatabase database = getWritableDatabase();
// int count = 0;
//
// try {
// database.beginTransaction();
//
// for (final ContentValues value : values) {
// database.insert(name, null, value);
//
// count++;
// }
//
// database.setTransactionSuccessful();
// } finally {
// database.endTransaction();
// }
//
// return count;
// } else {
// throw new RuntimeException();
// }
// }
//
// @Override
// public int delete(final Class<?> table, final String sql, final String... args) {
// final String name = getTableName(table);
//
// if (name != null) {
// final SQLiteDatabase database = getWritableDatabase();
// int count = 0;
//
// try {
// database.beginTransaction();
//
// count = database.delete(name, sql, args);
//
// database.setTransactionSuccessful();
// } finally {
// database.endTransaction();
// }
//
// return count;
// } else {
// throw new RuntimeException();
// }
// }
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/model/contract/User.java
// @Table(name = "USER")
// public final class User {
//
// @dbInteger
// public static final String ID = "id";
//
// @dbString
// public static final String TITLE = "title";
//
// @dbLong
// public static final String DATE = "date";
//
// }
| import com.example.mikhail_sianko.myapplication.db.DbHelper;
import com.example.mikhail_sianko.myapplication.model.contract.User;
import org.junit.Assert;
import org.junit.Test; | package com.example.mikhail_sianko.myapplication;
public class DbTest {
@Test
public void testCreateTableStatement() { | // Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/db/DbHelper.java
// public class DbHelper extends SQLiteOpenHelper implements IDbOperations {
//
// private static final String SQL_TABLE_CREATE_TEMPLATE = "CREATE TABLE IF NOT EXISTS %s (%s);";
// private static final String SQL_TABLE_CREATE_FIELD_TEMPLATE = "%s %s";
//
// public DbHelper(final Context context, final String name, final int version) {
// super(context, name, null, version);
// }
//
// @Nullable
// public static String getTableName(final AnnotatedElement clazz) {
// final Table table = clazz.getAnnotation(Table.class);
//
// if (table != null) {
// return table.name();
// } else {
// return null;
// }
// }
//
// @Nullable
// public static String getTableCreateQuery(final Class<?> clazz) {
// final Table table = clazz.getAnnotation(Table.class);
//
// if (table != null) {
// try {
// final String name = table.name();
//
// final StringBuilder builder = new StringBuilder();
// final Field[] fields = clazz.getFields();
//
// for (int i = 0; i < fields.length; i++) {
// final Field field = fields[i];
//
// final Annotation[] annotations = field.getAnnotations();
//
// String type = null;
//
// for (final Annotation annotation : annotations) {
// if (annotation instanceof dbInteger) {
// type = ((dbInteger) annotation).value();
// } else if (annotation instanceof dbLong) {
// type = ((dbLong) annotation).value();
// } else if (annotation instanceof dbString) {
// type = ((dbString) annotation).value();
// }
// }
//
// if (type == null) {
// return null;
// }
//
// final String value = (String) field.get(null);
//
// builder.append(String.format(Locale.US, SQL_TABLE_CREATE_FIELD_TEMPLATE, value, type));
//
// if (i < fields.length - 1) {
// builder.append(",");
// }
// }
//
// return String.format(Locale.US, SQL_TABLE_CREATE_TEMPLATE, name, builder);
// } catch (final Exception e) {
// return null;
// }
// } else {
// return null;
// }
// }
//
// @Override
// public void onCreate(final SQLiteDatabase db) {
// for (final Class<?> clazz : Contract.MODELS) {
// final String sql = getTableCreateQuery(clazz);
//
// if (sql != null) {
// db.execSQL(sql);
// }
// }
// }
//
// @Override
// public void onUpgrade(final SQLiteDatabase db, final int oldVersion, final int newVersion) {
//
// }
//
// @Override
// public Cursor query(final String sql, final String... args) {
// final SQLiteDatabase database = getReadableDatabase();
//
// return database.rawQuery(sql, args);
// }
//
// @Override
// public long insert(final Class<?> table, final ContentValues values) {
// final String name = getTableName(table);
//
// if (name != null) {
// final SQLiteDatabase database = getWritableDatabase();
// long id;
//
// try {
// database.beginTransaction();
//
// id = database.insert(name, null, values);
//
// database.setTransactionSuccessful();
// } finally {
// database.endTransaction();
// }
//
// return id;
// } else {
// throw new RuntimeException();
// }
// }
//
// @Override
// public int bulkInsert(final Class<?> table, final List<ContentValues> values) {
// final String name = getTableName(table);
//
// if (name != null) {
// final SQLiteDatabase database = getWritableDatabase();
// int count = 0;
//
// try {
// database.beginTransaction();
//
// for (final ContentValues value : values) {
// database.insert(name, null, value);
//
// count++;
// }
//
// database.setTransactionSuccessful();
// } finally {
// database.endTransaction();
// }
//
// return count;
// } else {
// throw new RuntimeException();
// }
// }
//
// @Override
// public int delete(final Class<?> table, final String sql, final String... args) {
// final String name = getTableName(table);
//
// if (name != null) {
// final SQLiteDatabase database = getWritableDatabase();
// int count = 0;
//
// try {
// database.beginTransaction();
//
// count = database.delete(name, sql, args);
//
// database.setTransactionSuccessful();
// } finally {
// database.endTransaction();
// }
//
// return count;
// } else {
// throw new RuntimeException();
// }
// }
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/model/contract/User.java
// @Table(name = "USER")
// public final class User {
//
// @dbInteger
// public static final String ID = "id";
//
// @dbString
// public static final String TITLE = "title";
//
// @dbLong
// public static final String DATE = "date";
//
// }
// Path: MyApplication/app/src/test/java/com/example/mikhail_sianko/myapplication/DbTest.java
import com.example.mikhail_sianko.myapplication.db.DbHelper;
import com.example.mikhail_sianko.myapplication.model.contract.User;
import org.junit.Assert;
import org.junit.Test;
package com.example.mikhail_sianko.myapplication;
public class DbTest {
@Test
public void testCreateTableStatement() { | final String sql = DbHelper.getTableCreateQuery(User.class); |
deniotokiari/training-epam-2016 | MyApplication/backend/src/main/java/com/training2016/backend/TrainingsEndpoint.java | // Path: MyApplication/util-lib/src/main/java/com/training2016/android/http/HttpClient.java
// public class HttpClient {
//
// public String get(String url) throws Exception {
// return doRequest(url, "GET", null, null);
// }
//
// public String get(String url, Map<String, String> headers) throws Exception {
// return doRequest(url, "GET", headers, null);
// }
//
// public String post(String url, Map<String, String> header, String body) throws Exception {
// return doRequest(url, "POST", header, body);
// }
//
// private String doRequest(String url, String type, Map<String, String> header, String body) throws Exception {
// String response = null;
// HttpURLConnection connection = null;
// try {
// URL reqUrl = new URL(url);
// connection = ((HttpURLConnection) reqUrl.openConnection());
// connection.setRequestMethod(type);
// if (header != null) {
// for (String key : header.keySet()) {
// connection.addRequestProperty(key, header.get(key));
// }
// }
// if (body != null) {
// applyBody(connection, body);
// }
//
// InputStream inputStream;
//
// boolean isSuccess = connection.getResponseCode() >= 200 && connection.getResponseCode() < 300;
// if (isSuccess) {
// inputStream = connection.getInputStream();
// } else {
// inputStream = connection.getErrorStream();
// }
//
// BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
// StringBuilder stringBuilder = new StringBuilder();
// String line;
// while ((line = reader.readLine()) != null) {
// stringBuilder.append(line);
// }
// response = stringBuilder.toString();
//
// inputStream.close();
//
// if (!isSuccess) {
// System.out.println("http exception = " + response);
// throw new Exception(response);
// }
//
// } finally {
// if (connection != null) {
// connection.disconnect();
// }
// }
// return response;
// }
//
// public interface ResultConverter<Result> {
//
// Result convert(InputStream inputStream);
//
// }
//
// public <Result> Result getResult(String url, ResultConverter<Result> resultConverter) throws IOException {
// HttpURLConnection connection = null;
// InputStream inputStream = null;
// try {
// URL reqUrl = new URL(url);
// connection = ((HttpURLConnection) reqUrl.openConnection());
// connection.setRequestMethod("GET");
// inputStream = connection.getInputStream();
// return resultConverter.convert(inputStream);
// } finally {
// if (inputStream != null) {
// inputStream.close();
// }
// if (connection != null) {
// connection.disconnect();
// }
// }
// }
//
// private void applyBody(HttpURLConnection httpURLConnection, String body) throws Exception {
// byte[] outputInBytes = body.getBytes("UTF-8");
// OutputStream os = httpURLConnection.getOutputStream();
// os.write(outputInBytes);
// os.close();
// }
//
//
// }
| import com.google.api.server.spi.config.Api;
import com.google.api.server.spi.config.ApiMethod;
import com.google.api.server.spi.config.ApiNamespace;
import com.training2016.android.http.HttpClient; | /*
For step-by-step instructions on connecting your Android application to this backend module,
see "App Engine Java Endpoints Module" template documentation at
https://github.com/GoogleCloudPlatform/gradle-appengine-templates/tree/master/HelloEndpoints
*/
package com.training2016.backend;
/**
* An endpoint class we are exposing
*/
@Api(
name = "trainingApi",
version = "2016",
namespace = @ApiNamespace(
ownerDomain = "backend.training2016.com",
ownerName = "backend.training2016.com",
packagePath = ""
)
)
public class TrainingsEndpoint {
public static final String STATS_URL = "https://dl.dropboxusercontent.com/u/20755008/response.json";
/**
* A simple endpoint method that takes a name and says Hi back
*/
@ApiMethod(name = "getStats")
public DataBean getStats() {
DataBean response = new DataBean();
String data = null;
try { | // Path: MyApplication/util-lib/src/main/java/com/training2016/android/http/HttpClient.java
// public class HttpClient {
//
// public String get(String url) throws Exception {
// return doRequest(url, "GET", null, null);
// }
//
// public String get(String url, Map<String, String> headers) throws Exception {
// return doRequest(url, "GET", headers, null);
// }
//
// public String post(String url, Map<String, String> header, String body) throws Exception {
// return doRequest(url, "POST", header, body);
// }
//
// private String doRequest(String url, String type, Map<String, String> header, String body) throws Exception {
// String response = null;
// HttpURLConnection connection = null;
// try {
// URL reqUrl = new URL(url);
// connection = ((HttpURLConnection) reqUrl.openConnection());
// connection.setRequestMethod(type);
// if (header != null) {
// for (String key : header.keySet()) {
// connection.addRequestProperty(key, header.get(key));
// }
// }
// if (body != null) {
// applyBody(connection, body);
// }
//
// InputStream inputStream;
//
// boolean isSuccess = connection.getResponseCode() >= 200 && connection.getResponseCode() < 300;
// if (isSuccess) {
// inputStream = connection.getInputStream();
// } else {
// inputStream = connection.getErrorStream();
// }
//
// BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
// StringBuilder stringBuilder = new StringBuilder();
// String line;
// while ((line = reader.readLine()) != null) {
// stringBuilder.append(line);
// }
// response = stringBuilder.toString();
//
// inputStream.close();
//
// if (!isSuccess) {
// System.out.println("http exception = " + response);
// throw new Exception(response);
// }
//
// } finally {
// if (connection != null) {
// connection.disconnect();
// }
// }
// return response;
// }
//
// public interface ResultConverter<Result> {
//
// Result convert(InputStream inputStream);
//
// }
//
// public <Result> Result getResult(String url, ResultConverter<Result> resultConverter) throws IOException {
// HttpURLConnection connection = null;
// InputStream inputStream = null;
// try {
// URL reqUrl = new URL(url);
// connection = ((HttpURLConnection) reqUrl.openConnection());
// connection.setRequestMethod("GET");
// inputStream = connection.getInputStream();
// return resultConverter.convert(inputStream);
// } finally {
// if (inputStream != null) {
// inputStream.close();
// }
// if (connection != null) {
// connection.disconnect();
// }
// }
// }
//
// private void applyBody(HttpURLConnection httpURLConnection, String body) throws Exception {
// byte[] outputInBytes = body.getBytes("UTF-8");
// OutputStream os = httpURLConnection.getOutputStream();
// os.write(outputInBytes);
// os.close();
// }
//
//
// }
// Path: MyApplication/backend/src/main/java/com/training2016/backend/TrainingsEndpoint.java
import com.google.api.server.spi.config.Api;
import com.google.api.server.spi.config.ApiMethod;
import com.google.api.server.spi.config.ApiNamespace;
import com.training2016.android.http.HttpClient;
/*
For step-by-step instructions on connecting your Android application to this backend module,
see "App Engine Java Endpoints Module" template documentation at
https://github.com/GoogleCloudPlatform/gradle-appengine-templates/tree/master/HelloEndpoints
*/
package com.training2016.backend;
/**
* An endpoint class we are exposing
*/
@Api(
name = "trainingApi",
version = "2016",
namespace = @ApiNamespace(
ownerDomain = "backend.training2016.com",
ownerName = "backend.training2016.com",
packagePath = ""
)
)
public class TrainingsEndpoint {
public static final String STATS_URL = "https://dl.dropboxusercontent.com/u/20755008/response.json";
/**
* A simple endpoint method that takes a name and says Hi back
*/
@ApiMethod(name = "getStats")
public DataBean getStats() {
DataBean response = new DataBean();
String data = null;
try { | data = new HttpClient().get(STATS_URL); |
deniotokiari/training-epam-2016 | MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/ui/MainPresenter.java | // Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/data/api/ApiManager.java
// public class ApiManager {
//
// public static final String APP_ENGINE_BASE_URL = "http://10.0.2.2:8080/_ah/api/";
//
// private static ApiManager sInstance;
// private TrainingApi appEngineApi;
//
// public static ApiManager get() {
// if (sInstance == null) {
// sInstance = new ApiManager();
// }
// return sInstance;
// }
//
// private ApiManager() {
// }
//
// public TrainingApi trainingsApi() {
// if (appEngineApi == null) {
// TrainingApi.Builder builder = new TrainingApi.Builder(AndroidHttp.newCompatibleTransport(),
// JacksonFactory.getDefaultInstance(), null)
// .setApplicationName(BuildConfig.APPLICATION_ID)
// .setRootUrl(APP_ENGINE_BASE_URL)
// .setGoogleClientRequestInitializer(new GoogleClientRequestInitializer() {
// @Override
// public void initialize(AbstractGoogleClientRequest<?> abstractGoogleClientRequest) throws IOException {
// abstractGoogleClientRequest.setDisableGZipContent(true);
// }
// });
// appEngineApi = builder.build();
// }
// return appEngineApi;
// }
// }
| import android.os.Handler;
import android.os.Looper;
import android.support.annotation.NonNull;
import android.util.Log;
import com.example.mikhail_sianko.myapplication.data.api.ApiManager;
import com.training2016.backend.trainingApi.TrainingApi;
import com.training2016.backend.trainingApi.model.DataBean;
import java.io.IOException;
import static android.content.ContentValues.TAG; | package com.example.mikhail_sianko.myapplication.ui;
public class MainPresenter implements Contract.Presenter {
private Contract.View view;
private Handler handler;
public MainPresenter(@NonNull Contract.View view) {
this.view = view;
handler = new Handler(Looper.getMainLooper());
}
@Override
public void onReady() {
view.showProgress(true);
loadData();
}
private void loadData() {
new Thread() {
@Override
public void run() {
try { | // Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/data/api/ApiManager.java
// public class ApiManager {
//
// public static final String APP_ENGINE_BASE_URL = "http://10.0.2.2:8080/_ah/api/";
//
// private static ApiManager sInstance;
// private TrainingApi appEngineApi;
//
// public static ApiManager get() {
// if (sInstance == null) {
// sInstance = new ApiManager();
// }
// return sInstance;
// }
//
// private ApiManager() {
// }
//
// public TrainingApi trainingsApi() {
// if (appEngineApi == null) {
// TrainingApi.Builder builder = new TrainingApi.Builder(AndroidHttp.newCompatibleTransport(),
// JacksonFactory.getDefaultInstance(), null)
// .setApplicationName(BuildConfig.APPLICATION_ID)
// .setRootUrl(APP_ENGINE_BASE_URL)
// .setGoogleClientRequestInitializer(new GoogleClientRequestInitializer() {
// @Override
// public void initialize(AbstractGoogleClientRequest<?> abstractGoogleClientRequest) throws IOException {
// abstractGoogleClientRequest.setDisableGZipContent(true);
// }
// });
// appEngineApi = builder.build();
// }
// return appEngineApi;
// }
// }
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/ui/MainPresenter.java
import android.os.Handler;
import android.os.Looper;
import android.support.annotation.NonNull;
import android.util.Log;
import com.example.mikhail_sianko.myapplication.data.api.ApiManager;
import com.training2016.backend.trainingApi.TrainingApi;
import com.training2016.backend.trainingApi.model.DataBean;
import java.io.IOException;
import static android.content.ContentValues.TAG;
package com.example.mikhail_sianko.myapplication.ui;
public class MainPresenter implements Contract.Presenter {
private Contract.View view;
private Handler handler;
public MainPresenter(@NonNull Contract.View view) {
this.view = view;
handler = new Handler(Looper.getMainLooper());
}
@Override
public void onReady() {
view.showProgress(true);
loadData();
}
private void loadData() {
new Thread() {
@Override
public void run() {
try { | TrainingApi.GetStats call = ApiManager.get().trainingsApi().getStats(); |
deniotokiari/training-epam-2016 | MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/api/API.java | // Path: MyApplication/app/src/release/java/com/epam/training/LoginHelper.java
// public class LoginHelper {
//
// public static String getLogin() {
// return "";
// }
//
// public static String getPassword() {
// return "";
// }
// }
| import com.epam.training.LoginHelper;
import com.example.mikhail_sianko.myapplication.BuildConfig; | package com.example.mikhail_sianko.myapplication.api;
public class API {
public static String getUser() { | // Path: MyApplication/app/src/release/java/com/epam/training/LoginHelper.java
// public class LoginHelper {
//
// public static String getLogin() {
// return "";
// }
//
// public static String getPassword() {
// return "";
// }
// }
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/api/API.java
import com.epam.training.LoginHelper;
import com.example.mikhail_sianko.myapplication.BuildConfig;
package com.example.mikhail_sianko.myapplication.api;
public class API {
public static String getUser() { | return LoginHelper.getLogin() + LoginHelper.getPassword(); |
deniotokiari/training-epam-2016 | MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/threads/operation/HttpPostOperation.java | // Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/model/HttpRequestModel.java
// public class HttpRequestModel {
//
// private String url;
//
// private Map<String, String> headers;
//
// private String body;
//
//
// public void setUrl(String url) {
// this.url = url;
// }
//
// public void setHeaders(Map<String, String> headers) {
// this.headers = headers;
// }
//
// public void setBody(String body) {
// this.body = body;
// }
//
// public String getUrl() {
// return url;
// }
//
// public Map<String, String> getHeaders() {
// return headers;
// }
//
// public String getBody() {
// return body;
// }
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/threads/Operation.java
// public interface Operation<Params, Progress, Result> {
//
// Result doing(Params params, ProgressCallback<Progress> progressCallback) throws Exception;
//
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/threads/ProgressCallback.java
// public interface ProgressCallback<Progress> {
//
// void onProgressChanged(Progress progress);
//
// }
//
// Path: MyApplication/util-lib/src/main/java/com/training2016/android/http/HttpClient.java
// public class HttpClient {
//
// public String get(String url) throws Exception {
// return doRequest(url, "GET", null, null);
// }
//
// public String get(String url, Map<String, String> headers) throws Exception {
// return doRequest(url, "GET", headers, null);
// }
//
// public String post(String url, Map<String, String> header, String body) throws Exception {
// return doRequest(url, "POST", header, body);
// }
//
// private String doRequest(String url, String type, Map<String, String> header, String body) throws Exception {
// String response = null;
// HttpURLConnection connection = null;
// try {
// URL reqUrl = new URL(url);
// connection = ((HttpURLConnection) reqUrl.openConnection());
// connection.setRequestMethod(type);
// if (header != null) {
// for (String key : header.keySet()) {
// connection.addRequestProperty(key, header.get(key));
// }
// }
// if (body != null) {
// applyBody(connection, body);
// }
//
// InputStream inputStream;
//
// boolean isSuccess = connection.getResponseCode() >= 200 && connection.getResponseCode() < 300;
// if (isSuccess) {
// inputStream = connection.getInputStream();
// } else {
// inputStream = connection.getErrorStream();
// }
//
// BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
// StringBuilder stringBuilder = new StringBuilder();
// String line;
// while ((line = reader.readLine()) != null) {
// stringBuilder.append(line);
// }
// response = stringBuilder.toString();
//
// inputStream.close();
//
// if (!isSuccess) {
// System.out.println("http exception = " + response);
// throw new Exception(response);
// }
//
// } finally {
// if (connection != null) {
// connection.disconnect();
// }
// }
// return response;
// }
//
// public interface ResultConverter<Result> {
//
// Result convert(InputStream inputStream);
//
// }
//
// public <Result> Result getResult(String url, ResultConverter<Result> resultConverter) throws IOException {
// HttpURLConnection connection = null;
// InputStream inputStream = null;
// try {
// URL reqUrl = new URL(url);
// connection = ((HttpURLConnection) reqUrl.openConnection());
// connection.setRequestMethod("GET");
// inputStream = connection.getInputStream();
// return resultConverter.convert(inputStream);
// } finally {
// if (inputStream != null) {
// inputStream.close();
// }
// if (connection != null) {
// connection.disconnect();
// }
// }
// }
//
// private void applyBody(HttpURLConnection httpURLConnection, String body) throws Exception {
// byte[] outputInBytes = body.getBytes("UTF-8");
// OutputStream os = httpURLConnection.getOutputStream();
// os.write(outputInBytes);
// os.close();
// }
//
//
// }
| import com.example.mikhail_sianko.myapplication.model.HttpRequestModel;
import com.example.mikhail_sianko.myapplication.threads.Operation;
import com.example.mikhail_sianko.myapplication.threads.ProgressCallback;
import com.training2016.android.http.HttpClient; | package com.example.mikhail_sianko.myapplication.threads.operation;
public class HttpPostOperation implements Operation<HttpRequestModel, Void, String> {
@Override | // Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/model/HttpRequestModel.java
// public class HttpRequestModel {
//
// private String url;
//
// private Map<String, String> headers;
//
// private String body;
//
//
// public void setUrl(String url) {
// this.url = url;
// }
//
// public void setHeaders(Map<String, String> headers) {
// this.headers = headers;
// }
//
// public void setBody(String body) {
// this.body = body;
// }
//
// public String getUrl() {
// return url;
// }
//
// public Map<String, String> getHeaders() {
// return headers;
// }
//
// public String getBody() {
// return body;
// }
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/threads/Operation.java
// public interface Operation<Params, Progress, Result> {
//
// Result doing(Params params, ProgressCallback<Progress> progressCallback) throws Exception;
//
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/threads/ProgressCallback.java
// public interface ProgressCallback<Progress> {
//
// void onProgressChanged(Progress progress);
//
// }
//
// Path: MyApplication/util-lib/src/main/java/com/training2016/android/http/HttpClient.java
// public class HttpClient {
//
// public String get(String url) throws Exception {
// return doRequest(url, "GET", null, null);
// }
//
// public String get(String url, Map<String, String> headers) throws Exception {
// return doRequest(url, "GET", headers, null);
// }
//
// public String post(String url, Map<String, String> header, String body) throws Exception {
// return doRequest(url, "POST", header, body);
// }
//
// private String doRequest(String url, String type, Map<String, String> header, String body) throws Exception {
// String response = null;
// HttpURLConnection connection = null;
// try {
// URL reqUrl = new URL(url);
// connection = ((HttpURLConnection) reqUrl.openConnection());
// connection.setRequestMethod(type);
// if (header != null) {
// for (String key : header.keySet()) {
// connection.addRequestProperty(key, header.get(key));
// }
// }
// if (body != null) {
// applyBody(connection, body);
// }
//
// InputStream inputStream;
//
// boolean isSuccess = connection.getResponseCode() >= 200 && connection.getResponseCode() < 300;
// if (isSuccess) {
// inputStream = connection.getInputStream();
// } else {
// inputStream = connection.getErrorStream();
// }
//
// BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
// StringBuilder stringBuilder = new StringBuilder();
// String line;
// while ((line = reader.readLine()) != null) {
// stringBuilder.append(line);
// }
// response = stringBuilder.toString();
//
// inputStream.close();
//
// if (!isSuccess) {
// System.out.println("http exception = " + response);
// throw new Exception(response);
// }
//
// } finally {
// if (connection != null) {
// connection.disconnect();
// }
// }
// return response;
// }
//
// public interface ResultConverter<Result> {
//
// Result convert(InputStream inputStream);
//
// }
//
// public <Result> Result getResult(String url, ResultConverter<Result> resultConverter) throws IOException {
// HttpURLConnection connection = null;
// InputStream inputStream = null;
// try {
// URL reqUrl = new URL(url);
// connection = ((HttpURLConnection) reqUrl.openConnection());
// connection.setRequestMethod("GET");
// inputStream = connection.getInputStream();
// return resultConverter.convert(inputStream);
// } finally {
// if (inputStream != null) {
// inputStream.close();
// }
// if (connection != null) {
// connection.disconnect();
// }
// }
// }
//
// private void applyBody(HttpURLConnection httpURLConnection, String body) throws Exception {
// byte[] outputInBytes = body.getBytes("UTF-8");
// OutputStream os = httpURLConnection.getOutputStream();
// os.write(outputInBytes);
// os.close();
// }
//
//
// }
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/threads/operation/HttpPostOperation.java
import com.example.mikhail_sianko.myapplication.model.HttpRequestModel;
import com.example.mikhail_sianko.myapplication.threads.Operation;
import com.example.mikhail_sianko.myapplication.threads.ProgressCallback;
import com.training2016.android.http.HttpClient;
package com.example.mikhail_sianko.myapplication.threads.operation;
public class HttpPostOperation implements Operation<HttpRequestModel, Void, String> {
@Override | public String doing(HttpRequestModel inputRequestModel, ProgressCallback<Void> progressCallback) throws Exception { |
deniotokiari/training-epam-2016 | MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/threads/operation/HttpPostOperation.java | // Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/model/HttpRequestModel.java
// public class HttpRequestModel {
//
// private String url;
//
// private Map<String, String> headers;
//
// private String body;
//
//
// public void setUrl(String url) {
// this.url = url;
// }
//
// public void setHeaders(Map<String, String> headers) {
// this.headers = headers;
// }
//
// public void setBody(String body) {
// this.body = body;
// }
//
// public String getUrl() {
// return url;
// }
//
// public Map<String, String> getHeaders() {
// return headers;
// }
//
// public String getBody() {
// return body;
// }
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/threads/Operation.java
// public interface Operation<Params, Progress, Result> {
//
// Result doing(Params params, ProgressCallback<Progress> progressCallback) throws Exception;
//
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/threads/ProgressCallback.java
// public interface ProgressCallback<Progress> {
//
// void onProgressChanged(Progress progress);
//
// }
//
// Path: MyApplication/util-lib/src/main/java/com/training2016/android/http/HttpClient.java
// public class HttpClient {
//
// public String get(String url) throws Exception {
// return doRequest(url, "GET", null, null);
// }
//
// public String get(String url, Map<String, String> headers) throws Exception {
// return doRequest(url, "GET", headers, null);
// }
//
// public String post(String url, Map<String, String> header, String body) throws Exception {
// return doRequest(url, "POST", header, body);
// }
//
// private String doRequest(String url, String type, Map<String, String> header, String body) throws Exception {
// String response = null;
// HttpURLConnection connection = null;
// try {
// URL reqUrl = new URL(url);
// connection = ((HttpURLConnection) reqUrl.openConnection());
// connection.setRequestMethod(type);
// if (header != null) {
// for (String key : header.keySet()) {
// connection.addRequestProperty(key, header.get(key));
// }
// }
// if (body != null) {
// applyBody(connection, body);
// }
//
// InputStream inputStream;
//
// boolean isSuccess = connection.getResponseCode() >= 200 && connection.getResponseCode() < 300;
// if (isSuccess) {
// inputStream = connection.getInputStream();
// } else {
// inputStream = connection.getErrorStream();
// }
//
// BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
// StringBuilder stringBuilder = new StringBuilder();
// String line;
// while ((line = reader.readLine()) != null) {
// stringBuilder.append(line);
// }
// response = stringBuilder.toString();
//
// inputStream.close();
//
// if (!isSuccess) {
// System.out.println("http exception = " + response);
// throw new Exception(response);
// }
//
// } finally {
// if (connection != null) {
// connection.disconnect();
// }
// }
// return response;
// }
//
// public interface ResultConverter<Result> {
//
// Result convert(InputStream inputStream);
//
// }
//
// public <Result> Result getResult(String url, ResultConverter<Result> resultConverter) throws IOException {
// HttpURLConnection connection = null;
// InputStream inputStream = null;
// try {
// URL reqUrl = new URL(url);
// connection = ((HttpURLConnection) reqUrl.openConnection());
// connection.setRequestMethod("GET");
// inputStream = connection.getInputStream();
// return resultConverter.convert(inputStream);
// } finally {
// if (inputStream != null) {
// inputStream.close();
// }
// if (connection != null) {
// connection.disconnect();
// }
// }
// }
//
// private void applyBody(HttpURLConnection httpURLConnection, String body) throws Exception {
// byte[] outputInBytes = body.getBytes("UTF-8");
// OutputStream os = httpURLConnection.getOutputStream();
// os.write(outputInBytes);
// os.close();
// }
//
//
// }
| import com.example.mikhail_sianko.myapplication.model.HttpRequestModel;
import com.example.mikhail_sianko.myapplication.threads.Operation;
import com.example.mikhail_sianko.myapplication.threads.ProgressCallback;
import com.training2016.android.http.HttpClient; | package com.example.mikhail_sianko.myapplication.threads.operation;
public class HttpPostOperation implements Operation<HttpRequestModel, Void, String> {
@Override
public String doing(HttpRequestModel inputRequestModel, ProgressCallback<Void> progressCallback) throws Exception { | // Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/model/HttpRequestModel.java
// public class HttpRequestModel {
//
// private String url;
//
// private Map<String, String> headers;
//
// private String body;
//
//
// public void setUrl(String url) {
// this.url = url;
// }
//
// public void setHeaders(Map<String, String> headers) {
// this.headers = headers;
// }
//
// public void setBody(String body) {
// this.body = body;
// }
//
// public String getUrl() {
// return url;
// }
//
// public Map<String, String> getHeaders() {
// return headers;
// }
//
// public String getBody() {
// return body;
// }
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/threads/Operation.java
// public interface Operation<Params, Progress, Result> {
//
// Result doing(Params params, ProgressCallback<Progress> progressCallback) throws Exception;
//
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/threads/ProgressCallback.java
// public interface ProgressCallback<Progress> {
//
// void onProgressChanged(Progress progress);
//
// }
//
// Path: MyApplication/util-lib/src/main/java/com/training2016/android/http/HttpClient.java
// public class HttpClient {
//
// public String get(String url) throws Exception {
// return doRequest(url, "GET", null, null);
// }
//
// public String get(String url, Map<String, String> headers) throws Exception {
// return doRequest(url, "GET", headers, null);
// }
//
// public String post(String url, Map<String, String> header, String body) throws Exception {
// return doRequest(url, "POST", header, body);
// }
//
// private String doRequest(String url, String type, Map<String, String> header, String body) throws Exception {
// String response = null;
// HttpURLConnection connection = null;
// try {
// URL reqUrl = new URL(url);
// connection = ((HttpURLConnection) reqUrl.openConnection());
// connection.setRequestMethod(type);
// if (header != null) {
// for (String key : header.keySet()) {
// connection.addRequestProperty(key, header.get(key));
// }
// }
// if (body != null) {
// applyBody(connection, body);
// }
//
// InputStream inputStream;
//
// boolean isSuccess = connection.getResponseCode() >= 200 && connection.getResponseCode() < 300;
// if (isSuccess) {
// inputStream = connection.getInputStream();
// } else {
// inputStream = connection.getErrorStream();
// }
//
// BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
// StringBuilder stringBuilder = new StringBuilder();
// String line;
// while ((line = reader.readLine()) != null) {
// stringBuilder.append(line);
// }
// response = stringBuilder.toString();
//
// inputStream.close();
//
// if (!isSuccess) {
// System.out.println("http exception = " + response);
// throw new Exception(response);
// }
//
// } finally {
// if (connection != null) {
// connection.disconnect();
// }
// }
// return response;
// }
//
// public interface ResultConverter<Result> {
//
// Result convert(InputStream inputStream);
//
// }
//
// public <Result> Result getResult(String url, ResultConverter<Result> resultConverter) throws IOException {
// HttpURLConnection connection = null;
// InputStream inputStream = null;
// try {
// URL reqUrl = new URL(url);
// connection = ((HttpURLConnection) reqUrl.openConnection());
// connection.setRequestMethod("GET");
// inputStream = connection.getInputStream();
// return resultConverter.convert(inputStream);
// } finally {
// if (inputStream != null) {
// inputStream.close();
// }
// if (connection != null) {
// connection.disconnect();
// }
// }
// }
//
// private void applyBody(HttpURLConnection httpURLConnection, String body) throws Exception {
// byte[] outputInBytes = body.getBytes("UTF-8");
// OutputStream os = httpURLConnection.getOutputStream();
// os.write(outputInBytes);
// os.close();
// }
//
//
// }
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/threads/operation/HttpPostOperation.java
import com.example.mikhail_sianko.myapplication.model.HttpRequestModel;
import com.example.mikhail_sianko.myapplication.threads.Operation;
import com.example.mikhail_sianko.myapplication.threads.ProgressCallback;
import com.training2016.android.http.HttpClient;
package com.example.mikhail_sianko.myapplication.threads.operation;
public class HttpPostOperation implements Operation<HttpRequestModel, Void, String> {
@Override
public String doing(HttpRequestModel inputRequestModel, ProgressCallback<Void> progressCallback) throws Exception { | HttpClient httpClient = new HttpClient(); |
deniotokiari/training-epam-2016 | MyApplication/app/src/test/java/com/example/mikhail_sianko/myapplication/TimeTest.java | // Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/examples/utils/CustomSimpleDayFormat.java
// public class CustomSimpleDayFormat {
// public String getFormattedTime (String pattern, long time) {
// return new SimpleDateFormat(pattern).format(time);
// }
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/examples/utils/ITime.java
// public interface ITime {
// long getCurrentTimeInMillis();
//
// String getFriendlyFormattedTime();
//
// String getDayPart();
//
// String getTimeFormat();
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/examples/utils/Time.java
// public class Time implements ITime {
//
// private CustomSimpleDayFormat mCustomSimpleDayFormat;
//
// public Time(CustomSimpleDayFormat pCustomSimpleDayFormat) {
// setCustomSimpleDayFormat(pCustomSimpleDayFormat);
// }
//
// @Override
// public long getCurrentTimeInMillis() {
// return System.currentTimeMillis();
// }
//
// @Override
// public String getFriendlyFormattedTime() {
// String timeFormat = getTimeFormat();
// if (timeFormat.contains("HH") && timeFormat.contains("mm")) {
// return mCustomSimpleDayFormat.getFormattedTime("HH:mm:ss", getCurrentTimeInMillis());
// }
//
// throw new IllegalArgumentException("time format not valid");
//
// }
//
// public void setCustomSimpleDayFormat(CustomSimpleDayFormat mCustomSimpleDayFormat) {
// this.mCustomSimpleDayFormat = mCustomSimpleDayFormat;
// }
//
// public String getTimeFormat() {
// return "HH:mm:ss";
// }
//
// @Override
// public String getDayPart() {
// Calendar calendar = getCalendar();
// calendar.setTimeInMillis(getCurrentTimeInMillis());
// int hours = calendar.get(Calendar.HOUR_OF_DAY);
//
// if (hours > 0 && hours < 7) {
// return "night";
// } else if (hours >= 7 && hours <= 12) {
// return "morning";
// } else if (hours > 12 && hours < 15) {
// return "lunch";
// } else if (hours >= 15 && hours < 22) {
// return "evening";
// } else {
// return "night";
// }
// }
//
// private Calendar getCalendar() {
// return Calendar.getInstance();
// }
// }
| import com.example.mikhail_sianko.myapplication.examples.utils.CustomSimpleDayFormat;
import com.example.mikhail_sianko.myapplication.examples.utils.ITime;
import com.example.mikhail_sianko.myapplication.examples.utils.Time;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.mockito.Matchers;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import static org.junit.Assert.assertEquals; | package com.example.mikhail_sianko.myapplication;
/**
* To work on unit tests, switch the Test Artifact in the Build Variants view.
*/
public class TimeTest {
private ITime mITime;
@Mock | // Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/examples/utils/CustomSimpleDayFormat.java
// public class CustomSimpleDayFormat {
// public String getFormattedTime (String pattern, long time) {
// return new SimpleDateFormat(pattern).format(time);
// }
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/examples/utils/ITime.java
// public interface ITime {
// long getCurrentTimeInMillis();
//
// String getFriendlyFormattedTime();
//
// String getDayPart();
//
// String getTimeFormat();
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/examples/utils/Time.java
// public class Time implements ITime {
//
// private CustomSimpleDayFormat mCustomSimpleDayFormat;
//
// public Time(CustomSimpleDayFormat pCustomSimpleDayFormat) {
// setCustomSimpleDayFormat(pCustomSimpleDayFormat);
// }
//
// @Override
// public long getCurrentTimeInMillis() {
// return System.currentTimeMillis();
// }
//
// @Override
// public String getFriendlyFormattedTime() {
// String timeFormat = getTimeFormat();
// if (timeFormat.contains("HH") && timeFormat.contains("mm")) {
// return mCustomSimpleDayFormat.getFormattedTime("HH:mm:ss", getCurrentTimeInMillis());
// }
//
// throw new IllegalArgumentException("time format not valid");
//
// }
//
// public void setCustomSimpleDayFormat(CustomSimpleDayFormat mCustomSimpleDayFormat) {
// this.mCustomSimpleDayFormat = mCustomSimpleDayFormat;
// }
//
// public String getTimeFormat() {
// return "HH:mm:ss";
// }
//
// @Override
// public String getDayPart() {
// Calendar calendar = getCalendar();
// calendar.setTimeInMillis(getCurrentTimeInMillis());
// int hours = calendar.get(Calendar.HOUR_OF_DAY);
//
// if (hours > 0 && hours < 7) {
// return "night";
// } else if (hours >= 7 && hours <= 12) {
// return "morning";
// } else if (hours > 12 && hours < 15) {
// return "lunch";
// } else if (hours >= 15 && hours < 22) {
// return "evening";
// } else {
// return "night";
// }
// }
//
// private Calendar getCalendar() {
// return Calendar.getInstance();
// }
// }
// Path: MyApplication/app/src/test/java/com/example/mikhail_sianko/myapplication/TimeTest.java
import com.example.mikhail_sianko.myapplication.examples.utils.CustomSimpleDayFormat;
import com.example.mikhail_sianko.myapplication.examples.utils.ITime;
import com.example.mikhail_sianko.myapplication.examples.utils.Time;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.mockito.Matchers;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import static org.junit.Assert.assertEquals;
package com.example.mikhail_sianko.myapplication;
/**
* To work on unit tests, switch the Test Artifact in the Build Variants view.
*/
public class TimeTest {
private ITime mITime;
@Mock | private CustomSimpleDayFormat mCustomSimpleDayFormat; |
deniotokiari/training-epam-2016 | MyApplication/app/src/test/java/com/example/mikhail_sianko/myapplication/TimeTest.java | // Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/examples/utils/CustomSimpleDayFormat.java
// public class CustomSimpleDayFormat {
// public String getFormattedTime (String pattern, long time) {
// return new SimpleDateFormat(pattern).format(time);
// }
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/examples/utils/ITime.java
// public interface ITime {
// long getCurrentTimeInMillis();
//
// String getFriendlyFormattedTime();
//
// String getDayPart();
//
// String getTimeFormat();
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/examples/utils/Time.java
// public class Time implements ITime {
//
// private CustomSimpleDayFormat mCustomSimpleDayFormat;
//
// public Time(CustomSimpleDayFormat pCustomSimpleDayFormat) {
// setCustomSimpleDayFormat(pCustomSimpleDayFormat);
// }
//
// @Override
// public long getCurrentTimeInMillis() {
// return System.currentTimeMillis();
// }
//
// @Override
// public String getFriendlyFormattedTime() {
// String timeFormat = getTimeFormat();
// if (timeFormat.contains("HH") && timeFormat.contains("mm")) {
// return mCustomSimpleDayFormat.getFormattedTime("HH:mm:ss", getCurrentTimeInMillis());
// }
//
// throw new IllegalArgumentException("time format not valid");
//
// }
//
// public void setCustomSimpleDayFormat(CustomSimpleDayFormat mCustomSimpleDayFormat) {
// this.mCustomSimpleDayFormat = mCustomSimpleDayFormat;
// }
//
// public String getTimeFormat() {
// return "HH:mm:ss";
// }
//
// @Override
// public String getDayPart() {
// Calendar calendar = getCalendar();
// calendar.setTimeInMillis(getCurrentTimeInMillis());
// int hours = calendar.get(Calendar.HOUR_OF_DAY);
//
// if (hours > 0 && hours < 7) {
// return "night";
// } else if (hours >= 7 && hours <= 12) {
// return "morning";
// } else if (hours > 12 && hours < 15) {
// return "lunch";
// } else if (hours >= 15 && hours < 22) {
// return "evening";
// } else {
// return "night";
// }
// }
//
// private Calendar getCalendar() {
// return Calendar.getInstance();
// }
// }
| import com.example.mikhail_sianko.myapplication.examples.utils.CustomSimpleDayFormat;
import com.example.mikhail_sianko.myapplication.examples.utils.ITime;
import com.example.mikhail_sianko.myapplication.examples.utils.Time;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.mockito.Matchers;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import static org.junit.Assert.assertEquals; | package com.example.mikhail_sianko.myapplication;
/**
* To work on unit tests, switch the Test Artifact in the Build Variants view.
*/
public class TimeTest {
private ITime mITime;
@Mock
private CustomSimpleDayFormat mCustomSimpleDayFormat;
@BeforeClass
public static void setUp() {
//open database connection
System.err.println("setUp");
}
@AfterClass
public static void destroy() {
//close database connection;
System.err.println("destroy");
}
@Before
public void init() {
MockitoAnnotations.initMocks(this); | // Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/examples/utils/CustomSimpleDayFormat.java
// public class CustomSimpleDayFormat {
// public String getFormattedTime (String pattern, long time) {
// return new SimpleDateFormat(pattern).format(time);
// }
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/examples/utils/ITime.java
// public interface ITime {
// long getCurrentTimeInMillis();
//
// String getFriendlyFormattedTime();
//
// String getDayPart();
//
// String getTimeFormat();
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/examples/utils/Time.java
// public class Time implements ITime {
//
// private CustomSimpleDayFormat mCustomSimpleDayFormat;
//
// public Time(CustomSimpleDayFormat pCustomSimpleDayFormat) {
// setCustomSimpleDayFormat(pCustomSimpleDayFormat);
// }
//
// @Override
// public long getCurrentTimeInMillis() {
// return System.currentTimeMillis();
// }
//
// @Override
// public String getFriendlyFormattedTime() {
// String timeFormat = getTimeFormat();
// if (timeFormat.contains("HH") && timeFormat.contains("mm")) {
// return mCustomSimpleDayFormat.getFormattedTime("HH:mm:ss", getCurrentTimeInMillis());
// }
//
// throw new IllegalArgumentException("time format not valid");
//
// }
//
// public void setCustomSimpleDayFormat(CustomSimpleDayFormat mCustomSimpleDayFormat) {
// this.mCustomSimpleDayFormat = mCustomSimpleDayFormat;
// }
//
// public String getTimeFormat() {
// return "HH:mm:ss";
// }
//
// @Override
// public String getDayPart() {
// Calendar calendar = getCalendar();
// calendar.setTimeInMillis(getCurrentTimeInMillis());
// int hours = calendar.get(Calendar.HOUR_OF_DAY);
//
// if (hours > 0 && hours < 7) {
// return "night";
// } else if (hours >= 7 && hours <= 12) {
// return "morning";
// } else if (hours > 12 && hours < 15) {
// return "lunch";
// } else if (hours >= 15 && hours < 22) {
// return "evening";
// } else {
// return "night";
// }
// }
//
// private Calendar getCalendar() {
// return Calendar.getInstance();
// }
// }
// Path: MyApplication/app/src/test/java/com/example/mikhail_sianko/myapplication/TimeTest.java
import com.example.mikhail_sianko.myapplication.examples.utils.CustomSimpleDayFormat;
import com.example.mikhail_sianko.myapplication.examples.utils.ITime;
import com.example.mikhail_sianko.myapplication.examples.utils.Time;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.mockito.Matchers;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import static org.junit.Assert.assertEquals;
package com.example.mikhail_sianko.myapplication;
/**
* To work on unit tests, switch the Test Artifact in the Build Variants view.
*/
public class TimeTest {
private ITime mITime;
@Mock
private CustomSimpleDayFormat mCustomSimpleDayFormat;
@BeforeClass
public static void setUp() {
//open database connection
System.err.println("setUp");
}
@AfterClass
public static void destroy() {
//close database connection;
System.err.println("destroy");
}
@Before
public void init() {
MockitoAnnotations.initMocks(this); | mITime = Mockito.spy(new Time(mCustomSimpleDayFormat)); |
deniotokiari/training-epam-2016 | MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/App.java | // Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/malevich/Malevich.java
// public interface Malevich {
//
// void drawBitmap(final ImageView imageView, final String imageUrl);
//
// class Impl {
//
// public static Malevich newInstance() {
// return new MalevichImpl();
// }
//
// }
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/utils/ContextGodObject.java
// public final class ContextGodObject {
//
// private static ContextGodObject sContextGodObject;
//
// private Context mContext;
//
// private ContextGodObject() {
//
// }
//
// public static ContextGodObject getInstance() {
// if (sContextGodObject == null) {
// sContextGodObject = new ContextGodObject();
// }
//
// return sContextGodObject;
// }
//
// public Context getContext() {
// return mContext;
// }
//
// public void setContext(final Context pContext) {
// mContext = pContext;
// }
//
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/utils/ContextHolder.java
// public enum ContextHolder {
//
// INSTANCE;
//
// private Context mContext;
//
// public Context getContext() {
// return mContext;
// }
//
// public void setContext(final Context pContext) {
// mContext = pContext;
// }
//
// public static Context get() {
// return INSTANCE.mContext;
// }
//
// public static void set(final Context pContext) {
// INSTANCE.mContext = pContext;
// }
//
// }
| import android.app.Application;
import android.os.AsyncTask;
import com.example.mikhail_sianko.myapplication.malevich.Malevich;
import com.example.mikhail_sianko.myapplication.utils.ContextGodObject;
import com.example.mikhail_sianko.myapplication.utils.ContextHolder;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration; | package com.example.mikhail_sianko.myapplication;
/**
* Created by Alex Dzeshko on 30-Sep-16.
*/
public class App extends Application {
private Malevich malevich;
public Malevich getMalevich() {
if (malevich == null) {
malevich = Malevich.Impl.newInstance();
}
return malevich;
}
@Override
public void onCreate() {
super.onCreate();
AsyncTask.SERIAL_EXECUTOR.execute(new Runnable() {
@Override
public void run() {
//init libraries
}
});
| // Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/malevich/Malevich.java
// public interface Malevich {
//
// void drawBitmap(final ImageView imageView, final String imageUrl);
//
// class Impl {
//
// public static Malevich newInstance() {
// return new MalevichImpl();
// }
//
// }
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/utils/ContextGodObject.java
// public final class ContextGodObject {
//
// private static ContextGodObject sContextGodObject;
//
// private Context mContext;
//
// private ContextGodObject() {
//
// }
//
// public static ContextGodObject getInstance() {
// if (sContextGodObject == null) {
// sContextGodObject = new ContextGodObject();
// }
//
// return sContextGodObject;
// }
//
// public Context getContext() {
// return mContext;
// }
//
// public void setContext(final Context pContext) {
// mContext = pContext;
// }
//
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/utils/ContextHolder.java
// public enum ContextHolder {
//
// INSTANCE;
//
// private Context mContext;
//
// public Context getContext() {
// return mContext;
// }
//
// public void setContext(final Context pContext) {
// mContext = pContext;
// }
//
// public static Context get() {
// return INSTANCE.mContext;
// }
//
// public static void set(final Context pContext) {
// INSTANCE.mContext = pContext;
// }
//
// }
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/App.java
import android.app.Application;
import android.os.AsyncTask;
import com.example.mikhail_sianko.myapplication.malevich.Malevich;
import com.example.mikhail_sianko.myapplication.utils.ContextGodObject;
import com.example.mikhail_sianko.myapplication.utils.ContextHolder;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
package com.example.mikhail_sianko.myapplication;
/**
* Created by Alex Dzeshko on 30-Sep-16.
*/
public class App extends Application {
private Malevich malevich;
public Malevich getMalevich() {
if (malevich == null) {
malevich = Malevich.Impl.newInstance();
}
return malevich;
}
@Override
public void onCreate() {
super.onCreate();
AsyncTask.SERIAL_EXECUTOR.execute(new Runnable() {
@Override
public void run() {
//init libraries
}
});
| ContextHolder.set(this); |
deniotokiari/training-epam-2016 | MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/App.java | // Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/malevich/Malevich.java
// public interface Malevich {
//
// void drawBitmap(final ImageView imageView, final String imageUrl);
//
// class Impl {
//
// public static Malevich newInstance() {
// return new MalevichImpl();
// }
//
// }
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/utils/ContextGodObject.java
// public final class ContextGodObject {
//
// private static ContextGodObject sContextGodObject;
//
// private Context mContext;
//
// private ContextGodObject() {
//
// }
//
// public static ContextGodObject getInstance() {
// if (sContextGodObject == null) {
// sContextGodObject = new ContextGodObject();
// }
//
// return sContextGodObject;
// }
//
// public Context getContext() {
// return mContext;
// }
//
// public void setContext(final Context pContext) {
// mContext = pContext;
// }
//
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/utils/ContextHolder.java
// public enum ContextHolder {
//
// INSTANCE;
//
// private Context mContext;
//
// public Context getContext() {
// return mContext;
// }
//
// public void setContext(final Context pContext) {
// mContext = pContext;
// }
//
// public static Context get() {
// return INSTANCE.mContext;
// }
//
// public static void set(final Context pContext) {
// INSTANCE.mContext = pContext;
// }
//
// }
| import android.app.Application;
import android.os.AsyncTask;
import com.example.mikhail_sianko.myapplication.malevich.Malevich;
import com.example.mikhail_sianko.myapplication.utils.ContextGodObject;
import com.example.mikhail_sianko.myapplication.utils.ContextHolder;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration; | package com.example.mikhail_sianko.myapplication;
/**
* Created by Alex Dzeshko on 30-Sep-16.
*/
public class App extends Application {
private Malevich malevich;
public Malevich getMalevich() {
if (malevich == null) {
malevich = Malevich.Impl.newInstance();
}
return malevich;
}
@Override
public void onCreate() {
super.onCreate();
AsyncTask.SERIAL_EXECUTOR.execute(new Runnable() {
@Override
public void run() {
//init libraries
}
});
ContextHolder.set(this); | // Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/malevich/Malevich.java
// public interface Malevich {
//
// void drawBitmap(final ImageView imageView, final String imageUrl);
//
// class Impl {
//
// public static Malevich newInstance() {
// return new MalevichImpl();
// }
//
// }
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/utils/ContextGodObject.java
// public final class ContextGodObject {
//
// private static ContextGodObject sContextGodObject;
//
// private Context mContext;
//
// private ContextGodObject() {
//
// }
//
// public static ContextGodObject getInstance() {
// if (sContextGodObject == null) {
// sContextGodObject = new ContextGodObject();
// }
//
// return sContextGodObject;
// }
//
// public Context getContext() {
// return mContext;
// }
//
// public void setContext(final Context pContext) {
// mContext = pContext;
// }
//
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/utils/ContextHolder.java
// public enum ContextHolder {
//
// INSTANCE;
//
// private Context mContext;
//
// public Context getContext() {
// return mContext;
// }
//
// public void setContext(final Context pContext) {
// mContext = pContext;
// }
//
// public static Context get() {
// return INSTANCE.mContext;
// }
//
// public static void set(final Context pContext) {
// INSTANCE.mContext = pContext;
// }
//
// }
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/App.java
import android.app.Application;
import android.os.AsyncTask;
import com.example.mikhail_sianko.myapplication.malevich.Malevich;
import com.example.mikhail_sianko.myapplication.utils.ContextGodObject;
import com.example.mikhail_sianko.myapplication.utils.ContextHolder;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
package com.example.mikhail_sianko.myapplication;
/**
* Created by Alex Dzeshko on 30-Sep-16.
*/
public class App extends Application {
private Malevich malevich;
public Malevich getMalevich() {
if (malevich == null) {
malevich = Malevich.Impl.newInstance();
}
return malevich;
}
@Override
public void onCreate() {
super.onCreate();
AsyncTask.SERIAL_EXECUTOR.execute(new Runnable() {
@Override
public void run() {
//init libraries
}
});
ContextHolder.set(this); | ContextGodObject.getInstance().setContext(this); |
deniotokiari/training-epam-2016 | MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/threads/operation/WorkerOperation.java | // Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/threads/Operation.java
// public interface Operation<Params, Progress, Result> {
//
// Result doing(Params params, ProgressCallback<Progress> progressCallback) throws Exception;
//
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/threads/ProgressCallback.java
// public interface ProgressCallback<Progress> {
//
// void onProgressChanged(Progress progress);
//
// }
| import android.util.Log;
import com.example.mikhail_sianko.myapplication.threads.Operation;
import com.example.mikhail_sianko.myapplication.threads.ProgressCallback;
import java.io.IOException; | package com.example.mikhail_sianko.myapplication.threads.operation;
public class WorkerOperation implements Operation<String, Integer, WorkerOperation.Result> {
public static final int N = 3;
@Override | // Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/threads/Operation.java
// public interface Operation<Params, Progress, Result> {
//
// Result doing(Params params, ProgressCallback<Progress> progressCallback) throws Exception;
//
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/threads/ProgressCallback.java
// public interface ProgressCallback<Progress> {
//
// void onProgressChanged(Progress progress);
//
// }
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/threads/operation/WorkerOperation.java
import android.util.Log;
import com.example.mikhail_sianko.myapplication.threads.Operation;
import com.example.mikhail_sianko.myapplication.threads.ProgressCallback;
import java.io.IOException;
package com.example.mikhail_sianko.myapplication.threads.operation;
public class WorkerOperation implements Operation<String, Integer, WorkerOperation.Result> {
public static final int N = 3;
@Override | public Result doing(final String whatYouDoing, final ProgressCallback<Integer> progressCallback) throws Exception { |
deniotokiari/training-epam-2016 | MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/ui/ListViewActivity.java | // Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/adapter/ListViewAdapter.java
// public class ListViewAdapter extends ArrayAdapter<TwitterSearchStatuses> {
//
//
// public ListViewAdapter(Context context, int resource) {
// super(context, resource);
// }
//
// public ListViewAdapter(Context context, int resource, List<TwitterSearchStatuses> objects) {
// super(context, resource, objects);
// }
//
// @NonNull
// @Override
// public View getView(int position, View convertView, ViewGroup parent) {
// View view;
// if (convertView == null) {
// view = LayoutInflater.from(getContext()).inflate(R.layout.list_item, parent, false);
// } else {
// view = convertView;
// }
// bindView(position, view);
// return view;
// }
//
// private void bindView(int position, View view) {
// TwitterSearchStatuses status = getItem(position);
// ((TextView) view.findViewById(R.id.user)).setText(status.getTwitterUser().getName());
// ((TextView) view.findViewById(R.id.value)).setText(status.getText());
// }
//
// @Override
// public int getCount() {
// return super.getCount();
// }
//
// @Override
// public int getItemViewType(int position) {
// return super.getItemViewType(position);
// }
//
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/adapter/RecyclerViewAdapter.java
// public class RecyclerViewAdapter extends AbstractAdapter<TwitterSearchStatuses> {
//
// public static final int TYPE_CHANGED = 0;
// public static final int TYPE_DEFAULT = 1;
// List<TwitterSearchStatuses> data = new ArrayList<>();
//
// public void setOnItemListener(RecyclerViewAdapter.onItemListener onItemListener) {
// this.onItemListener = onItemListener;
// }
//
// private onItemListener onItemListener;
//
//
// public interface onItemListener {
// void onClick(TwitterSearchStatuses item, int position);
// }
//
// public void setData(List<TwitterSearchStatuses> data) {
// this.data = data;
// notifyDataSetChanged();
// }
//
// @Override
// public void onBind(AbstractViewHolder holder, final TwitterSearchStatuses data, final int position, int viewType) {
// holder.<TextView>get(R.id.user).setText(data.getTwitterUser().getName());
// holder.<TextView>get(R.id.value).setText(data.getText());
// if (viewType == TYPE_CHANGED) {
// holder.itemView.setBackgroundColor(ContextCompat.getColor(holder.itemView.getContext(), R.color.colorAccent));
// }
// holder.itemView.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// if (onItemListener != null) {
// onItemListener.onClick(data, position);
// }
// }
// });
//
// }
//
// @Override
// public TwitterSearchStatuses getItem(int positoin) {
// return data.get(positoin);
// }
//
// @Override
// public AbstractViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
// View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item, parent, false);
// return new AbstractViewHolder(view);
// }
//
// @Override
// public int getItemCount() {
// return data.size();
// }
//
// public void addItem(TwitterSearchStatuses item, int position) {
// data.add(position, item);
// notifyItemInserted(position);
// int itemCount = data.size() - position;
// notifyItemRangeChanged(position, itemCount);
// }
//
// public void removeItem(int position) {
// data.remove(position);
// notifyItemRemoved(position);
// }
//
// @Override
// public int getItemViewType(int position) {
// TwitterSearchStatuses item = getItem(position);
// return item.changeMe ? TYPE_CHANGED : TYPE_DEFAULT;
// }
//
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/model/gson/TwitterSearchStatuses.java
// public class TwitterSearchStatuses {
//
// @SerializedName("created_at")
// private Date createdAt;
//
// @SerializedName("text")
// private String text;
//
// @SerializedName("user")
// private TwitterUser twitterUser;
//
// public boolean changeMe;
//
// public Date getCreatedAt() {
// return createdAt;
// }
//
// public String getText() {
// return text;
// }
//
// public TwitterUser getTwitterUser() {
// return twitterUser;
// }
//
// public static TwitterSearchStatuses dummy(String user, String text) {
// TwitterSearchStatuses statuses = new TwitterSearchStatuses();
// statuses.text = text;
// statuses.twitterUser = new TwitterUser();
// statuses.twitterUser.setName(user);
// return statuses;
// }
//
// public static List<TwitterSearchStatuses> listDummy() {
// List<TwitterSearchStatuses> results = new ArrayList<>();
// for (int i = 0; i < 1000; i++) {
// results.add(TwitterSearchStatuses.dummy("Text " + i, "User " + i));
// }
// return results;
// }
// }
| import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ListView;
import android.widget.Toast;
import com.example.mikhail_sianko.myapplication.R;
import com.example.mikhail_sianko.myapplication.adapter.ListViewAdapter;
import com.example.mikhail_sianko.myapplication.adapter.RecyclerViewAdapter;
import com.example.mikhail_sianko.myapplication.model.gson.TwitterSearchStatuses;
import java.util.ArrayList;
import java.util.List; | package com.example.mikhail_sianko.myapplication.ui;
public class ListViewActivity extends AppCompatActivity {
private static final String TAG = "ListViewActivity";
private ListView listView; | // Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/adapter/ListViewAdapter.java
// public class ListViewAdapter extends ArrayAdapter<TwitterSearchStatuses> {
//
//
// public ListViewAdapter(Context context, int resource) {
// super(context, resource);
// }
//
// public ListViewAdapter(Context context, int resource, List<TwitterSearchStatuses> objects) {
// super(context, resource, objects);
// }
//
// @NonNull
// @Override
// public View getView(int position, View convertView, ViewGroup parent) {
// View view;
// if (convertView == null) {
// view = LayoutInflater.from(getContext()).inflate(R.layout.list_item, parent, false);
// } else {
// view = convertView;
// }
// bindView(position, view);
// return view;
// }
//
// private void bindView(int position, View view) {
// TwitterSearchStatuses status = getItem(position);
// ((TextView) view.findViewById(R.id.user)).setText(status.getTwitterUser().getName());
// ((TextView) view.findViewById(R.id.value)).setText(status.getText());
// }
//
// @Override
// public int getCount() {
// return super.getCount();
// }
//
// @Override
// public int getItemViewType(int position) {
// return super.getItemViewType(position);
// }
//
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/adapter/RecyclerViewAdapter.java
// public class RecyclerViewAdapter extends AbstractAdapter<TwitterSearchStatuses> {
//
// public static final int TYPE_CHANGED = 0;
// public static final int TYPE_DEFAULT = 1;
// List<TwitterSearchStatuses> data = new ArrayList<>();
//
// public void setOnItemListener(RecyclerViewAdapter.onItemListener onItemListener) {
// this.onItemListener = onItemListener;
// }
//
// private onItemListener onItemListener;
//
//
// public interface onItemListener {
// void onClick(TwitterSearchStatuses item, int position);
// }
//
// public void setData(List<TwitterSearchStatuses> data) {
// this.data = data;
// notifyDataSetChanged();
// }
//
// @Override
// public void onBind(AbstractViewHolder holder, final TwitterSearchStatuses data, final int position, int viewType) {
// holder.<TextView>get(R.id.user).setText(data.getTwitterUser().getName());
// holder.<TextView>get(R.id.value).setText(data.getText());
// if (viewType == TYPE_CHANGED) {
// holder.itemView.setBackgroundColor(ContextCompat.getColor(holder.itemView.getContext(), R.color.colorAccent));
// }
// holder.itemView.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// if (onItemListener != null) {
// onItemListener.onClick(data, position);
// }
// }
// });
//
// }
//
// @Override
// public TwitterSearchStatuses getItem(int positoin) {
// return data.get(positoin);
// }
//
// @Override
// public AbstractViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
// View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item, parent, false);
// return new AbstractViewHolder(view);
// }
//
// @Override
// public int getItemCount() {
// return data.size();
// }
//
// public void addItem(TwitterSearchStatuses item, int position) {
// data.add(position, item);
// notifyItemInserted(position);
// int itemCount = data.size() - position;
// notifyItemRangeChanged(position, itemCount);
// }
//
// public void removeItem(int position) {
// data.remove(position);
// notifyItemRemoved(position);
// }
//
// @Override
// public int getItemViewType(int position) {
// TwitterSearchStatuses item = getItem(position);
// return item.changeMe ? TYPE_CHANGED : TYPE_DEFAULT;
// }
//
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/model/gson/TwitterSearchStatuses.java
// public class TwitterSearchStatuses {
//
// @SerializedName("created_at")
// private Date createdAt;
//
// @SerializedName("text")
// private String text;
//
// @SerializedName("user")
// private TwitterUser twitterUser;
//
// public boolean changeMe;
//
// public Date getCreatedAt() {
// return createdAt;
// }
//
// public String getText() {
// return text;
// }
//
// public TwitterUser getTwitterUser() {
// return twitterUser;
// }
//
// public static TwitterSearchStatuses dummy(String user, String text) {
// TwitterSearchStatuses statuses = new TwitterSearchStatuses();
// statuses.text = text;
// statuses.twitterUser = new TwitterUser();
// statuses.twitterUser.setName(user);
// return statuses;
// }
//
// public static List<TwitterSearchStatuses> listDummy() {
// List<TwitterSearchStatuses> results = new ArrayList<>();
// for (int i = 0; i < 1000; i++) {
// results.add(TwitterSearchStatuses.dummy("Text " + i, "User " + i));
// }
// return results;
// }
// }
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/ui/ListViewActivity.java
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ListView;
import android.widget.Toast;
import com.example.mikhail_sianko.myapplication.R;
import com.example.mikhail_sianko.myapplication.adapter.ListViewAdapter;
import com.example.mikhail_sianko.myapplication.adapter.RecyclerViewAdapter;
import com.example.mikhail_sianko.myapplication.model.gson.TwitterSearchStatuses;
import java.util.ArrayList;
import java.util.List;
package com.example.mikhail_sianko.myapplication.ui;
public class ListViewActivity extends AppCompatActivity {
private static final String TAG = "ListViewActivity";
private ListView listView; | private List<TwitterSearchStatuses> statusesList = new ArrayList<>(); |
deniotokiari/training-epam-2016 | MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/ui/ImagesActivity.java | // Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/App.java
// public class App extends Application {
//
// private Malevich malevich;
//
// public Malevich getMalevich() {
// if (malevich == null) {
// malevich = Malevich.Impl.newInstance();
// }
// return malevich;
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
//
// AsyncTask.SERIAL_EXECUTOR.execute(new Runnable() {
//
// @Override
// public void run() {
// //init libraries
// }
// });
//
// ContextHolder.set(this);
// ContextGodObject.getInstance().setContext(this);
//
// ImageLoaderConfiguration config = ImageLoaderConfiguration.createDefault(this);
//
// ImageLoader.getInstance().init(config);
// }
//
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/malevich/Malevich.java
// public interface Malevich {
//
// void drawBitmap(final ImageView imageView, final String imageUrl);
//
// class Impl {
//
// public static Malevich newInstance() {
// return new MalevichImpl();
// }
//
// }
// }
| import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import com.example.mikhail_sianko.myapplication.App;
import com.example.mikhail_sianko.myapplication.R;
import com.example.mikhail_sianko.myapplication.malevich.Malevich; | package com.example.mikhail_sianko.myapplication.ui;
public class ImagesActivity extends AppCompatActivity {
private static String[] IMAGE_URLS =
{
"http://makeitlast.se/wp-content/uploads/2015/10/loppis_12.jpg",
"https://images-na.ssl-images-amazon.com/images/G/01/img15/pet-products/small-tiles/30423_pets-products_january-site-flip_3-cathealth_short-tile_592x304._CB286975940_.jpg",
"https://s-media-cache-ak0.pinimg.com/236x/8a/1b/7c/8a1b7c35091025bf2417ce2d9a6b058d.jpg",
"https://cnet4.cbsistatic.com/hub/i/2011/10/27/a66dfbb7-fdc7-11e2-8c7c-d4ae52e62bcc/android-wallpaper5_2560x1600_1.jpg",
"https://www.android.com/static/img/home/more-from-2.png",
"http://www.howtablet.ru/wp-content/uploads/2016/04/%D0%9E%D0%B1%D0%BD%D0%BE%D0%B2%D0%BB%D0%B5%D0%BD%D0%B8%D0%B5-Android-6.0.1-Marshmallow.jpg",
"http://keddr.com/wp-content/uploads/2015/12/iOS-vs-Android.jpg",
"http://shushi168.com/data/out/8/37224223-android-wallpaper.jpg",
"https://www.android.com/static/img/history/features/feature_icecream_3.png",
"https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcRfZ5OiAt7GIz57jyvjK8ca82pIvgd7pvD-3JyPG73ppN8FbqpbUA",
"http://androidwallpape.rs/content/02-wallpapers/131-night-sky/wallpaper-2707591.jpg"
};
@Override
protected void onCreate(@Nullable final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_images);
final ImageView topImageView = (ImageView) findViewById(R.id.imageView); | // Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/App.java
// public class App extends Application {
//
// private Malevich malevich;
//
// public Malevich getMalevich() {
// if (malevich == null) {
// malevich = Malevich.Impl.newInstance();
// }
// return malevich;
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
//
// AsyncTask.SERIAL_EXECUTOR.execute(new Runnable() {
//
// @Override
// public void run() {
// //init libraries
// }
// });
//
// ContextHolder.set(this);
// ContextGodObject.getInstance().setContext(this);
//
// ImageLoaderConfiguration config = ImageLoaderConfiguration.createDefault(this);
//
// ImageLoader.getInstance().init(config);
// }
//
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/malevich/Malevich.java
// public interface Malevich {
//
// void drawBitmap(final ImageView imageView, final String imageUrl);
//
// class Impl {
//
// public static Malevich newInstance() {
// return new MalevichImpl();
// }
//
// }
// }
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/ui/ImagesActivity.java
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import com.example.mikhail_sianko.myapplication.App;
import com.example.mikhail_sianko.myapplication.R;
import com.example.mikhail_sianko.myapplication.malevich.Malevich;
package com.example.mikhail_sianko.myapplication.ui;
public class ImagesActivity extends AppCompatActivity {
private static String[] IMAGE_URLS =
{
"http://makeitlast.se/wp-content/uploads/2015/10/loppis_12.jpg",
"https://images-na.ssl-images-amazon.com/images/G/01/img15/pet-products/small-tiles/30423_pets-products_january-site-flip_3-cathealth_short-tile_592x304._CB286975940_.jpg",
"https://s-media-cache-ak0.pinimg.com/236x/8a/1b/7c/8a1b7c35091025bf2417ce2d9a6b058d.jpg",
"https://cnet4.cbsistatic.com/hub/i/2011/10/27/a66dfbb7-fdc7-11e2-8c7c-d4ae52e62bcc/android-wallpaper5_2560x1600_1.jpg",
"https://www.android.com/static/img/home/more-from-2.png",
"http://www.howtablet.ru/wp-content/uploads/2016/04/%D0%9E%D0%B1%D0%BD%D0%BE%D0%B2%D0%BB%D0%B5%D0%BD%D0%B8%D0%B5-Android-6.0.1-Marshmallow.jpg",
"http://keddr.com/wp-content/uploads/2015/12/iOS-vs-Android.jpg",
"http://shushi168.com/data/out/8/37224223-android-wallpaper.jpg",
"https://www.android.com/static/img/history/features/feature_icecream_3.png",
"https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcRfZ5OiAt7GIz57jyvjK8ca82pIvgd7pvD-3JyPG73ppN8FbqpbUA",
"http://androidwallpape.rs/content/02-wallpapers/131-night-sky/wallpaper-2707591.jpg"
};
@Override
protected void onCreate(@Nullable final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_images);
final ImageView topImageView = (ImageView) findViewById(R.id.imageView); | final Malevich malevich = ((App) getApplication()).getMalevich(); |
deniotokiari/training-epam-2016 | MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/ui/ImagesActivity.java | // Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/App.java
// public class App extends Application {
//
// private Malevich malevich;
//
// public Malevich getMalevich() {
// if (malevich == null) {
// malevich = Malevich.Impl.newInstance();
// }
// return malevich;
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
//
// AsyncTask.SERIAL_EXECUTOR.execute(new Runnable() {
//
// @Override
// public void run() {
// //init libraries
// }
// });
//
// ContextHolder.set(this);
// ContextGodObject.getInstance().setContext(this);
//
// ImageLoaderConfiguration config = ImageLoaderConfiguration.createDefault(this);
//
// ImageLoader.getInstance().init(config);
// }
//
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/malevich/Malevich.java
// public interface Malevich {
//
// void drawBitmap(final ImageView imageView, final String imageUrl);
//
// class Impl {
//
// public static Malevich newInstance() {
// return new MalevichImpl();
// }
//
// }
// }
| import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import com.example.mikhail_sianko.myapplication.App;
import com.example.mikhail_sianko.myapplication.R;
import com.example.mikhail_sianko.myapplication.malevich.Malevich; | package com.example.mikhail_sianko.myapplication.ui;
public class ImagesActivity extends AppCompatActivity {
private static String[] IMAGE_URLS =
{
"http://makeitlast.se/wp-content/uploads/2015/10/loppis_12.jpg",
"https://images-na.ssl-images-amazon.com/images/G/01/img15/pet-products/small-tiles/30423_pets-products_january-site-flip_3-cathealth_short-tile_592x304._CB286975940_.jpg",
"https://s-media-cache-ak0.pinimg.com/236x/8a/1b/7c/8a1b7c35091025bf2417ce2d9a6b058d.jpg",
"https://cnet4.cbsistatic.com/hub/i/2011/10/27/a66dfbb7-fdc7-11e2-8c7c-d4ae52e62bcc/android-wallpaper5_2560x1600_1.jpg",
"https://www.android.com/static/img/home/more-from-2.png",
"http://www.howtablet.ru/wp-content/uploads/2016/04/%D0%9E%D0%B1%D0%BD%D0%BE%D0%B2%D0%BB%D0%B5%D0%BD%D0%B8%D0%B5-Android-6.0.1-Marshmallow.jpg",
"http://keddr.com/wp-content/uploads/2015/12/iOS-vs-Android.jpg",
"http://shushi168.com/data/out/8/37224223-android-wallpaper.jpg",
"https://www.android.com/static/img/history/features/feature_icecream_3.png",
"https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcRfZ5OiAt7GIz57jyvjK8ca82pIvgd7pvD-3JyPG73ppN8FbqpbUA",
"http://androidwallpape.rs/content/02-wallpapers/131-night-sky/wallpaper-2707591.jpg"
};
@Override
protected void onCreate(@Nullable final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_images);
final ImageView topImageView = (ImageView) findViewById(R.id.imageView); | // Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/App.java
// public class App extends Application {
//
// private Malevich malevich;
//
// public Malevich getMalevich() {
// if (malevich == null) {
// malevich = Malevich.Impl.newInstance();
// }
// return malevich;
// }
//
// @Override
// public void onCreate() {
// super.onCreate();
//
// AsyncTask.SERIAL_EXECUTOR.execute(new Runnable() {
//
// @Override
// public void run() {
// //init libraries
// }
// });
//
// ContextHolder.set(this);
// ContextGodObject.getInstance().setContext(this);
//
// ImageLoaderConfiguration config = ImageLoaderConfiguration.createDefault(this);
//
// ImageLoader.getInstance().init(config);
// }
//
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/malevich/Malevich.java
// public interface Malevich {
//
// void drawBitmap(final ImageView imageView, final String imageUrl);
//
// class Impl {
//
// public static Malevich newInstance() {
// return new MalevichImpl();
// }
//
// }
// }
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/ui/ImagesActivity.java
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import com.example.mikhail_sianko.myapplication.App;
import com.example.mikhail_sianko.myapplication.R;
import com.example.mikhail_sianko.myapplication.malevich.Malevich;
package com.example.mikhail_sianko.myapplication.ui;
public class ImagesActivity extends AppCompatActivity {
private static String[] IMAGE_URLS =
{
"http://makeitlast.se/wp-content/uploads/2015/10/loppis_12.jpg",
"https://images-na.ssl-images-amazon.com/images/G/01/img15/pet-products/small-tiles/30423_pets-products_january-site-flip_3-cathealth_short-tile_592x304._CB286975940_.jpg",
"https://s-media-cache-ak0.pinimg.com/236x/8a/1b/7c/8a1b7c35091025bf2417ce2d9a6b058d.jpg",
"https://cnet4.cbsistatic.com/hub/i/2011/10/27/a66dfbb7-fdc7-11e2-8c7c-d4ae52e62bcc/android-wallpaper5_2560x1600_1.jpg",
"https://www.android.com/static/img/home/more-from-2.png",
"http://www.howtablet.ru/wp-content/uploads/2016/04/%D0%9E%D0%B1%D0%BD%D0%BE%D0%B2%D0%BB%D0%B5%D0%BD%D0%B8%D0%B5-Android-6.0.1-Marshmallow.jpg",
"http://keddr.com/wp-content/uploads/2015/12/iOS-vs-Android.jpg",
"http://shushi168.com/data/out/8/37224223-android-wallpaper.jpg",
"https://www.android.com/static/img/history/features/feature_icecream_3.png",
"https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcRfZ5OiAt7GIz57jyvjK8ca82pIvgd7pvD-3JyPG73ppN8FbqpbUA",
"http://androidwallpape.rs/content/02-wallpapers/131-night-sky/wallpaper-2707591.jpg"
};
@Override
protected void onCreate(@Nullable final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_images);
final ImageView topImageView = (ImageView) findViewById(R.id.imageView); | final Malevich malevich = ((App) getApplication()).getMalevich(); |
deniotokiari/training-epam-2016 | MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/examples/SecondActivity.java | // Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/adapter/AbstractAdapter.java
// public abstract class AbstractAdapter<Item> extends RecyclerView.Adapter<AbstractAdapter.AbstractViewHolder> {
//
// public abstract void onBind(AbstractViewHolder holder, Item item, int position, int viewType);
//
// public abstract Item getItem(int positoin);
//
// @Override
// public void onBindViewHolder(final AbstractViewHolder holder, final int position) {
// onBind(holder, getItem(position), position, getItemViewType(position));
// }
//
// public static class AbstractViewHolder extends RecyclerView.ViewHolder {
//
// private SparseArrayCompat<View> mViewSparseArray;
//
// public AbstractViewHolder(final View itemView, final int... ids) {
// super(itemView);
//
// mViewSparseArray = new SparseArrayCompat<>(ids.length);
//
// for (final int id : ids) {
// mViewSparseArray.append(id, itemView.findViewById(id));
// }
// }
//
// public <T> T get(final int id) {
// View view = mViewSparseArray.get(id);
// if (view == null) {
// view = itemView.findViewById(id);
// }
// return (T) view;
// }
//
// }
//
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/http/HttpClientFactory.java
// public class HttpClientFactory {
//
// public static enum Type {
//
// HTTP_PURE, OK_HTTP;
//
// }
//
// @Nullable
// public static IHttpClient get(final Type pType) {
// if (pType == Type.HTTP_PURE) {
// return new HttpClientAbstraction();
// } else if (pType == Type.OK_HTTP) {
// return new OkHttpClient();
// } else {
// return null;
// }
// }
//
// public static IHttpClient getDefault() {
// return get(Type.HTTP_PURE);
// }
//
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/http/IHttpClient.java
// public interface IHttpClient {
//
// InputStream get(IRequest pRequest);
//
// InputStream post(IRequest pRequest);
//
// interface IRequest {
//
// }
//
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/model/House.java
// public class House {
//
// private String doors;
// private String title;
// private int size;
//
// private House(final String pDoors, final String pTitle, final int pSize) {
// doors = pDoors;
// title = pTitle;
// size = pSize;
// }
//
// public String getDoors() {
// return doors;
// }
//
// public String getTitle() {
// return title;
// }
//
// public int getSize() {
// return size;
// }
//
// private House() {
//
// }
//
// public static class Builder {
//
// private String doors;
// private String title;
// private int size;
//
// public Builder setDoors(final String doors) {
// this.doors = doors;
//
// return this;
// }
//
// public Builder setTitle(final String title) {
// this.title = title;
//
// return this;
// }
//
// public Builder setSize(final int size) {
// this.size = size;
//
// return this;
// }
//
// public House build() {
// return new House(doors, title, size);
// }
//
// }
//
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/utils/ContextHolder.java
// public enum ContextHolder {
//
// INSTANCE;
//
// private Context mContext;
//
// public Context getContext() {
// return mContext;
// }
//
// public void setContext(final Context pContext) {
// mContext = pContext;
// }
//
// public static Context get() {
// return INSTANCE.mContext;
// }
//
// public static void set(final Context pContext) {
// INSTANCE.mContext = pContext;
// }
//
// }
| import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.widget.TextView;
import com.example.mikhail_sianko.myapplication.R;
import com.example.mikhail_sianko.myapplication.adapter.AbstractAdapter;
import com.example.mikhail_sianko.myapplication.http.HttpClientFactory;
import com.example.mikhail_sianko.myapplication.http.IHttpClient;
import com.example.mikhail_sianko.myapplication.model.House;
import com.example.mikhail_sianko.myapplication.utils.ContextHolder;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List; | package com.example.mikhail_sianko.myapplication.examples;
public class SecondActivity extends AppCompatActivity {
@Override
protected void onCreate(@Nullable final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
| // Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/adapter/AbstractAdapter.java
// public abstract class AbstractAdapter<Item> extends RecyclerView.Adapter<AbstractAdapter.AbstractViewHolder> {
//
// public abstract void onBind(AbstractViewHolder holder, Item item, int position, int viewType);
//
// public abstract Item getItem(int positoin);
//
// @Override
// public void onBindViewHolder(final AbstractViewHolder holder, final int position) {
// onBind(holder, getItem(position), position, getItemViewType(position));
// }
//
// public static class AbstractViewHolder extends RecyclerView.ViewHolder {
//
// private SparseArrayCompat<View> mViewSparseArray;
//
// public AbstractViewHolder(final View itemView, final int... ids) {
// super(itemView);
//
// mViewSparseArray = new SparseArrayCompat<>(ids.length);
//
// for (final int id : ids) {
// mViewSparseArray.append(id, itemView.findViewById(id));
// }
// }
//
// public <T> T get(final int id) {
// View view = mViewSparseArray.get(id);
// if (view == null) {
// view = itemView.findViewById(id);
// }
// return (T) view;
// }
//
// }
//
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/http/HttpClientFactory.java
// public class HttpClientFactory {
//
// public static enum Type {
//
// HTTP_PURE, OK_HTTP;
//
// }
//
// @Nullable
// public static IHttpClient get(final Type pType) {
// if (pType == Type.HTTP_PURE) {
// return new HttpClientAbstraction();
// } else if (pType == Type.OK_HTTP) {
// return new OkHttpClient();
// } else {
// return null;
// }
// }
//
// public static IHttpClient getDefault() {
// return get(Type.HTTP_PURE);
// }
//
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/http/IHttpClient.java
// public interface IHttpClient {
//
// InputStream get(IRequest pRequest);
//
// InputStream post(IRequest pRequest);
//
// interface IRequest {
//
// }
//
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/model/House.java
// public class House {
//
// private String doors;
// private String title;
// private int size;
//
// private House(final String pDoors, final String pTitle, final int pSize) {
// doors = pDoors;
// title = pTitle;
// size = pSize;
// }
//
// public String getDoors() {
// return doors;
// }
//
// public String getTitle() {
// return title;
// }
//
// public int getSize() {
// return size;
// }
//
// private House() {
//
// }
//
// public static class Builder {
//
// private String doors;
// private String title;
// private int size;
//
// public Builder setDoors(final String doors) {
// this.doors = doors;
//
// return this;
// }
//
// public Builder setTitle(final String title) {
// this.title = title;
//
// return this;
// }
//
// public Builder setSize(final int size) {
// this.size = size;
//
// return this;
// }
//
// public House build() {
// return new House(doors, title, size);
// }
//
// }
//
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/utils/ContextHolder.java
// public enum ContextHolder {
//
// INSTANCE;
//
// private Context mContext;
//
// public Context getContext() {
// return mContext;
// }
//
// public void setContext(final Context pContext) {
// mContext = pContext;
// }
//
// public static Context get() {
// return INSTANCE.mContext;
// }
//
// public static void set(final Context pContext) {
// INSTANCE.mContext = pContext;
// }
//
// }
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/examples/SecondActivity.java
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.widget.TextView;
import com.example.mikhail_sianko.myapplication.R;
import com.example.mikhail_sianko.myapplication.adapter.AbstractAdapter;
import com.example.mikhail_sianko.myapplication.http.HttpClientFactory;
import com.example.mikhail_sianko.myapplication.http.IHttpClient;
import com.example.mikhail_sianko.myapplication.model.House;
import com.example.mikhail_sianko.myapplication.utils.ContextHolder;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
package com.example.mikhail_sianko.myapplication.examples;
public class SecondActivity extends AppCompatActivity {
@Override
protected void onCreate(@Nullable final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
| final House house = new House.Builder() |
deniotokiari/training-epam-2016 | MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/examples/SecondActivity.java | // Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/adapter/AbstractAdapter.java
// public abstract class AbstractAdapter<Item> extends RecyclerView.Adapter<AbstractAdapter.AbstractViewHolder> {
//
// public abstract void onBind(AbstractViewHolder holder, Item item, int position, int viewType);
//
// public abstract Item getItem(int positoin);
//
// @Override
// public void onBindViewHolder(final AbstractViewHolder holder, final int position) {
// onBind(holder, getItem(position), position, getItemViewType(position));
// }
//
// public static class AbstractViewHolder extends RecyclerView.ViewHolder {
//
// private SparseArrayCompat<View> mViewSparseArray;
//
// public AbstractViewHolder(final View itemView, final int... ids) {
// super(itemView);
//
// mViewSparseArray = new SparseArrayCompat<>(ids.length);
//
// for (final int id : ids) {
// mViewSparseArray.append(id, itemView.findViewById(id));
// }
// }
//
// public <T> T get(final int id) {
// View view = mViewSparseArray.get(id);
// if (view == null) {
// view = itemView.findViewById(id);
// }
// return (T) view;
// }
//
// }
//
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/http/HttpClientFactory.java
// public class HttpClientFactory {
//
// public static enum Type {
//
// HTTP_PURE, OK_HTTP;
//
// }
//
// @Nullable
// public static IHttpClient get(final Type pType) {
// if (pType == Type.HTTP_PURE) {
// return new HttpClientAbstraction();
// } else if (pType == Type.OK_HTTP) {
// return new OkHttpClient();
// } else {
// return null;
// }
// }
//
// public static IHttpClient getDefault() {
// return get(Type.HTTP_PURE);
// }
//
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/http/IHttpClient.java
// public interface IHttpClient {
//
// InputStream get(IRequest pRequest);
//
// InputStream post(IRequest pRequest);
//
// interface IRequest {
//
// }
//
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/model/House.java
// public class House {
//
// private String doors;
// private String title;
// private int size;
//
// private House(final String pDoors, final String pTitle, final int pSize) {
// doors = pDoors;
// title = pTitle;
// size = pSize;
// }
//
// public String getDoors() {
// return doors;
// }
//
// public String getTitle() {
// return title;
// }
//
// public int getSize() {
// return size;
// }
//
// private House() {
//
// }
//
// public static class Builder {
//
// private String doors;
// private String title;
// private int size;
//
// public Builder setDoors(final String doors) {
// this.doors = doors;
//
// return this;
// }
//
// public Builder setTitle(final String title) {
// this.title = title;
//
// return this;
// }
//
// public Builder setSize(final int size) {
// this.size = size;
//
// return this;
// }
//
// public House build() {
// return new House(doors, title, size);
// }
//
// }
//
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/utils/ContextHolder.java
// public enum ContextHolder {
//
// INSTANCE;
//
// private Context mContext;
//
// public Context getContext() {
// return mContext;
// }
//
// public void setContext(final Context pContext) {
// mContext = pContext;
// }
//
// public static Context get() {
// return INSTANCE.mContext;
// }
//
// public static void set(final Context pContext) {
// INSTANCE.mContext = pContext;
// }
//
// }
| import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.widget.TextView;
import com.example.mikhail_sianko.myapplication.R;
import com.example.mikhail_sianko.myapplication.adapter.AbstractAdapter;
import com.example.mikhail_sianko.myapplication.http.HttpClientFactory;
import com.example.mikhail_sianko.myapplication.http.IHttpClient;
import com.example.mikhail_sianko.myapplication.model.House;
import com.example.mikhail_sianko.myapplication.utils.ContextHolder;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List; | package com.example.mikhail_sianko.myapplication.examples;
public class SecondActivity extends AppCompatActivity {
@Override
protected void onCreate(@Nullable final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final House house = new House.Builder()
.setTitle("")
.setDoors("")
.setSize(0)
.build();
final List<House> houses = new ArrayList<>();
houses.add(house);
| // Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/adapter/AbstractAdapter.java
// public abstract class AbstractAdapter<Item> extends RecyclerView.Adapter<AbstractAdapter.AbstractViewHolder> {
//
// public abstract void onBind(AbstractViewHolder holder, Item item, int position, int viewType);
//
// public abstract Item getItem(int positoin);
//
// @Override
// public void onBindViewHolder(final AbstractViewHolder holder, final int position) {
// onBind(holder, getItem(position), position, getItemViewType(position));
// }
//
// public static class AbstractViewHolder extends RecyclerView.ViewHolder {
//
// private SparseArrayCompat<View> mViewSparseArray;
//
// public AbstractViewHolder(final View itemView, final int... ids) {
// super(itemView);
//
// mViewSparseArray = new SparseArrayCompat<>(ids.length);
//
// for (final int id : ids) {
// mViewSparseArray.append(id, itemView.findViewById(id));
// }
// }
//
// public <T> T get(final int id) {
// View view = mViewSparseArray.get(id);
// if (view == null) {
// view = itemView.findViewById(id);
// }
// return (T) view;
// }
//
// }
//
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/http/HttpClientFactory.java
// public class HttpClientFactory {
//
// public static enum Type {
//
// HTTP_PURE, OK_HTTP;
//
// }
//
// @Nullable
// public static IHttpClient get(final Type pType) {
// if (pType == Type.HTTP_PURE) {
// return new HttpClientAbstraction();
// } else if (pType == Type.OK_HTTP) {
// return new OkHttpClient();
// } else {
// return null;
// }
// }
//
// public static IHttpClient getDefault() {
// return get(Type.HTTP_PURE);
// }
//
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/http/IHttpClient.java
// public interface IHttpClient {
//
// InputStream get(IRequest pRequest);
//
// InputStream post(IRequest pRequest);
//
// interface IRequest {
//
// }
//
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/model/House.java
// public class House {
//
// private String doors;
// private String title;
// private int size;
//
// private House(final String pDoors, final String pTitle, final int pSize) {
// doors = pDoors;
// title = pTitle;
// size = pSize;
// }
//
// public String getDoors() {
// return doors;
// }
//
// public String getTitle() {
// return title;
// }
//
// public int getSize() {
// return size;
// }
//
// private House() {
//
// }
//
// public static class Builder {
//
// private String doors;
// private String title;
// private int size;
//
// public Builder setDoors(final String doors) {
// this.doors = doors;
//
// return this;
// }
//
// public Builder setTitle(final String title) {
// this.title = title;
//
// return this;
// }
//
// public Builder setSize(final int size) {
// this.size = size;
//
// return this;
// }
//
// public House build() {
// return new House(doors, title, size);
// }
//
// }
//
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/utils/ContextHolder.java
// public enum ContextHolder {
//
// INSTANCE;
//
// private Context mContext;
//
// public Context getContext() {
// return mContext;
// }
//
// public void setContext(final Context pContext) {
// mContext = pContext;
// }
//
// public static Context get() {
// return INSTANCE.mContext;
// }
//
// public static void set(final Context pContext) {
// INSTANCE.mContext = pContext;
// }
//
// }
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/examples/SecondActivity.java
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.widget.TextView;
import com.example.mikhail_sianko.myapplication.R;
import com.example.mikhail_sianko.myapplication.adapter.AbstractAdapter;
import com.example.mikhail_sianko.myapplication.http.HttpClientFactory;
import com.example.mikhail_sianko.myapplication.http.IHttpClient;
import com.example.mikhail_sianko.myapplication.model.House;
import com.example.mikhail_sianko.myapplication.utils.ContextHolder;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
package com.example.mikhail_sianko.myapplication.examples;
public class SecondActivity extends AppCompatActivity {
@Override
protected void onCreate(@Nullable final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final House house = new House.Builder()
.setTitle("")
.setDoors("")
.setSize(0)
.build();
final List<House> houses = new ArrayList<>();
houses.add(house);
| final AbstractAdapter<House> adapter = new AbstractAdapter<House>() { |
deniotokiari/training-epam-2016 | MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/examples/SecondActivity.java | // Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/adapter/AbstractAdapter.java
// public abstract class AbstractAdapter<Item> extends RecyclerView.Adapter<AbstractAdapter.AbstractViewHolder> {
//
// public abstract void onBind(AbstractViewHolder holder, Item item, int position, int viewType);
//
// public abstract Item getItem(int positoin);
//
// @Override
// public void onBindViewHolder(final AbstractViewHolder holder, final int position) {
// onBind(holder, getItem(position), position, getItemViewType(position));
// }
//
// public static class AbstractViewHolder extends RecyclerView.ViewHolder {
//
// private SparseArrayCompat<View> mViewSparseArray;
//
// public AbstractViewHolder(final View itemView, final int... ids) {
// super(itemView);
//
// mViewSparseArray = new SparseArrayCompat<>(ids.length);
//
// for (final int id : ids) {
// mViewSparseArray.append(id, itemView.findViewById(id));
// }
// }
//
// public <T> T get(final int id) {
// View view = mViewSparseArray.get(id);
// if (view == null) {
// view = itemView.findViewById(id);
// }
// return (T) view;
// }
//
// }
//
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/http/HttpClientFactory.java
// public class HttpClientFactory {
//
// public static enum Type {
//
// HTTP_PURE, OK_HTTP;
//
// }
//
// @Nullable
// public static IHttpClient get(final Type pType) {
// if (pType == Type.HTTP_PURE) {
// return new HttpClientAbstraction();
// } else if (pType == Type.OK_HTTP) {
// return new OkHttpClient();
// } else {
// return null;
// }
// }
//
// public static IHttpClient getDefault() {
// return get(Type.HTTP_PURE);
// }
//
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/http/IHttpClient.java
// public interface IHttpClient {
//
// InputStream get(IRequest pRequest);
//
// InputStream post(IRequest pRequest);
//
// interface IRequest {
//
// }
//
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/model/House.java
// public class House {
//
// private String doors;
// private String title;
// private int size;
//
// private House(final String pDoors, final String pTitle, final int pSize) {
// doors = pDoors;
// title = pTitle;
// size = pSize;
// }
//
// public String getDoors() {
// return doors;
// }
//
// public String getTitle() {
// return title;
// }
//
// public int getSize() {
// return size;
// }
//
// private House() {
//
// }
//
// public static class Builder {
//
// private String doors;
// private String title;
// private int size;
//
// public Builder setDoors(final String doors) {
// this.doors = doors;
//
// return this;
// }
//
// public Builder setTitle(final String title) {
// this.title = title;
//
// return this;
// }
//
// public Builder setSize(final int size) {
// this.size = size;
//
// return this;
// }
//
// public House build() {
// return new House(doors, title, size);
// }
//
// }
//
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/utils/ContextHolder.java
// public enum ContextHolder {
//
// INSTANCE;
//
// private Context mContext;
//
// public Context getContext() {
// return mContext;
// }
//
// public void setContext(final Context pContext) {
// mContext = pContext;
// }
//
// public static Context get() {
// return INSTANCE.mContext;
// }
//
// public static void set(final Context pContext) {
// INSTANCE.mContext = pContext;
// }
//
// }
| import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.widget.TextView;
import com.example.mikhail_sianko.myapplication.R;
import com.example.mikhail_sianko.myapplication.adapter.AbstractAdapter;
import com.example.mikhail_sianko.myapplication.http.HttpClientFactory;
import com.example.mikhail_sianko.myapplication.http.IHttpClient;
import com.example.mikhail_sianko.myapplication.model.House;
import com.example.mikhail_sianko.myapplication.utils.ContextHolder;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List; | package com.example.mikhail_sianko.myapplication.examples;
public class SecondActivity extends AppCompatActivity {
@Override
protected void onCreate(@Nullable final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final House house = new House.Builder()
.setTitle("")
.setDoors("")
.setSize(0)
.build();
final List<House> houses = new ArrayList<>();
houses.add(house);
final AbstractAdapter<House> adapter = new AbstractAdapter<House>() {
@Override
public void onBind(final AbstractViewHolder holder, final House pHouse, final int position, final int viewType) {
holder.<TextView>get(R.id.text1).setText(pHouse.getTitle());
}
@Override
public House getItem(final int positoin) {
return houses.get(positoin);
}
@Override
public AbstractViewHolder onCreateViewHolder(final ViewGroup parent, final int viewType) { | // Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/adapter/AbstractAdapter.java
// public abstract class AbstractAdapter<Item> extends RecyclerView.Adapter<AbstractAdapter.AbstractViewHolder> {
//
// public abstract void onBind(AbstractViewHolder holder, Item item, int position, int viewType);
//
// public abstract Item getItem(int positoin);
//
// @Override
// public void onBindViewHolder(final AbstractViewHolder holder, final int position) {
// onBind(holder, getItem(position), position, getItemViewType(position));
// }
//
// public static class AbstractViewHolder extends RecyclerView.ViewHolder {
//
// private SparseArrayCompat<View> mViewSparseArray;
//
// public AbstractViewHolder(final View itemView, final int... ids) {
// super(itemView);
//
// mViewSparseArray = new SparseArrayCompat<>(ids.length);
//
// for (final int id : ids) {
// mViewSparseArray.append(id, itemView.findViewById(id));
// }
// }
//
// public <T> T get(final int id) {
// View view = mViewSparseArray.get(id);
// if (view == null) {
// view = itemView.findViewById(id);
// }
// return (T) view;
// }
//
// }
//
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/http/HttpClientFactory.java
// public class HttpClientFactory {
//
// public static enum Type {
//
// HTTP_PURE, OK_HTTP;
//
// }
//
// @Nullable
// public static IHttpClient get(final Type pType) {
// if (pType == Type.HTTP_PURE) {
// return new HttpClientAbstraction();
// } else if (pType == Type.OK_HTTP) {
// return new OkHttpClient();
// } else {
// return null;
// }
// }
//
// public static IHttpClient getDefault() {
// return get(Type.HTTP_PURE);
// }
//
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/http/IHttpClient.java
// public interface IHttpClient {
//
// InputStream get(IRequest pRequest);
//
// InputStream post(IRequest pRequest);
//
// interface IRequest {
//
// }
//
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/model/House.java
// public class House {
//
// private String doors;
// private String title;
// private int size;
//
// private House(final String pDoors, final String pTitle, final int pSize) {
// doors = pDoors;
// title = pTitle;
// size = pSize;
// }
//
// public String getDoors() {
// return doors;
// }
//
// public String getTitle() {
// return title;
// }
//
// public int getSize() {
// return size;
// }
//
// private House() {
//
// }
//
// public static class Builder {
//
// private String doors;
// private String title;
// private int size;
//
// public Builder setDoors(final String doors) {
// this.doors = doors;
//
// return this;
// }
//
// public Builder setTitle(final String title) {
// this.title = title;
//
// return this;
// }
//
// public Builder setSize(final int size) {
// this.size = size;
//
// return this;
// }
//
// public House build() {
// return new House(doors, title, size);
// }
//
// }
//
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/utils/ContextHolder.java
// public enum ContextHolder {
//
// INSTANCE;
//
// private Context mContext;
//
// public Context getContext() {
// return mContext;
// }
//
// public void setContext(final Context pContext) {
// mContext = pContext;
// }
//
// public static Context get() {
// return INSTANCE.mContext;
// }
//
// public static void set(final Context pContext) {
// INSTANCE.mContext = pContext;
// }
//
// }
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/examples/SecondActivity.java
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.widget.TextView;
import com.example.mikhail_sianko.myapplication.R;
import com.example.mikhail_sianko.myapplication.adapter.AbstractAdapter;
import com.example.mikhail_sianko.myapplication.http.HttpClientFactory;
import com.example.mikhail_sianko.myapplication.http.IHttpClient;
import com.example.mikhail_sianko.myapplication.model.House;
import com.example.mikhail_sianko.myapplication.utils.ContextHolder;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
package com.example.mikhail_sianko.myapplication.examples;
public class SecondActivity extends AppCompatActivity {
@Override
protected void onCreate(@Nullable final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final House house = new House.Builder()
.setTitle("")
.setDoors("")
.setSize(0)
.build();
final List<House> houses = new ArrayList<>();
houses.add(house);
final AbstractAdapter<House> adapter = new AbstractAdapter<House>() {
@Override
public void onBind(final AbstractViewHolder holder, final House pHouse, final int position, final int viewType) {
holder.<TextView>get(R.id.text1).setText(pHouse.getTitle());
}
@Override
public House getItem(final int positoin) {
return houses.get(positoin);
}
@Override
public AbstractViewHolder onCreateViewHolder(final ViewGroup parent, final int viewType) { | return new AbstractViewHolder(LayoutInflater.from(ContextHolder.get()).inflate(R.layout.view_bars, null), R.id.text1); |
deniotokiari/training-epam-2016 | MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/malevich/MalevichImpl.java | // Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/threads/OnResultCallback.java
// public interface OnResultCallback<Result, Progress> extends ProgressCallback<Progress> {
//
// void onSuccess(Result result);
//
// void onError(Exception e);
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/threads/Operation.java
// public interface Operation<Params, Progress, Result> {
//
// Result doing(Params params, ProgressCallback<Progress> progressCallback) throws Exception;
//
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/threads/ProgressCallback.java
// public interface ProgressCallback<Progress> {
//
// void onProgressChanged(Progress progress);
//
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/threads/ThreadManager.java
// public class ThreadManager {
//
// public static final int COUNT_CORE = 3;
// private final ExecutorService executorService;
//
// public ThreadManager() {
// this(Executors.newFixedThreadPool(3));
// }
//
// public ThreadManager(final ExecutorService executorService) {
// this.executorService = executorService;
// }
//
// public<Params, Progress, Result> void execute(final Operation<Params, Progress, Result> operation, final Params param, final OnResultCallback<Result, Progress> onResultCallback) {
// final Handler handler = new Handler();
// executorService.execute(new Runnable() {
//
// @Override
// public void run() {
// try {
// final Result result = operation.doing(param, new ProgressCallback<Progress>() {
//
// @Override
// public void onProgressChanged(final Progress progress) {
// handler.post(new Runnable() {
//
// @Override
// public void run() {
// onResultCallback.onProgressChanged(progress);
// }
// });
// }
// });
// handler.post(new Runnable() {
//
// @Override
// public void run() {
// onResultCallback.onSuccess(result);
// }
// });
// } catch (Exception e) {
// onResultCallback.onError(e);
// }
// }
// });
// }
//
// }
//
// Path: MyApplication/util-lib/src/main/java/com/training2016/android/http/HttpClient.java
// public class HttpClient {
//
// public String get(String url) throws Exception {
// return doRequest(url, "GET", null, null);
// }
//
// public String get(String url, Map<String, String> headers) throws Exception {
// return doRequest(url, "GET", headers, null);
// }
//
// public String post(String url, Map<String, String> header, String body) throws Exception {
// return doRequest(url, "POST", header, body);
// }
//
// private String doRequest(String url, String type, Map<String, String> header, String body) throws Exception {
// String response = null;
// HttpURLConnection connection = null;
// try {
// URL reqUrl = new URL(url);
// connection = ((HttpURLConnection) reqUrl.openConnection());
// connection.setRequestMethod(type);
// if (header != null) {
// for (String key : header.keySet()) {
// connection.addRequestProperty(key, header.get(key));
// }
// }
// if (body != null) {
// applyBody(connection, body);
// }
//
// InputStream inputStream;
//
// boolean isSuccess = connection.getResponseCode() >= 200 && connection.getResponseCode() < 300;
// if (isSuccess) {
// inputStream = connection.getInputStream();
// } else {
// inputStream = connection.getErrorStream();
// }
//
// BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
// StringBuilder stringBuilder = new StringBuilder();
// String line;
// while ((line = reader.readLine()) != null) {
// stringBuilder.append(line);
// }
// response = stringBuilder.toString();
//
// inputStream.close();
//
// if (!isSuccess) {
// System.out.println("http exception = " + response);
// throw new Exception(response);
// }
//
// } finally {
// if (connection != null) {
// connection.disconnect();
// }
// }
// return response;
// }
//
// public interface ResultConverter<Result> {
//
// Result convert(InputStream inputStream);
//
// }
//
// public <Result> Result getResult(String url, ResultConverter<Result> resultConverter) throws IOException {
// HttpURLConnection connection = null;
// InputStream inputStream = null;
// try {
// URL reqUrl = new URL(url);
// connection = ((HttpURLConnection) reqUrl.openConnection());
// connection.setRequestMethod("GET");
// inputStream = connection.getInputStream();
// return resultConverter.convert(inputStream);
// } finally {
// if (inputStream != null) {
// inputStream.close();
// }
// if (connection != null) {
// connection.disconnect();
// }
// }
// }
//
// private void applyBody(HttpURLConnection httpURLConnection, String body) throws Exception {
// byte[] outputInBytes = body.getBytes("UTF-8");
// OutputStream os = httpURLConnection.getOutputStream();
// os.write(outputInBytes);
// os.close();
// }
//
//
// }
| import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.support.v4.util.LruCache;
import android.util.Log;
import android.widget.ImageView;
import com.example.mikhail_sianko.myapplication.threads.OnResultCallback;
import com.example.mikhail_sianko.myapplication.threads.Operation;
import com.example.mikhail_sianko.myapplication.threads.ProgressCallback;
import com.example.mikhail_sianko.myapplication.threads.ThreadManager;
import com.training2016.android.http.HttpClient;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.ref.WeakReference;
import java.util.concurrent.Executors; | package com.example.mikhail_sianko.myapplication.malevich;
class MalevichImpl implements Malevich {
public static final int MAX_MEMORY_FOR_IMAGES = 64 * 1000 * 1000;
//TODO queue LIFO | // Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/threads/OnResultCallback.java
// public interface OnResultCallback<Result, Progress> extends ProgressCallback<Progress> {
//
// void onSuccess(Result result);
//
// void onError(Exception e);
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/threads/Operation.java
// public interface Operation<Params, Progress, Result> {
//
// Result doing(Params params, ProgressCallback<Progress> progressCallback) throws Exception;
//
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/threads/ProgressCallback.java
// public interface ProgressCallback<Progress> {
//
// void onProgressChanged(Progress progress);
//
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/threads/ThreadManager.java
// public class ThreadManager {
//
// public static final int COUNT_CORE = 3;
// private final ExecutorService executorService;
//
// public ThreadManager() {
// this(Executors.newFixedThreadPool(3));
// }
//
// public ThreadManager(final ExecutorService executorService) {
// this.executorService = executorService;
// }
//
// public<Params, Progress, Result> void execute(final Operation<Params, Progress, Result> operation, final Params param, final OnResultCallback<Result, Progress> onResultCallback) {
// final Handler handler = new Handler();
// executorService.execute(new Runnable() {
//
// @Override
// public void run() {
// try {
// final Result result = operation.doing(param, new ProgressCallback<Progress>() {
//
// @Override
// public void onProgressChanged(final Progress progress) {
// handler.post(new Runnable() {
//
// @Override
// public void run() {
// onResultCallback.onProgressChanged(progress);
// }
// });
// }
// });
// handler.post(new Runnable() {
//
// @Override
// public void run() {
// onResultCallback.onSuccess(result);
// }
// });
// } catch (Exception e) {
// onResultCallback.onError(e);
// }
// }
// });
// }
//
// }
//
// Path: MyApplication/util-lib/src/main/java/com/training2016/android/http/HttpClient.java
// public class HttpClient {
//
// public String get(String url) throws Exception {
// return doRequest(url, "GET", null, null);
// }
//
// public String get(String url, Map<String, String> headers) throws Exception {
// return doRequest(url, "GET", headers, null);
// }
//
// public String post(String url, Map<String, String> header, String body) throws Exception {
// return doRequest(url, "POST", header, body);
// }
//
// private String doRequest(String url, String type, Map<String, String> header, String body) throws Exception {
// String response = null;
// HttpURLConnection connection = null;
// try {
// URL reqUrl = new URL(url);
// connection = ((HttpURLConnection) reqUrl.openConnection());
// connection.setRequestMethod(type);
// if (header != null) {
// for (String key : header.keySet()) {
// connection.addRequestProperty(key, header.get(key));
// }
// }
// if (body != null) {
// applyBody(connection, body);
// }
//
// InputStream inputStream;
//
// boolean isSuccess = connection.getResponseCode() >= 200 && connection.getResponseCode() < 300;
// if (isSuccess) {
// inputStream = connection.getInputStream();
// } else {
// inputStream = connection.getErrorStream();
// }
//
// BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
// StringBuilder stringBuilder = new StringBuilder();
// String line;
// while ((line = reader.readLine()) != null) {
// stringBuilder.append(line);
// }
// response = stringBuilder.toString();
//
// inputStream.close();
//
// if (!isSuccess) {
// System.out.println("http exception = " + response);
// throw new Exception(response);
// }
//
// } finally {
// if (connection != null) {
// connection.disconnect();
// }
// }
// return response;
// }
//
// public interface ResultConverter<Result> {
//
// Result convert(InputStream inputStream);
//
// }
//
// public <Result> Result getResult(String url, ResultConverter<Result> resultConverter) throws IOException {
// HttpURLConnection connection = null;
// InputStream inputStream = null;
// try {
// URL reqUrl = new URL(url);
// connection = ((HttpURLConnection) reqUrl.openConnection());
// connection.setRequestMethod("GET");
// inputStream = connection.getInputStream();
// return resultConverter.convert(inputStream);
// } finally {
// if (inputStream != null) {
// inputStream.close();
// }
// if (connection != null) {
// connection.disconnect();
// }
// }
// }
//
// private void applyBody(HttpURLConnection httpURLConnection, String body) throws Exception {
// byte[] outputInBytes = body.getBytes("UTF-8");
// OutputStream os = httpURLConnection.getOutputStream();
// os.write(outputInBytes);
// os.close();
// }
//
//
// }
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/malevich/MalevichImpl.java
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.support.v4.util.LruCache;
import android.util.Log;
import android.widget.ImageView;
import com.example.mikhail_sianko.myapplication.threads.OnResultCallback;
import com.example.mikhail_sianko.myapplication.threads.Operation;
import com.example.mikhail_sianko.myapplication.threads.ProgressCallback;
import com.example.mikhail_sianko.myapplication.threads.ThreadManager;
import com.training2016.android.http.HttpClient;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.ref.WeakReference;
import java.util.concurrent.Executors;
package com.example.mikhail_sianko.myapplication.malevich;
class MalevichImpl implements Malevich {
public static final int MAX_MEMORY_FOR_IMAGES = 64 * 1000 * 1000;
//TODO queue LIFO | private ThreadManager threadManager = new ThreadManager(Executors.newFixedThreadPool(ThreadManager.COUNT_CORE)); |
deniotokiari/training-epam-2016 | MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/threads/operation/HttpGetRequest.java | // Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/model/HttpRequestModel.java
// public class HttpRequestModel {
//
// private String url;
//
// private Map<String, String> headers;
//
// private String body;
//
//
// public void setUrl(String url) {
// this.url = url;
// }
//
// public void setHeaders(Map<String, String> headers) {
// this.headers = headers;
// }
//
// public void setBody(String body) {
// this.body = body;
// }
//
// public String getUrl() {
// return url;
// }
//
// public Map<String, String> getHeaders() {
// return headers;
// }
//
// public String getBody() {
// return body;
// }
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/threads/Operation.java
// public interface Operation<Params, Progress, Result> {
//
// Result doing(Params params, ProgressCallback<Progress> progressCallback) throws Exception;
//
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/threads/ProgressCallback.java
// public interface ProgressCallback<Progress> {
//
// void onProgressChanged(Progress progress);
//
// }
//
// Path: MyApplication/util-lib/src/main/java/com/training2016/android/http/HttpClient.java
// public class HttpClient {
//
// public String get(String url) throws Exception {
// return doRequest(url, "GET", null, null);
// }
//
// public String get(String url, Map<String, String> headers) throws Exception {
// return doRequest(url, "GET", headers, null);
// }
//
// public String post(String url, Map<String, String> header, String body) throws Exception {
// return doRequest(url, "POST", header, body);
// }
//
// private String doRequest(String url, String type, Map<String, String> header, String body) throws Exception {
// String response = null;
// HttpURLConnection connection = null;
// try {
// URL reqUrl = new URL(url);
// connection = ((HttpURLConnection) reqUrl.openConnection());
// connection.setRequestMethod(type);
// if (header != null) {
// for (String key : header.keySet()) {
// connection.addRequestProperty(key, header.get(key));
// }
// }
// if (body != null) {
// applyBody(connection, body);
// }
//
// InputStream inputStream;
//
// boolean isSuccess = connection.getResponseCode() >= 200 && connection.getResponseCode() < 300;
// if (isSuccess) {
// inputStream = connection.getInputStream();
// } else {
// inputStream = connection.getErrorStream();
// }
//
// BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
// StringBuilder stringBuilder = new StringBuilder();
// String line;
// while ((line = reader.readLine()) != null) {
// stringBuilder.append(line);
// }
// response = stringBuilder.toString();
//
// inputStream.close();
//
// if (!isSuccess) {
// System.out.println("http exception = " + response);
// throw new Exception(response);
// }
//
// } finally {
// if (connection != null) {
// connection.disconnect();
// }
// }
// return response;
// }
//
// public interface ResultConverter<Result> {
//
// Result convert(InputStream inputStream);
//
// }
//
// public <Result> Result getResult(String url, ResultConverter<Result> resultConverter) throws IOException {
// HttpURLConnection connection = null;
// InputStream inputStream = null;
// try {
// URL reqUrl = new URL(url);
// connection = ((HttpURLConnection) reqUrl.openConnection());
// connection.setRequestMethod("GET");
// inputStream = connection.getInputStream();
// return resultConverter.convert(inputStream);
// } finally {
// if (inputStream != null) {
// inputStream.close();
// }
// if (connection != null) {
// connection.disconnect();
// }
// }
// }
//
// private void applyBody(HttpURLConnection httpURLConnection, String body) throws Exception {
// byte[] outputInBytes = body.getBytes("UTF-8");
// OutputStream os = httpURLConnection.getOutputStream();
// os.write(outputInBytes);
// os.close();
// }
//
//
// }
| import com.example.mikhail_sianko.myapplication.model.HttpRequestModel;
import com.example.mikhail_sianko.myapplication.threads.Operation;
import com.example.mikhail_sianko.myapplication.threads.ProgressCallback;
import com.training2016.android.http.HttpClient; | package com.example.mikhail_sianko.myapplication.threads.operation;
public class HttpGetRequest implements Operation<HttpRequestModel, Void, String> {
public HttpGetRequest() {
}
@Override | // Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/model/HttpRequestModel.java
// public class HttpRequestModel {
//
// private String url;
//
// private Map<String, String> headers;
//
// private String body;
//
//
// public void setUrl(String url) {
// this.url = url;
// }
//
// public void setHeaders(Map<String, String> headers) {
// this.headers = headers;
// }
//
// public void setBody(String body) {
// this.body = body;
// }
//
// public String getUrl() {
// return url;
// }
//
// public Map<String, String> getHeaders() {
// return headers;
// }
//
// public String getBody() {
// return body;
// }
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/threads/Operation.java
// public interface Operation<Params, Progress, Result> {
//
// Result doing(Params params, ProgressCallback<Progress> progressCallback) throws Exception;
//
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/threads/ProgressCallback.java
// public interface ProgressCallback<Progress> {
//
// void onProgressChanged(Progress progress);
//
// }
//
// Path: MyApplication/util-lib/src/main/java/com/training2016/android/http/HttpClient.java
// public class HttpClient {
//
// public String get(String url) throws Exception {
// return doRequest(url, "GET", null, null);
// }
//
// public String get(String url, Map<String, String> headers) throws Exception {
// return doRequest(url, "GET", headers, null);
// }
//
// public String post(String url, Map<String, String> header, String body) throws Exception {
// return doRequest(url, "POST", header, body);
// }
//
// private String doRequest(String url, String type, Map<String, String> header, String body) throws Exception {
// String response = null;
// HttpURLConnection connection = null;
// try {
// URL reqUrl = new URL(url);
// connection = ((HttpURLConnection) reqUrl.openConnection());
// connection.setRequestMethod(type);
// if (header != null) {
// for (String key : header.keySet()) {
// connection.addRequestProperty(key, header.get(key));
// }
// }
// if (body != null) {
// applyBody(connection, body);
// }
//
// InputStream inputStream;
//
// boolean isSuccess = connection.getResponseCode() >= 200 && connection.getResponseCode() < 300;
// if (isSuccess) {
// inputStream = connection.getInputStream();
// } else {
// inputStream = connection.getErrorStream();
// }
//
// BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
// StringBuilder stringBuilder = new StringBuilder();
// String line;
// while ((line = reader.readLine()) != null) {
// stringBuilder.append(line);
// }
// response = stringBuilder.toString();
//
// inputStream.close();
//
// if (!isSuccess) {
// System.out.println("http exception = " + response);
// throw new Exception(response);
// }
//
// } finally {
// if (connection != null) {
// connection.disconnect();
// }
// }
// return response;
// }
//
// public interface ResultConverter<Result> {
//
// Result convert(InputStream inputStream);
//
// }
//
// public <Result> Result getResult(String url, ResultConverter<Result> resultConverter) throws IOException {
// HttpURLConnection connection = null;
// InputStream inputStream = null;
// try {
// URL reqUrl = new URL(url);
// connection = ((HttpURLConnection) reqUrl.openConnection());
// connection.setRequestMethod("GET");
// inputStream = connection.getInputStream();
// return resultConverter.convert(inputStream);
// } finally {
// if (inputStream != null) {
// inputStream.close();
// }
// if (connection != null) {
// connection.disconnect();
// }
// }
// }
//
// private void applyBody(HttpURLConnection httpURLConnection, String body) throws Exception {
// byte[] outputInBytes = body.getBytes("UTF-8");
// OutputStream os = httpURLConnection.getOutputStream();
// os.write(outputInBytes);
// os.close();
// }
//
//
// }
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/threads/operation/HttpGetRequest.java
import com.example.mikhail_sianko.myapplication.model.HttpRequestModel;
import com.example.mikhail_sianko.myapplication.threads.Operation;
import com.example.mikhail_sianko.myapplication.threads.ProgressCallback;
import com.training2016.android.http.HttpClient;
package com.example.mikhail_sianko.myapplication.threads.operation;
public class HttpGetRequest implements Operation<HttpRequestModel, Void, String> {
public HttpGetRequest() {
}
@Override | public String doing(HttpRequestModel requestModel, ProgressCallback<Void> progressCallback) throws Exception { |
deniotokiari/training-epam-2016 | MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/threads/operation/HttpGetRequest.java | // Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/model/HttpRequestModel.java
// public class HttpRequestModel {
//
// private String url;
//
// private Map<String, String> headers;
//
// private String body;
//
//
// public void setUrl(String url) {
// this.url = url;
// }
//
// public void setHeaders(Map<String, String> headers) {
// this.headers = headers;
// }
//
// public void setBody(String body) {
// this.body = body;
// }
//
// public String getUrl() {
// return url;
// }
//
// public Map<String, String> getHeaders() {
// return headers;
// }
//
// public String getBody() {
// return body;
// }
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/threads/Operation.java
// public interface Operation<Params, Progress, Result> {
//
// Result doing(Params params, ProgressCallback<Progress> progressCallback) throws Exception;
//
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/threads/ProgressCallback.java
// public interface ProgressCallback<Progress> {
//
// void onProgressChanged(Progress progress);
//
// }
//
// Path: MyApplication/util-lib/src/main/java/com/training2016/android/http/HttpClient.java
// public class HttpClient {
//
// public String get(String url) throws Exception {
// return doRequest(url, "GET", null, null);
// }
//
// public String get(String url, Map<String, String> headers) throws Exception {
// return doRequest(url, "GET", headers, null);
// }
//
// public String post(String url, Map<String, String> header, String body) throws Exception {
// return doRequest(url, "POST", header, body);
// }
//
// private String doRequest(String url, String type, Map<String, String> header, String body) throws Exception {
// String response = null;
// HttpURLConnection connection = null;
// try {
// URL reqUrl = new URL(url);
// connection = ((HttpURLConnection) reqUrl.openConnection());
// connection.setRequestMethod(type);
// if (header != null) {
// for (String key : header.keySet()) {
// connection.addRequestProperty(key, header.get(key));
// }
// }
// if (body != null) {
// applyBody(connection, body);
// }
//
// InputStream inputStream;
//
// boolean isSuccess = connection.getResponseCode() >= 200 && connection.getResponseCode() < 300;
// if (isSuccess) {
// inputStream = connection.getInputStream();
// } else {
// inputStream = connection.getErrorStream();
// }
//
// BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
// StringBuilder stringBuilder = new StringBuilder();
// String line;
// while ((line = reader.readLine()) != null) {
// stringBuilder.append(line);
// }
// response = stringBuilder.toString();
//
// inputStream.close();
//
// if (!isSuccess) {
// System.out.println("http exception = " + response);
// throw new Exception(response);
// }
//
// } finally {
// if (connection != null) {
// connection.disconnect();
// }
// }
// return response;
// }
//
// public interface ResultConverter<Result> {
//
// Result convert(InputStream inputStream);
//
// }
//
// public <Result> Result getResult(String url, ResultConverter<Result> resultConverter) throws IOException {
// HttpURLConnection connection = null;
// InputStream inputStream = null;
// try {
// URL reqUrl = new URL(url);
// connection = ((HttpURLConnection) reqUrl.openConnection());
// connection.setRequestMethod("GET");
// inputStream = connection.getInputStream();
// return resultConverter.convert(inputStream);
// } finally {
// if (inputStream != null) {
// inputStream.close();
// }
// if (connection != null) {
// connection.disconnect();
// }
// }
// }
//
// private void applyBody(HttpURLConnection httpURLConnection, String body) throws Exception {
// byte[] outputInBytes = body.getBytes("UTF-8");
// OutputStream os = httpURLConnection.getOutputStream();
// os.write(outputInBytes);
// os.close();
// }
//
//
// }
| import com.example.mikhail_sianko.myapplication.model.HttpRequestModel;
import com.example.mikhail_sianko.myapplication.threads.Operation;
import com.example.mikhail_sianko.myapplication.threads.ProgressCallback;
import com.training2016.android.http.HttpClient; | package com.example.mikhail_sianko.myapplication.threads.operation;
public class HttpGetRequest implements Operation<HttpRequestModel, Void, String> {
public HttpGetRequest() {
}
@Override
public String doing(HttpRequestModel requestModel, ProgressCallback<Void> progressCallback) throws Exception { | // Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/model/HttpRequestModel.java
// public class HttpRequestModel {
//
// private String url;
//
// private Map<String, String> headers;
//
// private String body;
//
//
// public void setUrl(String url) {
// this.url = url;
// }
//
// public void setHeaders(Map<String, String> headers) {
// this.headers = headers;
// }
//
// public void setBody(String body) {
// this.body = body;
// }
//
// public String getUrl() {
// return url;
// }
//
// public Map<String, String> getHeaders() {
// return headers;
// }
//
// public String getBody() {
// return body;
// }
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/threads/Operation.java
// public interface Operation<Params, Progress, Result> {
//
// Result doing(Params params, ProgressCallback<Progress> progressCallback) throws Exception;
//
// }
//
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/threads/ProgressCallback.java
// public interface ProgressCallback<Progress> {
//
// void onProgressChanged(Progress progress);
//
// }
//
// Path: MyApplication/util-lib/src/main/java/com/training2016/android/http/HttpClient.java
// public class HttpClient {
//
// public String get(String url) throws Exception {
// return doRequest(url, "GET", null, null);
// }
//
// public String get(String url, Map<String, String> headers) throws Exception {
// return doRequest(url, "GET", headers, null);
// }
//
// public String post(String url, Map<String, String> header, String body) throws Exception {
// return doRequest(url, "POST", header, body);
// }
//
// private String doRequest(String url, String type, Map<String, String> header, String body) throws Exception {
// String response = null;
// HttpURLConnection connection = null;
// try {
// URL reqUrl = new URL(url);
// connection = ((HttpURLConnection) reqUrl.openConnection());
// connection.setRequestMethod(type);
// if (header != null) {
// for (String key : header.keySet()) {
// connection.addRequestProperty(key, header.get(key));
// }
// }
// if (body != null) {
// applyBody(connection, body);
// }
//
// InputStream inputStream;
//
// boolean isSuccess = connection.getResponseCode() >= 200 && connection.getResponseCode() < 300;
// if (isSuccess) {
// inputStream = connection.getInputStream();
// } else {
// inputStream = connection.getErrorStream();
// }
//
// BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
// StringBuilder stringBuilder = new StringBuilder();
// String line;
// while ((line = reader.readLine()) != null) {
// stringBuilder.append(line);
// }
// response = stringBuilder.toString();
//
// inputStream.close();
//
// if (!isSuccess) {
// System.out.println("http exception = " + response);
// throw new Exception(response);
// }
//
// } finally {
// if (connection != null) {
// connection.disconnect();
// }
// }
// return response;
// }
//
// public interface ResultConverter<Result> {
//
// Result convert(InputStream inputStream);
//
// }
//
// public <Result> Result getResult(String url, ResultConverter<Result> resultConverter) throws IOException {
// HttpURLConnection connection = null;
// InputStream inputStream = null;
// try {
// URL reqUrl = new URL(url);
// connection = ((HttpURLConnection) reqUrl.openConnection());
// connection.setRequestMethod("GET");
// inputStream = connection.getInputStream();
// return resultConverter.convert(inputStream);
// } finally {
// if (inputStream != null) {
// inputStream.close();
// }
// if (connection != null) {
// connection.disconnect();
// }
// }
// }
//
// private void applyBody(HttpURLConnection httpURLConnection, String body) throws Exception {
// byte[] outputInBytes = body.getBytes("UTF-8");
// OutputStream os = httpURLConnection.getOutputStream();
// os.write(outputInBytes);
// os.close();
// }
//
//
// }
// Path: MyApplication/app/src/main/java/com/example/mikhail_sianko/myapplication/threads/operation/HttpGetRequest.java
import com.example.mikhail_sianko.myapplication.model.HttpRequestModel;
import com.example.mikhail_sianko.myapplication.threads.Operation;
import com.example.mikhail_sianko.myapplication.threads.ProgressCallback;
import com.training2016.android.http.HttpClient;
package com.example.mikhail_sianko.myapplication.threads.operation;
public class HttpGetRequest implements Operation<HttpRequestModel, Void, String> {
public HttpGetRequest() {
}
@Override
public String doing(HttpRequestModel requestModel, ProgressCallback<Void> progressCallback) throws Exception { | HttpClient httpClient = new HttpClient(); |
realrolfje/anonimatron | src/test/java/com/rolfje/anonimatron/anonymizer/ToLowerAnonymizer.java | // Path: src/main/java/com/rolfje/anonimatron/synonyms/StringSynonym.java
// public class StringSynonym implements Synonym {
// private String type;
// private String from;
// private String to;
// private boolean shortlived = false;
//
// public StringSynonym() {
// }
//
// public StringSynonym(String type, String from, String to, boolean shortlived) {
// this.type = type;
// this.from = from;
// this.to = to;
// this.shortlived = shortlived;
// }
//
// @Override
// public String getType() {
// return type;
// }
//
// @Override
// public Object getFrom() {
// return from;
// }
//
// @Override
// public Object getTo() {
// return to;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setFrom(String from) {
// this.from = from;
// }
//
// public void setTo(String to) {
// this.to = to;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortlived;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
| import com.rolfje.anonimatron.synonyms.StringSynonym;
import com.rolfje.anonimatron.synonyms.Synonym; | package com.rolfje.anonimatron.anonymizer;
public class ToLowerAnonymizer implements Anonymizer {
@Override
public String getType() {
return "TO_LOWER_CASE";
}
@Override | // Path: src/main/java/com/rolfje/anonimatron/synonyms/StringSynonym.java
// public class StringSynonym implements Synonym {
// private String type;
// private String from;
// private String to;
// private boolean shortlived = false;
//
// public StringSynonym() {
// }
//
// public StringSynonym(String type, String from, String to, boolean shortlived) {
// this.type = type;
// this.from = from;
// this.to = to;
// this.shortlived = shortlived;
// }
//
// @Override
// public String getType() {
// return type;
// }
//
// @Override
// public Object getFrom() {
// return from;
// }
//
// @Override
// public Object getTo() {
// return to;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setFrom(String from) {
// this.from = from;
// }
//
// public void setTo(String to) {
// this.to = to;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortlived;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
// Path: src/test/java/com/rolfje/anonimatron/anonymizer/ToLowerAnonymizer.java
import com.rolfje.anonimatron.synonyms.StringSynonym;
import com.rolfje.anonimatron.synonyms.Synonym;
package com.rolfje.anonimatron.anonymizer;
public class ToLowerAnonymizer implements Anonymizer {
@Override
public String getType() {
return "TO_LOWER_CASE";
}
@Override | public Synonym anonymize(Object from, int size, boolean shortlived) { |
realrolfje/anonimatron | src/test/java/com/rolfje/anonimatron/anonymizer/ToLowerAnonymizer.java | // Path: src/main/java/com/rolfje/anonimatron/synonyms/StringSynonym.java
// public class StringSynonym implements Synonym {
// private String type;
// private String from;
// private String to;
// private boolean shortlived = false;
//
// public StringSynonym() {
// }
//
// public StringSynonym(String type, String from, String to, boolean shortlived) {
// this.type = type;
// this.from = from;
// this.to = to;
// this.shortlived = shortlived;
// }
//
// @Override
// public String getType() {
// return type;
// }
//
// @Override
// public Object getFrom() {
// return from;
// }
//
// @Override
// public Object getTo() {
// return to;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setFrom(String from) {
// this.from = from;
// }
//
// public void setTo(String to) {
// this.to = to;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortlived;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
| import com.rolfje.anonimatron.synonyms.StringSynonym;
import com.rolfje.anonimatron.synonyms.Synonym; | package com.rolfje.anonimatron.anonymizer;
public class ToLowerAnonymizer implements Anonymizer {
@Override
public String getType() {
return "TO_LOWER_CASE";
}
@Override
public Synonym anonymize(Object from, int size, boolean shortlived) { | // Path: src/main/java/com/rolfje/anonimatron/synonyms/StringSynonym.java
// public class StringSynonym implements Synonym {
// private String type;
// private String from;
// private String to;
// private boolean shortlived = false;
//
// public StringSynonym() {
// }
//
// public StringSynonym(String type, String from, String to, boolean shortlived) {
// this.type = type;
// this.from = from;
// this.to = to;
// this.shortlived = shortlived;
// }
//
// @Override
// public String getType() {
// return type;
// }
//
// @Override
// public Object getFrom() {
// return from;
// }
//
// @Override
// public Object getTo() {
// return to;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setFrom(String from) {
// this.from = from;
// }
//
// public void setTo(String to) {
// this.to = to;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortlived;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
// Path: src/test/java/com/rolfje/anonimatron/anonymizer/ToLowerAnonymizer.java
import com.rolfje.anonimatron.synonyms.StringSynonym;
import com.rolfje.anonimatron.synonyms.Synonym;
package com.rolfje.anonimatron.anonymizer;
public class ToLowerAnonymizer implements Anonymizer {
@Override
public String getType() {
return "TO_LOWER_CASE";
}
@Override
public Synonym anonymize(Object from, int size, boolean shortlived) { | return new StringSynonym( |
realrolfje/anonimatron | src/test/java/com/rolfje/anonimatron/anonymizer/AnonymizerServiceTest.java | // Path: src/main/java/com/rolfje/anonimatron/configuration/Column.java
// public class Column {
// private String name;
// private String type;
// private int size = -1;
// private boolean shortlived;
// private Map<String, String> parameters;
//
// public Column() {
//
// }
//
// public Column(String name, String type) {
// this.name = name;
// this.type = type;
// }
//
// public Column(String name, String type, int size) {
// this(name, type);
// this.size = size;
// }
//
// public Column(String name, String type, int size, boolean shortlived) {
// this(name, type);
// this.size = size;
// this.shortlived = shortlived;
// }
//
// public Column(String name, String type, int size, boolean shortlived, Map<String, String> parameters) {
// this(name, type, size, shortlived);
// this.parameters = parameters;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public int getSize() {
// return size;
// }
//
// public void setSize(int size) {
// this.size = size;
// }
//
// public boolean isShortLived() {
// return shortlived;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// public Map<String, String> getParameters() {
// return parameters;
// }
//
// public void setParameters(Map<String, String> parameters) {
// this.parameters = parameters;
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
| import com.rolfje.anonimatron.configuration.Column;
import com.rolfje.anonimatron.synonyms.Synonym;
import junit.framework.TestCase;
import java.sql.Date;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map; |
assertEquals(new Date(0), new Date(0));
List<Object> fromList = new ArrayList<>();
fromList.add(new Date(0));
fromList.add(new Date(86400000L));
fromList.add(new Date(172800000L));
String type = Date.class.getName();
testAnonymizer(fromList, type, "DATE");
}
public void testParameterizedAnonymizer() {
List<Object> fromList = new ArrayList<>();
fromList.add("String 1");
fromList.add("String 2");
fromList.add("String 3");
String type = new FixedValueAnonymizer().getType();
testAnonymizer(fromList, type, type);
}
private void testAnonymizer(List<Object> fromList, String lookupType, String synonymType) {
List<Object> toList = new ArrayList<>();
Map<String, String> parameters = new HashMap<>();
parameters.put("value", "testValue");
| // Path: src/main/java/com/rolfje/anonimatron/configuration/Column.java
// public class Column {
// private String name;
// private String type;
// private int size = -1;
// private boolean shortlived;
// private Map<String, String> parameters;
//
// public Column() {
//
// }
//
// public Column(String name, String type) {
// this.name = name;
// this.type = type;
// }
//
// public Column(String name, String type, int size) {
// this(name, type);
// this.size = size;
// }
//
// public Column(String name, String type, int size, boolean shortlived) {
// this(name, type);
// this.size = size;
// this.shortlived = shortlived;
// }
//
// public Column(String name, String type, int size, boolean shortlived, Map<String, String> parameters) {
// this(name, type, size, shortlived);
// this.parameters = parameters;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public int getSize() {
// return size;
// }
//
// public void setSize(int size) {
// this.size = size;
// }
//
// public boolean isShortLived() {
// return shortlived;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// public Map<String, String> getParameters() {
// return parameters;
// }
//
// public void setParameters(Map<String, String> parameters) {
// this.parameters = parameters;
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
// Path: src/test/java/com/rolfje/anonimatron/anonymizer/AnonymizerServiceTest.java
import com.rolfje.anonimatron.configuration.Column;
import com.rolfje.anonimatron.synonyms.Synonym;
import junit.framework.TestCase;
import java.sql.Date;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
assertEquals(new Date(0), new Date(0));
List<Object> fromList = new ArrayList<>();
fromList.add(new Date(0));
fromList.add(new Date(86400000L));
fromList.add(new Date(172800000L));
String type = Date.class.getName();
testAnonymizer(fromList, type, "DATE");
}
public void testParameterizedAnonymizer() {
List<Object> fromList = new ArrayList<>();
fromList.add("String 1");
fromList.add("String 2");
fromList.add("String 3");
String type = new FixedValueAnonymizer().getType();
testAnonymizer(fromList, type, type);
}
private void testAnonymizer(List<Object> fromList, String lookupType, String synonymType) {
List<Object> toList = new ArrayList<>();
Map<String, String> parameters = new HashMap<>();
parameters.put("value", "testValue");
| Column column = new Column("Testcolumn", lookupType, 100, false, parameters); |
realrolfje/anonimatron | src/test/java/com/rolfje/anonimatron/anonymizer/AnonymizerServiceTest.java | // Path: src/main/java/com/rolfje/anonimatron/configuration/Column.java
// public class Column {
// private String name;
// private String type;
// private int size = -1;
// private boolean shortlived;
// private Map<String, String> parameters;
//
// public Column() {
//
// }
//
// public Column(String name, String type) {
// this.name = name;
// this.type = type;
// }
//
// public Column(String name, String type, int size) {
// this(name, type);
// this.size = size;
// }
//
// public Column(String name, String type, int size, boolean shortlived) {
// this(name, type);
// this.size = size;
// this.shortlived = shortlived;
// }
//
// public Column(String name, String type, int size, boolean shortlived, Map<String, String> parameters) {
// this(name, type, size, shortlived);
// this.parameters = parameters;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public int getSize() {
// return size;
// }
//
// public void setSize(int size) {
// this.size = size;
// }
//
// public boolean isShortLived() {
// return shortlived;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// public Map<String, String> getParameters() {
// return parameters;
// }
//
// public void setParameters(Map<String, String> parameters) {
// this.parameters = parameters;
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
| import com.rolfje.anonimatron.configuration.Column;
import com.rolfje.anonimatron.synonyms.Synonym;
import junit.framework.TestCase;
import java.sql.Date;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map; | fromList.add(new Date(0));
fromList.add(new Date(86400000L));
fromList.add(new Date(172800000L));
String type = Date.class.getName();
testAnonymizer(fromList, type, "DATE");
}
public void testParameterizedAnonymizer() {
List<Object> fromList = new ArrayList<>();
fromList.add("String 1");
fromList.add("String 2");
fromList.add("String 3");
String type = new FixedValueAnonymizer().getType();
testAnonymizer(fromList, type, type);
}
private void testAnonymizer(List<Object> fromList, String lookupType, String synonymType) {
List<Object> toList = new ArrayList<>();
Map<String, String> parameters = new HashMap<>();
parameters.put("value", "testValue");
Column column = new Column("Testcolumn", lookupType, 100, false, parameters);
// First pass
for (Object from : fromList) { | // Path: src/main/java/com/rolfje/anonimatron/configuration/Column.java
// public class Column {
// private String name;
// private String type;
// private int size = -1;
// private boolean shortlived;
// private Map<String, String> parameters;
//
// public Column() {
//
// }
//
// public Column(String name, String type) {
// this.name = name;
// this.type = type;
// }
//
// public Column(String name, String type, int size) {
// this(name, type);
// this.size = size;
// }
//
// public Column(String name, String type, int size, boolean shortlived) {
// this(name, type);
// this.size = size;
// this.shortlived = shortlived;
// }
//
// public Column(String name, String type, int size, boolean shortlived, Map<String, String> parameters) {
// this(name, type, size, shortlived);
// this.parameters = parameters;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public int getSize() {
// return size;
// }
//
// public void setSize(int size) {
// this.size = size;
// }
//
// public boolean isShortLived() {
// return shortlived;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// public Map<String, String> getParameters() {
// return parameters;
// }
//
// public void setParameters(Map<String, String> parameters) {
// this.parameters = parameters;
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
// Path: src/test/java/com/rolfje/anonimatron/anonymizer/AnonymizerServiceTest.java
import com.rolfje.anonimatron.configuration.Column;
import com.rolfje.anonimatron.synonyms.Synonym;
import junit.framework.TestCase;
import java.sql.Date;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
fromList.add(new Date(0));
fromList.add(new Date(86400000L));
fromList.add(new Date(172800000L));
String type = Date.class.getName();
testAnonymizer(fromList, type, "DATE");
}
public void testParameterizedAnonymizer() {
List<Object> fromList = new ArrayList<>();
fromList.add("String 1");
fromList.add("String 2");
fromList.add("String 3");
String type = new FixedValueAnonymizer().getType();
testAnonymizer(fromList, type, type);
}
private void testAnonymizer(List<Object> fromList, String lookupType, String synonymType) {
List<Object> toList = new ArrayList<>();
Map<String, String> parameters = new HashMap<>();
parameters.put("value", "testValue");
Column column = new Column("Testcolumn", lookupType, 100, false, parameters);
// First pass
for (Object from : fromList) { | Synonym s = anonService.anonymize(column, from); |
realrolfje/anonimatron | src/main/java/com/rolfje/anonimatron/anonymizer/AbstractNameGenerator.java | // Path: src/main/java/com/rolfje/anonimatron/synonyms/StringSynonym.java
// public class StringSynonym implements Synonym {
// private String type;
// private String from;
// private String to;
// private boolean shortlived = false;
//
// public StringSynonym() {
// }
//
// public StringSynonym(String type, String from, String to, boolean shortlived) {
// this.type = type;
// this.from = from;
// this.to = to;
// this.shortlived = shortlived;
// }
//
// @Override
// public String getType() {
// return type;
// }
//
// @Override
// public Object getFrom() {
// return from;
// }
//
// @Override
// public Object getTo() {
// return to;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setFrom(String from) {
// this.from = from;
// }
//
// public void setTo(String to) {
// this.to = to;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortlived;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
| import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
import com.rolfje.anonimatron.synonyms.StringSynonym;
import com.rolfje.anonimatron.synonyms.Synonym; | + "but there is none. You should add one, or remove requirements that cannot be fulfilled.. the part used, was : \""
+ mid.get(b[i])
+ "\", which "
+ "means there should be a suffix available, that has \"-c\" requirement or no requirements for previous syllables at all.");
}
if (vocalLast(pureSyl(mid.get(b[i]))))
last = 1;
else
last = 2;
}
int c;
do {
c = (int) (Math.random() * sur.size());
} while (expecting == 1 && !vocalFirst(pureSyl(sur.get(c)))
|| expecting == 2
&& !consonantFirst(pureSyl(sur.get(c))) || last == 1
&& hatesPreviousVocals(sur.get(c)) || last == 2
&& hatesPreviousConsonants(sur.get(c)));
name = upper(pureSyl(pre.get(a).toLowerCase()));
for (int i = 0; i < b.length - 2; i++) {
name = name.concat(pureSyl(mid.get(b[i]).toLowerCase()));
}
if (syls > 1)
name = name.concat(pureSyl(sur.get(c).toLowerCase()));
return name;
}
@Override | // Path: src/main/java/com/rolfje/anonimatron/synonyms/StringSynonym.java
// public class StringSynonym implements Synonym {
// private String type;
// private String from;
// private String to;
// private boolean shortlived = false;
//
// public StringSynonym() {
// }
//
// public StringSynonym(String type, String from, String to, boolean shortlived) {
// this.type = type;
// this.from = from;
// this.to = to;
// this.shortlived = shortlived;
// }
//
// @Override
// public String getType() {
// return type;
// }
//
// @Override
// public Object getFrom() {
// return from;
// }
//
// @Override
// public Object getTo() {
// return to;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setFrom(String from) {
// this.from = from;
// }
//
// public void setTo(String to) {
// this.to = to;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortlived;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
// Path: src/main/java/com/rolfje/anonimatron/anonymizer/AbstractNameGenerator.java
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
import com.rolfje.anonimatron.synonyms.StringSynonym;
import com.rolfje.anonimatron.synonyms.Synonym;
+ "but there is none. You should add one, or remove requirements that cannot be fulfilled.. the part used, was : \""
+ mid.get(b[i])
+ "\", which "
+ "means there should be a suffix available, that has \"-c\" requirement or no requirements for previous syllables at all.");
}
if (vocalLast(pureSyl(mid.get(b[i]))))
last = 1;
else
last = 2;
}
int c;
do {
c = (int) (Math.random() * sur.size());
} while (expecting == 1 && !vocalFirst(pureSyl(sur.get(c)))
|| expecting == 2
&& !consonantFirst(pureSyl(sur.get(c))) || last == 1
&& hatesPreviousVocals(sur.get(c)) || last == 2
&& hatesPreviousConsonants(sur.get(c)));
name = upper(pureSyl(pre.get(a).toLowerCase()));
for (int i = 0; i < b.length - 2; i++) {
name = name.concat(pureSyl(mid.get(b[i]).toLowerCase()));
}
if (syls > 1)
name = name.concat(pureSyl(sur.get(c).toLowerCase()));
return name;
}
@Override | public Synonym anonymize(Object from, int size, boolean shortlived) { |
realrolfje/anonimatron | src/main/java/com/rolfje/anonimatron/anonymizer/AbstractNameGenerator.java | // Path: src/main/java/com/rolfje/anonimatron/synonyms/StringSynonym.java
// public class StringSynonym implements Synonym {
// private String type;
// private String from;
// private String to;
// private boolean shortlived = false;
//
// public StringSynonym() {
// }
//
// public StringSynonym(String type, String from, String to, boolean shortlived) {
// this.type = type;
// this.from = from;
// this.to = to;
// this.shortlived = shortlived;
// }
//
// @Override
// public String getType() {
// return type;
// }
//
// @Override
// public Object getFrom() {
// return from;
// }
//
// @Override
// public Object getTo() {
// return to;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setFrom(String from) {
// this.from = from;
// }
//
// public void setTo(String to) {
// this.to = to;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortlived;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
| import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
import com.rolfje.anonimatron.synonyms.StringSynonym;
import com.rolfje.anonimatron.synonyms.Synonym; | + mid.get(b[i])
+ "\", which "
+ "means there should be a suffix available, that has \"-c\" requirement or no requirements for previous syllables at all.");
}
if (vocalLast(pureSyl(mid.get(b[i]))))
last = 1;
else
last = 2;
}
int c;
do {
c = (int) (Math.random() * sur.size());
} while (expecting == 1 && !vocalFirst(pureSyl(sur.get(c)))
|| expecting == 2
&& !consonantFirst(pureSyl(sur.get(c))) || last == 1
&& hatesPreviousVocals(sur.get(c)) || last == 2
&& hatesPreviousConsonants(sur.get(c)));
name = upper(pureSyl(pre.get(a).toLowerCase()));
for (int i = 0; i < b.length - 2; i++) {
name = name.concat(pureSyl(mid.get(b[i]).toLowerCase()));
}
if (syls > 1)
name = name.concat(pureSyl(sur.get(c).toLowerCase()));
return name;
}
@Override
public Synonym anonymize(Object from, int size, boolean shortlived) { | // Path: src/main/java/com/rolfje/anonimatron/synonyms/StringSynonym.java
// public class StringSynonym implements Synonym {
// private String type;
// private String from;
// private String to;
// private boolean shortlived = false;
//
// public StringSynonym() {
// }
//
// public StringSynonym(String type, String from, String to, boolean shortlived) {
// this.type = type;
// this.from = from;
// this.to = to;
// this.shortlived = shortlived;
// }
//
// @Override
// public String getType() {
// return type;
// }
//
// @Override
// public Object getFrom() {
// return from;
// }
//
// @Override
// public Object getTo() {
// return to;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setFrom(String from) {
// this.from = from;
// }
//
// public void setTo(String to) {
// this.to = to;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortlived;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
// Path: src/main/java/com/rolfje/anonimatron/anonymizer/AbstractNameGenerator.java
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
import com.rolfje.anonimatron.synonyms.StringSynonym;
import com.rolfje.anonimatron.synonyms.Synonym;
+ mid.get(b[i])
+ "\", which "
+ "means there should be a suffix available, that has \"-c\" requirement or no requirements for previous syllables at all.");
}
if (vocalLast(pureSyl(mid.get(b[i]))))
last = 1;
else
last = 2;
}
int c;
do {
c = (int) (Math.random() * sur.size());
} while (expecting == 1 && !vocalFirst(pureSyl(sur.get(c)))
|| expecting == 2
&& !consonantFirst(pureSyl(sur.get(c))) || last == 1
&& hatesPreviousVocals(sur.get(c)) || last == 2
&& hatesPreviousConsonants(sur.get(c)));
name = upper(pureSyl(pre.get(a).toLowerCase()));
for (int i = 0; i < b.length - 2; i++) {
name = name.concat(pureSyl(mid.get(b[i]).toLowerCase()));
}
if (syls > 1)
name = name.concat(pureSyl(sur.get(c).toLowerCase()));
return name;
}
@Override
public Synonym anonymize(Object from, int size, boolean shortlived) { | return new StringSynonym( |
realrolfje/anonimatron | src/test/java/com/rolfje/anonimatron/anonymizer/StringAnonymizerTest.java | // Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
| import com.rolfje.anonimatron.synonyms.Synonym;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNull; | package com.rolfje.anonimatron.anonymizer;
public class StringAnonymizerTest {
private StringAnonymizer stringAnonymizer;
@Before
public void setUp() {
stringAnonymizer = new StringAnonymizer();
}
@Test
public void testHappyFlow() { | // Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
// Path: src/test/java/com/rolfje/anonimatron/anonymizer/StringAnonymizerTest.java
import com.rolfje.anonimatron.synonyms.Synonym;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNull;
package com.rolfje.anonimatron.anonymizer;
public class StringAnonymizerTest {
private StringAnonymizer stringAnonymizer;
@Before
public void setUp() {
stringAnonymizer = new StringAnonymizer();
}
@Test
public void testHappyFlow() { | Synonym synonym = stringAnonymizer.anonymize("FROM", Integer.MAX_VALUE, false); |
realrolfje/anonimatron | src/main/java/com/rolfje/anonimatron/anonymizer/AnonymizerService.java | // Path: src/main/java/com/rolfje/anonimatron/configuration/Column.java
// public class Column {
// private String name;
// private String type;
// private int size = -1;
// private boolean shortlived;
// private Map<String, String> parameters;
//
// public Column() {
//
// }
//
// public Column(String name, String type) {
// this.name = name;
// this.type = type;
// }
//
// public Column(String name, String type, int size) {
// this(name, type);
// this.size = size;
// }
//
// public Column(String name, String type, int size, boolean shortlived) {
// this(name, type);
// this.size = size;
// this.shortlived = shortlived;
// }
//
// public Column(String name, String type, int size, boolean shortlived, Map<String, String> parameters) {
// this(name, type, size, shortlived);
// this.parameters = parameters;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public int getSize() {
// return size;
// }
//
// public void setSize(int size) {
// this.size = size;
// }
//
// public boolean isShortLived() {
// return shortlived;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// public Map<String, String> getParameters() {
// return parameters;
// }
//
// public void setParameters(Map<String, String> parameters) {
// this.parameters = parameters;
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/NullSynonym.java
// public class NullSynonym implements Synonym {
// private final String type;
//
// public NullSynonym(String type) {
// this.type=type;
// }
//
// public String getType() {
// return type;
// }
//
// public Object getFrom() {
// return null;
// }
//
// public Object getTo() {
// return null;
// }
//
// @Override
// public boolean isShortLived() {
// return true;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
| import com.rolfje.anonimatron.configuration.Column;
import com.rolfje.anonimatron.synonyms.NullSynonym;
import com.rolfje.anonimatron.synonyms.Synonym;
import org.apache.log4j.Logger;
import java.sql.Date;
import java.util.*; | public void registerAnonymizers(List<String> anonymizers) {
if (anonymizers == null) {
return;
}
for (String anonymizer : anonymizers) {
try {
@SuppressWarnings("rawtypes")
Class anonymizerClass = Class.forName(anonymizer);
registerAnonymizer((Anonymizer)anonymizerClass.newInstance());
} catch (Exception e) {
LOG.fatal(
"Could not instantiate class "
+ anonymizer
+ ". Please make sure that the class is on the classpath, "
+ "and it has a default public constructor.", e);
}
}
LOG.info(anonymizers.size()+" anonymizers registered.");
}
public Set<String> getCustomAnonymizerTypes() {
return Collections.unmodifiableSet(customAnonymizers.keySet());
}
public Set<String> getDefaultAnonymizerTypes() {
return Collections.unmodifiableSet(defaultTypeMapping.keySet());
}
| // Path: src/main/java/com/rolfje/anonimatron/configuration/Column.java
// public class Column {
// private String name;
// private String type;
// private int size = -1;
// private boolean shortlived;
// private Map<String, String> parameters;
//
// public Column() {
//
// }
//
// public Column(String name, String type) {
// this.name = name;
// this.type = type;
// }
//
// public Column(String name, String type, int size) {
// this(name, type);
// this.size = size;
// }
//
// public Column(String name, String type, int size, boolean shortlived) {
// this(name, type);
// this.size = size;
// this.shortlived = shortlived;
// }
//
// public Column(String name, String type, int size, boolean shortlived, Map<String, String> parameters) {
// this(name, type, size, shortlived);
// this.parameters = parameters;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public int getSize() {
// return size;
// }
//
// public void setSize(int size) {
// this.size = size;
// }
//
// public boolean isShortLived() {
// return shortlived;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// public Map<String, String> getParameters() {
// return parameters;
// }
//
// public void setParameters(Map<String, String> parameters) {
// this.parameters = parameters;
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/NullSynonym.java
// public class NullSynonym implements Synonym {
// private final String type;
//
// public NullSynonym(String type) {
// this.type=type;
// }
//
// public String getType() {
// return type;
// }
//
// public Object getFrom() {
// return null;
// }
//
// public Object getTo() {
// return null;
// }
//
// @Override
// public boolean isShortLived() {
// return true;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
// Path: src/main/java/com/rolfje/anonimatron/anonymizer/AnonymizerService.java
import com.rolfje.anonimatron.configuration.Column;
import com.rolfje.anonimatron.synonyms.NullSynonym;
import com.rolfje.anonimatron.synonyms.Synonym;
import org.apache.log4j.Logger;
import java.sql.Date;
import java.util.*;
public void registerAnonymizers(List<String> anonymizers) {
if (anonymizers == null) {
return;
}
for (String anonymizer : anonymizers) {
try {
@SuppressWarnings("rawtypes")
Class anonymizerClass = Class.forName(anonymizer);
registerAnonymizer((Anonymizer)anonymizerClass.newInstance());
} catch (Exception e) {
LOG.fatal(
"Could not instantiate class "
+ anonymizer
+ ". Please make sure that the class is on the classpath, "
+ "and it has a default public constructor.", e);
}
}
LOG.info(anonymizers.size()+" anonymizers registered.");
}
public Set<String> getCustomAnonymizerTypes() {
return Collections.unmodifiableSet(customAnonymizers.keySet());
}
public Set<String> getDefaultAnonymizerTypes() {
return Collections.unmodifiableSet(defaultTypeMapping.keySet());
}
| public Synonym anonymize(Column column, Object from) { |
realrolfje/anonimatron | src/main/java/com/rolfje/anonimatron/anonymizer/AnonymizerService.java | // Path: src/main/java/com/rolfje/anonimatron/configuration/Column.java
// public class Column {
// private String name;
// private String type;
// private int size = -1;
// private boolean shortlived;
// private Map<String, String> parameters;
//
// public Column() {
//
// }
//
// public Column(String name, String type) {
// this.name = name;
// this.type = type;
// }
//
// public Column(String name, String type, int size) {
// this(name, type);
// this.size = size;
// }
//
// public Column(String name, String type, int size, boolean shortlived) {
// this(name, type);
// this.size = size;
// this.shortlived = shortlived;
// }
//
// public Column(String name, String type, int size, boolean shortlived, Map<String, String> parameters) {
// this(name, type, size, shortlived);
// this.parameters = parameters;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public int getSize() {
// return size;
// }
//
// public void setSize(int size) {
// this.size = size;
// }
//
// public boolean isShortLived() {
// return shortlived;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// public Map<String, String> getParameters() {
// return parameters;
// }
//
// public void setParameters(Map<String, String> parameters) {
// this.parameters = parameters;
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/NullSynonym.java
// public class NullSynonym implements Synonym {
// private final String type;
//
// public NullSynonym(String type) {
// this.type=type;
// }
//
// public String getType() {
// return type;
// }
//
// public Object getFrom() {
// return null;
// }
//
// public Object getTo() {
// return null;
// }
//
// @Override
// public boolean isShortLived() {
// return true;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
| import com.rolfje.anonimatron.configuration.Column;
import com.rolfje.anonimatron.synonyms.NullSynonym;
import com.rolfje.anonimatron.synonyms.Synonym;
import org.apache.log4j.Logger;
import java.sql.Date;
import java.util.*; | public void registerAnonymizers(List<String> anonymizers) {
if (anonymizers == null) {
return;
}
for (String anonymizer : anonymizers) {
try {
@SuppressWarnings("rawtypes")
Class anonymizerClass = Class.forName(anonymizer);
registerAnonymizer((Anonymizer)anonymizerClass.newInstance());
} catch (Exception e) {
LOG.fatal(
"Could not instantiate class "
+ anonymizer
+ ". Please make sure that the class is on the classpath, "
+ "and it has a default public constructor.", e);
}
}
LOG.info(anonymizers.size()+" anonymizers registered.");
}
public Set<String> getCustomAnonymizerTypes() {
return Collections.unmodifiableSet(customAnonymizers.keySet());
}
public Set<String> getDefaultAnonymizerTypes() {
return Collections.unmodifiableSet(defaultTypeMapping.keySet());
}
| // Path: src/main/java/com/rolfje/anonimatron/configuration/Column.java
// public class Column {
// private String name;
// private String type;
// private int size = -1;
// private boolean shortlived;
// private Map<String, String> parameters;
//
// public Column() {
//
// }
//
// public Column(String name, String type) {
// this.name = name;
// this.type = type;
// }
//
// public Column(String name, String type, int size) {
// this(name, type);
// this.size = size;
// }
//
// public Column(String name, String type, int size, boolean shortlived) {
// this(name, type);
// this.size = size;
// this.shortlived = shortlived;
// }
//
// public Column(String name, String type, int size, boolean shortlived, Map<String, String> parameters) {
// this(name, type, size, shortlived);
// this.parameters = parameters;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public int getSize() {
// return size;
// }
//
// public void setSize(int size) {
// this.size = size;
// }
//
// public boolean isShortLived() {
// return shortlived;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// public Map<String, String> getParameters() {
// return parameters;
// }
//
// public void setParameters(Map<String, String> parameters) {
// this.parameters = parameters;
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/NullSynonym.java
// public class NullSynonym implements Synonym {
// private final String type;
//
// public NullSynonym(String type) {
// this.type=type;
// }
//
// public String getType() {
// return type;
// }
//
// public Object getFrom() {
// return null;
// }
//
// public Object getTo() {
// return null;
// }
//
// @Override
// public boolean isShortLived() {
// return true;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
// Path: src/main/java/com/rolfje/anonimatron/anonymizer/AnonymizerService.java
import com.rolfje.anonimatron.configuration.Column;
import com.rolfje.anonimatron.synonyms.NullSynonym;
import com.rolfje.anonimatron.synonyms.Synonym;
import org.apache.log4j.Logger;
import java.sql.Date;
import java.util.*;
public void registerAnonymizers(List<String> anonymizers) {
if (anonymizers == null) {
return;
}
for (String anonymizer : anonymizers) {
try {
@SuppressWarnings("rawtypes")
Class anonymizerClass = Class.forName(anonymizer);
registerAnonymizer((Anonymizer)anonymizerClass.newInstance());
} catch (Exception e) {
LOG.fatal(
"Could not instantiate class "
+ anonymizer
+ ". Please make sure that the class is on the classpath, "
+ "and it has a default public constructor.", e);
}
}
LOG.info(anonymizers.size()+" anonymizers registered.");
}
public Set<String> getCustomAnonymizerTypes() {
return Collections.unmodifiableSet(customAnonymizers.keySet());
}
public Set<String> getDefaultAnonymizerTypes() {
return Collections.unmodifiableSet(defaultTypeMapping.keySet());
}
| public Synonym anonymize(Column column, Object from) { |
realrolfje/anonimatron | src/main/java/com/rolfje/anonimatron/anonymizer/AnonymizerService.java | // Path: src/main/java/com/rolfje/anonimatron/configuration/Column.java
// public class Column {
// private String name;
// private String type;
// private int size = -1;
// private boolean shortlived;
// private Map<String, String> parameters;
//
// public Column() {
//
// }
//
// public Column(String name, String type) {
// this.name = name;
// this.type = type;
// }
//
// public Column(String name, String type, int size) {
// this(name, type);
// this.size = size;
// }
//
// public Column(String name, String type, int size, boolean shortlived) {
// this(name, type);
// this.size = size;
// this.shortlived = shortlived;
// }
//
// public Column(String name, String type, int size, boolean shortlived, Map<String, String> parameters) {
// this(name, type, size, shortlived);
// this.parameters = parameters;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public int getSize() {
// return size;
// }
//
// public void setSize(int size) {
// this.size = size;
// }
//
// public boolean isShortLived() {
// return shortlived;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// public Map<String, String> getParameters() {
// return parameters;
// }
//
// public void setParameters(Map<String, String> parameters) {
// this.parameters = parameters;
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/NullSynonym.java
// public class NullSynonym implements Synonym {
// private final String type;
//
// public NullSynonym(String type) {
// this.type=type;
// }
//
// public String getType() {
// return type;
// }
//
// public Object getFrom() {
// return null;
// }
//
// public Object getTo() {
// return null;
// }
//
// @Override
// public boolean isShortLived() {
// return true;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
| import com.rolfje.anonimatron.configuration.Column;
import com.rolfje.anonimatron.synonyms.NullSynonym;
import com.rolfje.anonimatron.synonyms.Synonym;
import org.apache.log4j.Logger;
import java.sql.Date;
import java.util.*; | return;
}
for (String anonymizer : anonymizers) {
try {
@SuppressWarnings("rawtypes")
Class anonymizerClass = Class.forName(anonymizer);
registerAnonymizer((Anonymizer)anonymizerClass.newInstance());
} catch (Exception e) {
LOG.fatal(
"Could not instantiate class "
+ anonymizer
+ ". Please make sure that the class is on the classpath, "
+ "and it has a default public constructor.", e);
}
}
LOG.info(anonymizers.size()+" anonymizers registered.");
}
public Set<String> getCustomAnonymizerTypes() {
return Collections.unmodifiableSet(customAnonymizers.keySet());
}
public Set<String> getDefaultAnonymizerTypes() {
return Collections.unmodifiableSet(defaultTypeMapping.keySet());
}
public Synonym anonymize(Column column, Object from) {
if (from == null) { | // Path: src/main/java/com/rolfje/anonimatron/configuration/Column.java
// public class Column {
// private String name;
// private String type;
// private int size = -1;
// private boolean shortlived;
// private Map<String, String> parameters;
//
// public Column() {
//
// }
//
// public Column(String name, String type) {
// this.name = name;
// this.type = type;
// }
//
// public Column(String name, String type, int size) {
// this(name, type);
// this.size = size;
// }
//
// public Column(String name, String type, int size, boolean shortlived) {
// this(name, type);
// this.size = size;
// this.shortlived = shortlived;
// }
//
// public Column(String name, String type, int size, boolean shortlived, Map<String, String> parameters) {
// this(name, type, size, shortlived);
// this.parameters = parameters;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public int getSize() {
// return size;
// }
//
// public void setSize(int size) {
// this.size = size;
// }
//
// public boolean isShortLived() {
// return shortlived;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// public Map<String, String> getParameters() {
// return parameters;
// }
//
// public void setParameters(Map<String, String> parameters) {
// this.parameters = parameters;
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/NullSynonym.java
// public class NullSynonym implements Synonym {
// private final String type;
//
// public NullSynonym(String type) {
// this.type=type;
// }
//
// public String getType() {
// return type;
// }
//
// public Object getFrom() {
// return null;
// }
//
// public Object getTo() {
// return null;
// }
//
// @Override
// public boolean isShortLived() {
// return true;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
// Path: src/main/java/com/rolfje/anonimatron/anonymizer/AnonymizerService.java
import com.rolfje.anonimatron.configuration.Column;
import com.rolfje.anonimatron.synonyms.NullSynonym;
import com.rolfje.anonimatron.synonyms.Synonym;
import org.apache.log4j.Logger;
import java.sql.Date;
import java.util.*;
return;
}
for (String anonymizer : anonymizers) {
try {
@SuppressWarnings("rawtypes")
Class anonymizerClass = Class.forName(anonymizer);
registerAnonymizer((Anonymizer)anonymizerClass.newInstance());
} catch (Exception e) {
LOG.fatal(
"Could not instantiate class "
+ anonymizer
+ ". Please make sure that the class is on the classpath, "
+ "and it has a default public constructor.", e);
}
}
LOG.info(anonymizers.size()+" anonymizers registered.");
}
public Set<String> getCustomAnonymizerTypes() {
return Collections.unmodifiableSet(customAnonymizers.keySet());
}
public Set<String> getDefaultAnonymizerTypes() {
return Collections.unmodifiableSet(defaultTypeMapping.keySet());
}
public Synonym anonymize(Column column, Object from) {
if (from == null) { | return new NullSynonym(column.getType()); |
realrolfje/anonimatron | src/main/java/com/rolfje/anonimatron/commandline/CommandLine.java | // Path: src/main/java/com/rolfje/anonimatron/Anonimatron.java
// public static String VERSION = "UNKNOWN";
| import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.DefaultParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import static com.rolfje.anonimatron.Anonimatron.VERSION; | private static final String OPT_CONFIGEXAMPLE = "configexample";
private static final Options options = new Options()
.addOption(OPT_CONFIGFILE, true,
"The XML Configuration file describing what to anonymize.")
.addOption(OPT_SYNONYMFILE, true,
"The XML file to read/write synonyms to. "
+ "If the file does not exist it will be created.")
.addOption(OPT_CONFIGEXAMPLE, false,
"Prints out a demo/template configuration file.")
.addOption(OPT_DRYRUN, false, "Do not make changes to the database.")
.addOption(OPT_JDBCURL, true,
"The JDBC URL to connect to. " +
"If provided, overrides the value in the config file.")
.addOption(OPT_USERID, true,
"The user id for the database connection. " +
"If provided, overrides the value in the config file.")
.addOption(OPT_PASSWORD, true,
"The password for the database connection. " +
"If provided, overrides the value in the config file.");
private final org.apache.commons.cli.CommandLine clicommandLine;
public CommandLine(String[] arguments) throws ParseException {
CommandLineParser parser = new DefaultParser();
clicommandLine = parser.parse(options, arguments);
}
public static void printHelp() {
System.out | // Path: src/main/java/com/rolfje/anonimatron/Anonimatron.java
// public static String VERSION = "UNKNOWN";
// Path: src/main/java/com/rolfje/anonimatron/commandline/CommandLine.java
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.DefaultParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import static com.rolfje.anonimatron.Anonimatron.VERSION;
private static final String OPT_CONFIGEXAMPLE = "configexample";
private static final Options options = new Options()
.addOption(OPT_CONFIGFILE, true,
"The XML Configuration file describing what to anonymize.")
.addOption(OPT_SYNONYMFILE, true,
"The XML file to read/write synonyms to. "
+ "If the file does not exist it will be created.")
.addOption(OPT_CONFIGEXAMPLE, false,
"Prints out a demo/template configuration file.")
.addOption(OPT_DRYRUN, false, "Do not make changes to the database.")
.addOption(OPT_JDBCURL, true,
"The JDBC URL to connect to. " +
"If provided, overrides the value in the config file.")
.addOption(OPT_USERID, true,
"The user id for the database connection. " +
"If provided, overrides the value in the config file.")
.addOption(OPT_PASSWORD, true,
"The password for the database connection. " +
"If provided, overrides the value in the config file.");
private final org.apache.commons.cli.CommandLine clicommandLine;
public CommandLine(String[] arguments) throws ParseException {
CommandLineParser parser = new DefaultParser();
clicommandLine = parser.parse(options, arguments);
}
public static void printHelp() {
System.out | .println("\nThis is Anonimatron " + VERSION + ", a command line tool to consistently \n" |
realrolfje/anonimatron | src/main/java/com/rolfje/anonimatron/anonymizer/StringAnonymizer.java | // Path: src/main/java/com/rolfje/anonimatron/synonyms/StringSynonym.java
// public class StringSynonym implements Synonym {
// private String type;
// private String from;
// private String to;
// private boolean shortlived = false;
//
// public StringSynonym() {
// }
//
// public StringSynonym(String type, String from, String to, boolean shortlived) {
// this.type = type;
// this.from = from;
// this.to = to;
// this.shortlived = shortlived;
// }
//
// @Override
// public String getType() {
// return type;
// }
//
// @Override
// public Object getFrom() {
// return from;
// }
//
// @Override
// public Object getTo() {
// return to;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setFrom(String from) {
// this.from = from;
// }
//
// public void setTo(String to) {
// this.to = to;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortlived;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
| import com.rolfje.anonimatron.synonyms.StringSynonym;
import com.rolfje.anonimatron.synonyms.Synonym; | package com.rolfje.anonimatron.anonymizer;
public class StringAnonymizer implements Anonymizer {
private static final String TYPE = "STRING";
@Override | // Path: src/main/java/com/rolfje/anonimatron/synonyms/StringSynonym.java
// public class StringSynonym implements Synonym {
// private String type;
// private String from;
// private String to;
// private boolean shortlived = false;
//
// public StringSynonym() {
// }
//
// public StringSynonym(String type, String from, String to, boolean shortlived) {
// this.type = type;
// this.from = from;
// this.to = to;
// this.shortlived = shortlived;
// }
//
// @Override
// public String getType() {
// return type;
// }
//
// @Override
// public Object getFrom() {
// return from;
// }
//
// @Override
// public Object getTo() {
// return to;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setFrom(String from) {
// this.from = from;
// }
//
// public void setTo(String to) {
// this.to = to;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortlived;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
// Path: src/main/java/com/rolfje/anonimatron/anonymizer/StringAnonymizer.java
import com.rolfje.anonimatron.synonyms.StringSynonym;
import com.rolfje.anonimatron.synonyms.Synonym;
package com.rolfje.anonimatron.anonymizer;
public class StringAnonymizer implements Anonymizer {
private static final String TYPE = "STRING";
@Override | public Synonym anonymize(Object from, int size, boolean shortlived) { |
realrolfje/anonimatron | src/main/java/com/rolfje/anonimatron/anonymizer/StringAnonymizer.java | // Path: src/main/java/com/rolfje/anonimatron/synonyms/StringSynonym.java
// public class StringSynonym implements Synonym {
// private String type;
// private String from;
// private String to;
// private boolean shortlived = false;
//
// public StringSynonym() {
// }
//
// public StringSynonym(String type, String from, String to, boolean shortlived) {
// this.type = type;
// this.from = from;
// this.to = to;
// this.shortlived = shortlived;
// }
//
// @Override
// public String getType() {
// return type;
// }
//
// @Override
// public Object getFrom() {
// return from;
// }
//
// @Override
// public Object getTo() {
// return to;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setFrom(String from) {
// this.from = from;
// }
//
// public void setTo(String to) {
// this.to = to;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortlived;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
| import com.rolfje.anonimatron.synonyms.StringSynonym;
import com.rolfje.anonimatron.synonyms.Synonym; | package com.rolfje.anonimatron.anonymizer;
public class StringAnonymizer implements Anonymizer {
private static final String TYPE = "STRING";
@Override
public Synonym anonymize(Object from, int size, boolean shortlived) {
String randomHexString = getString(from, size);
| // Path: src/main/java/com/rolfje/anonimatron/synonyms/StringSynonym.java
// public class StringSynonym implements Synonym {
// private String type;
// private String from;
// private String to;
// private boolean shortlived = false;
//
// public StringSynonym() {
// }
//
// public StringSynonym(String type, String from, String to, boolean shortlived) {
// this.type = type;
// this.from = from;
// this.to = to;
// this.shortlived = shortlived;
// }
//
// @Override
// public String getType() {
// return type;
// }
//
// @Override
// public Object getFrom() {
// return from;
// }
//
// @Override
// public Object getTo() {
// return to;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setFrom(String from) {
// this.from = from;
// }
//
// public void setTo(String to) {
// this.to = to;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortlived;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
// Path: src/main/java/com/rolfje/anonimatron/anonymizer/StringAnonymizer.java
import com.rolfje.anonimatron.synonyms.StringSynonym;
import com.rolfje.anonimatron.synonyms.Synonym;
package com.rolfje.anonimatron.anonymizer;
public class StringAnonymizer implements Anonymizer {
private static final String TYPE = "STRING";
@Override
public Synonym anonymize(Object from, int size, boolean shortlived) {
String randomHexString = getString(from, size);
| return new StringSynonym( |
realrolfje/anonimatron | src/main/java/com/rolfje/anonimatron/anonymizer/DutchBSNAnononymizer.java | // Path: src/main/java/com/rolfje/anonimatron/synonyms/NumberSynonym.java
// public class NumberSynonym implements Synonym {
// private String type;
// private Number from;
// private Number to;
// private boolean shortLived = false;
//
// public NumberSynonym() {
// }
//
// public NumberSynonym(String type, Number from, Number to, boolean shortLived) {
// this.type = type;
// this.from = from;
// this.to = to;
// this.shortLived = shortLived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortLived;
// }
//
// @Override
// public String getType() {
// return type;
// }
//
// @Override
// public Number getFrom() {
// return from;
// }
//
// @Override
// public Number getTo() {
// return to;
// }
//
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setTo(Number to) {
// this.to = to;
// }
//
// public void setFrom(Number from) {
// this.from = from;
// }
//
// public void setShortLived(boolean shortLived) {
// this.shortLived = shortLived;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null || getClass() != obj.getClass())
// return false;
// return this.hashCode() == obj.hashCode();
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/StringSynonym.java
// public class StringSynonym implements Synonym {
// private String type;
// private String from;
// private String to;
// private boolean shortlived = false;
//
// public StringSynonym() {
// }
//
// public StringSynonym(String type, String from, String to, boolean shortlived) {
// this.type = type;
// this.from = from;
// this.to = to;
// this.shortlived = shortlived;
// }
//
// @Override
// public String getType() {
// return type;
// }
//
// @Override
// public Object getFrom() {
// return from;
// }
//
// @Override
// public Object getTo() {
// return to;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setFrom(String from) {
// this.from = from;
// }
//
// public void setTo(String to) {
// this.to = to;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortlived;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
| import com.rolfje.anonimatron.synonyms.NumberSynonym;
import com.rolfje.anonimatron.synonyms.StringSynonym;
import com.rolfje.anonimatron.synonyms.Synonym;
import org.apache.commons.lang3.StringUtils;
import java.math.BigDecimal;
import java.math.BigInteger; | package com.rolfje.anonimatron.anonymizer;
/**
* Generates valid Dutch "Burger Service Nummer" or "SOFI Nummer", a social
* security number uniquely identifying civilians to the governement.
* <p>
* A BSN Number is 9 digits long, can not start with 3 zeroes, the first digit
* must be less than 4, and the whole number passes the "11 proof"
* <p>
* See https://nl.wikipedia.org/wiki/Burgerservicenummer
*/
public class DutchBSNAnononymizer extends AbstractElevenProofAnonymizer {
private static final int LENGTH = 9;
@Override
public String getType() {
return "BURGERSERVICENUMMER";
}
@Override | // Path: src/main/java/com/rolfje/anonimatron/synonyms/NumberSynonym.java
// public class NumberSynonym implements Synonym {
// private String type;
// private Number from;
// private Number to;
// private boolean shortLived = false;
//
// public NumberSynonym() {
// }
//
// public NumberSynonym(String type, Number from, Number to, boolean shortLived) {
// this.type = type;
// this.from = from;
// this.to = to;
// this.shortLived = shortLived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortLived;
// }
//
// @Override
// public String getType() {
// return type;
// }
//
// @Override
// public Number getFrom() {
// return from;
// }
//
// @Override
// public Number getTo() {
// return to;
// }
//
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setTo(Number to) {
// this.to = to;
// }
//
// public void setFrom(Number from) {
// this.from = from;
// }
//
// public void setShortLived(boolean shortLived) {
// this.shortLived = shortLived;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null || getClass() != obj.getClass())
// return false;
// return this.hashCode() == obj.hashCode();
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/StringSynonym.java
// public class StringSynonym implements Synonym {
// private String type;
// private String from;
// private String to;
// private boolean shortlived = false;
//
// public StringSynonym() {
// }
//
// public StringSynonym(String type, String from, String to, boolean shortlived) {
// this.type = type;
// this.from = from;
// this.to = to;
// this.shortlived = shortlived;
// }
//
// @Override
// public String getType() {
// return type;
// }
//
// @Override
// public Object getFrom() {
// return from;
// }
//
// @Override
// public Object getTo() {
// return to;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setFrom(String from) {
// this.from = from;
// }
//
// public void setTo(String to) {
// this.to = to;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortlived;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
// Path: src/main/java/com/rolfje/anonimatron/anonymizer/DutchBSNAnononymizer.java
import com.rolfje.anonimatron.synonyms.NumberSynonym;
import com.rolfje.anonimatron.synonyms.StringSynonym;
import com.rolfje.anonimatron.synonyms.Synonym;
import org.apache.commons.lang3.StringUtils;
import java.math.BigDecimal;
import java.math.BigInteger;
package com.rolfje.anonimatron.anonymizer;
/**
* Generates valid Dutch "Burger Service Nummer" or "SOFI Nummer", a social
* security number uniquely identifying civilians to the governement.
* <p>
* A BSN Number is 9 digits long, can not start with 3 zeroes, the first digit
* must be less than 4, and the whole number passes the "11 proof"
* <p>
* See https://nl.wikipedia.org/wiki/Burgerservicenummer
*/
public class DutchBSNAnononymizer extends AbstractElevenProofAnonymizer {
private static final int LENGTH = 9;
@Override
public String getType() {
return "BURGERSERVICENUMMER";
}
@Override | public Synonym anonymize(Object from, int size, boolean isShortLived) { |
realrolfje/anonimatron | src/main/java/com/rolfje/anonimatron/anonymizer/DutchBSNAnononymizer.java | // Path: src/main/java/com/rolfje/anonimatron/synonyms/NumberSynonym.java
// public class NumberSynonym implements Synonym {
// private String type;
// private Number from;
// private Number to;
// private boolean shortLived = false;
//
// public NumberSynonym() {
// }
//
// public NumberSynonym(String type, Number from, Number to, boolean shortLived) {
// this.type = type;
// this.from = from;
// this.to = to;
// this.shortLived = shortLived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortLived;
// }
//
// @Override
// public String getType() {
// return type;
// }
//
// @Override
// public Number getFrom() {
// return from;
// }
//
// @Override
// public Number getTo() {
// return to;
// }
//
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setTo(Number to) {
// this.to = to;
// }
//
// public void setFrom(Number from) {
// this.from = from;
// }
//
// public void setShortLived(boolean shortLived) {
// this.shortLived = shortLived;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null || getClass() != obj.getClass())
// return false;
// return this.hashCode() == obj.hashCode();
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/StringSynonym.java
// public class StringSynonym implements Synonym {
// private String type;
// private String from;
// private String to;
// private boolean shortlived = false;
//
// public StringSynonym() {
// }
//
// public StringSynonym(String type, String from, String to, boolean shortlived) {
// this.type = type;
// this.from = from;
// this.to = to;
// this.shortlived = shortlived;
// }
//
// @Override
// public String getType() {
// return type;
// }
//
// @Override
// public Object getFrom() {
// return from;
// }
//
// @Override
// public Object getTo() {
// return to;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setFrom(String from) {
// this.from = from;
// }
//
// public void setTo(String to) {
// this.to = to;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortlived;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
| import com.rolfje.anonimatron.synonyms.NumberSynonym;
import com.rolfje.anonimatron.synonyms.StringSynonym;
import com.rolfje.anonimatron.synonyms.Synonym;
import org.apache.commons.lang3.StringUtils;
import java.math.BigDecimal;
import java.math.BigInteger; | package com.rolfje.anonimatron.anonymizer;
/**
* Generates valid Dutch "Burger Service Nummer" or "SOFI Nummer", a social
* security number uniquely identifying civilians to the governement.
* <p>
* A BSN Number is 9 digits long, can not start with 3 zeroes, the first digit
* must be less than 4, and the whole number passes the "11 proof"
* <p>
* See https://nl.wikipedia.org/wiki/Burgerservicenummer
*/
public class DutchBSNAnononymizer extends AbstractElevenProofAnonymizer {
private static final int LENGTH = 9;
@Override
public String getType() {
return "BURGERSERVICENUMMER";
}
@Override
public Synonym anonymize(Object from, int size, boolean isShortLived) {
if (size < LENGTH) {
throw new UnsupportedOperationException(
"Cannot generate a BSN that fits in a " + size + " character string. Must be " + LENGTH
+ " characters or more.");
}
String newBSN = generateNonIdenticalBSN(from);
if (from instanceof Number) { | // Path: src/main/java/com/rolfje/anonimatron/synonyms/NumberSynonym.java
// public class NumberSynonym implements Synonym {
// private String type;
// private Number from;
// private Number to;
// private boolean shortLived = false;
//
// public NumberSynonym() {
// }
//
// public NumberSynonym(String type, Number from, Number to, boolean shortLived) {
// this.type = type;
// this.from = from;
// this.to = to;
// this.shortLived = shortLived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortLived;
// }
//
// @Override
// public String getType() {
// return type;
// }
//
// @Override
// public Number getFrom() {
// return from;
// }
//
// @Override
// public Number getTo() {
// return to;
// }
//
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setTo(Number to) {
// this.to = to;
// }
//
// public void setFrom(Number from) {
// this.from = from;
// }
//
// public void setShortLived(boolean shortLived) {
// this.shortLived = shortLived;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null || getClass() != obj.getClass())
// return false;
// return this.hashCode() == obj.hashCode();
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/StringSynonym.java
// public class StringSynonym implements Synonym {
// private String type;
// private String from;
// private String to;
// private boolean shortlived = false;
//
// public StringSynonym() {
// }
//
// public StringSynonym(String type, String from, String to, boolean shortlived) {
// this.type = type;
// this.from = from;
// this.to = to;
// this.shortlived = shortlived;
// }
//
// @Override
// public String getType() {
// return type;
// }
//
// @Override
// public Object getFrom() {
// return from;
// }
//
// @Override
// public Object getTo() {
// return to;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setFrom(String from) {
// this.from = from;
// }
//
// public void setTo(String to) {
// this.to = to;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortlived;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
// Path: src/main/java/com/rolfje/anonimatron/anonymizer/DutchBSNAnononymizer.java
import com.rolfje.anonimatron.synonyms.NumberSynonym;
import com.rolfje.anonimatron.synonyms.StringSynonym;
import com.rolfje.anonimatron.synonyms.Synonym;
import org.apache.commons.lang3.StringUtils;
import java.math.BigDecimal;
import java.math.BigInteger;
package com.rolfje.anonimatron.anonymizer;
/**
* Generates valid Dutch "Burger Service Nummer" or "SOFI Nummer", a social
* security number uniquely identifying civilians to the governement.
* <p>
* A BSN Number is 9 digits long, can not start with 3 zeroes, the first digit
* must be less than 4, and the whole number passes the "11 proof"
* <p>
* See https://nl.wikipedia.org/wiki/Burgerservicenummer
*/
public class DutchBSNAnononymizer extends AbstractElevenProofAnonymizer {
private static final int LENGTH = 9;
@Override
public String getType() {
return "BURGERSERVICENUMMER";
}
@Override
public Synonym anonymize(Object from, int size, boolean isShortLived) {
if (size < LENGTH) {
throw new UnsupportedOperationException(
"Cannot generate a BSN that fits in a " + size + " character string. Must be " + LENGTH
+ " characters or more.");
}
String newBSN = generateNonIdenticalBSN(from);
if (from instanceof Number) { | return new NumberSynonym( |
realrolfje/anonimatron | src/main/java/com/rolfje/anonimatron/anonymizer/DutchBSNAnononymizer.java | // Path: src/main/java/com/rolfje/anonimatron/synonyms/NumberSynonym.java
// public class NumberSynonym implements Synonym {
// private String type;
// private Number from;
// private Number to;
// private boolean shortLived = false;
//
// public NumberSynonym() {
// }
//
// public NumberSynonym(String type, Number from, Number to, boolean shortLived) {
// this.type = type;
// this.from = from;
// this.to = to;
// this.shortLived = shortLived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortLived;
// }
//
// @Override
// public String getType() {
// return type;
// }
//
// @Override
// public Number getFrom() {
// return from;
// }
//
// @Override
// public Number getTo() {
// return to;
// }
//
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setTo(Number to) {
// this.to = to;
// }
//
// public void setFrom(Number from) {
// this.from = from;
// }
//
// public void setShortLived(boolean shortLived) {
// this.shortLived = shortLived;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null || getClass() != obj.getClass())
// return false;
// return this.hashCode() == obj.hashCode();
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/StringSynonym.java
// public class StringSynonym implements Synonym {
// private String type;
// private String from;
// private String to;
// private boolean shortlived = false;
//
// public StringSynonym() {
// }
//
// public StringSynonym(String type, String from, String to, boolean shortlived) {
// this.type = type;
// this.from = from;
// this.to = to;
// this.shortlived = shortlived;
// }
//
// @Override
// public String getType() {
// return type;
// }
//
// @Override
// public Object getFrom() {
// return from;
// }
//
// @Override
// public Object getTo() {
// return to;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setFrom(String from) {
// this.from = from;
// }
//
// public void setTo(String to) {
// this.to = to;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortlived;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
| import com.rolfje.anonimatron.synonyms.NumberSynonym;
import com.rolfje.anonimatron.synonyms.StringSynonym;
import com.rolfje.anonimatron.synonyms.Synonym;
import org.apache.commons.lang3.StringUtils;
import java.math.BigDecimal;
import java.math.BigInteger; | package com.rolfje.anonimatron.anonymizer;
/**
* Generates valid Dutch "Burger Service Nummer" or "SOFI Nummer", a social
* security number uniquely identifying civilians to the governement.
* <p>
* A BSN Number is 9 digits long, can not start with 3 zeroes, the first digit
* must be less than 4, and the whole number passes the "11 proof"
* <p>
* See https://nl.wikipedia.org/wiki/Burgerservicenummer
*/
public class DutchBSNAnononymizer extends AbstractElevenProofAnonymizer {
private static final int LENGTH = 9;
@Override
public String getType() {
return "BURGERSERVICENUMMER";
}
@Override
public Synonym anonymize(Object from, int size, boolean isShortLived) {
if (size < LENGTH) {
throw new UnsupportedOperationException(
"Cannot generate a BSN that fits in a " + size + " character string. Must be " + LENGTH
+ " characters or more.");
}
String newBSN = generateNonIdenticalBSN(from);
if (from instanceof Number) {
return new NumberSynonym(
getType(),
(Number) from,
asNumber(newBSN, (Number) from),
isShortLived);
} else if (from instanceof String) { | // Path: src/main/java/com/rolfje/anonimatron/synonyms/NumberSynonym.java
// public class NumberSynonym implements Synonym {
// private String type;
// private Number from;
// private Number to;
// private boolean shortLived = false;
//
// public NumberSynonym() {
// }
//
// public NumberSynonym(String type, Number from, Number to, boolean shortLived) {
// this.type = type;
// this.from = from;
// this.to = to;
// this.shortLived = shortLived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortLived;
// }
//
// @Override
// public String getType() {
// return type;
// }
//
// @Override
// public Number getFrom() {
// return from;
// }
//
// @Override
// public Number getTo() {
// return to;
// }
//
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setTo(Number to) {
// this.to = to;
// }
//
// public void setFrom(Number from) {
// this.from = from;
// }
//
// public void setShortLived(boolean shortLived) {
// this.shortLived = shortLived;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj)
// return true;
// if (obj == null || getClass() != obj.getClass())
// return false;
// return this.hashCode() == obj.hashCode();
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/StringSynonym.java
// public class StringSynonym implements Synonym {
// private String type;
// private String from;
// private String to;
// private boolean shortlived = false;
//
// public StringSynonym() {
// }
//
// public StringSynonym(String type, String from, String to, boolean shortlived) {
// this.type = type;
// this.from = from;
// this.to = to;
// this.shortlived = shortlived;
// }
//
// @Override
// public String getType() {
// return type;
// }
//
// @Override
// public Object getFrom() {
// return from;
// }
//
// @Override
// public Object getTo() {
// return to;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setFrom(String from) {
// this.from = from;
// }
//
// public void setTo(String to) {
// this.to = to;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortlived;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
// Path: src/main/java/com/rolfje/anonimatron/anonymizer/DutchBSNAnononymizer.java
import com.rolfje.anonimatron.synonyms.NumberSynonym;
import com.rolfje.anonimatron.synonyms.StringSynonym;
import com.rolfje.anonimatron.synonyms.Synonym;
import org.apache.commons.lang3.StringUtils;
import java.math.BigDecimal;
import java.math.BigInteger;
package com.rolfje.anonimatron.anonymizer;
/**
* Generates valid Dutch "Burger Service Nummer" or "SOFI Nummer", a social
* security number uniquely identifying civilians to the governement.
* <p>
* A BSN Number is 9 digits long, can not start with 3 zeroes, the first digit
* must be less than 4, and the whole number passes the "11 proof"
* <p>
* See https://nl.wikipedia.org/wiki/Burgerservicenummer
*/
public class DutchBSNAnononymizer extends AbstractElevenProofAnonymizer {
private static final int LENGTH = 9;
@Override
public String getType() {
return "BURGERSERVICENUMMER";
}
@Override
public Synonym anonymize(Object from, int size, boolean isShortLived) {
if (size < LENGTH) {
throw new UnsupportedOperationException(
"Cannot generate a BSN that fits in a " + size + " character string. Must be " + LENGTH
+ " characters or more.");
}
String newBSN = generateNonIdenticalBSN(from);
if (from instanceof Number) {
return new NumberSynonym(
getType(),
(Number) from,
asNumber(newBSN, (Number) from),
isShortLived);
} else if (from instanceof String) { | return new StringSynonym( |
realrolfje/anonimatron | src/test/java/com/rolfje/anonimatron/anonymizer/IbanAnonymizerTest.java | // Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
//
// Path: src/test/java/com/rolfje/junit/Asserts.java
// public class Asserts {
//
// public static void assertAnyOf(Object expected, Object... values) {
// for (Object value : values) {
// if (expected.equals(value)) {
// return;
// }
// }
// fail(expected.toString() + " did not match any of "
// + Arrays.stream(values).map(Object::toString).collect(Collectors.joining(", "))
// + ".");
// }
//
// public static void assertInstanceOf(Class<?> expectedClass, Object actualClass) {
// Class<?> matchable = matchableClass(expectedClass);
// assertTrue("Class " + actualClass.getClass().getSimpleName() + " is not an instance of " + expectedClass.getSimpleName(),
// matchable.isInstance(actualClass));
// }
//
// private static Class<?> matchableClass(Class<?> expectedClass) {
// if (boolean.class.equals(expectedClass)) return Boolean.class;
// if (byte.class.equals(expectedClass)) return Byte.class;
// if (char.class.equals(expectedClass)) return Character.class;
// if (double.class.equals(expectedClass)) return Double.class;
// if (float.class.equals(expectedClass)) return Float.class;
// if (int.class.equals(expectedClass)) return Integer.class;
// if (long.class.equals(expectedClass)) return Long.class;
// if (short.class.equals(expectedClass)) return Short.class;
// return expectedClass;
// }
// }
| import com.rolfje.anonimatron.synonyms.Synonym;
import com.rolfje.junit.Asserts;
import org.iban4j.CountryCode;
import org.iban4j.Iban;
import org.iban4j.bban.BbanStructure;
import org.junit.Test;
import java.util.EnumSet;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
| package com.rolfje.anonimatron.anonymizer;
/**
* Tests for {@link IbanAnonymizer}.
*
* @author Erik-Berndt Scheper
*/
public class IbanAnonymizerTest {
private IbanAnonymizer anonymizer = new IbanAnonymizer();
private EnumSet<CountryCode> countriesWithBankAccountAnonymizer = EnumSet
.copyOf(IbanAnonymizer.BANK_ACCOUNT_ANONYMIZERS.keySet());
private EnumSet<CountryCode> countriesWithoutBankAccountAnonymizer = EnumSet.complementOf(countriesWithBankAccountAnonymizer);
@Test
public void testAnonymizeForCountriesWithBankAccountAnonymizer() {
for (CountryCode countryCode : countriesWithBankAccountAnonymizer) {
testAnonymize(countryCode);
}
}
@Test
public void testAnonymizeForOtherCountries() {
for (CountryCode countryCode : countriesWithoutBankAccountAnonymizer) {
if (BbanStructure.forCountry(countryCode) != null) {
testAnonymize(countryCode);
}
}
}
private void testAnonymize(CountryCode countryCode) {
for (int i = 0; i < 1000; i++) {
String from = anonymizer.generateIban(countryCode);
| // Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
//
// Path: src/test/java/com/rolfje/junit/Asserts.java
// public class Asserts {
//
// public static void assertAnyOf(Object expected, Object... values) {
// for (Object value : values) {
// if (expected.equals(value)) {
// return;
// }
// }
// fail(expected.toString() + " did not match any of "
// + Arrays.stream(values).map(Object::toString).collect(Collectors.joining(", "))
// + ".");
// }
//
// public static void assertInstanceOf(Class<?> expectedClass, Object actualClass) {
// Class<?> matchable = matchableClass(expectedClass);
// assertTrue("Class " + actualClass.getClass().getSimpleName() + " is not an instance of " + expectedClass.getSimpleName(),
// matchable.isInstance(actualClass));
// }
//
// private static Class<?> matchableClass(Class<?> expectedClass) {
// if (boolean.class.equals(expectedClass)) return Boolean.class;
// if (byte.class.equals(expectedClass)) return Byte.class;
// if (char.class.equals(expectedClass)) return Character.class;
// if (double.class.equals(expectedClass)) return Double.class;
// if (float.class.equals(expectedClass)) return Float.class;
// if (int.class.equals(expectedClass)) return Integer.class;
// if (long.class.equals(expectedClass)) return Long.class;
// if (short.class.equals(expectedClass)) return Short.class;
// return expectedClass;
// }
// }
// Path: src/test/java/com/rolfje/anonimatron/anonymizer/IbanAnonymizerTest.java
import com.rolfje.anonimatron.synonyms.Synonym;
import com.rolfje.junit.Asserts;
import org.iban4j.CountryCode;
import org.iban4j.Iban;
import org.iban4j.bban.BbanStructure;
import org.junit.Test;
import java.util.EnumSet;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
package com.rolfje.anonimatron.anonymizer;
/**
* Tests for {@link IbanAnonymizer}.
*
* @author Erik-Berndt Scheper
*/
public class IbanAnonymizerTest {
private IbanAnonymizer anonymizer = new IbanAnonymizer();
private EnumSet<CountryCode> countriesWithBankAccountAnonymizer = EnumSet
.copyOf(IbanAnonymizer.BANK_ACCOUNT_ANONYMIZERS.keySet());
private EnumSet<CountryCode> countriesWithoutBankAccountAnonymizer = EnumSet.complementOf(countriesWithBankAccountAnonymizer);
@Test
public void testAnonymizeForCountriesWithBankAccountAnonymizer() {
for (CountryCode countryCode : countriesWithBankAccountAnonymizer) {
testAnonymize(countryCode);
}
}
@Test
public void testAnonymizeForOtherCountries() {
for (CountryCode countryCode : countriesWithoutBankAccountAnonymizer) {
if (BbanStructure.forCountry(countryCode) != null) {
testAnonymize(countryCode);
}
}
}
private void testAnonymize(CountryCode countryCode) {
for (int i = 0; i < 1000; i++) {
String from = anonymizer.generateIban(countryCode);
| Asserts.assertAnyOf(Iban.valueOf(from).getCountryCode(),
|
realrolfje/anonimatron | src/test/java/com/rolfje/anonimatron/anonymizer/IbanAnonymizerTest.java | // Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
//
// Path: src/test/java/com/rolfje/junit/Asserts.java
// public class Asserts {
//
// public static void assertAnyOf(Object expected, Object... values) {
// for (Object value : values) {
// if (expected.equals(value)) {
// return;
// }
// }
// fail(expected.toString() + " did not match any of "
// + Arrays.stream(values).map(Object::toString).collect(Collectors.joining(", "))
// + ".");
// }
//
// public static void assertInstanceOf(Class<?> expectedClass, Object actualClass) {
// Class<?> matchable = matchableClass(expectedClass);
// assertTrue("Class " + actualClass.getClass().getSimpleName() + " is not an instance of " + expectedClass.getSimpleName(),
// matchable.isInstance(actualClass));
// }
//
// private static Class<?> matchableClass(Class<?> expectedClass) {
// if (boolean.class.equals(expectedClass)) return Boolean.class;
// if (byte.class.equals(expectedClass)) return Byte.class;
// if (char.class.equals(expectedClass)) return Character.class;
// if (double.class.equals(expectedClass)) return Double.class;
// if (float.class.equals(expectedClass)) return Float.class;
// if (int.class.equals(expectedClass)) return Integer.class;
// if (long.class.equals(expectedClass)) return Long.class;
// if (short.class.equals(expectedClass)) return Short.class;
// return expectedClass;
// }
// }
| import com.rolfje.anonimatron.synonyms.Synonym;
import com.rolfje.junit.Asserts;
import org.iban4j.CountryCode;
import org.iban4j.Iban;
import org.iban4j.bban.BbanStructure;
import org.junit.Test;
import java.util.EnumSet;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
| @Test
public void testAnonymizeForCountriesWithBankAccountAnonymizer() {
for (CountryCode countryCode : countriesWithBankAccountAnonymizer) {
testAnonymize(countryCode);
}
}
@Test
public void testAnonymizeForOtherCountries() {
for (CountryCode countryCode : countriesWithoutBankAccountAnonymizer) {
if (BbanStructure.forCountry(countryCode) != null) {
testAnonymize(countryCode);
}
}
}
private void testAnonymize(CountryCode countryCode) {
for (int i = 0; i < 1000; i++) {
String from = anonymizer.generateIban(countryCode);
Asserts.assertAnyOf(Iban.valueOf(from).getCountryCode(),
countryCode,
IbanAnonymizer.DEFAULT_COUNTRY_CODE
);
testInternal(from.length(), from, countryCode);
}
}
private void testInternal(int size, String from, CountryCode countryCode) {
| // Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
//
// Path: src/test/java/com/rolfje/junit/Asserts.java
// public class Asserts {
//
// public static void assertAnyOf(Object expected, Object... values) {
// for (Object value : values) {
// if (expected.equals(value)) {
// return;
// }
// }
// fail(expected.toString() + " did not match any of "
// + Arrays.stream(values).map(Object::toString).collect(Collectors.joining(", "))
// + ".");
// }
//
// public static void assertInstanceOf(Class<?> expectedClass, Object actualClass) {
// Class<?> matchable = matchableClass(expectedClass);
// assertTrue("Class " + actualClass.getClass().getSimpleName() + " is not an instance of " + expectedClass.getSimpleName(),
// matchable.isInstance(actualClass));
// }
//
// private static Class<?> matchableClass(Class<?> expectedClass) {
// if (boolean.class.equals(expectedClass)) return Boolean.class;
// if (byte.class.equals(expectedClass)) return Byte.class;
// if (char.class.equals(expectedClass)) return Character.class;
// if (double.class.equals(expectedClass)) return Double.class;
// if (float.class.equals(expectedClass)) return Float.class;
// if (int.class.equals(expectedClass)) return Integer.class;
// if (long.class.equals(expectedClass)) return Long.class;
// if (short.class.equals(expectedClass)) return Short.class;
// return expectedClass;
// }
// }
// Path: src/test/java/com/rolfje/anonimatron/anonymizer/IbanAnonymizerTest.java
import com.rolfje.anonimatron.synonyms.Synonym;
import com.rolfje.junit.Asserts;
import org.iban4j.CountryCode;
import org.iban4j.Iban;
import org.iban4j.bban.BbanStructure;
import org.junit.Test;
import java.util.EnumSet;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
@Test
public void testAnonymizeForCountriesWithBankAccountAnonymizer() {
for (CountryCode countryCode : countriesWithBankAccountAnonymizer) {
testAnonymize(countryCode);
}
}
@Test
public void testAnonymizeForOtherCountries() {
for (CountryCode countryCode : countriesWithoutBankAccountAnonymizer) {
if (BbanStructure.forCountry(countryCode) != null) {
testAnonymize(countryCode);
}
}
}
private void testAnonymize(CountryCode countryCode) {
for (int i = 0; i < 1000; i++) {
String from = anonymizer.generateIban(countryCode);
Asserts.assertAnyOf(Iban.valueOf(from).getCountryCode(),
countryCode,
IbanAnonymizer.DEFAULT_COUNTRY_CODE
);
testInternal(from.length(), from, countryCode);
}
}
private void testInternal(int size, String from, CountryCode countryCode) {
| Synonym synonym = anonymizer.anonymize(from, size, false);
|
realrolfje/anonimatron | src/test/java/com/rolfje/anonimatron/anonymizer/DigitStringAnonymizerTest.java | // Path: src/test/java/com/javamonitor/tools/Stopwatch.java
// public final class Stopwatch implements Serializable {
// private static final long serialVersionUID = 1L;
//
// private static final Logger log = Logger.getLogger(Stopwatch.class);
//
// private final long start;
// private long lastTime;
// private Level loglevel = Level.WARN;
//
// private final StringBuilder message = new StringBuilder();
//
// /**
// * Start a new stopwatch, specifying the class we work for.
// *
// * @param clazz The class we work for.
// */
// public Stopwatch(final Class<?> clazz) {
// this(clazz.getName());
// }
//
// /**
// * Start a new stopwatch, with a custom name.
// *
// * @param name The name of this Stopwatch
// */
// public Stopwatch(final String name) {
// super();
//
// start = System.currentTimeMillis();
// lastTime = start;
//
// message.append("entering ").append(name).append(" took ");
// }
//
// /**
// * Mark the time of the operation that we are about to perform.
// *
// * @param operation The operation we are about to perform.
// */
// public void aboutTo(final String operation) {
// final long now = System.currentTimeMillis();
// final long timeDiff = now - lastTime;
// lastTime = now;
//
// message.append(timeDiff).append("; ").append(operation)
// .append(" took ");
// }
//
// /**
// * Stop the stopwatch, logging the events in case the time was longer than
// * the specified threshold time value. This method is typically invoked in a
// * finally block.
// *
// * @param thresholdMillis The threshold above which we print the events.
// * @return <code>true</code> if the operation completes within the specified time
// */
// public boolean stop(final long thresholdMillis) {
// final long now = System.currentTimeMillis();
// final long timeDiff = now - lastTime;
// lastTime = now;
//
// long total = now - start;
// message.append(timeDiff).append(". Total: ").append(total).append(" ms.");
//
// if ((total) > thresholdMillis) {
// log.log(loglevel, message);
// return false;
// }
// return true;
// }
//
// public String getMessage(){
// return message.toString();
// }
//
// public Stopwatch setLoglevel(Level loglevel) {
// this.loglevel = loglevel;
// return this;
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
| import com.javamonitor.tools.Stopwatch;
import com.rolfje.anonimatron.synonyms.Synonym;
import org.junit.Before;
import org.junit.Test;
import java.util.HashMap;
import java.util.Map;
import static org.junit.Assert.*; | package com.rolfje.anonimatron.anonymizer;
public class DigitStringAnonymizerTest {
private DigitStringAnonymizer anonymizer;
@Before
public void setUp() {
anonymizer = new DigitStringAnonymizer();
}
@Test
public void anonymize() {
String original = "ORIGINAL";
| // Path: src/test/java/com/javamonitor/tools/Stopwatch.java
// public final class Stopwatch implements Serializable {
// private static final long serialVersionUID = 1L;
//
// private static final Logger log = Logger.getLogger(Stopwatch.class);
//
// private final long start;
// private long lastTime;
// private Level loglevel = Level.WARN;
//
// private final StringBuilder message = new StringBuilder();
//
// /**
// * Start a new stopwatch, specifying the class we work for.
// *
// * @param clazz The class we work for.
// */
// public Stopwatch(final Class<?> clazz) {
// this(clazz.getName());
// }
//
// /**
// * Start a new stopwatch, with a custom name.
// *
// * @param name The name of this Stopwatch
// */
// public Stopwatch(final String name) {
// super();
//
// start = System.currentTimeMillis();
// lastTime = start;
//
// message.append("entering ").append(name).append(" took ");
// }
//
// /**
// * Mark the time of the operation that we are about to perform.
// *
// * @param operation The operation we are about to perform.
// */
// public void aboutTo(final String operation) {
// final long now = System.currentTimeMillis();
// final long timeDiff = now - lastTime;
// lastTime = now;
//
// message.append(timeDiff).append("; ").append(operation)
// .append(" took ");
// }
//
// /**
// * Stop the stopwatch, logging the events in case the time was longer than
// * the specified threshold time value. This method is typically invoked in a
// * finally block.
// *
// * @param thresholdMillis The threshold above which we print the events.
// * @return <code>true</code> if the operation completes within the specified time
// */
// public boolean stop(final long thresholdMillis) {
// final long now = System.currentTimeMillis();
// final long timeDiff = now - lastTime;
// lastTime = now;
//
// long total = now - start;
// message.append(timeDiff).append(". Total: ").append(total).append(" ms.");
//
// if ((total) > thresholdMillis) {
// log.log(loglevel, message);
// return false;
// }
// return true;
// }
//
// public String getMessage(){
// return message.toString();
// }
//
// public Stopwatch setLoglevel(Level loglevel) {
// this.loglevel = loglevel;
// return this;
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
// Path: src/test/java/com/rolfje/anonimatron/anonymizer/DigitStringAnonymizerTest.java
import com.javamonitor.tools.Stopwatch;
import com.rolfje.anonimatron.synonyms.Synonym;
import org.junit.Before;
import org.junit.Test;
import java.util.HashMap;
import java.util.Map;
import static org.junit.Assert.*;
package com.rolfje.anonimatron.anonymizer;
public class DigitStringAnonymizerTest {
private DigitStringAnonymizer anonymizer;
@Before
public void setUp() {
anonymizer = new DigitStringAnonymizer();
}
@Test
public void anonymize() {
String original = "ORIGINAL";
| Synonym synonym = anonymizer.anonymize(original, Integer.MAX_VALUE, false); |
realrolfje/anonimatron | src/test/java/com/rolfje/anonimatron/anonymizer/DigitStringAnonymizerTest.java | // Path: src/test/java/com/javamonitor/tools/Stopwatch.java
// public final class Stopwatch implements Serializable {
// private static final long serialVersionUID = 1L;
//
// private static final Logger log = Logger.getLogger(Stopwatch.class);
//
// private final long start;
// private long lastTime;
// private Level loglevel = Level.WARN;
//
// private final StringBuilder message = new StringBuilder();
//
// /**
// * Start a new stopwatch, specifying the class we work for.
// *
// * @param clazz The class we work for.
// */
// public Stopwatch(final Class<?> clazz) {
// this(clazz.getName());
// }
//
// /**
// * Start a new stopwatch, with a custom name.
// *
// * @param name The name of this Stopwatch
// */
// public Stopwatch(final String name) {
// super();
//
// start = System.currentTimeMillis();
// lastTime = start;
//
// message.append("entering ").append(name).append(" took ");
// }
//
// /**
// * Mark the time of the operation that we are about to perform.
// *
// * @param operation The operation we are about to perform.
// */
// public void aboutTo(final String operation) {
// final long now = System.currentTimeMillis();
// final long timeDiff = now - lastTime;
// lastTime = now;
//
// message.append(timeDiff).append("; ").append(operation)
// .append(" took ");
// }
//
// /**
// * Stop the stopwatch, logging the events in case the time was longer than
// * the specified threshold time value. This method is typically invoked in a
// * finally block.
// *
// * @param thresholdMillis The threshold above which we print the events.
// * @return <code>true</code> if the operation completes within the specified time
// */
// public boolean stop(final long thresholdMillis) {
// final long now = System.currentTimeMillis();
// final long timeDiff = now - lastTime;
// lastTime = now;
//
// long total = now - start;
// message.append(timeDiff).append(". Total: ").append(total).append(" ms.");
//
// if ((total) > thresholdMillis) {
// log.log(loglevel, message);
// return false;
// }
// return true;
// }
//
// public String getMessage(){
// return message.toString();
// }
//
// public Stopwatch setLoglevel(Level loglevel) {
// this.loglevel = loglevel;
// return this;
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
| import com.javamonitor.tools.Stopwatch;
import com.rolfje.anonimatron.synonyms.Synonym;
import org.junit.Before;
import org.junit.Test;
import java.util.HashMap;
import java.util.Map;
import static org.junit.Assert.*; | public void testMaskedAnonymize() {
String original = "ABCDEFGH";
String mask = "1,1-1*99";
String expected = "AxCxExGH";
Synonym synonym = anonymizer.anonymize(
original, Integer.MAX_VALUE, false,
getMaskParameters(mask)
);
String toString = synonym.getTo().toString();
assertEquals(original, synonym.getFrom());
assertNotEquals(synonym.getFrom(), synonym.getTo());
assertEquals(synonym.getFrom().toString().length(), toString.length());
char[] toChars = toString.toCharArray();
char[] expectedChars = expected.toCharArray();
for (int i = 0; i < expectedChars.length; i++) {
assertEquals("Character at position " + i + " not what we expected. String is '" + toString + "'", (expectedChars[i] == 'x'), (Character.isDigit(toChars[i])));
}
}
@Test
public void testMaskedDigitsPerformance() {
String original = "ABCDEFGH";
String mask = "1,1-1*99";
Map<String, String> maskParameters = getMaskParameters(mask);
| // Path: src/test/java/com/javamonitor/tools/Stopwatch.java
// public final class Stopwatch implements Serializable {
// private static final long serialVersionUID = 1L;
//
// private static final Logger log = Logger.getLogger(Stopwatch.class);
//
// private final long start;
// private long lastTime;
// private Level loglevel = Level.WARN;
//
// private final StringBuilder message = new StringBuilder();
//
// /**
// * Start a new stopwatch, specifying the class we work for.
// *
// * @param clazz The class we work for.
// */
// public Stopwatch(final Class<?> clazz) {
// this(clazz.getName());
// }
//
// /**
// * Start a new stopwatch, with a custom name.
// *
// * @param name The name of this Stopwatch
// */
// public Stopwatch(final String name) {
// super();
//
// start = System.currentTimeMillis();
// lastTime = start;
//
// message.append("entering ").append(name).append(" took ");
// }
//
// /**
// * Mark the time of the operation that we are about to perform.
// *
// * @param operation The operation we are about to perform.
// */
// public void aboutTo(final String operation) {
// final long now = System.currentTimeMillis();
// final long timeDiff = now - lastTime;
// lastTime = now;
//
// message.append(timeDiff).append("; ").append(operation)
// .append(" took ");
// }
//
// /**
// * Stop the stopwatch, logging the events in case the time was longer than
// * the specified threshold time value. This method is typically invoked in a
// * finally block.
// *
// * @param thresholdMillis The threshold above which we print the events.
// * @return <code>true</code> if the operation completes within the specified time
// */
// public boolean stop(final long thresholdMillis) {
// final long now = System.currentTimeMillis();
// final long timeDiff = now - lastTime;
// lastTime = now;
//
// long total = now - start;
// message.append(timeDiff).append(". Total: ").append(total).append(" ms.");
//
// if ((total) > thresholdMillis) {
// log.log(loglevel, message);
// return false;
// }
// return true;
// }
//
// public String getMessage(){
// return message.toString();
// }
//
// public Stopwatch setLoglevel(Level loglevel) {
// this.loglevel = loglevel;
// return this;
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
// Path: src/test/java/com/rolfje/anonimatron/anonymizer/DigitStringAnonymizerTest.java
import com.javamonitor.tools.Stopwatch;
import com.rolfje.anonimatron.synonyms.Synonym;
import org.junit.Before;
import org.junit.Test;
import java.util.HashMap;
import java.util.Map;
import static org.junit.Assert.*;
public void testMaskedAnonymize() {
String original = "ABCDEFGH";
String mask = "1,1-1*99";
String expected = "AxCxExGH";
Synonym synonym = anonymizer.anonymize(
original, Integer.MAX_VALUE, false,
getMaskParameters(mask)
);
String toString = synonym.getTo().toString();
assertEquals(original, synonym.getFrom());
assertNotEquals(synonym.getFrom(), synonym.getTo());
assertEquals(synonym.getFrom().toString().length(), toString.length());
char[] toChars = toString.toCharArray();
char[] expectedChars = expected.toCharArray();
for (int i = 0; i < expectedChars.length; i++) {
assertEquals("Character at position " + i + " not what we expected. String is '" + toString + "'", (expectedChars[i] == 'x'), (Character.isDigit(toChars[i])));
}
}
@Test
public void testMaskedDigitsPerformance() {
String original = "ABCDEFGH";
String mask = "1,1-1*99";
Map<String, String> maskParameters = getMaskParameters(mask);
| Stopwatch stopwatchNano = new Stopwatch("Masked performance"); |
realrolfje/anonimatron | src/main/java/com/rolfje/anonimatron/anonymizer/CharacterStringPrefetchAnonymizer.java | // Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
| import org.apache.log4j.Logger;
import com.rolfje.anonimatron.synonyms.Synonym; | package com.rolfje.anonimatron.anonymizer;
/**
* Provides the same functionality as {@link CharacterStringAnonymizer}, but
* uses the prefetch cycle to collect its output character set. This causes
* the anonymized dataset to contain the same characters as used the input set,
* enabling debugging/reproduction of strange character set issues.
*
* @author rolf
*/
public class CharacterStringPrefetchAnonymizer extends CharacterStringAnonymizer implements Prefetcher {
private static final Logger LOG = Logger.getLogger(CharacterStringPrefetchAnonymizer.class);
public CharacterStringPrefetchAnonymizer() {
CHARS = "";
}
@Override
public void prefetch(Object sourceData) {
if (sourceData == null) {
return;
}
char[] sourcechars = sourceData.toString().toCharArray();
for (char c : sourcechars) {
if (CHARS.indexOf(c) == -1) {
CHARS += c;
}
}
}
@Override | // Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
// Path: src/main/java/com/rolfje/anonimatron/anonymizer/CharacterStringPrefetchAnonymizer.java
import org.apache.log4j.Logger;
import com.rolfje.anonimatron.synonyms.Synonym;
package com.rolfje.anonimatron.anonymizer;
/**
* Provides the same functionality as {@link CharacterStringAnonymizer}, but
* uses the prefetch cycle to collect its output character set. This causes
* the anonymized dataset to contain the same characters as used the input set,
* enabling debugging/reproduction of strange character set issues.
*
* @author rolf
*/
public class CharacterStringPrefetchAnonymizer extends CharacterStringAnonymizer implements Prefetcher {
private static final Logger LOG = Logger.getLogger(CharacterStringPrefetchAnonymizer.class);
public CharacterStringPrefetchAnonymizer() {
CHARS = "";
}
@Override
public void prefetch(Object sourceData) {
if (sourceData == null) {
return;
}
char[] sourcechars = sourceData.toString().toCharArray();
for (char c : sourcechars) {
if (CHARS.indexOf(c) == -1) {
CHARS += c;
}
}
}
@Override | public Synonym anonymize(Object from, int size, boolean shortlived) { |
realrolfje/anonimatron | src/main/java/com/rolfje/anonimatron/anonymizer/IbanAnonymizer.java | // Path: src/main/java/com/rolfje/anonimatron/synonyms/StringSynonym.java
// public class StringSynonym implements Synonym {
// private String type;
// private String from;
// private String to;
// private boolean shortlived = false;
//
// public StringSynonym() {
// }
//
// public StringSynonym(String type, String from, String to, boolean shortlived) {
// this.type = type;
// this.from = from;
// this.to = to;
// this.shortlived = shortlived;
// }
//
// @Override
// public String getType() {
// return type;
// }
//
// @Override
// public Object getFrom() {
// return from;
// }
//
// @Override
// public Object getTo() {
// return to;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setFrom(String from) {
// this.from = from;
// }
//
// public void setTo(String to) {
// this.to = to;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortlived;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
| import static org.apache.log4j.Logger.getLogger;
import java.util.EnumMap;
import java.util.Locale;
import java.util.Map;
import org.apache.log4j.Logger;
import org.iban4j.CountryCode;
import org.iban4j.Iban;
import org.iban4j.Iban4jException;
import org.iban4j.bban.BbanStructure;
import com.rolfje.anonimatron.synonyms.StringSynonym;
import com.rolfje.anonimatron.synonyms.Synonym;
| package com.rolfje.anonimatron.anonymizer;
/**
* Generates valid International Bank Account Numbers, or {@code IBAN}'s.
* Tries to use the {@link BankAccountAnonymizer} to generate valid {@code BBAN}'s for the system default country code.
* If no such anonymizer exists, a random account is generated.
* <p>
*
* @author Erik-Berndt Scheper
* @see <a href="https://en.wikipedia.org/wiki/International_Bank_Account_Number">https://en.wikipedia.org/wiki/International_Bank_Account_Number</a>
*/
public class IbanAnonymizer implements Anonymizer {
private static final Logger LOGGER = getLogger(IbanAnonymizer.class);
private static final String TYPE = "IBAN";
static final Map<CountryCode, BankAccountAnonymizer> BANK_ACCOUNT_ANONYMIZERS;
static final CountryCode DEFAULT_COUNTRY_CODE;
static {
// initialize bank account anonymizers
BANK_ACCOUNT_ANONYMIZERS = new EnumMap<>(CountryCode.class);
BANK_ACCOUNT_ANONYMIZERS.put(CountryCode.NL, new DutchBankAccountAnononymizer());
// set a default country code to be used when the original iban cannot be parsed
CountryCode countryCode = CountryCode.getByCode(Locale.getDefault().getCountry());
if (countryCode != null && BbanStructure.forCountry(countryCode) != null) {
DEFAULT_COUNTRY_CODE = countryCode;
} else {
DEFAULT_COUNTRY_CODE = CountryCode.NL;
}
}
@Override
public String getType() {
return TYPE;
}
@Override
| // Path: src/main/java/com/rolfje/anonimatron/synonyms/StringSynonym.java
// public class StringSynonym implements Synonym {
// private String type;
// private String from;
// private String to;
// private boolean shortlived = false;
//
// public StringSynonym() {
// }
//
// public StringSynonym(String type, String from, String to, boolean shortlived) {
// this.type = type;
// this.from = from;
// this.to = to;
// this.shortlived = shortlived;
// }
//
// @Override
// public String getType() {
// return type;
// }
//
// @Override
// public Object getFrom() {
// return from;
// }
//
// @Override
// public Object getTo() {
// return to;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setFrom(String from) {
// this.from = from;
// }
//
// public void setTo(String to) {
// this.to = to;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortlived;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
// Path: src/main/java/com/rolfje/anonimatron/anonymizer/IbanAnonymizer.java
import static org.apache.log4j.Logger.getLogger;
import java.util.EnumMap;
import java.util.Locale;
import java.util.Map;
import org.apache.log4j.Logger;
import org.iban4j.CountryCode;
import org.iban4j.Iban;
import org.iban4j.Iban4jException;
import org.iban4j.bban.BbanStructure;
import com.rolfje.anonimatron.synonyms.StringSynonym;
import com.rolfje.anonimatron.synonyms.Synonym;
package com.rolfje.anonimatron.anonymizer;
/**
* Generates valid International Bank Account Numbers, or {@code IBAN}'s.
* Tries to use the {@link BankAccountAnonymizer} to generate valid {@code BBAN}'s for the system default country code.
* If no such anonymizer exists, a random account is generated.
* <p>
*
* @author Erik-Berndt Scheper
* @see <a href="https://en.wikipedia.org/wiki/International_Bank_Account_Number">https://en.wikipedia.org/wiki/International_Bank_Account_Number</a>
*/
public class IbanAnonymizer implements Anonymizer {
private static final Logger LOGGER = getLogger(IbanAnonymizer.class);
private static final String TYPE = "IBAN";
static final Map<CountryCode, BankAccountAnonymizer> BANK_ACCOUNT_ANONYMIZERS;
static final CountryCode DEFAULT_COUNTRY_CODE;
static {
// initialize bank account anonymizers
BANK_ACCOUNT_ANONYMIZERS = new EnumMap<>(CountryCode.class);
BANK_ACCOUNT_ANONYMIZERS.put(CountryCode.NL, new DutchBankAccountAnononymizer());
// set a default country code to be used when the original iban cannot be parsed
CountryCode countryCode = CountryCode.getByCode(Locale.getDefault().getCountry());
if (countryCode != null && BbanStructure.forCountry(countryCode) != null) {
DEFAULT_COUNTRY_CODE = countryCode;
} else {
DEFAULT_COUNTRY_CODE = CountryCode.NL;
}
}
@Override
public String getType() {
return TYPE;
}
@Override
| public Synonym anonymize(Object from, int size, boolean shortlived) {
|
realrolfje/anonimatron | src/main/java/com/rolfje/anonimatron/anonymizer/IbanAnonymizer.java | // Path: src/main/java/com/rolfje/anonimatron/synonyms/StringSynonym.java
// public class StringSynonym implements Synonym {
// private String type;
// private String from;
// private String to;
// private boolean shortlived = false;
//
// public StringSynonym() {
// }
//
// public StringSynonym(String type, String from, String to, boolean shortlived) {
// this.type = type;
// this.from = from;
// this.to = to;
// this.shortlived = shortlived;
// }
//
// @Override
// public String getType() {
// return type;
// }
//
// @Override
// public Object getFrom() {
// return from;
// }
//
// @Override
// public Object getTo() {
// return to;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setFrom(String from) {
// this.from = from;
// }
//
// public void setTo(String to) {
// this.to = to;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortlived;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
| import static org.apache.log4j.Logger.getLogger;
import java.util.EnumMap;
import java.util.Locale;
import java.util.Map;
import org.apache.log4j.Logger;
import org.iban4j.CountryCode;
import org.iban4j.Iban;
import org.iban4j.Iban4jException;
import org.iban4j.bban.BbanStructure;
import com.rolfje.anonimatron.synonyms.StringSynonym;
import com.rolfje.anonimatron.synonyms.Synonym;
| package com.rolfje.anonimatron.anonymizer;
/**
* Generates valid International Bank Account Numbers, or {@code IBAN}'s.
* Tries to use the {@link BankAccountAnonymizer} to generate valid {@code BBAN}'s for the system default country code.
* If no such anonymizer exists, a random account is generated.
* <p>
*
* @author Erik-Berndt Scheper
* @see <a href="https://en.wikipedia.org/wiki/International_Bank_Account_Number">https://en.wikipedia.org/wiki/International_Bank_Account_Number</a>
*/
public class IbanAnonymizer implements Anonymizer {
private static final Logger LOGGER = getLogger(IbanAnonymizer.class);
private static final String TYPE = "IBAN";
static final Map<CountryCode, BankAccountAnonymizer> BANK_ACCOUNT_ANONYMIZERS;
static final CountryCode DEFAULT_COUNTRY_CODE;
static {
// initialize bank account anonymizers
BANK_ACCOUNT_ANONYMIZERS = new EnumMap<>(CountryCode.class);
BANK_ACCOUNT_ANONYMIZERS.put(CountryCode.NL, new DutchBankAccountAnononymizer());
// set a default country code to be used when the original iban cannot be parsed
CountryCode countryCode = CountryCode.getByCode(Locale.getDefault().getCountry());
if (countryCode != null && BbanStructure.forCountry(countryCode) != null) {
DEFAULT_COUNTRY_CODE = countryCode;
} else {
DEFAULT_COUNTRY_CODE = CountryCode.NL;
}
}
@Override
public String getType() {
return TYPE;
}
@Override
public Synonym anonymize(Object from, int size, boolean shortlived) {
CountryCode countryCode = getCountryCode(from);
String result = generateIban(countryCode);
| // Path: src/main/java/com/rolfje/anonimatron/synonyms/StringSynonym.java
// public class StringSynonym implements Synonym {
// private String type;
// private String from;
// private String to;
// private boolean shortlived = false;
//
// public StringSynonym() {
// }
//
// public StringSynonym(String type, String from, String to, boolean shortlived) {
// this.type = type;
// this.from = from;
// this.to = to;
// this.shortlived = shortlived;
// }
//
// @Override
// public String getType() {
// return type;
// }
//
// @Override
// public Object getFrom() {
// return from;
// }
//
// @Override
// public Object getTo() {
// return to;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setFrom(String from) {
// this.from = from;
// }
//
// public void setTo(String to) {
// this.to = to;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortlived;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
// Path: src/main/java/com/rolfje/anonimatron/anonymizer/IbanAnonymizer.java
import static org.apache.log4j.Logger.getLogger;
import java.util.EnumMap;
import java.util.Locale;
import java.util.Map;
import org.apache.log4j.Logger;
import org.iban4j.CountryCode;
import org.iban4j.Iban;
import org.iban4j.Iban4jException;
import org.iban4j.bban.BbanStructure;
import com.rolfje.anonimatron.synonyms.StringSynonym;
import com.rolfje.anonimatron.synonyms.Synonym;
package com.rolfje.anonimatron.anonymizer;
/**
* Generates valid International Bank Account Numbers, or {@code IBAN}'s.
* Tries to use the {@link BankAccountAnonymizer} to generate valid {@code BBAN}'s for the system default country code.
* If no such anonymizer exists, a random account is generated.
* <p>
*
* @author Erik-Berndt Scheper
* @see <a href="https://en.wikipedia.org/wiki/International_Bank_Account_Number">https://en.wikipedia.org/wiki/International_Bank_Account_Number</a>
*/
public class IbanAnonymizer implements Anonymizer {
private static final Logger LOGGER = getLogger(IbanAnonymizer.class);
private static final String TYPE = "IBAN";
static final Map<CountryCode, BankAccountAnonymizer> BANK_ACCOUNT_ANONYMIZERS;
static final CountryCode DEFAULT_COUNTRY_CODE;
static {
// initialize bank account anonymizers
BANK_ACCOUNT_ANONYMIZERS = new EnumMap<>(CountryCode.class);
BANK_ACCOUNT_ANONYMIZERS.put(CountryCode.NL, new DutchBankAccountAnononymizer());
// set a default country code to be used when the original iban cannot be parsed
CountryCode countryCode = CountryCode.getByCode(Locale.getDefault().getCountry());
if (countryCode != null && BbanStructure.forCountry(countryCode) != null) {
DEFAULT_COUNTRY_CODE = countryCode;
} else {
DEFAULT_COUNTRY_CODE = CountryCode.NL;
}
}
@Override
public String getType() {
return TYPE;
}
@Override
public Synonym anonymize(Object from, int size, boolean shortlived) {
CountryCode countryCode = getCountryCode(from);
String result = generateIban(countryCode);
| return new StringSynonym(
|
realrolfje/anonimatron | src/main/java/com/rolfje/anonimatron/anonymizer/DigitStringAnonymizer.java | // Path: src/main/java/com/rolfje/anonimatron/synonyms/StringSynonym.java
// public class StringSynonym implements Synonym {
// private String type;
// private String from;
// private String to;
// private boolean shortlived = false;
//
// public StringSynonym() {
// }
//
// public StringSynonym(String type, String from, String to, boolean shortlived) {
// this.type = type;
// this.from = from;
// this.to = to;
// this.shortlived = shortlived;
// }
//
// @Override
// public String getType() {
// return type;
// }
//
// @Override
// public Object getFrom() {
// return from;
// }
//
// @Override
// public Object getTo() {
// return to;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setFrom(String from) {
// this.from = from;
// }
//
// public void setTo(String to) {
// this.to = to;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortlived;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
| import com.rolfje.anonimatron.synonyms.StringSynonym;
import com.rolfje.anonimatron.synonyms.Synonym;
import java.util.Map; | package com.rolfje.anonimatron.anonymizer;
public class DigitStringAnonymizer extends AbstractElevenProofAnonymizer {
final static String PARAMETER = "mask";
@Override
public String getType() {
return "RANDOMDIGITS";
}
@Override | // Path: src/main/java/com/rolfje/anonimatron/synonyms/StringSynonym.java
// public class StringSynonym implements Synonym {
// private String type;
// private String from;
// private String to;
// private boolean shortlived = false;
//
// public StringSynonym() {
// }
//
// public StringSynonym(String type, String from, String to, boolean shortlived) {
// this.type = type;
// this.from = from;
// this.to = to;
// this.shortlived = shortlived;
// }
//
// @Override
// public String getType() {
// return type;
// }
//
// @Override
// public Object getFrom() {
// return from;
// }
//
// @Override
// public Object getTo() {
// return to;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setFrom(String from) {
// this.from = from;
// }
//
// public void setTo(String to) {
// this.to = to;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortlived;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
// Path: src/main/java/com/rolfje/anonimatron/anonymizer/DigitStringAnonymizer.java
import com.rolfje.anonimatron.synonyms.StringSynonym;
import com.rolfje.anonimatron.synonyms.Synonym;
import java.util.Map;
package com.rolfje.anonimatron.anonymizer;
public class DigitStringAnonymizer extends AbstractElevenProofAnonymizer {
final static String PARAMETER = "mask";
@Override
public String getType() {
return "RANDOMDIGITS";
}
@Override | public Synonym anonymize(Object from, int size, boolean shortlived, Map<String, String> parameters) { |
realrolfje/anonimatron | src/main/java/com/rolfje/anonimatron/anonymizer/DigitStringAnonymizer.java | // Path: src/main/java/com/rolfje/anonimatron/synonyms/StringSynonym.java
// public class StringSynonym implements Synonym {
// private String type;
// private String from;
// private String to;
// private boolean shortlived = false;
//
// public StringSynonym() {
// }
//
// public StringSynonym(String type, String from, String to, boolean shortlived) {
// this.type = type;
// this.from = from;
// this.to = to;
// this.shortlived = shortlived;
// }
//
// @Override
// public String getType() {
// return type;
// }
//
// @Override
// public Object getFrom() {
// return from;
// }
//
// @Override
// public Object getTo() {
// return to;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setFrom(String from) {
// this.from = from;
// }
//
// public void setTo(String to) {
// this.to = to;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortlived;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
| import com.rolfje.anonimatron.synonyms.StringSynonym;
import com.rolfje.anonimatron.synonyms.Synonym;
import java.util.Map; | package com.rolfje.anonimatron.anonymizer;
public class DigitStringAnonymizer extends AbstractElevenProofAnonymizer {
final static String PARAMETER = "mask";
@Override
public String getType() {
return "RANDOMDIGITS";
}
@Override
public Synonym anonymize(Object from, int size, boolean shortlived, Map<String, String> parameters) {
if (parameters == null || parameters.isEmpty()) {
return anonymize(from, size, shortlived);
} else if (!parameters.containsKey(PARAMETER)) {
throw new UnsupportedOperationException("Please provide '" + PARAMETER + "' with a digit mask in the form 111******, where only stars are replaced with random characters.");
}
return anonymizeMasked(from, size, shortlived, parameters.get(PARAMETER));
}
@Override
public Synonym anonymize(Object from, int size, boolean shortlived) {
if (from == null) { | // Path: src/main/java/com/rolfje/anonimatron/synonyms/StringSynonym.java
// public class StringSynonym implements Synonym {
// private String type;
// private String from;
// private String to;
// private boolean shortlived = false;
//
// public StringSynonym() {
// }
//
// public StringSynonym(String type, String from, String to, boolean shortlived) {
// this.type = type;
// this.from = from;
// this.to = to;
// this.shortlived = shortlived;
// }
//
// @Override
// public String getType() {
// return type;
// }
//
// @Override
// public Object getFrom() {
// return from;
// }
//
// @Override
// public Object getTo() {
// return to;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setFrom(String from) {
// this.from = from;
// }
//
// public void setTo(String to) {
// this.to = to;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortlived;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
// Path: src/main/java/com/rolfje/anonimatron/anonymizer/DigitStringAnonymizer.java
import com.rolfje.anonimatron.synonyms.StringSynonym;
import com.rolfje.anonimatron.synonyms.Synonym;
import java.util.Map;
package com.rolfje.anonimatron.anonymizer;
public class DigitStringAnonymizer extends AbstractElevenProofAnonymizer {
final static String PARAMETER = "mask";
@Override
public String getType() {
return "RANDOMDIGITS";
}
@Override
public Synonym anonymize(Object from, int size, boolean shortlived, Map<String, String> parameters) {
if (parameters == null || parameters.isEmpty()) {
return anonymize(from, size, shortlived);
} else if (!parameters.containsKey(PARAMETER)) {
throw new UnsupportedOperationException("Please provide '" + PARAMETER + "' with a digit mask in the form 111******, where only stars are replaced with random characters.");
}
return anonymizeMasked(from, size, shortlived, parameters.get(PARAMETER));
}
@Override
public Synonym anonymize(Object from, int size, boolean shortlived) {
if (from == null) { | return new StringSynonym( |
realrolfje/anonimatron | src/main/java/com/rolfje/anonimatron/anonymizer/CountryCodeAnonymizer.java | // Path: src/main/java/com/rolfje/anonimatron/synonyms/StringSynonym.java
// public class StringSynonym implements Synonym {
// private String type;
// private String from;
// private String to;
// private boolean shortlived = false;
//
// public StringSynonym() {
// }
//
// public StringSynonym(String type, String from, String to, boolean shortlived) {
// this.type = type;
// this.from = from;
// this.to = to;
// this.shortlived = shortlived;
// }
//
// @Override
// public String getType() {
// return type;
// }
//
// @Override
// public Object getFrom() {
// return from;
// }
//
// @Override
// public Object getTo() {
// return to;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setFrom(String from) {
// this.from = from;
// }
//
// public void setTo(String to) {
// this.to = to;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortlived;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
| import com.rolfje.anonimatron.synonyms.StringSynonym;
import com.rolfje.anonimatron.synonyms.Synonym;
import org.springframework.util.StringUtils;
import java.security.SecureRandom;
import java.text.SimpleDateFormat;
import java.util.Locale;
import java.util.MissingResourceException; | package com.rolfje.anonimatron.anonymizer;
/**
* Produces valid 2 or 3 character country codes.
*/
public class CountryCodeAnonymizer implements Anonymizer {
private static final String TYPE = "COUNTRY_CODE";
protected static final Locale[] AVAILABLE_LOCALES = SimpleDateFormat.getAvailableLocales();
SecureRandom r = new SecureRandom();
@Override
public String getType() {
return TYPE;
}
@Override | // Path: src/main/java/com/rolfje/anonimatron/synonyms/StringSynonym.java
// public class StringSynonym implements Synonym {
// private String type;
// private String from;
// private String to;
// private boolean shortlived = false;
//
// public StringSynonym() {
// }
//
// public StringSynonym(String type, String from, String to, boolean shortlived) {
// this.type = type;
// this.from = from;
// this.to = to;
// this.shortlived = shortlived;
// }
//
// @Override
// public String getType() {
// return type;
// }
//
// @Override
// public Object getFrom() {
// return from;
// }
//
// @Override
// public Object getTo() {
// return to;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setFrom(String from) {
// this.from = from;
// }
//
// public void setTo(String to) {
// this.to = to;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortlived;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
// Path: src/main/java/com/rolfje/anonimatron/anonymizer/CountryCodeAnonymizer.java
import com.rolfje.anonimatron.synonyms.StringSynonym;
import com.rolfje.anonimatron.synonyms.Synonym;
import org.springframework.util.StringUtils;
import java.security.SecureRandom;
import java.text.SimpleDateFormat;
import java.util.Locale;
import java.util.MissingResourceException;
package com.rolfje.anonimatron.anonymizer;
/**
* Produces valid 2 or 3 character country codes.
*/
public class CountryCodeAnonymizer implements Anonymizer {
private static final String TYPE = "COUNTRY_CODE";
protected static final Locale[] AVAILABLE_LOCALES = SimpleDateFormat.getAvailableLocales();
SecureRandom r = new SecureRandom();
@Override
public String getType() {
return TYPE;
}
@Override | public Synonym anonymize(Object from, int size, boolean shortlived) { |
realrolfje/anonimatron | src/main/java/com/rolfje/anonimatron/anonymizer/CountryCodeAnonymizer.java | // Path: src/main/java/com/rolfje/anonimatron/synonyms/StringSynonym.java
// public class StringSynonym implements Synonym {
// private String type;
// private String from;
// private String to;
// private boolean shortlived = false;
//
// public StringSynonym() {
// }
//
// public StringSynonym(String type, String from, String to, boolean shortlived) {
// this.type = type;
// this.from = from;
// this.to = to;
// this.shortlived = shortlived;
// }
//
// @Override
// public String getType() {
// return type;
// }
//
// @Override
// public Object getFrom() {
// return from;
// }
//
// @Override
// public Object getTo() {
// return to;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setFrom(String from) {
// this.from = from;
// }
//
// public void setTo(String to) {
// this.to = to;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortlived;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
| import com.rolfje.anonimatron.synonyms.StringSynonym;
import com.rolfje.anonimatron.synonyms.Synonym;
import org.springframework.util.StringUtils;
import java.security.SecureRandom;
import java.text.SimpleDateFormat;
import java.util.Locale;
import java.util.MissingResourceException; | }
@Override
public Synonym anonymize(Object from, int size, boolean shortlived) {
if (size < 2) {
throw new UnsupportedOperationException("Can not produce country codes of one character.");
}
String country = null;
while (country == null || country.length() < 1) {
Locale l = AVAILABLE_LOCALES[r.nextInt(AVAILABLE_LOCALES.length)];
try {
if (size > 2) {
country = l.getISO3Country();
if(StringUtils.isEmpty(country)) {
continue;
}
country = padRight(country, size);
}
else if (size == 2) {
country = l.getCountry();
}
} catch (MissingResourceException e) {
// Locale.getISOCountries() has inconsistent behaviour for "AN", "BU" and "CS" country codes
// See https://bugs.openjdk.java.net/browse/JDK-8071929
}
}
| // Path: src/main/java/com/rolfje/anonimatron/synonyms/StringSynonym.java
// public class StringSynonym implements Synonym {
// private String type;
// private String from;
// private String to;
// private boolean shortlived = false;
//
// public StringSynonym() {
// }
//
// public StringSynonym(String type, String from, String to, boolean shortlived) {
// this.type = type;
// this.from = from;
// this.to = to;
// this.shortlived = shortlived;
// }
//
// @Override
// public String getType() {
// return type;
// }
//
// @Override
// public Object getFrom() {
// return from;
// }
//
// @Override
// public Object getTo() {
// return to;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setFrom(String from) {
// this.from = from;
// }
//
// public void setTo(String to) {
// this.to = to;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortlived;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
// Path: src/main/java/com/rolfje/anonimatron/anonymizer/CountryCodeAnonymizer.java
import com.rolfje.anonimatron.synonyms.StringSynonym;
import com.rolfje.anonimatron.synonyms.Synonym;
import org.springframework.util.StringUtils;
import java.security.SecureRandom;
import java.text.SimpleDateFormat;
import java.util.Locale;
import java.util.MissingResourceException;
}
@Override
public Synonym anonymize(Object from, int size, boolean shortlived) {
if (size < 2) {
throw new UnsupportedOperationException("Can not produce country codes of one character.");
}
String country = null;
while (country == null || country.length() < 1) {
Locale l = AVAILABLE_LOCALES[r.nextInt(AVAILABLE_LOCALES.length)];
try {
if (size > 2) {
country = l.getISO3Country();
if(StringUtils.isEmpty(country)) {
continue;
}
country = padRight(country, size);
}
else if (size == 2) {
country = l.getCountry();
}
} catch (MissingResourceException e) {
// Locale.getISOCountries() has inconsistent behaviour for "AN", "BU" and "CS" country codes
// See https://bugs.openjdk.java.net/browse/JDK-8071929
}
}
| return new StringSynonym( |
realrolfje/anonimatron | src/main/java/com/rolfje/anonimatron/anonymizer/EmailAddressAnonymizer.java | // Path: src/main/java/com/rolfje/anonimatron/synonyms/StringSynonym.java
// public class StringSynonym implements Synonym {
// private String type;
// private String from;
// private String to;
// private boolean shortlived = false;
//
// public StringSynonym() {
// }
//
// public StringSynonym(String type, String from, String to, boolean shortlived) {
// this.type = type;
// this.from = from;
// this.to = to;
// this.shortlived = shortlived;
// }
//
// @Override
// public String getType() {
// return type;
// }
//
// @Override
// public Object getFrom() {
// return from;
// }
//
// @Override
// public Object getTo() {
// return to;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setFrom(String from) {
// this.from = from;
// }
//
// public void setTo(String to) {
// this.to = to;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortlived;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
| import com.rolfje.anonimatron.synonyms.StringSynonym;
import com.rolfje.anonimatron.synonyms.Synonym; | package com.rolfje.anonimatron.anonymizer;
public class EmailAddressAnonymizer implements Anonymizer {
private static final String EMAIL_DOMAIN = "@example.com";
private static final String TYPE = "EMAIL_ADDRESS";
@Override | // Path: src/main/java/com/rolfje/anonimatron/synonyms/StringSynonym.java
// public class StringSynonym implements Synonym {
// private String type;
// private String from;
// private String to;
// private boolean shortlived = false;
//
// public StringSynonym() {
// }
//
// public StringSynonym(String type, String from, String to, boolean shortlived) {
// this.type = type;
// this.from = from;
// this.to = to;
// this.shortlived = shortlived;
// }
//
// @Override
// public String getType() {
// return type;
// }
//
// @Override
// public Object getFrom() {
// return from;
// }
//
// @Override
// public Object getTo() {
// return to;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setFrom(String from) {
// this.from = from;
// }
//
// public void setTo(String to) {
// this.to = to;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortlived;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
// Path: src/main/java/com/rolfje/anonimatron/anonymizer/EmailAddressAnonymizer.java
import com.rolfje.anonimatron.synonyms.StringSynonym;
import com.rolfje.anonimatron.synonyms.Synonym;
package com.rolfje.anonimatron.anonymizer;
public class EmailAddressAnonymizer implements Anonymizer {
private static final String EMAIL_DOMAIN = "@example.com";
private static final String TYPE = "EMAIL_ADDRESS";
@Override | public Synonym anonymize(Object from, int size, boolean shortlived) { |
realrolfje/anonimatron | src/main/java/com/rolfje/anonimatron/anonymizer/EmailAddressAnonymizer.java | // Path: src/main/java/com/rolfje/anonimatron/synonyms/StringSynonym.java
// public class StringSynonym implements Synonym {
// private String type;
// private String from;
// private String to;
// private boolean shortlived = false;
//
// public StringSynonym() {
// }
//
// public StringSynonym(String type, String from, String to, boolean shortlived) {
// this.type = type;
// this.from = from;
// this.to = to;
// this.shortlived = shortlived;
// }
//
// @Override
// public String getType() {
// return type;
// }
//
// @Override
// public Object getFrom() {
// return from;
// }
//
// @Override
// public Object getTo() {
// return to;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setFrom(String from) {
// this.from = from;
// }
//
// public void setTo(String to) {
// this.to = to;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortlived;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
| import com.rolfje.anonimatron.synonyms.StringSynonym;
import com.rolfje.anonimatron.synonyms.Synonym; | package com.rolfje.anonimatron.anonymizer;
public class EmailAddressAnonymizer implements Anonymizer {
private static final String EMAIL_DOMAIN = "@example.com";
private static final String TYPE = "EMAIL_ADDRESS";
@Override
public Synonym anonymize(Object from, int size, boolean shortlived) {
String randomHexString = null;
if (from instanceof String) {
randomHexString = Long.toHexString(Double
.doubleToLongBits(Math.random()));
randomHexString += EMAIL_DOMAIN;
if (randomHexString.length() > size) {
throw new UnsupportedOperationException(
"Can not generate email address with length " + size
+ ".");
}
} else {
throw new UnsupportedOperationException(
"Can not anonymize objects of type " + from.getClass());
}
| // Path: src/main/java/com/rolfje/anonimatron/synonyms/StringSynonym.java
// public class StringSynonym implements Synonym {
// private String type;
// private String from;
// private String to;
// private boolean shortlived = false;
//
// public StringSynonym() {
// }
//
// public StringSynonym(String type, String from, String to, boolean shortlived) {
// this.type = type;
// this.from = from;
// this.to = to;
// this.shortlived = shortlived;
// }
//
// @Override
// public String getType() {
// return type;
// }
//
// @Override
// public Object getFrom() {
// return from;
// }
//
// @Override
// public Object getTo() {
// return to;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setFrom(String from) {
// this.from = from;
// }
//
// public void setTo(String to) {
// this.to = to;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortlived;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
// Path: src/main/java/com/rolfje/anonimatron/anonymizer/EmailAddressAnonymizer.java
import com.rolfje.anonimatron.synonyms.StringSynonym;
import com.rolfje.anonimatron.synonyms.Synonym;
package com.rolfje.anonimatron.anonymizer;
public class EmailAddressAnonymizer implements Anonymizer {
private static final String EMAIL_DOMAIN = "@example.com";
private static final String TYPE = "EMAIL_ADDRESS";
@Override
public Synonym anonymize(Object from, int size, boolean shortlived) {
String randomHexString = null;
if (from instanceof String) {
randomHexString = Long.toHexString(Double
.doubleToLongBits(Math.random()));
randomHexString += EMAIL_DOMAIN;
if (randomHexString.length() > size) {
throw new UnsupportedOperationException(
"Can not generate email address with length " + size
+ ".");
}
} else {
throw new UnsupportedOperationException(
"Can not anonymize objects of type " + from.getClass());
}
| return new StringSynonym( |
realrolfje/anonimatron | src/main/java/com/rolfje/anonimatron/anonymizer/DateAnonymizer.java | // Path: src/main/java/com/rolfje/anonimatron/synonyms/DateSynonym.java
// public class DateSynonym implements Synonym {
// private String type;
// private Date from;
// private Date to;
// private boolean shortlived = false;
//
// public String getType() {
// return type;
// }
//
// public Object getFrom() {
// return from;
// }
//
// public Object getTo() {
// return to;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setTo(Object to) {
// this.to = (Date) to;
// }
//
// public void setFrom(Object from) {
// this.from = (Date) from;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortlived;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
| import com.rolfje.anonimatron.synonyms.DateSynonym;
import com.rolfje.anonimatron.synonyms.Synonym;
import java.sql.Date;
import java.util.HashSet;
import java.util.Set; | package com.rolfje.anonimatron.anonymizer;
class DateAnonymizer implements Anonymizer {
private static final String TYPE = "DATE";
private static final long RANDOMIZATION_MILLIS = 1000L * 60L * 60L * 24L * 31L;
private Set<Date> generatedDates = new HashSet<>();
@Override | // Path: src/main/java/com/rolfje/anonimatron/synonyms/DateSynonym.java
// public class DateSynonym implements Synonym {
// private String type;
// private Date from;
// private Date to;
// private boolean shortlived = false;
//
// public String getType() {
// return type;
// }
//
// public Object getFrom() {
// return from;
// }
//
// public Object getTo() {
// return to;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setTo(Object to) {
// this.to = (Date) to;
// }
//
// public void setFrom(Object from) {
// this.from = (Date) from;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortlived;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
// Path: src/main/java/com/rolfje/anonimatron/anonymizer/DateAnonymizer.java
import com.rolfje.anonimatron.synonyms.DateSynonym;
import com.rolfje.anonimatron.synonyms.Synonym;
import java.sql.Date;
import java.util.HashSet;
import java.util.Set;
package com.rolfje.anonimatron.anonymizer;
class DateAnonymizer implements Anonymizer {
private static final String TYPE = "DATE";
private static final long RANDOMIZATION_MILLIS = 1000L * 60L * 60L * 24L * 31L;
private Set<Date> generatedDates = new HashSet<>();
@Override | public Synonym anonymize(Object from, int size, boolean shortlived) { |
realrolfje/anonimatron | src/main/java/com/rolfje/anonimatron/anonymizer/DateAnonymizer.java | // Path: src/main/java/com/rolfje/anonimatron/synonyms/DateSynonym.java
// public class DateSynonym implements Synonym {
// private String type;
// private Date from;
// private Date to;
// private boolean shortlived = false;
//
// public String getType() {
// return type;
// }
//
// public Object getFrom() {
// return from;
// }
//
// public Object getTo() {
// return to;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setTo(Object to) {
// this.to = (Date) to;
// }
//
// public void setFrom(Object from) {
// this.from = (Date) from;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortlived;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
| import com.rolfje.anonimatron.synonyms.DateSynonym;
import com.rolfje.anonimatron.synonyms.Synonym;
import java.sql.Date;
import java.util.HashSet;
import java.util.Set; | package com.rolfje.anonimatron.anonymizer;
class DateAnonymizer implements Anonymizer {
private static final String TYPE = "DATE";
private static final long RANDOMIZATION_MILLIS = 1000L * 60L * 60L * 24L * 31L;
private Set<Date> generatedDates = new HashSet<>();
@Override
public Synonym anonymize(Object from, int size, boolean shortlived) { | // Path: src/main/java/com/rolfje/anonimatron/synonyms/DateSynonym.java
// public class DateSynonym implements Synonym {
// private String type;
// private Date from;
// private Date to;
// private boolean shortlived = false;
//
// public String getType() {
// return type;
// }
//
// public Object getFrom() {
// return from;
// }
//
// public Object getTo() {
// return to;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setTo(Object to) {
// this.to = (Date) to;
// }
//
// public void setFrom(Object from) {
// this.from = (Date) from;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortlived;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
// Path: src/main/java/com/rolfje/anonimatron/anonymizer/DateAnonymizer.java
import com.rolfje.anonimatron.synonyms.DateSynonym;
import com.rolfje.anonimatron.synonyms.Synonym;
import java.sql.Date;
import java.util.HashSet;
import java.util.Set;
package com.rolfje.anonimatron.anonymizer;
class DateAnonymizer implements Anonymizer {
private static final String TYPE = "DATE";
private static final long RANDOMIZATION_MILLIS = 1000L * 60L * 60L * 24L * 31L;
private Set<Date> generatedDates = new HashSet<>();
@Override
public Synonym anonymize(Object from, int size, boolean shortlived) { | DateSynonym s = new DateSynonym(); |
realrolfje/anonimatron | src/main/java/com/rolfje/anonimatron/anonymizer/DutchZipCodeAnonymizer.java | // Path: src/main/java/com/rolfje/anonimatron/synonyms/StringSynonym.java
// public class StringSynonym implements Synonym {
// private String type;
// private String from;
// private String to;
// private boolean shortlived = false;
//
// public StringSynonym() {
// }
//
// public StringSynonym(String type, String from, String to, boolean shortlived) {
// this.type = type;
// this.from = from;
// this.to = to;
// this.shortlived = shortlived;
// }
//
// @Override
// public String getType() {
// return type;
// }
//
// @Override
// public Object getFrom() {
// return from;
// }
//
// @Override
// public Object getTo() {
// return to;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setFrom(String from) {
// this.from = from;
// }
//
// public void setTo(String to) {
// this.to = to;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortlived;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
| import com.rolfje.anonimatron.synonyms.StringSynonym;
import com.rolfje.anonimatron.synonyms.Synonym;
import java.util.Random;
| package com.rolfje.anonimatron.anonymizer;
/**
* Generates valid Dutch zip codes.
* <p>
* The generated zip code has the following characteristics:
* <ul>
* <li>Starts with [1-9]</li>
* <li>Followed by [0-9]{3}</li>
* <li>Ends with two uppercase letters, that may <strong>NOT</strong> include:
* <ul>
* <li>SA</li>
* <li>SD</li>
* <li>SS</li>
* </ul></li>
* </ul>
* <p>
*
* @author Erik-Berndt Scheper
* @see <a href="https://nl.wikipedia.org/wiki/Postcodes_in_Nederland">https://nl.wikipedia.org/wiki/Postcodes_in_Nederland</a>
*/
public class DutchZipCodeAnonymizer implements Anonymizer {
private static final String TYPE = "DUTCH_ZIP_CODE";
private static final String CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
private static final String CHARS_WITHOUT_ADS = "BCEFGHIJKLMNOPQRTUVWXYZ";
protected static final Random RANDOM = new Random();
@Override
public String getType() {
return TYPE;
}
@Override
| // Path: src/main/java/com/rolfje/anonimatron/synonyms/StringSynonym.java
// public class StringSynonym implements Synonym {
// private String type;
// private String from;
// private String to;
// private boolean shortlived = false;
//
// public StringSynonym() {
// }
//
// public StringSynonym(String type, String from, String to, boolean shortlived) {
// this.type = type;
// this.from = from;
// this.to = to;
// this.shortlived = shortlived;
// }
//
// @Override
// public String getType() {
// return type;
// }
//
// @Override
// public Object getFrom() {
// return from;
// }
//
// @Override
// public Object getTo() {
// return to;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setFrom(String from) {
// this.from = from;
// }
//
// public void setTo(String to) {
// this.to = to;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortlived;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
// Path: src/main/java/com/rolfje/anonimatron/anonymizer/DutchZipCodeAnonymizer.java
import com.rolfje.anonimatron.synonyms.StringSynonym;
import com.rolfje.anonimatron.synonyms.Synonym;
import java.util.Random;
package com.rolfje.anonimatron.anonymizer;
/**
* Generates valid Dutch zip codes.
* <p>
* The generated zip code has the following characteristics:
* <ul>
* <li>Starts with [1-9]</li>
* <li>Followed by [0-9]{3}</li>
* <li>Ends with two uppercase letters, that may <strong>NOT</strong> include:
* <ul>
* <li>SA</li>
* <li>SD</li>
* <li>SS</li>
* </ul></li>
* </ul>
* <p>
*
* @author Erik-Berndt Scheper
* @see <a href="https://nl.wikipedia.org/wiki/Postcodes_in_Nederland">https://nl.wikipedia.org/wiki/Postcodes_in_Nederland</a>
*/
public class DutchZipCodeAnonymizer implements Anonymizer {
private static final String TYPE = "DUTCH_ZIP_CODE";
private static final String CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
private static final String CHARS_WITHOUT_ADS = "BCEFGHIJKLMNOPQRTUVWXYZ";
protected static final Random RANDOM = new Random();
@Override
public String getType() {
return TYPE;
}
@Override
| public Synonym anonymize(Object from, int size, boolean shortlived) {
|
realrolfje/anonimatron | src/main/java/com/rolfje/anonimatron/anonymizer/DutchZipCodeAnonymizer.java | // Path: src/main/java/com/rolfje/anonimatron/synonyms/StringSynonym.java
// public class StringSynonym implements Synonym {
// private String type;
// private String from;
// private String to;
// private boolean shortlived = false;
//
// public StringSynonym() {
// }
//
// public StringSynonym(String type, String from, String to, boolean shortlived) {
// this.type = type;
// this.from = from;
// this.to = to;
// this.shortlived = shortlived;
// }
//
// @Override
// public String getType() {
// return type;
// }
//
// @Override
// public Object getFrom() {
// return from;
// }
//
// @Override
// public Object getTo() {
// return to;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setFrom(String from) {
// this.from = from;
// }
//
// public void setTo(String to) {
// this.to = to;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortlived;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
| import com.rolfje.anonimatron.synonyms.StringSynonym;
import com.rolfje.anonimatron.synonyms.Synonym;
import java.util.Random;
| package com.rolfje.anonimatron.anonymizer;
/**
* Generates valid Dutch zip codes.
* <p>
* The generated zip code has the following characteristics:
* <ul>
* <li>Starts with [1-9]</li>
* <li>Followed by [0-9]{3}</li>
* <li>Ends with two uppercase letters, that may <strong>NOT</strong> include:
* <ul>
* <li>SA</li>
* <li>SD</li>
* <li>SS</li>
* </ul></li>
* </ul>
* <p>
*
* @author Erik-Berndt Scheper
* @see <a href="https://nl.wikipedia.org/wiki/Postcodes_in_Nederland">https://nl.wikipedia.org/wiki/Postcodes_in_Nederland</a>
*/
public class DutchZipCodeAnonymizer implements Anonymizer {
private static final String TYPE = "DUTCH_ZIP_CODE";
private static final String CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
private static final String CHARS_WITHOUT_ADS = "BCEFGHIJKLMNOPQRTUVWXYZ";
protected static final Random RANDOM = new Random();
@Override
public String getType() {
return TYPE;
}
@Override
public Synonym anonymize(Object from, int size, boolean shortlived) {
String result = buildZipCode();
| // Path: src/main/java/com/rolfje/anonimatron/synonyms/StringSynonym.java
// public class StringSynonym implements Synonym {
// private String type;
// private String from;
// private String to;
// private boolean shortlived = false;
//
// public StringSynonym() {
// }
//
// public StringSynonym(String type, String from, String to, boolean shortlived) {
// this.type = type;
// this.from = from;
// this.to = to;
// this.shortlived = shortlived;
// }
//
// @Override
// public String getType() {
// return type;
// }
//
// @Override
// public Object getFrom() {
// return from;
// }
//
// @Override
// public Object getTo() {
// return to;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setFrom(String from) {
// this.from = from;
// }
//
// public void setTo(String to) {
// this.to = to;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortlived;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
// Path: src/main/java/com/rolfje/anonimatron/anonymizer/DutchZipCodeAnonymizer.java
import com.rolfje.anonimatron.synonyms.StringSynonym;
import com.rolfje.anonimatron.synonyms.Synonym;
import java.util.Random;
package com.rolfje.anonimatron.anonymizer;
/**
* Generates valid Dutch zip codes.
* <p>
* The generated zip code has the following characteristics:
* <ul>
* <li>Starts with [1-9]</li>
* <li>Followed by [0-9]{3}</li>
* <li>Ends with two uppercase letters, that may <strong>NOT</strong> include:
* <ul>
* <li>SA</li>
* <li>SD</li>
* <li>SS</li>
* </ul></li>
* </ul>
* <p>
*
* @author Erik-Berndt Scheper
* @see <a href="https://nl.wikipedia.org/wiki/Postcodes_in_Nederland">https://nl.wikipedia.org/wiki/Postcodes_in_Nederland</a>
*/
public class DutchZipCodeAnonymizer implements Anonymizer {
private static final String TYPE = "DUTCH_ZIP_CODE";
private static final String CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
private static final String CHARS_WITHOUT_ADS = "BCEFGHIJKLMNOPQRTUVWXYZ";
protected static final Random RANDOM = new Random();
@Override
public String getType() {
return TYPE;
}
@Override
public Synonym anonymize(Object from, int size, boolean shortlived) {
String result = buildZipCode();
| return new StringSynonym(TYPE, (String) from, result, shortlived);
|
realrolfje/anonimatron | src/main/java/com/rolfje/anonimatron/anonymizer/CharacterStringAnonymizer.java | // Path: src/main/java/com/rolfje/anonimatron/synonyms/StringSynonym.java
// public class StringSynonym implements Synonym {
// private String type;
// private String from;
// private String to;
// private boolean shortlived = false;
//
// public StringSynonym() {
// }
//
// public StringSynonym(String type, String from, String to, boolean shortlived) {
// this.type = type;
// this.from = from;
// this.to = to;
// this.shortlived = shortlived;
// }
//
// @Override
// public String getType() {
// return type;
// }
//
// @Override
// public Object getFrom() {
// return from;
// }
//
// @Override
// public Object getTo() {
// return to;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setFrom(String from) {
// this.from = from;
// }
//
// public void setTo(String to) {
// this.to = to;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortlived;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
| import com.rolfje.anonimatron.synonyms.StringSynonym;
import com.rolfje.anonimatron.synonyms.Synonym;
import java.util.Map;
import java.util.Random; | package com.rolfje.anonimatron.anonymizer;
/**
* Generates an output string based on the configured characters
* to use.
*/
public class CharacterStringAnonymizer implements Anonymizer {
public static final String PARAMETER = "characters";
protected String CHARS;
protected static final Random RANDOM = new Random();
public CharacterStringAnonymizer() {
CHARS = getDefaultCharacterString();
}
protected String getDefaultCharacterString() {
return "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
}
@Override
public String getType() {
return "RANDOMCHARACTERS";
}
@Override | // Path: src/main/java/com/rolfje/anonimatron/synonyms/StringSynonym.java
// public class StringSynonym implements Synonym {
// private String type;
// private String from;
// private String to;
// private boolean shortlived = false;
//
// public StringSynonym() {
// }
//
// public StringSynonym(String type, String from, String to, boolean shortlived) {
// this.type = type;
// this.from = from;
// this.to = to;
// this.shortlived = shortlived;
// }
//
// @Override
// public String getType() {
// return type;
// }
//
// @Override
// public Object getFrom() {
// return from;
// }
//
// @Override
// public Object getTo() {
// return to;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setFrom(String from) {
// this.from = from;
// }
//
// public void setTo(String to) {
// this.to = to;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortlived;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
// Path: src/main/java/com/rolfje/anonimatron/anonymizer/CharacterStringAnonymizer.java
import com.rolfje.anonimatron.synonyms.StringSynonym;
import com.rolfje.anonimatron.synonyms.Synonym;
import java.util.Map;
import java.util.Random;
package com.rolfje.anonimatron.anonymizer;
/**
* Generates an output string based on the configured characters
* to use.
*/
public class CharacterStringAnonymizer implements Anonymizer {
public static final String PARAMETER = "characters";
protected String CHARS;
protected static final Random RANDOM = new Random();
public CharacterStringAnonymizer() {
CHARS = getDefaultCharacterString();
}
protected String getDefaultCharacterString() {
return "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
}
@Override
public String getType() {
return "RANDOMCHARACTERS";
}
@Override | public Synonym anonymize(Object from, int size, boolean shortlived, Map<String, String> parameters) { |
realrolfje/anonimatron | src/main/java/com/rolfje/anonimatron/anonymizer/CharacterStringAnonymizer.java | // Path: src/main/java/com/rolfje/anonimatron/synonyms/StringSynonym.java
// public class StringSynonym implements Synonym {
// private String type;
// private String from;
// private String to;
// private boolean shortlived = false;
//
// public StringSynonym() {
// }
//
// public StringSynonym(String type, String from, String to, boolean shortlived) {
// this.type = type;
// this.from = from;
// this.to = to;
// this.shortlived = shortlived;
// }
//
// @Override
// public String getType() {
// return type;
// }
//
// @Override
// public Object getFrom() {
// return from;
// }
//
// @Override
// public Object getTo() {
// return to;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setFrom(String from) {
// this.from = from;
// }
//
// public void setTo(String to) {
// this.to = to;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortlived;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
| import com.rolfje.anonimatron.synonyms.StringSynonym;
import com.rolfje.anonimatron.synonyms.Synonym;
import java.util.Map;
import java.util.Random; |
@Override
public String getType() {
return "RANDOMCHARACTERS";
}
@Override
public Synonym anonymize(Object from, int size, boolean shortlived, Map<String, String> parameters) {
if (parameters == null || !parameters.containsKey(PARAMETER)) {
throw new UnsupportedOperationException("Please provide '" + PARAMETER + "' as configuration parameter.");
}
return anonymize(from, size, shortlived, parameters.get(PARAMETER));
}
@Override
public Synonym anonymize(Object from, int size, boolean shortlived) {
return anonymize(from, size, shortlived, CHARS);
}
private Synonym anonymize(Object from, int size, boolean shortlived, String characters) {
String fromString = from.toString();
int length = fromString.length();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < length; i++) {
sb.append(characters.charAt(RANDOM.nextInt(characters.length())));
}
String to = sb.toString();
| // Path: src/main/java/com/rolfje/anonimatron/synonyms/StringSynonym.java
// public class StringSynonym implements Synonym {
// private String type;
// private String from;
// private String to;
// private boolean shortlived = false;
//
// public StringSynonym() {
// }
//
// public StringSynonym(String type, String from, String to, boolean shortlived) {
// this.type = type;
// this.from = from;
// this.to = to;
// this.shortlived = shortlived;
// }
//
// @Override
// public String getType() {
// return type;
// }
//
// @Override
// public Object getFrom() {
// return from;
// }
//
// @Override
// public Object getTo() {
// return to;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setFrom(String from) {
// this.from = from;
// }
//
// public void setTo(String to) {
// this.to = to;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortlived;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
// Path: src/main/java/com/rolfje/anonimatron/anonymizer/CharacterStringAnonymizer.java
import com.rolfje.anonimatron.synonyms.StringSynonym;
import com.rolfje.anonimatron.synonyms.Synonym;
import java.util.Map;
import java.util.Random;
@Override
public String getType() {
return "RANDOMCHARACTERS";
}
@Override
public Synonym anonymize(Object from, int size, boolean shortlived, Map<String, String> parameters) {
if (parameters == null || !parameters.containsKey(PARAMETER)) {
throw new UnsupportedOperationException("Please provide '" + PARAMETER + "' as configuration parameter.");
}
return anonymize(from, size, shortlived, parameters.get(PARAMETER));
}
@Override
public Synonym anonymize(Object from, int size, boolean shortlived) {
return anonymize(from, size, shortlived, CHARS);
}
private Synonym anonymize(Object from, int size, boolean shortlived, String characters) {
String fromString = from.toString();
int length = fromString.length();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < length; i++) {
sb.append(characters.charAt(RANDOM.nextInt(characters.length())));
}
String to = sb.toString();
| return new StringSynonym( |
realrolfje/anonimatron | src/main/java/com/rolfje/anonimatron/anonymizer/Anonymizer.java | // Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
| import com.rolfje.anonimatron.synonyms.Synonym;
import java.sql.Date;
import java.util.Map; | package com.rolfje.anonimatron.anonymizer;
/**
* Provides functionality for consitently anonymizing a piece of data.
* <p>
* Implementations of this interface must make sure that anonymization is done
* in a reproducable manner. That is, if A transforms into B, it has to
* consistently do so on each and every call.
* <p>
* By doing this, anonimatron can guarantee that data is transformed
* consistently accross all tables of the database, and referential constraints
* can be re-enforced after anonymization.
*/
public interface Anonymizer {
/**
* @return The ID or name of this anonymizer, as used in the XML
* configuration file. This is generally something along the lines
* of "LASTNAME" or "UNEVENNUMBER". Please see the output of the
* -configexample command line option when running Anonimatron.
*/
String getType();
/**
* Anonymizes the given data into a non-tracable, non-reversible synonym,
* and does it consistently, so that A always translates to B.
*
* @param from the data to be anonymized, usually passed in as a
* {@link String}, {@link Integer}, {@link Date} or other classes
* which can be stored in a single JDBC database column.
* @param size the optional maximum size of the generated value
* @param shortlived indicates that the generated synonym must have the
* {@link Synonym#isShortLived()} boolean set
* @return a {@link Synonym}
*/ | // Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
// Path: src/main/java/com/rolfje/anonimatron/anonymizer/Anonymizer.java
import com.rolfje.anonimatron.synonyms.Synonym;
import java.sql.Date;
import java.util.Map;
package com.rolfje.anonimatron.anonymizer;
/**
* Provides functionality for consitently anonymizing a piece of data.
* <p>
* Implementations of this interface must make sure that anonymization is done
* in a reproducable manner. That is, if A transforms into B, it has to
* consistently do so on each and every call.
* <p>
* By doing this, anonimatron can guarantee that data is transformed
* consistently accross all tables of the database, and referential constraints
* can be re-enforced after anonymization.
*/
public interface Anonymizer {
/**
* @return The ID or name of this anonymizer, as used in the XML
* configuration file. This is generally something along the lines
* of "LASTNAME" or "UNEVENNUMBER". Please see the output of the
* -configexample command line option when running Anonimatron.
*/
String getType();
/**
* Anonymizes the given data into a non-tracable, non-reversible synonym,
* and does it consistently, so that A always translates to B.
*
* @param from the data to be anonymized, usually passed in as a
* {@link String}, {@link Integer}, {@link Date} or other classes
* which can be stored in a single JDBC database column.
* @param size the optional maximum size of the generated value
* @param shortlived indicates that the generated synonym must have the
* {@link Synonym#isShortLived()} boolean set
* @return a {@link Synonym}
*/ | Synonym anonymize(Object from, int size, boolean shortlived); |
realrolfje/anonimatron | src/test/java/com/rolfje/anonimatron/anonymizer/UkPostCodeAnonymizerTest.java | // Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
| import com.rolfje.anonimatron.synonyms.Synonym;
import org.junit.Before;
import org.junit.Test;
import java.util.regex.Pattern;
import static org.junit.Assert.*; | }
@Test
public void testPostalCodeFlavor1() {
assertValidPostalCode(ukPostCodeAnonymizer.buildZipCodeFlavor1());
}
@Test
public void testPostalCodeFlavor2() {
assertValidPostalCode(ukPostCodeAnonymizer.buildZipCodeFlavor2());
}
private void assertValidPostalCode(String s) {
if (s.length() > 8) {
fail("length longer than 8");
}
// See https://stackoverflow.com/a/164994
String regex = "^([Gg][Ii][Rr] ?0[Aa]{2})|" +
"((([A-Za-z][0-9]{1,2})|(([A-Za-z][A-Ha-hJ-Yj-y][0-9]{1,2})|(([A-Za-z][0-9][A-Za-z])|([A-Za-z][A-Ha-hJ-Yj-y][0-9]?[A-Za-z]))))" +
" ?[0-9][A-Za-z]{2})$";
Pattern regexPattern = Pattern.compile(regex);
assertTrue("Invalid postal code generated: '" + s + "'", regexPattern.matcher(s).matches());
}
@Test
public void testGenerateCorrectSynonym() { | // Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
// Path: src/test/java/com/rolfje/anonimatron/anonymizer/UkPostCodeAnonymizerTest.java
import com.rolfje.anonimatron.synonyms.Synonym;
import org.junit.Before;
import org.junit.Test;
import java.util.regex.Pattern;
import static org.junit.Assert.*;
}
@Test
public void testPostalCodeFlavor1() {
assertValidPostalCode(ukPostCodeAnonymizer.buildZipCodeFlavor1());
}
@Test
public void testPostalCodeFlavor2() {
assertValidPostalCode(ukPostCodeAnonymizer.buildZipCodeFlavor2());
}
private void assertValidPostalCode(String s) {
if (s.length() > 8) {
fail("length longer than 8");
}
// See https://stackoverflow.com/a/164994
String regex = "^([Gg][Ii][Rr] ?0[Aa]{2})|" +
"((([A-Za-z][0-9]{1,2})|(([A-Za-z][A-Ha-hJ-Yj-y][0-9]{1,2})|(([A-Za-z][0-9][A-Za-z])|([A-Za-z][A-Ha-hJ-Yj-y][0-9]?[A-Za-z]))))" +
" ?[0-9][A-Za-z]{2})$";
Pattern regexPattern = Pattern.compile(regex);
assertTrue("Invalid postal code generated: '" + s + "'", regexPattern.matcher(s).matches());
}
@Test
public void testGenerateCorrectSynonym() { | Synonym s1 = ukPostCodeAnonymizer.anonymize("x", 10, false); |
realrolfje/anonimatron | src/test/java/com/rolfje/anonimatron/anonymizer/DutchBSNAnononymizerTest.java | // Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
//
// Path: src/test/java/com/rolfje/junit/Asserts.java
// public class Asserts {
//
// public static void assertAnyOf(Object expected, Object... values) {
// for (Object value : values) {
// if (expected.equals(value)) {
// return;
// }
// }
// fail(expected.toString() + " did not match any of "
// + Arrays.stream(values).map(Object::toString).collect(Collectors.joining(", "))
// + ".");
// }
//
// public static void assertInstanceOf(Class<?> expectedClass, Object actualClass) {
// Class<?> matchable = matchableClass(expectedClass);
// assertTrue("Class " + actualClass.getClass().getSimpleName() + " is not an instance of " + expectedClass.getSimpleName(),
// matchable.isInstance(actualClass));
// }
//
// private static Class<?> matchableClass(Class<?> expectedClass) {
// if (boolean.class.equals(expectedClass)) return Boolean.class;
// if (byte.class.equals(expectedClass)) return Byte.class;
// if (char.class.equals(expectedClass)) return Character.class;
// if (double.class.equals(expectedClass)) return Double.class;
// if (float.class.equals(expectedClass)) return Float.class;
// if (int.class.equals(expectedClass)) return Integer.class;
// if (long.class.equals(expectedClass)) return Long.class;
// if (short.class.equals(expectedClass)) return Short.class;
// return expectedClass;
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/anonymizer/DutchBSNAnononymizer.java
// public static boolean isValidBSN(String burgerServiceNummer) {
// // Number must be at least 7 at maximum 9 characters in length,
// if (burgerServiceNummer == null
// || burgerServiceNummer.length() > 9
// || burgerServiceNummer.length() < 7) {
// return false;
// }
//
// // Numbers shorter than 9 characters are padded with zeroes.
// burgerServiceNummer = StringUtils.leftPad(burgerServiceNummer, 9, "0");
//
// // The leftmost character dan not be higher than 3
// if (burgerServiceNummer.charAt(0) > '3') {
// return false;
// }
//
// return isBSNElevenProof(burgerServiceNummer);
// }
| import com.rolfje.anonimatron.synonyms.Synonym;
import com.rolfje.junit.Asserts;
import org.junit.Before;
import org.junit.Test;
import java.math.BigDecimal;
import java.math.BigInteger;
import static com.rolfje.anonimatron.anonymizer.DutchBSNAnononymizer.isValidBSN;
import static org.junit.Assert.*; | package com.rolfje.anonimatron.anonymizer;
public class DutchBSNAnononymizerTest {
private DutchBSNAnononymizer bsnAnonymizer = new DutchBSNAnononymizer();
private String original;
boolean shortlived = true;
@Before
public void setUp() {
original = bsnAnonymizer.generateBSN(9);
}
@Test
public void testAnonymizeNumbers() {
Object[] originals = {
Integer.valueOf(original),
Long.valueOf(original),
new BigDecimal(original),
new Integer(original)
};
for (Object originalAsNumber : originals) { | // Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
//
// Path: src/test/java/com/rolfje/junit/Asserts.java
// public class Asserts {
//
// public static void assertAnyOf(Object expected, Object... values) {
// for (Object value : values) {
// if (expected.equals(value)) {
// return;
// }
// }
// fail(expected.toString() + " did not match any of "
// + Arrays.stream(values).map(Object::toString).collect(Collectors.joining(", "))
// + ".");
// }
//
// public static void assertInstanceOf(Class<?> expectedClass, Object actualClass) {
// Class<?> matchable = matchableClass(expectedClass);
// assertTrue("Class " + actualClass.getClass().getSimpleName() + " is not an instance of " + expectedClass.getSimpleName(),
// matchable.isInstance(actualClass));
// }
//
// private static Class<?> matchableClass(Class<?> expectedClass) {
// if (boolean.class.equals(expectedClass)) return Boolean.class;
// if (byte.class.equals(expectedClass)) return Byte.class;
// if (char.class.equals(expectedClass)) return Character.class;
// if (double.class.equals(expectedClass)) return Double.class;
// if (float.class.equals(expectedClass)) return Float.class;
// if (int.class.equals(expectedClass)) return Integer.class;
// if (long.class.equals(expectedClass)) return Long.class;
// if (short.class.equals(expectedClass)) return Short.class;
// return expectedClass;
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/anonymizer/DutchBSNAnononymizer.java
// public static boolean isValidBSN(String burgerServiceNummer) {
// // Number must be at least 7 at maximum 9 characters in length,
// if (burgerServiceNummer == null
// || burgerServiceNummer.length() > 9
// || burgerServiceNummer.length() < 7) {
// return false;
// }
//
// // Numbers shorter than 9 characters are padded with zeroes.
// burgerServiceNummer = StringUtils.leftPad(burgerServiceNummer, 9, "0");
//
// // The leftmost character dan not be higher than 3
// if (burgerServiceNummer.charAt(0) > '3') {
// return false;
// }
//
// return isBSNElevenProof(burgerServiceNummer);
// }
// Path: src/test/java/com/rolfje/anonimatron/anonymizer/DutchBSNAnononymizerTest.java
import com.rolfje.anonimatron.synonyms.Synonym;
import com.rolfje.junit.Asserts;
import org.junit.Before;
import org.junit.Test;
import java.math.BigDecimal;
import java.math.BigInteger;
import static com.rolfje.anonimatron.anonymizer.DutchBSNAnononymizer.isValidBSN;
import static org.junit.Assert.*;
package com.rolfje.anonimatron.anonymizer;
public class DutchBSNAnononymizerTest {
private DutchBSNAnononymizer bsnAnonymizer = new DutchBSNAnononymizer();
private String original;
boolean shortlived = true;
@Before
public void setUp() {
original = bsnAnonymizer.generateBSN(9);
}
@Test
public void testAnonymizeNumbers() {
Object[] originals = {
Integer.valueOf(original),
Long.valueOf(original),
new BigDecimal(original),
new Integer(original)
};
for (Object originalAsNumber : originals) { | Synonym synonym = bsnAnonymizer.anonymize(originalAsNumber, 9, shortlived); |
realrolfje/anonimatron | src/test/java/com/rolfje/anonimatron/anonymizer/DutchBSNAnononymizerTest.java | // Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
//
// Path: src/test/java/com/rolfje/junit/Asserts.java
// public class Asserts {
//
// public static void assertAnyOf(Object expected, Object... values) {
// for (Object value : values) {
// if (expected.equals(value)) {
// return;
// }
// }
// fail(expected.toString() + " did not match any of "
// + Arrays.stream(values).map(Object::toString).collect(Collectors.joining(", "))
// + ".");
// }
//
// public static void assertInstanceOf(Class<?> expectedClass, Object actualClass) {
// Class<?> matchable = matchableClass(expectedClass);
// assertTrue("Class " + actualClass.getClass().getSimpleName() + " is not an instance of " + expectedClass.getSimpleName(),
// matchable.isInstance(actualClass));
// }
//
// private static Class<?> matchableClass(Class<?> expectedClass) {
// if (boolean.class.equals(expectedClass)) return Boolean.class;
// if (byte.class.equals(expectedClass)) return Byte.class;
// if (char.class.equals(expectedClass)) return Character.class;
// if (double.class.equals(expectedClass)) return Double.class;
// if (float.class.equals(expectedClass)) return Float.class;
// if (int.class.equals(expectedClass)) return Integer.class;
// if (long.class.equals(expectedClass)) return Long.class;
// if (short.class.equals(expectedClass)) return Short.class;
// return expectedClass;
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/anonymizer/DutchBSNAnononymizer.java
// public static boolean isValidBSN(String burgerServiceNummer) {
// // Number must be at least 7 at maximum 9 characters in length,
// if (burgerServiceNummer == null
// || burgerServiceNummer.length() > 9
// || burgerServiceNummer.length() < 7) {
// return false;
// }
//
// // Numbers shorter than 9 characters are padded with zeroes.
// burgerServiceNummer = StringUtils.leftPad(burgerServiceNummer, 9, "0");
//
// // The leftmost character dan not be higher than 3
// if (burgerServiceNummer.charAt(0) > '3') {
// return false;
// }
//
// return isBSNElevenProof(burgerServiceNummer);
// }
| import com.rolfje.anonimatron.synonyms.Synonym;
import com.rolfje.junit.Asserts;
import org.junit.Before;
import org.junit.Test;
import java.math.BigDecimal;
import java.math.BigInteger;
import static com.rolfje.anonimatron.anonymizer.DutchBSNAnononymizer.isValidBSN;
import static org.junit.Assert.*; | package com.rolfje.anonimatron.anonymizer;
public class DutchBSNAnononymizerTest {
private DutchBSNAnononymizer bsnAnonymizer = new DutchBSNAnononymizer();
private String original;
boolean shortlived = true;
@Before
public void setUp() {
original = bsnAnonymizer.generateBSN(9);
}
@Test
public void testAnonymizeNumbers() {
Object[] originals = {
Integer.valueOf(original),
Long.valueOf(original),
new BigDecimal(original),
new Integer(original)
};
for (Object originalAsNumber : originals) {
Synonym synonym = bsnAnonymizer.anonymize(originalAsNumber, 9, shortlived);
assertEquals(originalAsNumber, synonym.getFrom());
assertNotEquals(originalAsNumber, synonym.getTo());
Class<?> expectedClass = originalAsNumber.getClass();
Object actualClass = synonym.getTo(); | // Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
//
// Path: src/test/java/com/rolfje/junit/Asserts.java
// public class Asserts {
//
// public static void assertAnyOf(Object expected, Object... values) {
// for (Object value : values) {
// if (expected.equals(value)) {
// return;
// }
// }
// fail(expected.toString() + " did not match any of "
// + Arrays.stream(values).map(Object::toString).collect(Collectors.joining(", "))
// + ".");
// }
//
// public static void assertInstanceOf(Class<?> expectedClass, Object actualClass) {
// Class<?> matchable = matchableClass(expectedClass);
// assertTrue("Class " + actualClass.getClass().getSimpleName() + " is not an instance of " + expectedClass.getSimpleName(),
// matchable.isInstance(actualClass));
// }
//
// private static Class<?> matchableClass(Class<?> expectedClass) {
// if (boolean.class.equals(expectedClass)) return Boolean.class;
// if (byte.class.equals(expectedClass)) return Byte.class;
// if (char.class.equals(expectedClass)) return Character.class;
// if (double.class.equals(expectedClass)) return Double.class;
// if (float.class.equals(expectedClass)) return Float.class;
// if (int.class.equals(expectedClass)) return Integer.class;
// if (long.class.equals(expectedClass)) return Long.class;
// if (short.class.equals(expectedClass)) return Short.class;
// return expectedClass;
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/anonymizer/DutchBSNAnononymizer.java
// public static boolean isValidBSN(String burgerServiceNummer) {
// // Number must be at least 7 at maximum 9 characters in length,
// if (burgerServiceNummer == null
// || burgerServiceNummer.length() > 9
// || burgerServiceNummer.length() < 7) {
// return false;
// }
//
// // Numbers shorter than 9 characters are padded with zeroes.
// burgerServiceNummer = StringUtils.leftPad(burgerServiceNummer, 9, "0");
//
// // The leftmost character dan not be higher than 3
// if (burgerServiceNummer.charAt(0) > '3') {
// return false;
// }
//
// return isBSNElevenProof(burgerServiceNummer);
// }
// Path: src/test/java/com/rolfje/anonimatron/anonymizer/DutchBSNAnononymizerTest.java
import com.rolfje.anonimatron.synonyms.Synonym;
import com.rolfje.junit.Asserts;
import org.junit.Before;
import org.junit.Test;
import java.math.BigDecimal;
import java.math.BigInteger;
import static com.rolfje.anonimatron.anonymizer.DutchBSNAnononymizer.isValidBSN;
import static org.junit.Assert.*;
package com.rolfje.anonimatron.anonymizer;
public class DutchBSNAnononymizerTest {
private DutchBSNAnononymizer bsnAnonymizer = new DutchBSNAnononymizer();
private String original;
boolean shortlived = true;
@Before
public void setUp() {
original = bsnAnonymizer.generateBSN(9);
}
@Test
public void testAnonymizeNumbers() {
Object[] originals = {
Integer.valueOf(original),
Long.valueOf(original),
new BigDecimal(original),
new Integer(original)
};
for (Object originalAsNumber : originals) {
Synonym synonym = bsnAnonymizer.anonymize(originalAsNumber, 9, shortlived);
assertEquals(originalAsNumber, synonym.getFrom());
assertNotEquals(originalAsNumber, synonym.getTo());
Class<?> expectedClass = originalAsNumber.getClass();
Object actualClass = synonym.getTo(); | Asserts.assertInstanceOf(expectedClass, actualClass); |
realrolfje/anonimatron | src/test/java/com/rolfje/anonimatron/anonymizer/DutchBSNAnononymizerTest.java | // Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
//
// Path: src/test/java/com/rolfje/junit/Asserts.java
// public class Asserts {
//
// public static void assertAnyOf(Object expected, Object... values) {
// for (Object value : values) {
// if (expected.equals(value)) {
// return;
// }
// }
// fail(expected.toString() + " did not match any of "
// + Arrays.stream(values).map(Object::toString).collect(Collectors.joining(", "))
// + ".");
// }
//
// public static void assertInstanceOf(Class<?> expectedClass, Object actualClass) {
// Class<?> matchable = matchableClass(expectedClass);
// assertTrue("Class " + actualClass.getClass().getSimpleName() + " is not an instance of " + expectedClass.getSimpleName(),
// matchable.isInstance(actualClass));
// }
//
// private static Class<?> matchableClass(Class<?> expectedClass) {
// if (boolean.class.equals(expectedClass)) return Boolean.class;
// if (byte.class.equals(expectedClass)) return Byte.class;
// if (char.class.equals(expectedClass)) return Character.class;
// if (double.class.equals(expectedClass)) return Double.class;
// if (float.class.equals(expectedClass)) return Float.class;
// if (int.class.equals(expectedClass)) return Integer.class;
// if (long.class.equals(expectedClass)) return Long.class;
// if (short.class.equals(expectedClass)) return Short.class;
// return expectedClass;
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/anonymizer/DutchBSNAnononymizer.java
// public static boolean isValidBSN(String burgerServiceNummer) {
// // Number must be at least 7 at maximum 9 characters in length,
// if (burgerServiceNummer == null
// || burgerServiceNummer.length() > 9
// || burgerServiceNummer.length() < 7) {
// return false;
// }
//
// // Numbers shorter than 9 characters are padded with zeroes.
// burgerServiceNummer = StringUtils.leftPad(burgerServiceNummer, 9, "0");
//
// // The leftmost character dan not be higher than 3
// if (burgerServiceNummer.charAt(0) > '3') {
// return false;
// }
//
// return isBSNElevenProof(burgerServiceNummer);
// }
| import com.rolfje.anonimatron.synonyms.Synonym;
import com.rolfje.junit.Asserts;
import org.junit.Before;
import org.junit.Test;
import java.math.BigDecimal;
import java.math.BigInteger;
import static com.rolfje.anonimatron.anonymizer.DutchBSNAnononymizer.isValidBSN;
import static org.junit.Assert.*; | Synonym synonym = bsnAnonymizer.anonymize(originalAsNumber, 9, shortlived);
assertEquals(originalAsNumber, synonym.getFrom());
assertNotEquals(originalAsNumber, synonym.getTo());
Class<?> expectedClass = originalAsNumber.getClass();
Object actualClass = synonym.getTo();
Asserts.assertInstanceOf(expectedClass, actualClass);
assertEquals(shortlived, synonym.isShortLived());
validate(synonym);
}
}
@Test
public void testLength() {
bsnAnonymizer.anonymize("dummy", 10000, false);
bsnAnonymizer.anonymize("dummy", 9, false);
try {
bsnAnonymizer.anonymize("dummy", 8, false);
fail("should throw exception");
} catch (UnsupportedOperationException e) {
// ok
}
}
@Test
public void testGenerateBSN() {
boolean hadNonZeroLastDigit = false;
for (int i = 0; i < 1000; i++) {
String bsn = bsnAnonymizer.generateBSN(9); | // Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
//
// Path: src/test/java/com/rolfje/junit/Asserts.java
// public class Asserts {
//
// public static void assertAnyOf(Object expected, Object... values) {
// for (Object value : values) {
// if (expected.equals(value)) {
// return;
// }
// }
// fail(expected.toString() + " did not match any of "
// + Arrays.stream(values).map(Object::toString).collect(Collectors.joining(", "))
// + ".");
// }
//
// public static void assertInstanceOf(Class<?> expectedClass, Object actualClass) {
// Class<?> matchable = matchableClass(expectedClass);
// assertTrue("Class " + actualClass.getClass().getSimpleName() + " is not an instance of " + expectedClass.getSimpleName(),
// matchable.isInstance(actualClass));
// }
//
// private static Class<?> matchableClass(Class<?> expectedClass) {
// if (boolean.class.equals(expectedClass)) return Boolean.class;
// if (byte.class.equals(expectedClass)) return Byte.class;
// if (char.class.equals(expectedClass)) return Character.class;
// if (double.class.equals(expectedClass)) return Double.class;
// if (float.class.equals(expectedClass)) return Float.class;
// if (int.class.equals(expectedClass)) return Integer.class;
// if (long.class.equals(expectedClass)) return Long.class;
// if (short.class.equals(expectedClass)) return Short.class;
// return expectedClass;
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/anonymizer/DutchBSNAnononymizer.java
// public static boolean isValidBSN(String burgerServiceNummer) {
// // Number must be at least 7 at maximum 9 characters in length,
// if (burgerServiceNummer == null
// || burgerServiceNummer.length() > 9
// || burgerServiceNummer.length() < 7) {
// return false;
// }
//
// // Numbers shorter than 9 characters are padded with zeroes.
// burgerServiceNummer = StringUtils.leftPad(burgerServiceNummer, 9, "0");
//
// // The leftmost character dan not be higher than 3
// if (burgerServiceNummer.charAt(0) > '3') {
// return false;
// }
//
// return isBSNElevenProof(burgerServiceNummer);
// }
// Path: src/test/java/com/rolfje/anonimatron/anonymizer/DutchBSNAnononymizerTest.java
import com.rolfje.anonimatron.synonyms.Synonym;
import com.rolfje.junit.Asserts;
import org.junit.Before;
import org.junit.Test;
import java.math.BigDecimal;
import java.math.BigInteger;
import static com.rolfje.anonimatron.anonymizer.DutchBSNAnononymizer.isValidBSN;
import static org.junit.Assert.*;
Synonym synonym = bsnAnonymizer.anonymize(originalAsNumber, 9, shortlived);
assertEquals(originalAsNumber, synonym.getFrom());
assertNotEquals(originalAsNumber, synonym.getTo());
Class<?> expectedClass = originalAsNumber.getClass();
Object actualClass = synonym.getTo();
Asserts.assertInstanceOf(expectedClass, actualClass);
assertEquals(shortlived, synonym.isShortLived());
validate(synonym);
}
}
@Test
public void testLength() {
bsnAnonymizer.anonymize("dummy", 10000, false);
bsnAnonymizer.anonymize("dummy", 9, false);
try {
bsnAnonymizer.anonymize("dummy", 8, false);
fail("should throw exception");
} catch (UnsupportedOperationException e) {
// ok
}
}
@Test
public void testGenerateBSN() {
boolean hadNonZeroLastDigit = false;
for (int i = 0; i < 1000; i++) {
String bsn = bsnAnonymizer.generateBSN(9); | assertTrue("Incorrect BSN " + bsn, isValidBSN(bsn)); |
realrolfje/anonimatron | src/main/java/com/rolfje/anonimatron/anonymizer/UkPostCodeAnonymizer.java | // Path: src/main/java/com/rolfje/anonimatron/synonyms/StringSynonym.java
// public class StringSynonym implements Synonym {
// private String type;
// private String from;
// private String to;
// private boolean shortlived = false;
//
// public StringSynonym() {
// }
//
// public StringSynonym(String type, String from, String to, boolean shortlived) {
// this.type = type;
// this.from = from;
// this.to = to;
// this.shortlived = shortlived;
// }
//
// @Override
// public String getType() {
// return type;
// }
//
// @Override
// public Object getFrom() {
// return from;
// }
//
// @Override
// public Object getTo() {
// return to;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setFrom(String from) {
// this.from = from;
// }
//
// public void setTo(String to) {
// this.to = to;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortlived;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
| import com.rolfje.anonimatron.synonyms.StringSynonym;
import com.rolfje.anonimatron.synonyms.Synonym;
import java.util.Random; | package com.rolfje.anonimatron.anonymizer;
/**
* Generates format valid Uk Post codes.
* See https://en.wikipedia.org/wiki/Postcodes_in_the_United_Kingdom
* and See https://stackoverflow.com/a/164994
* <p>
* Let me know if this isn't correct in practice; UK postal codes seem
* to have a very strange organically grown format.
*/
public class UkPostCodeAnonymizer implements Anonymizer {
private final Random random = new Random();
private static final String CHARACTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
private static final String DIGITS = "0123456789";
@Override
public String getType() {
return "UK_POST_CODE";
}
@Override | // Path: src/main/java/com/rolfje/anonimatron/synonyms/StringSynonym.java
// public class StringSynonym implements Synonym {
// private String type;
// private String from;
// private String to;
// private boolean shortlived = false;
//
// public StringSynonym() {
// }
//
// public StringSynonym(String type, String from, String to, boolean shortlived) {
// this.type = type;
// this.from = from;
// this.to = to;
// this.shortlived = shortlived;
// }
//
// @Override
// public String getType() {
// return type;
// }
//
// @Override
// public Object getFrom() {
// return from;
// }
//
// @Override
// public Object getTo() {
// return to;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setFrom(String from) {
// this.from = from;
// }
//
// public void setTo(String to) {
// this.to = to;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortlived;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
// Path: src/main/java/com/rolfje/anonimatron/anonymizer/UkPostCodeAnonymizer.java
import com.rolfje.anonimatron.synonyms.StringSynonym;
import com.rolfje.anonimatron.synonyms.Synonym;
import java.util.Random;
package com.rolfje.anonimatron.anonymizer;
/**
* Generates format valid Uk Post codes.
* See https://en.wikipedia.org/wiki/Postcodes_in_the_United_Kingdom
* and See https://stackoverflow.com/a/164994
* <p>
* Let me know if this isn't correct in practice; UK postal codes seem
* to have a very strange organically grown format.
*/
public class UkPostCodeAnonymizer implements Anonymizer {
private final Random random = new Random();
private static final String CHARACTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
private static final String DIGITS = "0123456789";
@Override
public String getType() {
return "UK_POST_CODE";
}
@Override | public Synonym anonymize(Object from, int size, boolean shortlived) { |
realrolfje/anonimatron | src/main/java/com/rolfje/anonimatron/anonymizer/UkPostCodeAnonymizer.java | // Path: src/main/java/com/rolfje/anonimatron/synonyms/StringSynonym.java
// public class StringSynonym implements Synonym {
// private String type;
// private String from;
// private String to;
// private boolean shortlived = false;
//
// public StringSynonym() {
// }
//
// public StringSynonym(String type, String from, String to, boolean shortlived) {
// this.type = type;
// this.from = from;
// this.to = to;
// this.shortlived = shortlived;
// }
//
// @Override
// public String getType() {
// return type;
// }
//
// @Override
// public Object getFrom() {
// return from;
// }
//
// @Override
// public Object getTo() {
// return to;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setFrom(String from) {
// this.from = from;
// }
//
// public void setTo(String to) {
// this.to = to;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortlived;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
| import com.rolfje.anonimatron.synonyms.StringSynonym;
import com.rolfje.anonimatron.synonyms.Synonym;
import java.util.Random; | package com.rolfje.anonimatron.anonymizer;
/**
* Generates format valid Uk Post codes.
* See https://en.wikipedia.org/wiki/Postcodes_in_the_United_Kingdom
* and See https://stackoverflow.com/a/164994
* <p>
* Let me know if this isn't correct in practice; UK postal codes seem
* to have a very strange organically grown format.
*/
public class UkPostCodeAnonymizer implements Anonymizer {
private final Random random = new Random();
private static final String CHARACTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
private static final String DIGITS = "0123456789";
@Override
public String getType() {
return "UK_POST_CODE";
}
@Override
public Synonym anonymize(Object from, int size, boolean shortlived) {
if (from == null) { | // Path: src/main/java/com/rolfje/anonimatron/synonyms/StringSynonym.java
// public class StringSynonym implements Synonym {
// private String type;
// private String from;
// private String to;
// private boolean shortlived = false;
//
// public StringSynonym() {
// }
//
// public StringSynonym(String type, String from, String to, boolean shortlived) {
// this.type = type;
// this.from = from;
// this.to = to;
// this.shortlived = shortlived;
// }
//
// @Override
// public String getType() {
// return type;
// }
//
// @Override
// public Object getFrom() {
// return from;
// }
//
// @Override
// public Object getTo() {
// return to;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setFrom(String from) {
// this.from = from;
// }
//
// public void setTo(String to) {
// this.to = to;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortlived;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
// Path: src/main/java/com/rolfje/anonimatron/anonymizer/UkPostCodeAnonymizer.java
import com.rolfje.anonimatron.synonyms.StringSynonym;
import com.rolfje.anonimatron.synonyms.Synonym;
import java.util.Random;
package com.rolfje.anonimatron.anonymizer;
/**
* Generates format valid Uk Post codes.
* See https://en.wikipedia.org/wiki/Postcodes_in_the_United_Kingdom
* and See https://stackoverflow.com/a/164994
* <p>
* Let me know if this isn't correct in practice; UK postal codes seem
* to have a very strange organically grown format.
*/
public class UkPostCodeAnonymizer implements Anonymizer {
private final Random random = new Random();
private static final String CHARACTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
private static final String DIGITS = "0123456789";
@Override
public String getType() {
return "UK_POST_CODE";
}
@Override
public Synonym anonymize(Object from, int size, boolean shortlived) {
if (from == null) { | return new StringSynonym(getType(), null, null, shortlived); |
realrolfje/anonimatron | src/test/java/com/rolfje/anonimatron/anonymizer/SynonymCacheTest.java | // Path: src/main/java/com/rolfje/anonimatron/synonyms/NullSynonym.java
// public class NullSynonym implements Synonym {
// private final String type;
//
// public NullSynonym(String type) {
// this.type=type;
// }
//
// public String getType() {
// return type;
// }
//
// public Object getFrom() {
// return null;
// }
//
// public Object getTo() {
// return null;
// }
//
// @Override
// public boolean isShortLived() {
// return true;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/StringSynonym.java
// public class StringSynonym implements Synonym {
// private String type;
// private String from;
// private String to;
// private boolean shortlived = false;
//
// public StringSynonym() {
// }
//
// public StringSynonym(String type, String from, String to, boolean shortlived) {
// this.type = type;
// this.from = from;
// this.to = to;
// this.shortlived = shortlived;
// }
//
// @Override
// public String getType() {
// return type;
// }
//
// @Override
// public Object getFrom() {
// return from;
// }
//
// @Override
// public Object getTo() {
// return to;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setFrom(String from) {
// this.from = from;
// }
//
// public void setTo(String to) {
// this.to = to;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortlived;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
| import com.rolfje.anonimatron.synonyms.NullSynonym;
import com.rolfje.anonimatron.synonyms.StringSynonym;
import com.rolfje.anonimatron.synonyms.Synonym;
import junit.framework.TestCase;
import static org.junit.Assert.assertNotEquals; | package com.rolfje.anonimatron.anonymizer;
public class SynonymCacheTest extends TestCase {
public void testNoStorageOfShortLivedSynonyms() {
SynonymCache synonymCache = new SynonymCache();
| // Path: src/main/java/com/rolfje/anonimatron/synonyms/NullSynonym.java
// public class NullSynonym implements Synonym {
// private final String type;
//
// public NullSynonym(String type) {
// this.type=type;
// }
//
// public String getType() {
// return type;
// }
//
// public Object getFrom() {
// return null;
// }
//
// public Object getTo() {
// return null;
// }
//
// @Override
// public boolean isShortLived() {
// return true;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/StringSynonym.java
// public class StringSynonym implements Synonym {
// private String type;
// private String from;
// private String to;
// private boolean shortlived = false;
//
// public StringSynonym() {
// }
//
// public StringSynonym(String type, String from, String to, boolean shortlived) {
// this.type = type;
// this.from = from;
// this.to = to;
// this.shortlived = shortlived;
// }
//
// @Override
// public String getType() {
// return type;
// }
//
// @Override
// public Object getFrom() {
// return from;
// }
//
// @Override
// public Object getTo() {
// return to;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setFrom(String from) {
// this.from = from;
// }
//
// public void setTo(String to) {
// this.to = to;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortlived;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
// Path: src/test/java/com/rolfje/anonimatron/anonymizer/SynonymCacheTest.java
import com.rolfje.anonimatron.synonyms.NullSynonym;
import com.rolfje.anonimatron.synonyms.StringSynonym;
import com.rolfje.anonimatron.synonyms.Synonym;
import junit.framework.TestCase;
import static org.junit.Assert.assertNotEquals;
package com.rolfje.anonimatron.anonymizer;
public class SynonymCacheTest extends TestCase {
public void testNoStorageOfShortLivedSynonyms() {
SynonymCache synonymCache = new SynonymCache();
| NullSynonym n = new NullSynonym("null"); |
realrolfje/anonimatron | src/test/java/com/rolfje/anonimatron/anonymizer/SynonymCacheTest.java | // Path: src/main/java/com/rolfje/anonimatron/synonyms/NullSynonym.java
// public class NullSynonym implements Synonym {
// private final String type;
//
// public NullSynonym(String type) {
// this.type=type;
// }
//
// public String getType() {
// return type;
// }
//
// public Object getFrom() {
// return null;
// }
//
// public Object getTo() {
// return null;
// }
//
// @Override
// public boolean isShortLived() {
// return true;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/StringSynonym.java
// public class StringSynonym implements Synonym {
// private String type;
// private String from;
// private String to;
// private boolean shortlived = false;
//
// public StringSynonym() {
// }
//
// public StringSynonym(String type, String from, String to, boolean shortlived) {
// this.type = type;
// this.from = from;
// this.to = to;
// this.shortlived = shortlived;
// }
//
// @Override
// public String getType() {
// return type;
// }
//
// @Override
// public Object getFrom() {
// return from;
// }
//
// @Override
// public Object getTo() {
// return to;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setFrom(String from) {
// this.from = from;
// }
//
// public void setTo(String to) {
// this.to = to;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortlived;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
| import com.rolfje.anonimatron.synonyms.NullSynonym;
import com.rolfje.anonimatron.synonyms.StringSynonym;
import com.rolfje.anonimatron.synonyms.Synonym;
import junit.framework.TestCase;
import static org.junit.Assert.assertNotEquals; | package com.rolfje.anonimatron.anonymizer;
public class SynonymCacheTest extends TestCase {
public void testNoStorageOfShortLivedSynonyms() {
SynonymCache synonymCache = new SynonymCache();
NullSynonym n = new NullSynonym("null");
synonymCache.put(n);
assertNull(synonymCache.get(n.getType(), n.getFrom()));
}
public void testNoHashing() {
SynonymCache synonymCache = new SynonymCache();
| // Path: src/main/java/com/rolfje/anonimatron/synonyms/NullSynonym.java
// public class NullSynonym implements Synonym {
// private final String type;
//
// public NullSynonym(String type) {
// this.type=type;
// }
//
// public String getType() {
// return type;
// }
//
// public Object getFrom() {
// return null;
// }
//
// public Object getTo() {
// return null;
// }
//
// @Override
// public boolean isShortLived() {
// return true;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/StringSynonym.java
// public class StringSynonym implements Synonym {
// private String type;
// private String from;
// private String to;
// private boolean shortlived = false;
//
// public StringSynonym() {
// }
//
// public StringSynonym(String type, String from, String to, boolean shortlived) {
// this.type = type;
// this.from = from;
// this.to = to;
// this.shortlived = shortlived;
// }
//
// @Override
// public String getType() {
// return type;
// }
//
// @Override
// public Object getFrom() {
// return from;
// }
//
// @Override
// public Object getTo() {
// return to;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setFrom(String from) {
// this.from = from;
// }
//
// public void setTo(String to) {
// this.to = to;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortlived;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
// Path: src/test/java/com/rolfje/anonimatron/anonymizer/SynonymCacheTest.java
import com.rolfje.anonimatron.synonyms.NullSynonym;
import com.rolfje.anonimatron.synonyms.StringSynonym;
import com.rolfje.anonimatron.synonyms.Synonym;
import junit.framework.TestCase;
import static org.junit.Assert.assertNotEquals;
package com.rolfje.anonimatron.anonymizer;
public class SynonymCacheTest extends TestCase {
public void testNoStorageOfShortLivedSynonyms() {
SynonymCache synonymCache = new SynonymCache();
NullSynonym n = new NullSynonym("null");
synonymCache.put(n);
assertNull(synonymCache.get(n.getType(), n.getFrom()));
}
public void testNoHashing() {
SynonymCache synonymCache = new SynonymCache();
| StringSynonym originalSynonym = new StringSynonym("type", "from", "to", false); |
realrolfje/anonimatron | src/test/java/com/rolfje/anonimatron/anonymizer/SynonymCacheTest.java | // Path: src/main/java/com/rolfje/anonimatron/synonyms/NullSynonym.java
// public class NullSynonym implements Synonym {
// private final String type;
//
// public NullSynonym(String type) {
// this.type=type;
// }
//
// public String getType() {
// return type;
// }
//
// public Object getFrom() {
// return null;
// }
//
// public Object getTo() {
// return null;
// }
//
// @Override
// public boolean isShortLived() {
// return true;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/StringSynonym.java
// public class StringSynonym implements Synonym {
// private String type;
// private String from;
// private String to;
// private boolean shortlived = false;
//
// public StringSynonym() {
// }
//
// public StringSynonym(String type, String from, String to, boolean shortlived) {
// this.type = type;
// this.from = from;
// this.to = to;
// this.shortlived = shortlived;
// }
//
// @Override
// public String getType() {
// return type;
// }
//
// @Override
// public Object getFrom() {
// return from;
// }
//
// @Override
// public Object getTo() {
// return to;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setFrom(String from) {
// this.from = from;
// }
//
// public void setTo(String to) {
// this.to = to;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortlived;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
| import com.rolfje.anonimatron.synonyms.NullSynonym;
import com.rolfje.anonimatron.synonyms.StringSynonym;
import com.rolfje.anonimatron.synonyms.Synonym;
import junit.framework.TestCase;
import static org.junit.Assert.assertNotEquals; | package com.rolfje.anonimatron.anonymizer;
public class SynonymCacheTest extends TestCase {
public void testNoStorageOfShortLivedSynonyms() {
SynonymCache synonymCache = new SynonymCache();
NullSynonym n = new NullSynonym("null");
synonymCache.put(n);
assertNull(synonymCache.get(n.getType(), n.getFrom()));
}
public void testNoHashing() {
SynonymCache synonymCache = new SynonymCache();
StringSynonym originalSynonym = new StringSynonym("type", "from", "to", false);
// Store and retrieve
synonymCache.put(originalSynonym); | // Path: src/main/java/com/rolfje/anonimatron/synonyms/NullSynonym.java
// public class NullSynonym implements Synonym {
// private final String type;
//
// public NullSynonym(String type) {
// this.type=type;
// }
//
// public String getType() {
// return type;
// }
//
// public Object getFrom() {
// return null;
// }
//
// public Object getTo() {
// return null;
// }
//
// @Override
// public boolean isShortLived() {
// return true;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/StringSynonym.java
// public class StringSynonym implements Synonym {
// private String type;
// private String from;
// private String to;
// private boolean shortlived = false;
//
// public StringSynonym() {
// }
//
// public StringSynonym(String type, String from, String to, boolean shortlived) {
// this.type = type;
// this.from = from;
// this.to = to;
// this.shortlived = shortlived;
// }
//
// @Override
// public String getType() {
// return type;
// }
//
// @Override
// public Object getFrom() {
// return from;
// }
//
// @Override
// public Object getTo() {
// return to;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setFrom(String from) {
// this.from = from;
// }
//
// public void setTo(String to) {
// this.to = to;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortlived;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
// Path: src/test/java/com/rolfje/anonimatron/anonymizer/SynonymCacheTest.java
import com.rolfje.anonimatron.synonyms.NullSynonym;
import com.rolfje.anonimatron.synonyms.StringSynonym;
import com.rolfje.anonimatron.synonyms.Synonym;
import junit.framework.TestCase;
import static org.junit.Assert.assertNotEquals;
package com.rolfje.anonimatron.anonymizer;
public class SynonymCacheTest extends TestCase {
public void testNoStorageOfShortLivedSynonyms() {
SynonymCache synonymCache = new SynonymCache();
NullSynonym n = new NullSynonym("null");
synonymCache.put(n);
assertNull(synonymCache.get(n.getType(), n.getFrom()));
}
public void testNoHashing() {
SynonymCache synonymCache = new SynonymCache();
StringSynonym originalSynonym = new StringSynonym("type", "from", "to", false);
// Store and retrieve
synonymCache.put(originalSynonym); | Synonym storedSynonym = synonymCache.get(originalSynonym.getType(), originalSynonym.getFrom()); |
realrolfje/anonimatron | src/test/java/com/rolfje/anonimatron/anonymizer/CharacterStringAnonymizerTest.java | // Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
| import com.rolfje.anonimatron.synonyms.Synonym;
import org.junit.Test;
import java.util.HashMap;
import static org.junit.Assert.*; | package com.rolfje.anonimatron.anonymizer;
public class CharacterStringAnonymizerTest {
CharacterStringAnonymizer characterStrAnon = new CharacterStringAnonymizer();
@Test
public void testIncorrectParamter() {
try {
characterStrAnon.anonymize("dummy", 0, false, new HashMap<String, String>() {{
put("PaRaMeTeR", "any");
}});
fail("Should fail with unsupported operation exception.");
} catch (UnsupportedOperationException e) {
assertEquals(
"Please provide '" + CharacterStringAnonymizer.PARAMETER + "' as configuration parameter.",
e.getMessage());
}
}
@Test
public void testCorrectParameter() { | // Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
// Path: src/test/java/com/rolfje/anonimatron/anonymizer/CharacterStringAnonymizerTest.java
import com.rolfje.anonimatron.synonyms.Synonym;
import org.junit.Test;
import java.util.HashMap;
import static org.junit.Assert.*;
package com.rolfje.anonimatron.anonymizer;
public class CharacterStringAnonymizerTest {
CharacterStringAnonymizer characterStrAnon = new CharacterStringAnonymizer();
@Test
public void testIncorrectParamter() {
try {
characterStrAnon.anonymize("dummy", 0, false, new HashMap<String, String>() {{
put("PaRaMeTeR", "any");
}});
fail("Should fail with unsupported operation exception.");
} catch (UnsupportedOperationException e) {
assertEquals(
"Please provide '" + CharacterStringAnonymizer.PARAMETER + "' as configuration parameter.",
e.getMessage());
}
}
@Test
public void testCorrectParameter() { | Synonym anonymize = characterStrAnon.anonymize("dummy", 0, false, new HashMap<String, String>() {{ |
realrolfje/anonimatron | src/main/java/com/rolfje/anonimatron/synonyms/HashedFromSynonym.java | // Path: src/main/java/com/rolfje/anonimatron/anonymizer/Hasher.java
// public class Hasher {
//
// // Ideally more iterations mean better protection against brute
// // force attacks. Since synonyms are accross the while dataset,
// // an attacker would only know the generated synonym type based
// // on the synonym file, but not the source date type or location.
// private static final int ITERATIONS = 64;
//
// // Roughly same space as version 4 UUID, more than 5 undecillion combinations,
// // very unlikely to generate collisions.
// private static final int SIZE = 128;
//
// private static final String ALGORITHM = "PBKDF2WithHmacSHA1";
// public static final Charset CHARSET = StandardCharsets.UTF_8;
// private byte[] salt;
//
// public Hasher(String salt) {
// this.salt = salt.getBytes();
// }
//
// public String base64Hash(Object object) {
// byte[] serialize = serialize(object);
// char[] chars = toCharArray(serialize);
// return new String(Base64Encoder.encode(pbkdf2(chars)));
// }
//
// public String base64Hash(String object) {
// byte[] hash = pbkdf2(object.toCharArray());
// return new String(Base64Encoder.encode(hash));
// }
//
// private char[] toCharArray(byte[] bytes) {
// return new String(bytes, CHARSET).toCharArray();
// }
//
// private byte[] serialize(Object object) {
// try {
// ByteArrayOutputStream out = new ByteArrayOutputStream();
// ObjectOutputStream objectOutputStream = new ObjectOutputStream(out);
// objectOutputStream.writeObject(object);
// objectOutputStream.close();
// return out.toByteArray();
// } catch (IOException e) {
// throw new RuntimeException("Unexpected problem serializing object.", e);
// }
// }
//
// private byte[] pbkdf2(char[] password) {
// KeySpec spec = new PBEKeySpec(password, salt, ITERATIONS, SIZE);
// try {
// SecretKeyFactory f = SecretKeyFactory.getInstance(ALGORITHM);
// return f.generateSecret(spec).getEncoded();
// } catch (NoSuchAlgorithmException ex) {
// throw new IllegalStateException("Missing algorithm: " + ALGORITHM, ex);
// } catch (InvalidKeySpecException ex) {
// throw new IllegalStateException("Invalid SecretKeyFactory", ex);
// }
// }
//
// }
| import com.rolfje.anonimatron.anonymizer.Hasher; | package com.rolfje.anonimatron.synonyms;
public class HashedFromSynonym implements Synonym {
private String from;
private Object to;
private String type;
private boolean shortLived = false;
public HashedFromSynonym() {
}
| // Path: src/main/java/com/rolfje/anonimatron/anonymizer/Hasher.java
// public class Hasher {
//
// // Ideally more iterations mean better protection against brute
// // force attacks. Since synonyms are accross the while dataset,
// // an attacker would only know the generated synonym type based
// // on the synonym file, but not the source date type or location.
// private static final int ITERATIONS = 64;
//
// // Roughly same space as version 4 UUID, more than 5 undecillion combinations,
// // very unlikely to generate collisions.
// private static final int SIZE = 128;
//
// private static final String ALGORITHM = "PBKDF2WithHmacSHA1";
// public static final Charset CHARSET = StandardCharsets.UTF_8;
// private byte[] salt;
//
// public Hasher(String salt) {
// this.salt = salt.getBytes();
// }
//
// public String base64Hash(Object object) {
// byte[] serialize = serialize(object);
// char[] chars = toCharArray(serialize);
// return new String(Base64Encoder.encode(pbkdf2(chars)));
// }
//
// public String base64Hash(String object) {
// byte[] hash = pbkdf2(object.toCharArray());
// return new String(Base64Encoder.encode(hash));
// }
//
// private char[] toCharArray(byte[] bytes) {
// return new String(bytes, CHARSET).toCharArray();
// }
//
// private byte[] serialize(Object object) {
// try {
// ByteArrayOutputStream out = new ByteArrayOutputStream();
// ObjectOutputStream objectOutputStream = new ObjectOutputStream(out);
// objectOutputStream.writeObject(object);
// objectOutputStream.close();
// return out.toByteArray();
// } catch (IOException e) {
// throw new RuntimeException("Unexpected problem serializing object.", e);
// }
// }
//
// private byte[] pbkdf2(char[] password) {
// KeySpec spec = new PBEKeySpec(password, salt, ITERATIONS, SIZE);
// try {
// SecretKeyFactory f = SecretKeyFactory.getInstance(ALGORITHM);
// return f.generateSecret(spec).getEncoded();
// } catch (NoSuchAlgorithmException ex) {
// throw new IllegalStateException("Missing algorithm: " + ALGORITHM, ex);
// } catch (InvalidKeySpecException ex) {
// throw new IllegalStateException("Invalid SecretKeyFactory", ex);
// }
// }
//
// }
// Path: src/main/java/com/rolfje/anonimatron/synonyms/HashedFromSynonym.java
import com.rolfje.anonimatron.anonymizer.Hasher;
package com.rolfje.anonimatron.synonyms;
public class HashedFromSynonym implements Synonym {
private String from;
private Object to;
private String type;
private boolean shortLived = false;
public HashedFromSynonym() {
}
| public HashedFromSynonym(Hasher hasher, Synonym synonym) { |
realrolfje/anonimatron | src/test/java/com/rolfje/anonimatron/anonymizer/FixedValueAnonymizer.java | // Path: src/main/java/com/rolfje/anonimatron/synonyms/StringSynonym.java
// public class StringSynonym implements Synonym {
// private String type;
// private String from;
// private String to;
// private boolean shortlived = false;
//
// public StringSynonym() {
// }
//
// public StringSynonym(String type, String from, String to, boolean shortlived) {
// this.type = type;
// this.from = from;
// this.to = to;
// this.shortlived = shortlived;
// }
//
// @Override
// public String getType() {
// return type;
// }
//
// @Override
// public Object getFrom() {
// return from;
// }
//
// @Override
// public Object getTo() {
// return to;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setFrom(String from) {
// this.from = from;
// }
//
// public void setTo(String to) {
// this.to = to;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortlived;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
| import java.util.HashMap;
import java.util.Map;
import com.rolfje.anonimatron.synonyms.StringSynonym;
import com.rolfje.anonimatron.synonyms.Synonym; | package com.rolfje.anonimatron.anonymizer;
public class FixedValueAnonymizer implements Anonymizer {
private static final String TYPE = "FIXED";
@Override | // Path: src/main/java/com/rolfje/anonimatron/synonyms/StringSynonym.java
// public class StringSynonym implements Synonym {
// private String type;
// private String from;
// private String to;
// private boolean shortlived = false;
//
// public StringSynonym() {
// }
//
// public StringSynonym(String type, String from, String to, boolean shortlived) {
// this.type = type;
// this.from = from;
// this.to = to;
// this.shortlived = shortlived;
// }
//
// @Override
// public String getType() {
// return type;
// }
//
// @Override
// public Object getFrom() {
// return from;
// }
//
// @Override
// public Object getTo() {
// return to;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setFrom(String from) {
// this.from = from;
// }
//
// public void setTo(String to) {
// this.to = to;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortlived;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
// Path: src/test/java/com/rolfje/anonimatron/anonymizer/FixedValueAnonymizer.java
import java.util.HashMap;
import java.util.Map;
import com.rolfje.anonimatron.synonyms.StringSynonym;
import com.rolfje.anonimatron.synonyms.Synonym;
package com.rolfje.anonimatron.anonymizer;
public class FixedValueAnonymizer implements Anonymizer {
private static final String TYPE = "FIXED";
@Override | public Synonym anonymize(Object from, int size, boolean shortlived) { |
realrolfje/anonimatron | src/test/java/com/rolfje/anonimatron/anonymizer/FixedValueAnonymizer.java | // Path: src/main/java/com/rolfje/anonimatron/synonyms/StringSynonym.java
// public class StringSynonym implements Synonym {
// private String type;
// private String from;
// private String to;
// private boolean shortlived = false;
//
// public StringSynonym() {
// }
//
// public StringSynonym(String type, String from, String to, boolean shortlived) {
// this.type = type;
// this.from = from;
// this.to = to;
// this.shortlived = shortlived;
// }
//
// @Override
// public String getType() {
// return type;
// }
//
// @Override
// public Object getFrom() {
// return from;
// }
//
// @Override
// public Object getTo() {
// return to;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setFrom(String from) {
// this.from = from;
// }
//
// public void setTo(String to) {
// this.to = to;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortlived;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
| import java.util.HashMap;
import java.util.Map;
import com.rolfje.anonimatron.synonyms.StringSynonym;
import com.rolfje.anonimatron.synonyms.Synonym; | package com.rolfje.anonimatron.anonymizer;
public class FixedValueAnonymizer implements Anonymizer {
private static final String TYPE = "FIXED";
@Override
public Synonym anonymize(Object from, int size, boolean shortlived) {
return anonymize(from, size, shortlived, new HashMap<>());
}
@Override
public Synonym anonymize(Object from, int size, boolean shortlived, Map<String, String> parameters) {
if (parameters == null || !parameters.containsKey("value")) {
throw new UnsupportedOperationException("no value");
} | // Path: src/main/java/com/rolfje/anonimatron/synonyms/StringSynonym.java
// public class StringSynonym implements Synonym {
// private String type;
// private String from;
// private String to;
// private boolean shortlived = false;
//
// public StringSynonym() {
// }
//
// public StringSynonym(String type, String from, String to, boolean shortlived) {
// this.type = type;
// this.from = from;
// this.to = to;
// this.shortlived = shortlived;
// }
//
// @Override
// public String getType() {
// return type;
// }
//
// @Override
// public Object getFrom() {
// return from;
// }
//
// @Override
// public Object getTo() {
// return to;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setFrom(String from) {
// this.from = from;
// }
//
// public void setTo(String to) {
// this.to = to;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortlived;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
// Path: src/test/java/com/rolfje/anonimatron/anonymizer/FixedValueAnonymizer.java
import java.util.HashMap;
import java.util.Map;
import com.rolfje.anonimatron.synonyms.StringSynonym;
import com.rolfje.anonimatron.synonyms.Synonym;
package com.rolfje.anonimatron.anonymizer;
public class FixedValueAnonymizer implements Anonymizer {
private static final String TYPE = "FIXED";
@Override
public Synonym anonymize(Object from, int size, boolean shortlived) {
return anonymize(from, size, shortlived, new HashMap<>());
}
@Override
public Synonym anonymize(Object from, int size, boolean shortlived, Map<String, String> parameters) {
if (parameters == null || !parameters.containsKey("value")) {
throw new UnsupportedOperationException("no value");
} | return new StringSynonym(getType(), |
realrolfje/anonimatron | src/main/java/com/rolfje/anonimatron/anonymizer/UUIDAnonymizer.java | // Path: src/main/java/com/rolfje/anonimatron/synonyms/StringSynonym.java
// public class StringSynonym implements Synonym {
// private String type;
// private String from;
// private String to;
// private boolean shortlived = false;
//
// public StringSynonym() {
// }
//
// public StringSynonym(String type, String from, String to, boolean shortlived) {
// this.type = type;
// this.from = from;
// this.to = to;
// this.shortlived = shortlived;
// }
//
// @Override
// public String getType() {
// return type;
// }
//
// @Override
// public Object getFrom() {
// return from;
// }
//
// @Override
// public Object getTo() {
// return to;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setFrom(String from) {
// this.from = from;
// }
//
// public void setTo(String to) {
// this.to = to;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortlived;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
| import com.rolfje.anonimatron.synonyms.StringSynonym;
import com.rolfje.anonimatron.synonyms.Synonym;
import java.util.UUID; | package com.rolfje.anonimatron.anonymizer;
public class UUIDAnonymizer implements Anonymizer {
private static final String TYPE = "UUID";
@Override | // Path: src/main/java/com/rolfje/anonimatron/synonyms/StringSynonym.java
// public class StringSynonym implements Synonym {
// private String type;
// private String from;
// private String to;
// private boolean shortlived = false;
//
// public StringSynonym() {
// }
//
// public StringSynonym(String type, String from, String to, boolean shortlived) {
// this.type = type;
// this.from = from;
// this.to = to;
// this.shortlived = shortlived;
// }
//
// @Override
// public String getType() {
// return type;
// }
//
// @Override
// public Object getFrom() {
// return from;
// }
//
// @Override
// public Object getTo() {
// return to;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setFrom(String from) {
// this.from = from;
// }
//
// public void setTo(String to) {
// this.to = to;
// }
//
// public void setShortlived(boolean shortlived) {
// this.shortlived = shortlived;
// }
//
// @Override
// public boolean isShortLived() {
// return shortlived;
// }
//
// @Override
// public boolean equals(Object obj) {
// return (obj != null) && (this.getClass() == obj.getClass()) && (this.hashCode() == obj.hashCode());
// }
//
// @Override
// public int hashCode() {
// return from.hashCode() + to.hashCode() + type.hashCode();
// }
// }
//
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
//
// /**
// * Indicates if this Synonym is short-lived or transient, meaning that
// * it should not be stored in the synonyms file. Transient Synonyms
// * are not stored, need to be calculated each run time.
// *
// * Transient synonyms are:
// *
// * <ol>
// * <li>Not stored in memory.</li>
// * <li>Not stored in the synonym file.</li>
// * </ol>
// *
// * @return <code>true</code> if the synonym should be thrown away
// * after use (not stored in the synonym file).
// */
// boolean isShortLived();
//
// /**
// * @return The semantic data type of this Synonym, usually something
// * descriptive as "NAME" or "STREET".
// */
// String getType();
//
// /**
// * @return The data which was in the original database for this Synonym
// */
// Object getFrom();
//
// /**
// *
// * @return The data with which the original data in the database will be or
// * is replaced when the Anonymizer runs.
// */
// Object getTo();
// }
// Path: src/main/java/com/rolfje/anonimatron/anonymizer/UUIDAnonymizer.java
import com.rolfje.anonimatron.synonyms.StringSynonym;
import com.rolfje.anonimatron.synonyms.Synonym;
import java.util.UUID;
package com.rolfje.anonimatron.anonymizer;
public class UUIDAnonymizer implements Anonymizer {
private static final String TYPE = "UUID";
@Override | public Synonym anonymize(Object from, int size, boolean shortlived) { |
Subsets and Splits