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
|
---|---|---|---|---|---|---|
latraccia/sd-dss-util | sd-dss-util-lib/src/main/java/it/latraccia/dss/util/builder/token/PKCSTokenBuilder.java | // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/exception/SignatureMoccaAlgorithmMismatchException.java
// public class SignatureMoccaAlgorithmMismatchException extends SignatureException {
// public SignatureMoccaAlgorithmMismatchException() {
// }
// public SignatureMoccaAlgorithmMismatchException(Exception e) {
// super(e);
// }
//
// @Override
// public String getMessage() {
// return "The selected MOCCA algorithm is not valid!";
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/exception/SignatureMoccaUnavailabilityException.java
// public class SignatureMoccaUnavailabilityException extends SignatureException {
// public SignatureMoccaUnavailabilityException() {
// }
// public SignatureMoccaUnavailabilityException(Exception e) {
// super(e);
// }
//
// @Override
// public String getMessage() {
// return "MOCCA is not available!";
// }
// }
| import java.io.FileNotFoundException;
import it.latraccia.dss.util.exception.SignatureMoccaAlgorithmMismatchException;
import it.latraccia.dss.util.exception.SignatureMoccaUnavailabilityException; | /*
* SD-DSS-Util, a Utility Library and a Command Line Interface for SD-DSS.
* Copyright (C) 2013 La Traccia http://www.latraccia.it/en/
* Developed by Francesco Pontillo
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see [http://www.gnu.org/licenses/].
*/
package it.latraccia.dss.util.builder.token;
/**
* Date: 07/12/13
* Time: 9.08
*
* @author Francesco Pontillo
*/
public abstract class PKCSTokenBuilder extends TokenBuilder {
protected String file;
protected String password;
@Override | // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/exception/SignatureMoccaAlgorithmMismatchException.java
// public class SignatureMoccaAlgorithmMismatchException extends SignatureException {
// public SignatureMoccaAlgorithmMismatchException() {
// }
// public SignatureMoccaAlgorithmMismatchException(Exception e) {
// super(e);
// }
//
// @Override
// public String getMessage() {
// return "The selected MOCCA algorithm is not valid!";
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/exception/SignatureMoccaUnavailabilityException.java
// public class SignatureMoccaUnavailabilityException extends SignatureException {
// public SignatureMoccaUnavailabilityException() {
// }
// public SignatureMoccaUnavailabilityException(Exception e) {
// super(e);
// }
//
// @Override
// public String getMessage() {
// return "MOCCA is not available!";
// }
// }
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/builder/token/PKCSTokenBuilder.java
import java.io.FileNotFoundException;
import it.latraccia.dss.util.exception.SignatureMoccaAlgorithmMismatchException;
import it.latraccia.dss.util.exception.SignatureMoccaUnavailabilityException;
/*
* SD-DSS-Util, a Utility Library and a Command Line Interface for SD-DSS.
* Copyright (C) 2013 La Traccia http://www.latraccia.it/en/
* Developed by Francesco Pontillo
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see [http://www.gnu.org/licenses/].
*/
package it.latraccia.dss.util.builder.token;
/**
* Date: 07/12/13
* Time: 9.08
*
* @author Francesco Pontillo
*/
public abstract class PKCSTokenBuilder extends TokenBuilder {
protected String file;
protected String password;
@Override | public SignatureToken build() throws SignatureMoccaAlgorithmMismatchException, SignatureMoccaUnavailabilityException, FileNotFoundException { |
latraccia/sd-dss-util | sd-dss-util-lib/src/main/java/it/latraccia/dss/util/builder/token/PKCSTokenBuilder.java | // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/exception/SignatureMoccaAlgorithmMismatchException.java
// public class SignatureMoccaAlgorithmMismatchException extends SignatureException {
// public SignatureMoccaAlgorithmMismatchException() {
// }
// public SignatureMoccaAlgorithmMismatchException(Exception e) {
// super(e);
// }
//
// @Override
// public String getMessage() {
// return "The selected MOCCA algorithm is not valid!";
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/exception/SignatureMoccaUnavailabilityException.java
// public class SignatureMoccaUnavailabilityException extends SignatureException {
// public SignatureMoccaUnavailabilityException() {
// }
// public SignatureMoccaUnavailabilityException(Exception e) {
// super(e);
// }
//
// @Override
// public String getMessage() {
// return "MOCCA is not available!";
// }
// }
| import java.io.FileNotFoundException;
import it.latraccia.dss.util.exception.SignatureMoccaAlgorithmMismatchException;
import it.latraccia.dss.util.exception.SignatureMoccaUnavailabilityException; | /*
* SD-DSS-Util, a Utility Library and a Command Line Interface for SD-DSS.
* Copyright (C) 2013 La Traccia http://www.latraccia.it/en/
* Developed by Francesco Pontillo
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see [http://www.gnu.org/licenses/].
*/
package it.latraccia.dss.util.builder.token;
/**
* Date: 07/12/13
* Time: 9.08
*
* @author Francesco Pontillo
*/
public abstract class PKCSTokenBuilder extends TokenBuilder {
protected String file;
protected String password;
@Override | // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/exception/SignatureMoccaAlgorithmMismatchException.java
// public class SignatureMoccaAlgorithmMismatchException extends SignatureException {
// public SignatureMoccaAlgorithmMismatchException() {
// }
// public SignatureMoccaAlgorithmMismatchException(Exception e) {
// super(e);
// }
//
// @Override
// public String getMessage() {
// return "The selected MOCCA algorithm is not valid!";
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/exception/SignatureMoccaUnavailabilityException.java
// public class SignatureMoccaUnavailabilityException extends SignatureException {
// public SignatureMoccaUnavailabilityException() {
// }
// public SignatureMoccaUnavailabilityException(Exception e) {
// super(e);
// }
//
// @Override
// public String getMessage() {
// return "MOCCA is not available!";
// }
// }
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/builder/token/PKCSTokenBuilder.java
import java.io.FileNotFoundException;
import it.latraccia.dss.util.exception.SignatureMoccaAlgorithmMismatchException;
import it.latraccia.dss.util.exception.SignatureMoccaUnavailabilityException;
/*
* SD-DSS-Util, a Utility Library and a Command Line Interface for SD-DSS.
* Copyright (C) 2013 La Traccia http://www.latraccia.it/en/
* Developed by Francesco Pontillo
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see [http://www.gnu.org/licenses/].
*/
package it.latraccia.dss.util.builder.token;
/**
* Date: 07/12/13
* Time: 9.08
*
* @author Francesco Pontillo
*/
public abstract class PKCSTokenBuilder extends TokenBuilder {
protected String file;
protected String password;
@Override | public SignatureToken build() throws SignatureMoccaAlgorithmMismatchException, SignatureMoccaUnavailabilityException, FileNotFoundException { |
latraccia/sd-dss-util | sd-dss-util-lib/src/main/java/it/latraccia/dss/util/builder/format/XAdESFormatBuilder.java | // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/format/SignatureFormat.java
// public class SignatureFormat extends GeneralEnum {
// public static final String XAdES_NAME = "XAdES";
// public static final String CAdES_NAME = "CAdES";
// public static final String PAdES_NAME = "PAdES";
//
// public static final SignatureFormat XAdES = new SignatureXAdESFormat(XAdES_NAME);
// public static final SignatureFormat CAdES = new SignatureCAdESFormat(CAdES_NAME);
// public static final SignatureFormat PAdES = new SignaturePAdESFormat(PAdES_NAME);
//
// public SignatureFormat(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/format/SignatureXAdESFormat.java
// public class SignatureXAdESFormat extends SignatureFormat {
// public SignatureXAdESFormat(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/level/SignatureXAdESLevel.java
// public class SignatureXAdESLevel extends SignatureLevel {
// public static SignatureXAdESLevel BES = new SignatureXAdESLevel(SignatureLevel.BES);
// public static SignatureXAdESLevel EPES = new SignatureXAdESLevel(SignatureLevel.EPES);
// public static SignatureXAdESLevel T = new SignatureXAdESLevel(SignatureLevel.T);
// public static SignatureXAdESLevel C = new SignatureXAdESLevel(SignatureLevel.C);
// public static SignatureXAdESLevel X = new SignatureXAdESLevel(SignatureLevel.X);
// public static SignatureXAdESLevel XL = new SignatureXAdESLevel(SignatureLevel.XL);
// public static SignatureXAdESLevel A = new SignatureXAdESLevel(SignatureLevel.A);
//
// public SignatureXAdESLevel(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/packaging/SignatureXAdESPackaging.java
// public class SignatureXAdESPackaging extends SignaturePackaging {
// public static SignatureXAdESPackaging ENVELOPING = new SignatureXAdESPackaging(SignaturePackaging.ENVELOPING);
// public static SignatureXAdESPackaging ENVELOPED = new SignatureXAdESPackaging(SignaturePackaging.ENVELOPED);
// public static SignatureXAdESPackaging DETACHED = new SignatureXAdESPackaging(SignaturePackaging.DETACHED);
//
// public SignatureXAdESPackaging(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/exception/SignatureServiceUrlException.java
// public class SignatureServiceUrlException extends SignatureException {
// public SignatureServiceUrlException() {
// }
// public SignatureServiceUrlException(Exception e) {
// super(e);
// }
//
// @Override
// public String getMessage() {
// return "The service URL was required but not specified!";
// }
// }
| import it.latraccia.dss.util.entity.format.SignatureFormat;
import it.latraccia.dss.util.entity.format.SignatureXAdESFormat;
import it.latraccia.dss.util.entity.level.SignatureXAdESLevel;
import it.latraccia.dss.util.entity.packaging.SignatureXAdESPackaging;
import it.latraccia.dss.util.exception.SignatureServiceUrlException; | /*
* SD-DSS-Util, a Utility Library and a Command Line Interface for SD-DSS.
* Copyright (C) 2013 La Traccia http://www.latraccia.it/en/
* Developed by Francesco Pontillo
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see [http://www.gnu.org/licenses/].
*/
package it.latraccia.dss.util.builder.format;
/**
* Date: 06/12/13
* Time: 11.10
*
* @author Francesco Pontillo
*/
public class XAdESFormatBuilder extends FormatBuilder<SignatureXAdESFormat> {
// FORMAT
public XAdESFormatBuilder() { | // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/format/SignatureFormat.java
// public class SignatureFormat extends GeneralEnum {
// public static final String XAdES_NAME = "XAdES";
// public static final String CAdES_NAME = "CAdES";
// public static final String PAdES_NAME = "PAdES";
//
// public static final SignatureFormat XAdES = new SignatureXAdESFormat(XAdES_NAME);
// public static final SignatureFormat CAdES = new SignatureCAdESFormat(CAdES_NAME);
// public static final SignatureFormat PAdES = new SignaturePAdESFormat(PAdES_NAME);
//
// public SignatureFormat(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/format/SignatureXAdESFormat.java
// public class SignatureXAdESFormat extends SignatureFormat {
// public SignatureXAdESFormat(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/level/SignatureXAdESLevel.java
// public class SignatureXAdESLevel extends SignatureLevel {
// public static SignatureXAdESLevel BES = new SignatureXAdESLevel(SignatureLevel.BES);
// public static SignatureXAdESLevel EPES = new SignatureXAdESLevel(SignatureLevel.EPES);
// public static SignatureXAdESLevel T = new SignatureXAdESLevel(SignatureLevel.T);
// public static SignatureXAdESLevel C = new SignatureXAdESLevel(SignatureLevel.C);
// public static SignatureXAdESLevel X = new SignatureXAdESLevel(SignatureLevel.X);
// public static SignatureXAdESLevel XL = new SignatureXAdESLevel(SignatureLevel.XL);
// public static SignatureXAdESLevel A = new SignatureXAdESLevel(SignatureLevel.A);
//
// public SignatureXAdESLevel(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/packaging/SignatureXAdESPackaging.java
// public class SignatureXAdESPackaging extends SignaturePackaging {
// public static SignatureXAdESPackaging ENVELOPING = new SignatureXAdESPackaging(SignaturePackaging.ENVELOPING);
// public static SignatureXAdESPackaging ENVELOPED = new SignatureXAdESPackaging(SignaturePackaging.ENVELOPED);
// public static SignatureXAdESPackaging DETACHED = new SignatureXAdESPackaging(SignaturePackaging.DETACHED);
//
// public SignatureXAdESPackaging(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/exception/SignatureServiceUrlException.java
// public class SignatureServiceUrlException extends SignatureException {
// public SignatureServiceUrlException() {
// }
// public SignatureServiceUrlException(Exception e) {
// super(e);
// }
//
// @Override
// public String getMessage() {
// return "The service URL was required but not specified!";
// }
// }
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/builder/format/XAdESFormatBuilder.java
import it.latraccia.dss.util.entity.format.SignatureFormat;
import it.latraccia.dss.util.entity.format.SignatureXAdESFormat;
import it.latraccia.dss.util.entity.level.SignatureXAdESLevel;
import it.latraccia.dss.util.entity.packaging.SignatureXAdESPackaging;
import it.latraccia.dss.util.exception.SignatureServiceUrlException;
/*
* SD-DSS-Util, a Utility Library and a Command Line Interface for SD-DSS.
* Copyright (C) 2013 La Traccia http://www.latraccia.it/en/
* Developed by Francesco Pontillo
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see [http://www.gnu.org/licenses/].
*/
package it.latraccia.dss.util.builder.format;
/**
* Date: 06/12/13
* Time: 11.10
*
* @author Francesco Pontillo
*/
public class XAdESFormatBuilder extends FormatBuilder<SignatureXAdESFormat> {
// FORMAT
public XAdESFormatBuilder() { | setFormat(SignatureFormat.XAdES); |
latraccia/sd-dss-util | sd-dss-util-lib/src/main/java/it/latraccia/dss/util/builder/format/XAdESFormatBuilder.java | // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/format/SignatureFormat.java
// public class SignatureFormat extends GeneralEnum {
// public static final String XAdES_NAME = "XAdES";
// public static final String CAdES_NAME = "CAdES";
// public static final String PAdES_NAME = "PAdES";
//
// public static final SignatureFormat XAdES = new SignatureXAdESFormat(XAdES_NAME);
// public static final SignatureFormat CAdES = new SignatureCAdESFormat(CAdES_NAME);
// public static final SignatureFormat PAdES = new SignaturePAdESFormat(PAdES_NAME);
//
// public SignatureFormat(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/format/SignatureXAdESFormat.java
// public class SignatureXAdESFormat extends SignatureFormat {
// public SignatureXAdESFormat(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/level/SignatureXAdESLevel.java
// public class SignatureXAdESLevel extends SignatureLevel {
// public static SignatureXAdESLevel BES = new SignatureXAdESLevel(SignatureLevel.BES);
// public static SignatureXAdESLevel EPES = new SignatureXAdESLevel(SignatureLevel.EPES);
// public static SignatureXAdESLevel T = new SignatureXAdESLevel(SignatureLevel.T);
// public static SignatureXAdESLevel C = new SignatureXAdESLevel(SignatureLevel.C);
// public static SignatureXAdESLevel X = new SignatureXAdESLevel(SignatureLevel.X);
// public static SignatureXAdESLevel XL = new SignatureXAdESLevel(SignatureLevel.XL);
// public static SignatureXAdESLevel A = new SignatureXAdESLevel(SignatureLevel.A);
//
// public SignatureXAdESLevel(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/packaging/SignatureXAdESPackaging.java
// public class SignatureXAdESPackaging extends SignaturePackaging {
// public static SignatureXAdESPackaging ENVELOPING = new SignatureXAdESPackaging(SignaturePackaging.ENVELOPING);
// public static SignatureXAdESPackaging ENVELOPED = new SignatureXAdESPackaging(SignaturePackaging.ENVELOPED);
// public static SignatureXAdESPackaging DETACHED = new SignatureXAdESPackaging(SignaturePackaging.DETACHED);
//
// public SignatureXAdESPackaging(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/exception/SignatureServiceUrlException.java
// public class SignatureServiceUrlException extends SignatureException {
// public SignatureServiceUrlException() {
// }
// public SignatureServiceUrlException(Exception e) {
// super(e);
// }
//
// @Override
// public String getMessage() {
// return "The service URL was required but not specified!";
// }
// }
| import it.latraccia.dss.util.entity.format.SignatureFormat;
import it.latraccia.dss.util.entity.format.SignatureXAdESFormat;
import it.latraccia.dss.util.entity.level.SignatureXAdESLevel;
import it.latraccia.dss.util.entity.packaging.SignatureXAdESPackaging;
import it.latraccia.dss.util.exception.SignatureServiceUrlException; | /*
* SD-DSS-Util, a Utility Library and a Command Line Interface for SD-DSS.
* Copyright (C) 2013 La Traccia http://www.latraccia.it/en/
* Developed by Francesco Pontillo
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see [http://www.gnu.org/licenses/].
*/
package it.latraccia.dss.util.builder.format;
/**
* Date: 06/12/13
* Time: 11.10
*
* @author Francesco Pontillo
*/
public class XAdESFormatBuilder extends FormatBuilder<SignatureXAdESFormat> {
// FORMAT
public XAdESFormatBuilder() {
setFormat(SignatureFormat.XAdES);
}
// LEVEL
public XAdESFormatBuilder BES() { | // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/format/SignatureFormat.java
// public class SignatureFormat extends GeneralEnum {
// public static final String XAdES_NAME = "XAdES";
// public static final String CAdES_NAME = "CAdES";
// public static final String PAdES_NAME = "PAdES";
//
// public static final SignatureFormat XAdES = new SignatureXAdESFormat(XAdES_NAME);
// public static final SignatureFormat CAdES = new SignatureCAdESFormat(CAdES_NAME);
// public static final SignatureFormat PAdES = new SignaturePAdESFormat(PAdES_NAME);
//
// public SignatureFormat(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/format/SignatureXAdESFormat.java
// public class SignatureXAdESFormat extends SignatureFormat {
// public SignatureXAdESFormat(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/level/SignatureXAdESLevel.java
// public class SignatureXAdESLevel extends SignatureLevel {
// public static SignatureXAdESLevel BES = new SignatureXAdESLevel(SignatureLevel.BES);
// public static SignatureXAdESLevel EPES = new SignatureXAdESLevel(SignatureLevel.EPES);
// public static SignatureXAdESLevel T = new SignatureXAdESLevel(SignatureLevel.T);
// public static SignatureXAdESLevel C = new SignatureXAdESLevel(SignatureLevel.C);
// public static SignatureXAdESLevel X = new SignatureXAdESLevel(SignatureLevel.X);
// public static SignatureXAdESLevel XL = new SignatureXAdESLevel(SignatureLevel.XL);
// public static SignatureXAdESLevel A = new SignatureXAdESLevel(SignatureLevel.A);
//
// public SignatureXAdESLevel(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/packaging/SignatureXAdESPackaging.java
// public class SignatureXAdESPackaging extends SignaturePackaging {
// public static SignatureXAdESPackaging ENVELOPING = new SignatureXAdESPackaging(SignaturePackaging.ENVELOPING);
// public static SignatureXAdESPackaging ENVELOPED = new SignatureXAdESPackaging(SignaturePackaging.ENVELOPED);
// public static SignatureXAdESPackaging DETACHED = new SignatureXAdESPackaging(SignaturePackaging.DETACHED);
//
// public SignatureXAdESPackaging(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/exception/SignatureServiceUrlException.java
// public class SignatureServiceUrlException extends SignatureException {
// public SignatureServiceUrlException() {
// }
// public SignatureServiceUrlException(Exception e) {
// super(e);
// }
//
// @Override
// public String getMessage() {
// return "The service URL was required but not specified!";
// }
// }
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/builder/format/XAdESFormatBuilder.java
import it.latraccia.dss.util.entity.format.SignatureFormat;
import it.latraccia.dss.util.entity.format.SignatureXAdESFormat;
import it.latraccia.dss.util.entity.level.SignatureXAdESLevel;
import it.latraccia.dss.util.entity.packaging.SignatureXAdESPackaging;
import it.latraccia.dss.util.exception.SignatureServiceUrlException;
/*
* SD-DSS-Util, a Utility Library and a Command Line Interface for SD-DSS.
* Copyright (C) 2013 La Traccia http://www.latraccia.it/en/
* Developed by Francesco Pontillo
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see [http://www.gnu.org/licenses/].
*/
package it.latraccia.dss.util.builder.format;
/**
* Date: 06/12/13
* Time: 11.10
*
* @author Francesco Pontillo
*/
public class XAdESFormatBuilder extends FormatBuilder<SignatureXAdESFormat> {
// FORMAT
public XAdESFormatBuilder() {
setFormat(SignatureFormat.XAdES);
}
// LEVEL
public XAdESFormatBuilder BES() { | setLevel(SignatureXAdESLevel.BES); |
latraccia/sd-dss-util | sd-dss-util-lib/src/main/java/it/latraccia/dss/util/builder/format/XAdESFormatBuilder.java | // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/format/SignatureFormat.java
// public class SignatureFormat extends GeneralEnum {
// public static final String XAdES_NAME = "XAdES";
// public static final String CAdES_NAME = "CAdES";
// public static final String PAdES_NAME = "PAdES";
//
// public static final SignatureFormat XAdES = new SignatureXAdESFormat(XAdES_NAME);
// public static final SignatureFormat CAdES = new SignatureCAdESFormat(CAdES_NAME);
// public static final SignatureFormat PAdES = new SignaturePAdESFormat(PAdES_NAME);
//
// public SignatureFormat(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/format/SignatureXAdESFormat.java
// public class SignatureXAdESFormat extends SignatureFormat {
// public SignatureXAdESFormat(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/level/SignatureXAdESLevel.java
// public class SignatureXAdESLevel extends SignatureLevel {
// public static SignatureXAdESLevel BES = new SignatureXAdESLevel(SignatureLevel.BES);
// public static SignatureXAdESLevel EPES = new SignatureXAdESLevel(SignatureLevel.EPES);
// public static SignatureXAdESLevel T = new SignatureXAdESLevel(SignatureLevel.T);
// public static SignatureXAdESLevel C = new SignatureXAdESLevel(SignatureLevel.C);
// public static SignatureXAdESLevel X = new SignatureXAdESLevel(SignatureLevel.X);
// public static SignatureXAdESLevel XL = new SignatureXAdESLevel(SignatureLevel.XL);
// public static SignatureXAdESLevel A = new SignatureXAdESLevel(SignatureLevel.A);
//
// public SignatureXAdESLevel(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/packaging/SignatureXAdESPackaging.java
// public class SignatureXAdESPackaging extends SignaturePackaging {
// public static SignatureXAdESPackaging ENVELOPING = new SignatureXAdESPackaging(SignaturePackaging.ENVELOPING);
// public static SignatureXAdESPackaging ENVELOPED = new SignatureXAdESPackaging(SignaturePackaging.ENVELOPED);
// public static SignatureXAdESPackaging DETACHED = new SignatureXAdESPackaging(SignaturePackaging.DETACHED);
//
// public SignatureXAdESPackaging(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/exception/SignatureServiceUrlException.java
// public class SignatureServiceUrlException extends SignatureException {
// public SignatureServiceUrlException() {
// }
// public SignatureServiceUrlException(Exception e) {
// super(e);
// }
//
// @Override
// public String getMessage() {
// return "The service URL was required but not specified!";
// }
// }
| import it.latraccia.dss.util.entity.format.SignatureFormat;
import it.latraccia.dss.util.entity.format.SignatureXAdESFormat;
import it.latraccia.dss.util.entity.level.SignatureXAdESLevel;
import it.latraccia.dss.util.entity.packaging.SignatureXAdESPackaging;
import it.latraccia.dss.util.exception.SignatureServiceUrlException; | /*
* SD-DSS-Util, a Utility Library and a Command Line Interface for SD-DSS.
* Copyright (C) 2013 La Traccia http://www.latraccia.it/en/
* Developed by Francesco Pontillo
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see [http://www.gnu.org/licenses/].
*/
package it.latraccia.dss.util.builder.format;
/**
* Date: 06/12/13
* Time: 11.10
*
* @author Francesco Pontillo
*/
public class XAdESFormatBuilder extends FormatBuilder<SignatureXAdESFormat> {
// FORMAT
public XAdESFormatBuilder() {
setFormat(SignatureFormat.XAdES);
}
// LEVEL
public XAdESFormatBuilder BES() {
setLevel(SignatureXAdESLevel.BES);
return this;
}
public XAdESFormatBuilder EPES() {
setLevel(SignatureXAdESLevel.EPES);
return this;
}
| // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/format/SignatureFormat.java
// public class SignatureFormat extends GeneralEnum {
// public static final String XAdES_NAME = "XAdES";
// public static final String CAdES_NAME = "CAdES";
// public static final String PAdES_NAME = "PAdES";
//
// public static final SignatureFormat XAdES = new SignatureXAdESFormat(XAdES_NAME);
// public static final SignatureFormat CAdES = new SignatureCAdESFormat(CAdES_NAME);
// public static final SignatureFormat PAdES = new SignaturePAdESFormat(PAdES_NAME);
//
// public SignatureFormat(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/format/SignatureXAdESFormat.java
// public class SignatureXAdESFormat extends SignatureFormat {
// public SignatureXAdESFormat(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/level/SignatureXAdESLevel.java
// public class SignatureXAdESLevel extends SignatureLevel {
// public static SignatureXAdESLevel BES = new SignatureXAdESLevel(SignatureLevel.BES);
// public static SignatureXAdESLevel EPES = new SignatureXAdESLevel(SignatureLevel.EPES);
// public static SignatureXAdESLevel T = new SignatureXAdESLevel(SignatureLevel.T);
// public static SignatureXAdESLevel C = new SignatureXAdESLevel(SignatureLevel.C);
// public static SignatureXAdESLevel X = new SignatureXAdESLevel(SignatureLevel.X);
// public static SignatureXAdESLevel XL = new SignatureXAdESLevel(SignatureLevel.XL);
// public static SignatureXAdESLevel A = new SignatureXAdESLevel(SignatureLevel.A);
//
// public SignatureXAdESLevel(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/packaging/SignatureXAdESPackaging.java
// public class SignatureXAdESPackaging extends SignaturePackaging {
// public static SignatureXAdESPackaging ENVELOPING = new SignatureXAdESPackaging(SignaturePackaging.ENVELOPING);
// public static SignatureXAdESPackaging ENVELOPED = new SignatureXAdESPackaging(SignaturePackaging.ENVELOPED);
// public static SignatureXAdESPackaging DETACHED = new SignatureXAdESPackaging(SignaturePackaging.DETACHED);
//
// public SignatureXAdESPackaging(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/exception/SignatureServiceUrlException.java
// public class SignatureServiceUrlException extends SignatureException {
// public SignatureServiceUrlException() {
// }
// public SignatureServiceUrlException(Exception e) {
// super(e);
// }
//
// @Override
// public String getMessage() {
// return "The service URL was required but not specified!";
// }
// }
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/builder/format/XAdESFormatBuilder.java
import it.latraccia.dss.util.entity.format.SignatureFormat;
import it.latraccia.dss.util.entity.format.SignatureXAdESFormat;
import it.latraccia.dss.util.entity.level.SignatureXAdESLevel;
import it.latraccia.dss.util.entity.packaging.SignatureXAdESPackaging;
import it.latraccia.dss.util.exception.SignatureServiceUrlException;
/*
* SD-DSS-Util, a Utility Library and a Command Line Interface for SD-DSS.
* Copyright (C) 2013 La Traccia http://www.latraccia.it/en/
* Developed by Francesco Pontillo
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see [http://www.gnu.org/licenses/].
*/
package it.latraccia.dss.util.builder.format;
/**
* Date: 06/12/13
* Time: 11.10
*
* @author Francesco Pontillo
*/
public class XAdESFormatBuilder extends FormatBuilder<SignatureXAdESFormat> {
// FORMAT
public XAdESFormatBuilder() {
setFormat(SignatureFormat.XAdES);
}
// LEVEL
public XAdESFormatBuilder BES() {
setLevel(SignatureXAdESLevel.BES);
return this;
}
public XAdESFormatBuilder EPES() {
setLevel(SignatureXAdESLevel.EPES);
return this;
}
| public XAdESFormatBuilder T(String serviceUrl) throws SignatureServiceUrlException { |
latraccia/sd-dss-util | sd-dss-util-lib/src/main/java/it/latraccia/dss/util/builder/format/XAdESFormatBuilder.java | // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/format/SignatureFormat.java
// public class SignatureFormat extends GeneralEnum {
// public static final String XAdES_NAME = "XAdES";
// public static final String CAdES_NAME = "CAdES";
// public static final String PAdES_NAME = "PAdES";
//
// public static final SignatureFormat XAdES = new SignatureXAdESFormat(XAdES_NAME);
// public static final SignatureFormat CAdES = new SignatureCAdESFormat(CAdES_NAME);
// public static final SignatureFormat PAdES = new SignaturePAdESFormat(PAdES_NAME);
//
// public SignatureFormat(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/format/SignatureXAdESFormat.java
// public class SignatureXAdESFormat extends SignatureFormat {
// public SignatureXAdESFormat(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/level/SignatureXAdESLevel.java
// public class SignatureXAdESLevel extends SignatureLevel {
// public static SignatureXAdESLevel BES = new SignatureXAdESLevel(SignatureLevel.BES);
// public static SignatureXAdESLevel EPES = new SignatureXAdESLevel(SignatureLevel.EPES);
// public static SignatureXAdESLevel T = new SignatureXAdESLevel(SignatureLevel.T);
// public static SignatureXAdESLevel C = new SignatureXAdESLevel(SignatureLevel.C);
// public static SignatureXAdESLevel X = new SignatureXAdESLevel(SignatureLevel.X);
// public static SignatureXAdESLevel XL = new SignatureXAdESLevel(SignatureLevel.XL);
// public static SignatureXAdESLevel A = new SignatureXAdESLevel(SignatureLevel.A);
//
// public SignatureXAdESLevel(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/packaging/SignatureXAdESPackaging.java
// public class SignatureXAdESPackaging extends SignaturePackaging {
// public static SignatureXAdESPackaging ENVELOPING = new SignatureXAdESPackaging(SignaturePackaging.ENVELOPING);
// public static SignatureXAdESPackaging ENVELOPED = new SignatureXAdESPackaging(SignaturePackaging.ENVELOPED);
// public static SignatureXAdESPackaging DETACHED = new SignatureXAdESPackaging(SignaturePackaging.DETACHED);
//
// public SignatureXAdESPackaging(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/exception/SignatureServiceUrlException.java
// public class SignatureServiceUrlException extends SignatureException {
// public SignatureServiceUrlException() {
// }
// public SignatureServiceUrlException(Exception e) {
// super(e);
// }
//
// @Override
// public String getMessage() {
// return "The service URL was required but not specified!";
// }
// }
| import it.latraccia.dss.util.entity.format.SignatureFormat;
import it.latraccia.dss.util.entity.format.SignatureXAdESFormat;
import it.latraccia.dss.util.entity.level.SignatureXAdESLevel;
import it.latraccia.dss.util.entity.packaging.SignatureXAdESPackaging;
import it.latraccia.dss.util.exception.SignatureServiceUrlException; | return this;
}
public XAdESFormatBuilder C(String serviceUrl) throws SignatureServiceUrlException {
setLevel(SignatureXAdESLevel.C);
setServiceUrl(serviceUrl);
return this;
}
public XAdESFormatBuilder X(String serviceUrl) throws SignatureServiceUrlException {
setLevel(SignatureXAdESLevel.BES);
setServiceUrl(serviceUrl);
return this;
}
public XAdESFormatBuilder XL(String serviceUrl) throws SignatureServiceUrlException {
setLevel(SignatureXAdESLevel.EPES);
setServiceUrl(serviceUrl);
return this;
}
public XAdESFormatBuilder A(String serviceUrl) throws SignatureServiceUrlException {
setLevel(SignatureXAdESLevel.A);
setServiceUrl(serviceUrl);
return this;
}
// PACKAGING
public XAdESFormatBuilder enveloping() { | // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/format/SignatureFormat.java
// public class SignatureFormat extends GeneralEnum {
// public static final String XAdES_NAME = "XAdES";
// public static final String CAdES_NAME = "CAdES";
// public static final String PAdES_NAME = "PAdES";
//
// public static final SignatureFormat XAdES = new SignatureXAdESFormat(XAdES_NAME);
// public static final SignatureFormat CAdES = new SignatureCAdESFormat(CAdES_NAME);
// public static final SignatureFormat PAdES = new SignaturePAdESFormat(PAdES_NAME);
//
// public SignatureFormat(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/format/SignatureXAdESFormat.java
// public class SignatureXAdESFormat extends SignatureFormat {
// public SignatureXAdESFormat(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/level/SignatureXAdESLevel.java
// public class SignatureXAdESLevel extends SignatureLevel {
// public static SignatureXAdESLevel BES = new SignatureXAdESLevel(SignatureLevel.BES);
// public static SignatureXAdESLevel EPES = new SignatureXAdESLevel(SignatureLevel.EPES);
// public static SignatureXAdESLevel T = new SignatureXAdESLevel(SignatureLevel.T);
// public static SignatureXAdESLevel C = new SignatureXAdESLevel(SignatureLevel.C);
// public static SignatureXAdESLevel X = new SignatureXAdESLevel(SignatureLevel.X);
// public static SignatureXAdESLevel XL = new SignatureXAdESLevel(SignatureLevel.XL);
// public static SignatureXAdESLevel A = new SignatureXAdESLevel(SignatureLevel.A);
//
// public SignatureXAdESLevel(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/packaging/SignatureXAdESPackaging.java
// public class SignatureXAdESPackaging extends SignaturePackaging {
// public static SignatureXAdESPackaging ENVELOPING = new SignatureXAdESPackaging(SignaturePackaging.ENVELOPING);
// public static SignatureXAdESPackaging ENVELOPED = new SignatureXAdESPackaging(SignaturePackaging.ENVELOPED);
// public static SignatureXAdESPackaging DETACHED = new SignatureXAdESPackaging(SignaturePackaging.DETACHED);
//
// public SignatureXAdESPackaging(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/exception/SignatureServiceUrlException.java
// public class SignatureServiceUrlException extends SignatureException {
// public SignatureServiceUrlException() {
// }
// public SignatureServiceUrlException(Exception e) {
// super(e);
// }
//
// @Override
// public String getMessage() {
// return "The service URL was required but not specified!";
// }
// }
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/builder/format/XAdESFormatBuilder.java
import it.latraccia.dss.util.entity.format.SignatureFormat;
import it.latraccia.dss.util.entity.format.SignatureXAdESFormat;
import it.latraccia.dss.util.entity.level.SignatureXAdESLevel;
import it.latraccia.dss.util.entity.packaging.SignatureXAdESPackaging;
import it.latraccia.dss.util.exception.SignatureServiceUrlException;
return this;
}
public XAdESFormatBuilder C(String serviceUrl) throws SignatureServiceUrlException {
setLevel(SignatureXAdESLevel.C);
setServiceUrl(serviceUrl);
return this;
}
public XAdESFormatBuilder X(String serviceUrl) throws SignatureServiceUrlException {
setLevel(SignatureXAdESLevel.BES);
setServiceUrl(serviceUrl);
return this;
}
public XAdESFormatBuilder XL(String serviceUrl) throws SignatureServiceUrlException {
setLevel(SignatureXAdESLevel.EPES);
setServiceUrl(serviceUrl);
return this;
}
public XAdESFormatBuilder A(String serviceUrl) throws SignatureServiceUrlException {
setLevel(SignatureXAdESLevel.A);
setServiceUrl(serviceUrl);
return this;
}
// PACKAGING
public XAdESFormatBuilder enveloping() { | setPackaging(SignatureXAdESPackaging.ENVELOPING); |
latraccia/sd-dss-util | sd-dss-util-cli/src/test/java/it/latraccia/dss/util/cli/test/CADESSuccessfulGenericTest.java | // Path: sd-dss-util-cli/src/test/java/it/latraccia/dss/util/cli/test/util/SignatureArgsHelper.java
// public class SignatureArgsHelper {
//
// private static String resourceRoot;
//
// static {
// resourceRoot = "";
// }
//
// // All possibilities to be tested are listed here, then they are combined together
//
// public static class Url {
// public static String DSS = "http://localhost:8080/service";
// }
//
// public static class Input {
// public static String PDF_FILE = getFile("pdf");
//
// public static String DOC_FILE = getFile("doc");
//
// public static String DOCX_FILE = getFile("docx");
//
// public static String ODT_FILE = getFile("odt");
//
// public static String XML_FILE = getFile("xml");
//
// private static String getFile(String extension) {
// return "test." + extension;
// }
// }
//
// public static class Output {
// public static String ROOT = resourceRoot;
// }
//
// public static class PKCS12 {
// public static String KEY = FileHelper.getResource("0F.p12");
//
// public static String PASSWORD = "password";
// }
//
// public static class PKCS11 {
// public static String LIBRARY = FileHelper.getResource("drivers/bit4ipki.dll");
//
// public static String PASSWORD = "16061981";
// }
//
// public static class Format {
// public static String CADES = "CAdES";
//
// public static String PADES = "PAdES";
//
// public static String XADES = "XAdES";
//
// public static String ASICS = "ASiC-S";
// }
//
// public static class Level {
// public static String BES = "BES";
//
// public static String EPES = "EPES";
//
// public static String LTV = "LTV";
//
// public static String T = "T";
//
// public static String C = "C";
//
// public static String X = "X";
//
// public static String XL = "XL";
//
// public static String A = "A";
// }
//
// public static class Packaging {
// public static String ENVELOPED = "ENVELOPED";
//
// public static String ENVELOPING = "ENVELOPING";
//
// public static String DETACHED = "DETACHED";
// }
//
// public static class DigestAlgorithm {
// public static String SHA256 = "SHA256";
// }
//
// public static class KeyRegex {
// public static String MATCH_ALL = ".*";
// }
//
// public List<String> getBaseArgs() {
// List<String> arguments = new ArrayList<String>();
// Collections.addAll(arguments);
// return arguments;
// }
// }
| import it.latraccia.dss.util.cli.test.util.SignatureArgsHelper;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.util.Arrays;
import java.util.Collection; | /*
* SD-DSS-Util, a Utility Library and a Command Line Interface for SD-DSS.
* Copyright (C) 2013 La Traccia http://www.latraccia.it/en/
* Developed by Francesco Pontillo
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see [http://www.gnu.org/licenses/].
*/
package it.latraccia.dss.util.cli.test;
@RunWith(value = Parameterized.class)
public abstract class CADESSuccessfulGenericTest extends SuccessfulGenericTest {
public CADESSuccessfulGenericTest(String description, Object[] args) {
super(description, args);
}
@Parameterized.Parameters
public static Collection<Object[]> getSuccessfulTestParams() {
final Object[][] params =
{
// All files, BES, ENVELOPING
{"DOC, BES, ENVELOPING", new String[] { | // Path: sd-dss-util-cli/src/test/java/it/latraccia/dss/util/cli/test/util/SignatureArgsHelper.java
// public class SignatureArgsHelper {
//
// private static String resourceRoot;
//
// static {
// resourceRoot = "";
// }
//
// // All possibilities to be tested are listed here, then they are combined together
//
// public static class Url {
// public static String DSS = "http://localhost:8080/service";
// }
//
// public static class Input {
// public static String PDF_FILE = getFile("pdf");
//
// public static String DOC_FILE = getFile("doc");
//
// public static String DOCX_FILE = getFile("docx");
//
// public static String ODT_FILE = getFile("odt");
//
// public static String XML_FILE = getFile("xml");
//
// private static String getFile(String extension) {
// return "test." + extension;
// }
// }
//
// public static class Output {
// public static String ROOT = resourceRoot;
// }
//
// public static class PKCS12 {
// public static String KEY = FileHelper.getResource("0F.p12");
//
// public static String PASSWORD = "password";
// }
//
// public static class PKCS11 {
// public static String LIBRARY = FileHelper.getResource("drivers/bit4ipki.dll");
//
// public static String PASSWORD = "16061981";
// }
//
// public static class Format {
// public static String CADES = "CAdES";
//
// public static String PADES = "PAdES";
//
// public static String XADES = "XAdES";
//
// public static String ASICS = "ASiC-S";
// }
//
// public static class Level {
// public static String BES = "BES";
//
// public static String EPES = "EPES";
//
// public static String LTV = "LTV";
//
// public static String T = "T";
//
// public static String C = "C";
//
// public static String X = "X";
//
// public static String XL = "XL";
//
// public static String A = "A";
// }
//
// public static class Packaging {
// public static String ENVELOPED = "ENVELOPED";
//
// public static String ENVELOPING = "ENVELOPING";
//
// public static String DETACHED = "DETACHED";
// }
//
// public static class DigestAlgorithm {
// public static String SHA256 = "SHA256";
// }
//
// public static class KeyRegex {
// public static String MATCH_ALL = ".*";
// }
//
// public List<String> getBaseArgs() {
// List<String> arguments = new ArrayList<String>();
// Collections.addAll(arguments);
// return arguments;
// }
// }
// Path: sd-dss-util-cli/src/test/java/it/latraccia/dss/util/cli/test/CADESSuccessfulGenericTest.java
import it.latraccia.dss.util.cli.test.util.SignatureArgsHelper;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.util.Arrays;
import java.util.Collection;
/*
* SD-DSS-Util, a Utility Library and a Command Line Interface for SD-DSS.
* Copyright (C) 2013 La Traccia http://www.latraccia.it/en/
* Developed by Francesco Pontillo
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see [http://www.gnu.org/licenses/].
*/
package it.latraccia.dss.util.cli.test;
@RunWith(value = Parameterized.class)
public abstract class CADESSuccessfulGenericTest extends SuccessfulGenericTest {
public CADESSuccessfulGenericTest(String description, Object[] args) {
super(description, args);
}
@Parameterized.Parameters
public static Collection<Object[]> getSuccessfulTestParams() {
final Object[][] params =
{
// All files, BES, ENVELOPING
{"DOC, BES, ENVELOPING", new String[] { | SignatureArgsHelper.Input.DOC_FILE, |
latraccia/sd-dss-util | sd-dss-util-lib/src/main/java/it/latraccia/dss/util/builder/token/MSCAPITokenBuilder.java | // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/token/SignatureTokenType.java
// public class SignatureTokenType extends GeneralEnum {
// public static SignatureTokenType PKCS11 = new SignatureTokenType("PKCS11");
// public static SignatureTokenType PKCS12 = new SignatureTokenType("PKCS12");
// public static SignatureTokenType MOCCA = new SignatureTokenType("MOCCA");
// public static SignatureTokenType MSCAPI = new SignatureTokenType("MSCAPI");
//
// public SignatureTokenType(String value) {
// super(value);
// }
// }
| import it.latraccia.dss.util.entity.token.SignatureTokenType; | /*
* SD-DSS-Util, a Utility Library and a Command Line Interface for SD-DSS.
* Copyright (C) 2013 La Traccia http://www.latraccia.it/en/
* Developed by Francesco Pontillo
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see [http://www.gnu.org/licenses/].
*/
package it.latraccia.dss.util.builder.token;
/**
* Date: 07/12/13
* Time: 12.09
*
* @author Francesco Pontillo
*/
public class MSCAPITokenBuilder extends TokenBuilder {
public MSCAPITokenBuilder() { | // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/token/SignatureTokenType.java
// public class SignatureTokenType extends GeneralEnum {
// public static SignatureTokenType PKCS11 = new SignatureTokenType("PKCS11");
// public static SignatureTokenType PKCS12 = new SignatureTokenType("PKCS12");
// public static SignatureTokenType MOCCA = new SignatureTokenType("MOCCA");
// public static SignatureTokenType MSCAPI = new SignatureTokenType("MSCAPI");
//
// public SignatureTokenType(String value) {
// super(value);
// }
// }
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/builder/token/MSCAPITokenBuilder.java
import it.latraccia.dss.util.entity.token.SignatureTokenType;
/*
* SD-DSS-Util, a Utility Library and a Command Line Interface for SD-DSS.
* Copyright (C) 2013 La Traccia http://www.latraccia.it/en/
* Developed by Francesco Pontillo
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see [http://www.gnu.org/licenses/].
*/
package it.latraccia.dss.util.builder.token;
/**
* Date: 07/12/13
* Time: 12.09
*
* @author Francesco Pontillo
*/
public class MSCAPITokenBuilder extends TokenBuilder {
public MSCAPITokenBuilder() { | setTokenType(SignatureTokenType.MSCAPI); |
latraccia/sd-dss-util | sd-dss-util-cli/src/test/java/it/latraccia/dss/util/cli/test/unit/PKCS11PADESSuccessfulUnitTest.java | // Path: sd-dss-util-cli/src/test/java/it/latraccia/dss/util/cli/test/PADESSuccessfulGenericTest.java
// @RunWith(value = Parameterized.class)
// public abstract class PADESSuccessfulGenericTest extends SuccessfulGenericTest {
//
// public PADESSuccessfulGenericTest(String description, Object[] args) {
// super(description, args);
// }
//
// @Parameterized.Parameters
// public static Collection<Object[]> getSuccessfulTestParams() {
// final Object[][] params =
// {
// // PDF, BES, ENVELOPED
// {"PDF, BES, ENVELOPED", new String[] {
// SignatureArgsHelper.Input.PDF_FILE,
// "-u=" + SignatureArgsHelper.Url.DSS,
// "-f=" + SignatureArgsHelper.Format.PADES,
// "-l=" + SignatureArgsHelper.Level.BES,
// "-p=" + SignatureArgsHelper.Packaging.ENVELOPED,
// "-o=\"" + SignatureArgsHelper.Output.ROOT + "\"",
// "-d=" + SignatureArgsHelper.DigestAlgorithm.SHA256,
// "-icn=\"" + SignatureArgsHelper.KeyRegex.MATCH_ALL + "\""
// }},
// // PDF, EPES, ENVELOPED
// {"PDF, EPES, ENVELOPED", new String[] {
// SignatureArgsHelper.Input.PDF_FILE,
// "-u=" + SignatureArgsHelper.Url.DSS,
// "-f=" + SignatureArgsHelper.Format.PADES,
// "-l=" + SignatureArgsHelper.Level.EPES,
// "-p=" + SignatureArgsHelper.Packaging.ENVELOPED,
// "-o=\"" + SignatureArgsHelper.Output.ROOT + "\"",
// "-d=" + SignatureArgsHelper.DigestAlgorithm.SHA256,
// "-icn=\"" + SignatureArgsHelper.KeyRegex.MATCH_ALL + "\""
// }}
// };
//
// return Arrays.asList(params);
// }
// }
//
// Path: sd-dss-util-cli/src/test/java/it/latraccia/dss/util/cli/test/util/SignatureArgsHelper.java
// public class SignatureArgsHelper {
//
// private static String resourceRoot;
//
// static {
// resourceRoot = "";
// }
//
// // All possibilities to be tested are listed here, then they are combined together
//
// public static class Url {
// public static String DSS = "http://localhost:8080/service";
// }
//
// public static class Input {
// public static String PDF_FILE = getFile("pdf");
//
// public static String DOC_FILE = getFile("doc");
//
// public static String DOCX_FILE = getFile("docx");
//
// public static String ODT_FILE = getFile("odt");
//
// public static String XML_FILE = getFile("xml");
//
// private static String getFile(String extension) {
// return "test." + extension;
// }
// }
//
// public static class Output {
// public static String ROOT = resourceRoot;
// }
//
// public static class PKCS12 {
// public static String KEY = FileHelper.getResource("0F.p12");
//
// public static String PASSWORD = "password";
// }
//
// public static class PKCS11 {
// public static String LIBRARY = FileHelper.getResource("drivers/bit4ipki.dll");
//
// public static String PASSWORD = "16061981";
// }
//
// public static class Format {
// public static String CADES = "CAdES";
//
// public static String PADES = "PAdES";
//
// public static String XADES = "XAdES";
//
// public static String ASICS = "ASiC-S";
// }
//
// public static class Level {
// public static String BES = "BES";
//
// public static String EPES = "EPES";
//
// public static String LTV = "LTV";
//
// public static String T = "T";
//
// public static String C = "C";
//
// public static String X = "X";
//
// public static String XL = "XL";
//
// public static String A = "A";
// }
//
// public static class Packaging {
// public static String ENVELOPED = "ENVELOPED";
//
// public static String ENVELOPING = "ENVELOPING";
//
// public static String DETACHED = "DETACHED";
// }
//
// public static class DigestAlgorithm {
// public static String SHA256 = "SHA256";
// }
//
// public static class KeyRegex {
// public static String MATCH_ALL = ".*";
// }
//
// public List<String> getBaseArgs() {
// List<String> arguments = new ArrayList<String>();
// Collections.addAll(arguments);
// return arguments;
// }
// }
| import it.latraccia.dss.util.cli.test.PADESSuccessfulGenericTest;
import it.latraccia.dss.util.cli.test.util.SignatureArgsHelper;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized; | /*
* SD-DSS-Util, a Utility Library and a Command Line Interface for SD-DSS.
* Copyright (C) 2013 La Traccia http://www.latraccia.it/en/
* Developed by Francesco Pontillo
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see [http://www.gnu.org/licenses/].
*/
package it.latraccia.dss.util.cli.test.unit;
@RunWith(value = Parameterized.class)
@Category(value = it.latraccia.dss.util.cli.test.unit.PKCS11UnitTest.class) | // Path: sd-dss-util-cli/src/test/java/it/latraccia/dss/util/cli/test/PADESSuccessfulGenericTest.java
// @RunWith(value = Parameterized.class)
// public abstract class PADESSuccessfulGenericTest extends SuccessfulGenericTest {
//
// public PADESSuccessfulGenericTest(String description, Object[] args) {
// super(description, args);
// }
//
// @Parameterized.Parameters
// public static Collection<Object[]> getSuccessfulTestParams() {
// final Object[][] params =
// {
// // PDF, BES, ENVELOPED
// {"PDF, BES, ENVELOPED", new String[] {
// SignatureArgsHelper.Input.PDF_FILE,
// "-u=" + SignatureArgsHelper.Url.DSS,
// "-f=" + SignatureArgsHelper.Format.PADES,
// "-l=" + SignatureArgsHelper.Level.BES,
// "-p=" + SignatureArgsHelper.Packaging.ENVELOPED,
// "-o=\"" + SignatureArgsHelper.Output.ROOT + "\"",
// "-d=" + SignatureArgsHelper.DigestAlgorithm.SHA256,
// "-icn=\"" + SignatureArgsHelper.KeyRegex.MATCH_ALL + "\""
// }},
// // PDF, EPES, ENVELOPED
// {"PDF, EPES, ENVELOPED", new String[] {
// SignatureArgsHelper.Input.PDF_FILE,
// "-u=" + SignatureArgsHelper.Url.DSS,
// "-f=" + SignatureArgsHelper.Format.PADES,
// "-l=" + SignatureArgsHelper.Level.EPES,
// "-p=" + SignatureArgsHelper.Packaging.ENVELOPED,
// "-o=\"" + SignatureArgsHelper.Output.ROOT + "\"",
// "-d=" + SignatureArgsHelper.DigestAlgorithm.SHA256,
// "-icn=\"" + SignatureArgsHelper.KeyRegex.MATCH_ALL + "\""
// }}
// };
//
// return Arrays.asList(params);
// }
// }
//
// Path: sd-dss-util-cli/src/test/java/it/latraccia/dss/util/cli/test/util/SignatureArgsHelper.java
// public class SignatureArgsHelper {
//
// private static String resourceRoot;
//
// static {
// resourceRoot = "";
// }
//
// // All possibilities to be tested are listed here, then they are combined together
//
// public static class Url {
// public static String DSS = "http://localhost:8080/service";
// }
//
// public static class Input {
// public static String PDF_FILE = getFile("pdf");
//
// public static String DOC_FILE = getFile("doc");
//
// public static String DOCX_FILE = getFile("docx");
//
// public static String ODT_FILE = getFile("odt");
//
// public static String XML_FILE = getFile("xml");
//
// private static String getFile(String extension) {
// return "test." + extension;
// }
// }
//
// public static class Output {
// public static String ROOT = resourceRoot;
// }
//
// public static class PKCS12 {
// public static String KEY = FileHelper.getResource("0F.p12");
//
// public static String PASSWORD = "password";
// }
//
// public static class PKCS11 {
// public static String LIBRARY = FileHelper.getResource("drivers/bit4ipki.dll");
//
// public static String PASSWORD = "16061981";
// }
//
// public static class Format {
// public static String CADES = "CAdES";
//
// public static String PADES = "PAdES";
//
// public static String XADES = "XAdES";
//
// public static String ASICS = "ASiC-S";
// }
//
// public static class Level {
// public static String BES = "BES";
//
// public static String EPES = "EPES";
//
// public static String LTV = "LTV";
//
// public static String T = "T";
//
// public static String C = "C";
//
// public static String X = "X";
//
// public static String XL = "XL";
//
// public static String A = "A";
// }
//
// public static class Packaging {
// public static String ENVELOPED = "ENVELOPED";
//
// public static String ENVELOPING = "ENVELOPING";
//
// public static String DETACHED = "DETACHED";
// }
//
// public static class DigestAlgorithm {
// public static String SHA256 = "SHA256";
// }
//
// public static class KeyRegex {
// public static String MATCH_ALL = ".*";
// }
//
// public List<String> getBaseArgs() {
// List<String> arguments = new ArrayList<String>();
// Collections.addAll(arguments);
// return arguments;
// }
// }
// Path: sd-dss-util-cli/src/test/java/it/latraccia/dss/util/cli/test/unit/PKCS11PADESSuccessfulUnitTest.java
import it.latraccia.dss.util.cli.test.PADESSuccessfulGenericTest;
import it.latraccia.dss.util.cli.test.util.SignatureArgsHelper;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
/*
* SD-DSS-Util, a Utility Library and a Command Line Interface for SD-DSS.
* Copyright (C) 2013 La Traccia http://www.latraccia.it/en/
* Developed by Francesco Pontillo
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see [http://www.gnu.org/licenses/].
*/
package it.latraccia.dss.util.cli.test.unit;
@RunWith(value = Parameterized.class)
@Category(value = it.latraccia.dss.util.cli.test.unit.PKCS11UnitTest.class) | public class PKCS11PADESSuccessfulUnitTest extends PADESSuccessfulGenericTest { |
latraccia/sd-dss-util | sd-dss-util-cli/src/test/java/it/latraccia/dss/util/cli/test/unit/PKCS11PADESSuccessfulUnitTest.java | // Path: sd-dss-util-cli/src/test/java/it/latraccia/dss/util/cli/test/PADESSuccessfulGenericTest.java
// @RunWith(value = Parameterized.class)
// public abstract class PADESSuccessfulGenericTest extends SuccessfulGenericTest {
//
// public PADESSuccessfulGenericTest(String description, Object[] args) {
// super(description, args);
// }
//
// @Parameterized.Parameters
// public static Collection<Object[]> getSuccessfulTestParams() {
// final Object[][] params =
// {
// // PDF, BES, ENVELOPED
// {"PDF, BES, ENVELOPED", new String[] {
// SignatureArgsHelper.Input.PDF_FILE,
// "-u=" + SignatureArgsHelper.Url.DSS,
// "-f=" + SignatureArgsHelper.Format.PADES,
// "-l=" + SignatureArgsHelper.Level.BES,
// "-p=" + SignatureArgsHelper.Packaging.ENVELOPED,
// "-o=\"" + SignatureArgsHelper.Output.ROOT + "\"",
// "-d=" + SignatureArgsHelper.DigestAlgorithm.SHA256,
// "-icn=\"" + SignatureArgsHelper.KeyRegex.MATCH_ALL + "\""
// }},
// // PDF, EPES, ENVELOPED
// {"PDF, EPES, ENVELOPED", new String[] {
// SignatureArgsHelper.Input.PDF_FILE,
// "-u=" + SignatureArgsHelper.Url.DSS,
// "-f=" + SignatureArgsHelper.Format.PADES,
// "-l=" + SignatureArgsHelper.Level.EPES,
// "-p=" + SignatureArgsHelper.Packaging.ENVELOPED,
// "-o=\"" + SignatureArgsHelper.Output.ROOT + "\"",
// "-d=" + SignatureArgsHelper.DigestAlgorithm.SHA256,
// "-icn=\"" + SignatureArgsHelper.KeyRegex.MATCH_ALL + "\""
// }}
// };
//
// return Arrays.asList(params);
// }
// }
//
// Path: sd-dss-util-cli/src/test/java/it/latraccia/dss/util/cli/test/util/SignatureArgsHelper.java
// public class SignatureArgsHelper {
//
// private static String resourceRoot;
//
// static {
// resourceRoot = "";
// }
//
// // All possibilities to be tested are listed here, then they are combined together
//
// public static class Url {
// public static String DSS = "http://localhost:8080/service";
// }
//
// public static class Input {
// public static String PDF_FILE = getFile("pdf");
//
// public static String DOC_FILE = getFile("doc");
//
// public static String DOCX_FILE = getFile("docx");
//
// public static String ODT_FILE = getFile("odt");
//
// public static String XML_FILE = getFile("xml");
//
// private static String getFile(String extension) {
// return "test." + extension;
// }
// }
//
// public static class Output {
// public static String ROOT = resourceRoot;
// }
//
// public static class PKCS12 {
// public static String KEY = FileHelper.getResource("0F.p12");
//
// public static String PASSWORD = "password";
// }
//
// public static class PKCS11 {
// public static String LIBRARY = FileHelper.getResource("drivers/bit4ipki.dll");
//
// public static String PASSWORD = "16061981";
// }
//
// public static class Format {
// public static String CADES = "CAdES";
//
// public static String PADES = "PAdES";
//
// public static String XADES = "XAdES";
//
// public static String ASICS = "ASiC-S";
// }
//
// public static class Level {
// public static String BES = "BES";
//
// public static String EPES = "EPES";
//
// public static String LTV = "LTV";
//
// public static String T = "T";
//
// public static String C = "C";
//
// public static String X = "X";
//
// public static String XL = "XL";
//
// public static String A = "A";
// }
//
// public static class Packaging {
// public static String ENVELOPED = "ENVELOPED";
//
// public static String ENVELOPING = "ENVELOPING";
//
// public static String DETACHED = "DETACHED";
// }
//
// public static class DigestAlgorithm {
// public static String SHA256 = "SHA256";
// }
//
// public static class KeyRegex {
// public static String MATCH_ALL = ".*";
// }
//
// public List<String> getBaseArgs() {
// List<String> arguments = new ArrayList<String>();
// Collections.addAll(arguments);
// return arguments;
// }
// }
| import it.latraccia.dss.util.cli.test.PADESSuccessfulGenericTest;
import it.latraccia.dss.util.cli.test.util.SignatureArgsHelper;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized; | /*
* SD-DSS-Util, a Utility Library and a Command Line Interface for SD-DSS.
* Copyright (C) 2013 La Traccia http://www.latraccia.it/en/
* Developed by Francesco Pontillo
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see [http://www.gnu.org/licenses/].
*/
package it.latraccia.dss.util.cli.test.unit;
@RunWith(value = Parameterized.class)
@Category(value = it.latraccia.dss.util.cli.test.unit.PKCS11UnitTest.class)
public class PKCS11PADESSuccessfulUnitTest extends PADESSuccessfulGenericTest {
public PKCS11PADESSuccessfulUnitTest(String description, Object[] args) {
super(description, args);
}
@Override
public boolean getSimulate() {
return true;
}
@Override
public String[] getClassArgs() {
return new String[] { | // Path: sd-dss-util-cli/src/test/java/it/latraccia/dss/util/cli/test/PADESSuccessfulGenericTest.java
// @RunWith(value = Parameterized.class)
// public abstract class PADESSuccessfulGenericTest extends SuccessfulGenericTest {
//
// public PADESSuccessfulGenericTest(String description, Object[] args) {
// super(description, args);
// }
//
// @Parameterized.Parameters
// public static Collection<Object[]> getSuccessfulTestParams() {
// final Object[][] params =
// {
// // PDF, BES, ENVELOPED
// {"PDF, BES, ENVELOPED", new String[] {
// SignatureArgsHelper.Input.PDF_FILE,
// "-u=" + SignatureArgsHelper.Url.DSS,
// "-f=" + SignatureArgsHelper.Format.PADES,
// "-l=" + SignatureArgsHelper.Level.BES,
// "-p=" + SignatureArgsHelper.Packaging.ENVELOPED,
// "-o=\"" + SignatureArgsHelper.Output.ROOT + "\"",
// "-d=" + SignatureArgsHelper.DigestAlgorithm.SHA256,
// "-icn=\"" + SignatureArgsHelper.KeyRegex.MATCH_ALL + "\""
// }},
// // PDF, EPES, ENVELOPED
// {"PDF, EPES, ENVELOPED", new String[] {
// SignatureArgsHelper.Input.PDF_FILE,
// "-u=" + SignatureArgsHelper.Url.DSS,
// "-f=" + SignatureArgsHelper.Format.PADES,
// "-l=" + SignatureArgsHelper.Level.EPES,
// "-p=" + SignatureArgsHelper.Packaging.ENVELOPED,
// "-o=\"" + SignatureArgsHelper.Output.ROOT + "\"",
// "-d=" + SignatureArgsHelper.DigestAlgorithm.SHA256,
// "-icn=\"" + SignatureArgsHelper.KeyRegex.MATCH_ALL + "\""
// }}
// };
//
// return Arrays.asList(params);
// }
// }
//
// Path: sd-dss-util-cli/src/test/java/it/latraccia/dss/util/cli/test/util/SignatureArgsHelper.java
// public class SignatureArgsHelper {
//
// private static String resourceRoot;
//
// static {
// resourceRoot = "";
// }
//
// // All possibilities to be tested are listed here, then they are combined together
//
// public static class Url {
// public static String DSS = "http://localhost:8080/service";
// }
//
// public static class Input {
// public static String PDF_FILE = getFile("pdf");
//
// public static String DOC_FILE = getFile("doc");
//
// public static String DOCX_FILE = getFile("docx");
//
// public static String ODT_FILE = getFile("odt");
//
// public static String XML_FILE = getFile("xml");
//
// private static String getFile(String extension) {
// return "test." + extension;
// }
// }
//
// public static class Output {
// public static String ROOT = resourceRoot;
// }
//
// public static class PKCS12 {
// public static String KEY = FileHelper.getResource("0F.p12");
//
// public static String PASSWORD = "password";
// }
//
// public static class PKCS11 {
// public static String LIBRARY = FileHelper.getResource("drivers/bit4ipki.dll");
//
// public static String PASSWORD = "16061981";
// }
//
// public static class Format {
// public static String CADES = "CAdES";
//
// public static String PADES = "PAdES";
//
// public static String XADES = "XAdES";
//
// public static String ASICS = "ASiC-S";
// }
//
// public static class Level {
// public static String BES = "BES";
//
// public static String EPES = "EPES";
//
// public static String LTV = "LTV";
//
// public static String T = "T";
//
// public static String C = "C";
//
// public static String X = "X";
//
// public static String XL = "XL";
//
// public static String A = "A";
// }
//
// public static class Packaging {
// public static String ENVELOPED = "ENVELOPED";
//
// public static String ENVELOPING = "ENVELOPING";
//
// public static String DETACHED = "DETACHED";
// }
//
// public static class DigestAlgorithm {
// public static String SHA256 = "SHA256";
// }
//
// public static class KeyRegex {
// public static String MATCH_ALL = ".*";
// }
//
// public List<String> getBaseArgs() {
// List<String> arguments = new ArrayList<String>();
// Collections.addAll(arguments);
// return arguments;
// }
// }
// Path: sd-dss-util-cli/src/test/java/it/latraccia/dss/util/cli/test/unit/PKCS11PADESSuccessfulUnitTest.java
import it.latraccia.dss.util.cli.test.PADESSuccessfulGenericTest;
import it.latraccia.dss.util.cli.test.util.SignatureArgsHelper;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
/*
* SD-DSS-Util, a Utility Library and a Command Line Interface for SD-DSS.
* Copyright (C) 2013 La Traccia http://www.latraccia.it/en/
* Developed by Francesco Pontillo
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see [http://www.gnu.org/licenses/].
*/
package it.latraccia.dss.util.cli.test.unit;
@RunWith(value = Parameterized.class)
@Category(value = it.latraccia.dss.util.cli.test.unit.PKCS11UnitTest.class)
public class PKCS11PADESSuccessfulUnitTest extends PADESSuccessfulGenericTest {
public PKCS11PADESSuccessfulUnitTest(String description, Object[] args) {
super(description, args);
}
@Override
public boolean getSimulate() {
return true;
}
@Override
public String[] getClassArgs() {
return new String[] { | "-p11=\"" + SignatureArgsHelper.PKCS11.LIBRARY + "\"", |
latraccia/sd-dss-util | sd-dss-util-cli/src/test/java/it/latraccia/dss/util/cli/test/unit/PKCS12PADESSuccessfulUnitTest.java | // Path: sd-dss-util-cli/src/test/java/it/latraccia/dss/util/cli/test/PADESSuccessfulGenericTest.java
// @RunWith(value = Parameterized.class)
// public abstract class PADESSuccessfulGenericTest extends SuccessfulGenericTest {
//
// public PADESSuccessfulGenericTest(String description, Object[] args) {
// super(description, args);
// }
//
// @Parameterized.Parameters
// public static Collection<Object[]> getSuccessfulTestParams() {
// final Object[][] params =
// {
// // PDF, BES, ENVELOPED
// {"PDF, BES, ENVELOPED", new String[] {
// SignatureArgsHelper.Input.PDF_FILE,
// "-u=" + SignatureArgsHelper.Url.DSS,
// "-f=" + SignatureArgsHelper.Format.PADES,
// "-l=" + SignatureArgsHelper.Level.BES,
// "-p=" + SignatureArgsHelper.Packaging.ENVELOPED,
// "-o=\"" + SignatureArgsHelper.Output.ROOT + "\"",
// "-d=" + SignatureArgsHelper.DigestAlgorithm.SHA256,
// "-icn=\"" + SignatureArgsHelper.KeyRegex.MATCH_ALL + "\""
// }},
// // PDF, EPES, ENVELOPED
// {"PDF, EPES, ENVELOPED", new String[] {
// SignatureArgsHelper.Input.PDF_FILE,
// "-u=" + SignatureArgsHelper.Url.DSS,
// "-f=" + SignatureArgsHelper.Format.PADES,
// "-l=" + SignatureArgsHelper.Level.EPES,
// "-p=" + SignatureArgsHelper.Packaging.ENVELOPED,
// "-o=\"" + SignatureArgsHelper.Output.ROOT + "\"",
// "-d=" + SignatureArgsHelper.DigestAlgorithm.SHA256,
// "-icn=\"" + SignatureArgsHelper.KeyRegex.MATCH_ALL + "\""
// }}
// };
//
// return Arrays.asList(params);
// }
// }
//
// Path: sd-dss-util-cli/src/test/java/it/latraccia/dss/util/cli/test/util/SignatureArgsHelper.java
// public class SignatureArgsHelper {
//
// private static String resourceRoot;
//
// static {
// resourceRoot = "";
// }
//
// // All possibilities to be tested are listed here, then they are combined together
//
// public static class Url {
// public static String DSS = "http://localhost:8080/service";
// }
//
// public static class Input {
// public static String PDF_FILE = getFile("pdf");
//
// public static String DOC_FILE = getFile("doc");
//
// public static String DOCX_FILE = getFile("docx");
//
// public static String ODT_FILE = getFile("odt");
//
// public static String XML_FILE = getFile("xml");
//
// private static String getFile(String extension) {
// return "test." + extension;
// }
// }
//
// public static class Output {
// public static String ROOT = resourceRoot;
// }
//
// public static class PKCS12 {
// public static String KEY = FileHelper.getResource("0F.p12");
//
// public static String PASSWORD = "password";
// }
//
// public static class PKCS11 {
// public static String LIBRARY = FileHelper.getResource("drivers/bit4ipki.dll");
//
// public static String PASSWORD = "16061981";
// }
//
// public static class Format {
// public static String CADES = "CAdES";
//
// public static String PADES = "PAdES";
//
// public static String XADES = "XAdES";
//
// public static String ASICS = "ASiC-S";
// }
//
// public static class Level {
// public static String BES = "BES";
//
// public static String EPES = "EPES";
//
// public static String LTV = "LTV";
//
// public static String T = "T";
//
// public static String C = "C";
//
// public static String X = "X";
//
// public static String XL = "XL";
//
// public static String A = "A";
// }
//
// public static class Packaging {
// public static String ENVELOPED = "ENVELOPED";
//
// public static String ENVELOPING = "ENVELOPING";
//
// public static String DETACHED = "DETACHED";
// }
//
// public static class DigestAlgorithm {
// public static String SHA256 = "SHA256";
// }
//
// public static class KeyRegex {
// public static String MATCH_ALL = ".*";
// }
//
// public List<String> getBaseArgs() {
// List<String> arguments = new ArrayList<String>();
// Collections.addAll(arguments);
// return arguments;
// }
// }
| import it.latraccia.dss.util.cli.test.PADESSuccessfulGenericTest;
import it.latraccia.dss.util.cli.test.util.SignatureArgsHelper;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized; | /*
* SD-DSS-Util, a Utility Library and a Command Line Interface for SD-DSS.
* Copyright (C) 2013 La Traccia http://www.latraccia.it/en/
* Developed by Francesco Pontillo
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see [http://www.gnu.org/licenses/].
*/
package it.latraccia.dss.util.cli.test.unit;
@RunWith(value = Parameterized.class)
@Category(value = it.latraccia.dss.util.cli.test.unit.PKCS12UnitTest.class) | // Path: sd-dss-util-cli/src/test/java/it/latraccia/dss/util/cli/test/PADESSuccessfulGenericTest.java
// @RunWith(value = Parameterized.class)
// public abstract class PADESSuccessfulGenericTest extends SuccessfulGenericTest {
//
// public PADESSuccessfulGenericTest(String description, Object[] args) {
// super(description, args);
// }
//
// @Parameterized.Parameters
// public static Collection<Object[]> getSuccessfulTestParams() {
// final Object[][] params =
// {
// // PDF, BES, ENVELOPED
// {"PDF, BES, ENVELOPED", new String[] {
// SignatureArgsHelper.Input.PDF_FILE,
// "-u=" + SignatureArgsHelper.Url.DSS,
// "-f=" + SignatureArgsHelper.Format.PADES,
// "-l=" + SignatureArgsHelper.Level.BES,
// "-p=" + SignatureArgsHelper.Packaging.ENVELOPED,
// "-o=\"" + SignatureArgsHelper.Output.ROOT + "\"",
// "-d=" + SignatureArgsHelper.DigestAlgorithm.SHA256,
// "-icn=\"" + SignatureArgsHelper.KeyRegex.MATCH_ALL + "\""
// }},
// // PDF, EPES, ENVELOPED
// {"PDF, EPES, ENVELOPED", new String[] {
// SignatureArgsHelper.Input.PDF_FILE,
// "-u=" + SignatureArgsHelper.Url.DSS,
// "-f=" + SignatureArgsHelper.Format.PADES,
// "-l=" + SignatureArgsHelper.Level.EPES,
// "-p=" + SignatureArgsHelper.Packaging.ENVELOPED,
// "-o=\"" + SignatureArgsHelper.Output.ROOT + "\"",
// "-d=" + SignatureArgsHelper.DigestAlgorithm.SHA256,
// "-icn=\"" + SignatureArgsHelper.KeyRegex.MATCH_ALL + "\""
// }}
// };
//
// return Arrays.asList(params);
// }
// }
//
// Path: sd-dss-util-cli/src/test/java/it/latraccia/dss/util/cli/test/util/SignatureArgsHelper.java
// public class SignatureArgsHelper {
//
// private static String resourceRoot;
//
// static {
// resourceRoot = "";
// }
//
// // All possibilities to be tested are listed here, then they are combined together
//
// public static class Url {
// public static String DSS = "http://localhost:8080/service";
// }
//
// public static class Input {
// public static String PDF_FILE = getFile("pdf");
//
// public static String DOC_FILE = getFile("doc");
//
// public static String DOCX_FILE = getFile("docx");
//
// public static String ODT_FILE = getFile("odt");
//
// public static String XML_FILE = getFile("xml");
//
// private static String getFile(String extension) {
// return "test." + extension;
// }
// }
//
// public static class Output {
// public static String ROOT = resourceRoot;
// }
//
// public static class PKCS12 {
// public static String KEY = FileHelper.getResource("0F.p12");
//
// public static String PASSWORD = "password";
// }
//
// public static class PKCS11 {
// public static String LIBRARY = FileHelper.getResource("drivers/bit4ipki.dll");
//
// public static String PASSWORD = "16061981";
// }
//
// public static class Format {
// public static String CADES = "CAdES";
//
// public static String PADES = "PAdES";
//
// public static String XADES = "XAdES";
//
// public static String ASICS = "ASiC-S";
// }
//
// public static class Level {
// public static String BES = "BES";
//
// public static String EPES = "EPES";
//
// public static String LTV = "LTV";
//
// public static String T = "T";
//
// public static String C = "C";
//
// public static String X = "X";
//
// public static String XL = "XL";
//
// public static String A = "A";
// }
//
// public static class Packaging {
// public static String ENVELOPED = "ENVELOPED";
//
// public static String ENVELOPING = "ENVELOPING";
//
// public static String DETACHED = "DETACHED";
// }
//
// public static class DigestAlgorithm {
// public static String SHA256 = "SHA256";
// }
//
// public static class KeyRegex {
// public static String MATCH_ALL = ".*";
// }
//
// public List<String> getBaseArgs() {
// List<String> arguments = new ArrayList<String>();
// Collections.addAll(arguments);
// return arguments;
// }
// }
// Path: sd-dss-util-cli/src/test/java/it/latraccia/dss/util/cli/test/unit/PKCS12PADESSuccessfulUnitTest.java
import it.latraccia.dss.util.cli.test.PADESSuccessfulGenericTest;
import it.latraccia.dss.util.cli.test.util.SignatureArgsHelper;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
/*
* SD-DSS-Util, a Utility Library and a Command Line Interface for SD-DSS.
* Copyright (C) 2013 La Traccia http://www.latraccia.it/en/
* Developed by Francesco Pontillo
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see [http://www.gnu.org/licenses/].
*/
package it.latraccia.dss.util.cli.test.unit;
@RunWith(value = Parameterized.class)
@Category(value = it.latraccia.dss.util.cli.test.unit.PKCS12UnitTest.class) | public class PKCS12PADESSuccessfulUnitTest extends PADESSuccessfulGenericTest { |
latraccia/sd-dss-util | sd-dss-util-cli/src/test/java/it/latraccia/dss/util/cli/test/unit/PKCS12PADESSuccessfulUnitTest.java | // Path: sd-dss-util-cli/src/test/java/it/latraccia/dss/util/cli/test/PADESSuccessfulGenericTest.java
// @RunWith(value = Parameterized.class)
// public abstract class PADESSuccessfulGenericTest extends SuccessfulGenericTest {
//
// public PADESSuccessfulGenericTest(String description, Object[] args) {
// super(description, args);
// }
//
// @Parameterized.Parameters
// public static Collection<Object[]> getSuccessfulTestParams() {
// final Object[][] params =
// {
// // PDF, BES, ENVELOPED
// {"PDF, BES, ENVELOPED", new String[] {
// SignatureArgsHelper.Input.PDF_FILE,
// "-u=" + SignatureArgsHelper.Url.DSS,
// "-f=" + SignatureArgsHelper.Format.PADES,
// "-l=" + SignatureArgsHelper.Level.BES,
// "-p=" + SignatureArgsHelper.Packaging.ENVELOPED,
// "-o=\"" + SignatureArgsHelper.Output.ROOT + "\"",
// "-d=" + SignatureArgsHelper.DigestAlgorithm.SHA256,
// "-icn=\"" + SignatureArgsHelper.KeyRegex.MATCH_ALL + "\""
// }},
// // PDF, EPES, ENVELOPED
// {"PDF, EPES, ENVELOPED", new String[] {
// SignatureArgsHelper.Input.PDF_FILE,
// "-u=" + SignatureArgsHelper.Url.DSS,
// "-f=" + SignatureArgsHelper.Format.PADES,
// "-l=" + SignatureArgsHelper.Level.EPES,
// "-p=" + SignatureArgsHelper.Packaging.ENVELOPED,
// "-o=\"" + SignatureArgsHelper.Output.ROOT + "\"",
// "-d=" + SignatureArgsHelper.DigestAlgorithm.SHA256,
// "-icn=\"" + SignatureArgsHelper.KeyRegex.MATCH_ALL + "\""
// }}
// };
//
// return Arrays.asList(params);
// }
// }
//
// Path: sd-dss-util-cli/src/test/java/it/latraccia/dss/util/cli/test/util/SignatureArgsHelper.java
// public class SignatureArgsHelper {
//
// private static String resourceRoot;
//
// static {
// resourceRoot = "";
// }
//
// // All possibilities to be tested are listed here, then they are combined together
//
// public static class Url {
// public static String DSS = "http://localhost:8080/service";
// }
//
// public static class Input {
// public static String PDF_FILE = getFile("pdf");
//
// public static String DOC_FILE = getFile("doc");
//
// public static String DOCX_FILE = getFile("docx");
//
// public static String ODT_FILE = getFile("odt");
//
// public static String XML_FILE = getFile("xml");
//
// private static String getFile(String extension) {
// return "test." + extension;
// }
// }
//
// public static class Output {
// public static String ROOT = resourceRoot;
// }
//
// public static class PKCS12 {
// public static String KEY = FileHelper.getResource("0F.p12");
//
// public static String PASSWORD = "password";
// }
//
// public static class PKCS11 {
// public static String LIBRARY = FileHelper.getResource("drivers/bit4ipki.dll");
//
// public static String PASSWORD = "16061981";
// }
//
// public static class Format {
// public static String CADES = "CAdES";
//
// public static String PADES = "PAdES";
//
// public static String XADES = "XAdES";
//
// public static String ASICS = "ASiC-S";
// }
//
// public static class Level {
// public static String BES = "BES";
//
// public static String EPES = "EPES";
//
// public static String LTV = "LTV";
//
// public static String T = "T";
//
// public static String C = "C";
//
// public static String X = "X";
//
// public static String XL = "XL";
//
// public static String A = "A";
// }
//
// public static class Packaging {
// public static String ENVELOPED = "ENVELOPED";
//
// public static String ENVELOPING = "ENVELOPING";
//
// public static String DETACHED = "DETACHED";
// }
//
// public static class DigestAlgorithm {
// public static String SHA256 = "SHA256";
// }
//
// public static class KeyRegex {
// public static String MATCH_ALL = ".*";
// }
//
// public List<String> getBaseArgs() {
// List<String> arguments = new ArrayList<String>();
// Collections.addAll(arguments);
// return arguments;
// }
// }
| import it.latraccia.dss.util.cli.test.PADESSuccessfulGenericTest;
import it.latraccia.dss.util.cli.test.util.SignatureArgsHelper;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized; | /*
* SD-DSS-Util, a Utility Library and a Command Line Interface for SD-DSS.
* Copyright (C) 2013 La Traccia http://www.latraccia.it/en/
* Developed by Francesco Pontillo
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see [http://www.gnu.org/licenses/].
*/
package it.latraccia.dss.util.cli.test.unit;
@RunWith(value = Parameterized.class)
@Category(value = it.latraccia.dss.util.cli.test.unit.PKCS12UnitTest.class)
public class PKCS12PADESSuccessfulUnitTest extends PADESSuccessfulGenericTest {
public PKCS12PADESSuccessfulUnitTest(String description, Object[] args) {
super(description, args);
}
@Override
public boolean getSimulate() {
return true;
}
@Override
public String[] getClassArgs() {
return new String[] { | // Path: sd-dss-util-cli/src/test/java/it/latraccia/dss/util/cli/test/PADESSuccessfulGenericTest.java
// @RunWith(value = Parameterized.class)
// public abstract class PADESSuccessfulGenericTest extends SuccessfulGenericTest {
//
// public PADESSuccessfulGenericTest(String description, Object[] args) {
// super(description, args);
// }
//
// @Parameterized.Parameters
// public static Collection<Object[]> getSuccessfulTestParams() {
// final Object[][] params =
// {
// // PDF, BES, ENVELOPED
// {"PDF, BES, ENVELOPED", new String[] {
// SignatureArgsHelper.Input.PDF_FILE,
// "-u=" + SignatureArgsHelper.Url.DSS,
// "-f=" + SignatureArgsHelper.Format.PADES,
// "-l=" + SignatureArgsHelper.Level.BES,
// "-p=" + SignatureArgsHelper.Packaging.ENVELOPED,
// "-o=\"" + SignatureArgsHelper.Output.ROOT + "\"",
// "-d=" + SignatureArgsHelper.DigestAlgorithm.SHA256,
// "-icn=\"" + SignatureArgsHelper.KeyRegex.MATCH_ALL + "\""
// }},
// // PDF, EPES, ENVELOPED
// {"PDF, EPES, ENVELOPED", new String[] {
// SignatureArgsHelper.Input.PDF_FILE,
// "-u=" + SignatureArgsHelper.Url.DSS,
// "-f=" + SignatureArgsHelper.Format.PADES,
// "-l=" + SignatureArgsHelper.Level.EPES,
// "-p=" + SignatureArgsHelper.Packaging.ENVELOPED,
// "-o=\"" + SignatureArgsHelper.Output.ROOT + "\"",
// "-d=" + SignatureArgsHelper.DigestAlgorithm.SHA256,
// "-icn=\"" + SignatureArgsHelper.KeyRegex.MATCH_ALL + "\""
// }}
// };
//
// return Arrays.asList(params);
// }
// }
//
// Path: sd-dss-util-cli/src/test/java/it/latraccia/dss/util/cli/test/util/SignatureArgsHelper.java
// public class SignatureArgsHelper {
//
// private static String resourceRoot;
//
// static {
// resourceRoot = "";
// }
//
// // All possibilities to be tested are listed here, then they are combined together
//
// public static class Url {
// public static String DSS = "http://localhost:8080/service";
// }
//
// public static class Input {
// public static String PDF_FILE = getFile("pdf");
//
// public static String DOC_FILE = getFile("doc");
//
// public static String DOCX_FILE = getFile("docx");
//
// public static String ODT_FILE = getFile("odt");
//
// public static String XML_FILE = getFile("xml");
//
// private static String getFile(String extension) {
// return "test." + extension;
// }
// }
//
// public static class Output {
// public static String ROOT = resourceRoot;
// }
//
// public static class PKCS12 {
// public static String KEY = FileHelper.getResource("0F.p12");
//
// public static String PASSWORD = "password";
// }
//
// public static class PKCS11 {
// public static String LIBRARY = FileHelper.getResource("drivers/bit4ipki.dll");
//
// public static String PASSWORD = "16061981";
// }
//
// public static class Format {
// public static String CADES = "CAdES";
//
// public static String PADES = "PAdES";
//
// public static String XADES = "XAdES";
//
// public static String ASICS = "ASiC-S";
// }
//
// public static class Level {
// public static String BES = "BES";
//
// public static String EPES = "EPES";
//
// public static String LTV = "LTV";
//
// public static String T = "T";
//
// public static String C = "C";
//
// public static String X = "X";
//
// public static String XL = "XL";
//
// public static String A = "A";
// }
//
// public static class Packaging {
// public static String ENVELOPED = "ENVELOPED";
//
// public static String ENVELOPING = "ENVELOPING";
//
// public static String DETACHED = "DETACHED";
// }
//
// public static class DigestAlgorithm {
// public static String SHA256 = "SHA256";
// }
//
// public static class KeyRegex {
// public static String MATCH_ALL = ".*";
// }
//
// public List<String> getBaseArgs() {
// List<String> arguments = new ArrayList<String>();
// Collections.addAll(arguments);
// return arguments;
// }
// }
// Path: sd-dss-util-cli/src/test/java/it/latraccia/dss/util/cli/test/unit/PKCS12PADESSuccessfulUnitTest.java
import it.latraccia.dss.util.cli.test.PADESSuccessfulGenericTest;
import it.latraccia.dss.util.cli.test.util.SignatureArgsHelper;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
/*
* SD-DSS-Util, a Utility Library and a Command Line Interface for SD-DSS.
* Copyright (C) 2013 La Traccia http://www.latraccia.it/en/
* Developed by Francesco Pontillo
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see [http://www.gnu.org/licenses/].
*/
package it.latraccia.dss.util.cli.test.unit;
@RunWith(value = Parameterized.class)
@Category(value = it.latraccia.dss.util.cli.test.unit.PKCS12UnitTest.class)
public class PKCS12PADESSuccessfulUnitTest extends PADESSuccessfulGenericTest {
public PKCS12PADESSuccessfulUnitTest(String description, Object[] args) {
super(description, args);
}
@Override
public boolean getSimulate() {
return true;
}
@Override
public String[] getClassArgs() {
return new String[] { | "-p12=\"" + SignatureArgsHelper.PKCS12.KEY + "\"", |
latraccia/sd-dss-util | sd-dss-util-cli/src/main/java/it/latraccia/dss/util/cli/argument/converter/DigestAlgorithmConverter.java | // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/util/AssertHelper.java
// public class AssertHelper {
// public static boolean stringMustEqual(String what, String string, String equalToThis) {
// if (!(string == null && equalToThis == null)
// || !string.equals(equalToThis)) {
// System.err.println(String.format("The %s has to be \"%s\" instead of \"%s\"",
// what, equalToThis, string));
// return false;
// }
// return true;
// }
//
// public static boolean stringMustNotEqual(String what, String string, String notEqualToThis) {
// if ((string == null && notEqualToThis == null)
// || string.equals(notEqualToThis)) {
// System.err.println(String.format("The %s has to be different than \"%s\" so it can't be \"%s\"",
// what, notEqualToThis, string));
// return false;
// }
// return true;
// }
//
// public static boolean stringMustBeInList(String what, String string, String[] list) {
// if (Util.isNullOrEmpty(string)) {
// System.err.println(String.format("The %s must be defined.", what));
// return false;
// }
//
// if (!isStringInList(string, list)) {System.err.println(String.format(
// "The %s can't be \"%s\". It must be one of \"%s\"",
// what, string,
// stringifyStringArray(list)));
// return false;
// }
//
// return true;
// }
//
// /**
// * Check if a {@link String} is in a {@link String} array.
// *
// * @param string The {@link String} to look for
// * @param list The array of {@link String}s to search in
// * @return true, if the {@link String} exists, false otherwise
// */
// public static boolean isStringInList(String string, String[] list) {
// if (Util.isNullOrEmpty(string)) {
// return false;
// }
//
// if (list != null) {
// for (String s : list) {
// if (s.equalsIgnoreCase(string)) {
// return true;
// }
// }
// }
//
// return false;
// }
//
// public static boolean packageMustBeInList(String what, SignaturePackaging packaging, SignaturePackaging[] list) {
// if (list != null) {
// for (SignaturePackaging e : list) {
// if (e == packaging) {
// return true;
// }
// }
// }
//
// HashMap<SignaturePackaging, String> packagingMap = new HashMap<SignaturePackaging, String>();
// packagingMap.put(SignaturePackaging.DETACHED, "DETACHED");
// packagingMap.put(SignaturePackaging.ENVELOPING, "ENVELOPING");
// packagingMap.put(SignaturePackaging.ENVELOPED, "ENVELOPED");
//
// String[] valuesArray = new String[0];
// valuesArray = packagingMap.values().toArray(valuesArray);
// System.err.println(String.format(
// "The %s can't be \"%s\". It must be one of \"%s\"",
// what,
// packagingMap.get(packaging),
// stringifySignaturePackagingArray(list)));
// return false;
// }
//
// public static String stringifyStringArray(String[] list) {
// String stringified = "";
// for (String s : list) {
// stringified += s + ", ";
// }
// stringified = stringified.substring(0, stringified.length() - 2);
// return stringified;
// }
//
// public static String stringifySignaturePackagingArray(SignaturePackaging[] list) {
// String[] stringList = new String[list.length];
// for (int i = 0; i < list.length; i++) {
// stringList[i] = list[i].name();
// }
// return stringifyStringArray(stringList);
// }
// }
| import it.latraccia.dss.util.util.AssertHelper;
import com.beust.jcommander.IStringConverter;
import com.beust.jcommander.ParameterException;
import eu.europa.ec.markt.dss.DigestAlgorithm; | /*
* SD-DSS-Util, a Utility Library and a Command Line Interface for SD-DSS.
* Copyright (C) 2013 La Traccia http://www.latraccia.it/en/
* Developed by Francesco Pontillo
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see [http://www.gnu.org/licenses/].
*/
package it.latraccia.dss.util.cli.argument.converter;
public class DigestAlgorithmConverter implements IStringConverter<DigestAlgorithm> {
@Override
public DigestAlgorithm convert(String s) { | // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/util/AssertHelper.java
// public class AssertHelper {
// public static boolean stringMustEqual(String what, String string, String equalToThis) {
// if (!(string == null && equalToThis == null)
// || !string.equals(equalToThis)) {
// System.err.println(String.format("The %s has to be \"%s\" instead of \"%s\"",
// what, equalToThis, string));
// return false;
// }
// return true;
// }
//
// public static boolean stringMustNotEqual(String what, String string, String notEqualToThis) {
// if ((string == null && notEqualToThis == null)
// || string.equals(notEqualToThis)) {
// System.err.println(String.format("The %s has to be different than \"%s\" so it can't be \"%s\"",
// what, notEqualToThis, string));
// return false;
// }
// return true;
// }
//
// public static boolean stringMustBeInList(String what, String string, String[] list) {
// if (Util.isNullOrEmpty(string)) {
// System.err.println(String.format("The %s must be defined.", what));
// return false;
// }
//
// if (!isStringInList(string, list)) {System.err.println(String.format(
// "The %s can't be \"%s\". It must be one of \"%s\"",
// what, string,
// stringifyStringArray(list)));
// return false;
// }
//
// return true;
// }
//
// /**
// * Check if a {@link String} is in a {@link String} array.
// *
// * @param string The {@link String} to look for
// * @param list The array of {@link String}s to search in
// * @return true, if the {@link String} exists, false otherwise
// */
// public static boolean isStringInList(String string, String[] list) {
// if (Util.isNullOrEmpty(string)) {
// return false;
// }
//
// if (list != null) {
// for (String s : list) {
// if (s.equalsIgnoreCase(string)) {
// return true;
// }
// }
// }
//
// return false;
// }
//
// public static boolean packageMustBeInList(String what, SignaturePackaging packaging, SignaturePackaging[] list) {
// if (list != null) {
// for (SignaturePackaging e : list) {
// if (e == packaging) {
// return true;
// }
// }
// }
//
// HashMap<SignaturePackaging, String> packagingMap = new HashMap<SignaturePackaging, String>();
// packagingMap.put(SignaturePackaging.DETACHED, "DETACHED");
// packagingMap.put(SignaturePackaging.ENVELOPING, "ENVELOPING");
// packagingMap.put(SignaturePackaging.ENVELOPED, "ENVELOPED");
//
// String[] valuesArray = new String[0];
// valuesArray = packagingMap.values().toArray(valuesArray);
// System.err.println(String.format(
// "The %s can't be \"%s\". It must be one of \"%s\"",
// what,
// packagingMap.get(packaging),
// stringifySignaturePackagingArray(list)));
// return false;
// }
//
// public static String stringifyStringArray(String[] list) {
// String stringified = "";
// for (String s : list) {
// stringified += s + ", ";
// }
// stringified = stringified.substring(0, stringified.length() - 2);
// return stringified;
// }
//
// public static String stringifySignaturePackagingArray(SignaturePackaging[] list) {
// String[] stringList = new String[list.length];
// for (int i = 0; i < list.length; i++) {
// stringList[i] = list[i].name();
// }
// return stringifyStringArray(stringList);
// }
// }
// Path: sd-dss-util-cli/src/main/java/it/latraccia/dss/util/cli/argument/converter/DigestAlgorithmConverter.java
import it.latraccia.dss.util.util.AssertHelper;
import com.beust.jcommander.IStringConverter;
import com.beust.jcommander.ParameterException;
import eu.europa.ec.markt.dss.DigestAlgorithm;
/*
* SD-DSS-Util, a Utility Library and a Command Line Interface for SD-DSS.
* Copyright (C) 2013 La Traccia http://www.latraccia.it/en/
* Developed by Francesco Pontillo
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see [http://www.gnu.org/licenses/].
*/
package it.latraccia.dss.util.cli.argument.converter;
public class DigestAlgorithmConverter implements IStringConverter<DigestAlgorithm> {
@Override
public DigestAlgorithm convert(String s) { | if (!AssertHelper.stringMustBeInList("digest algorithm", s, new String[] {"SHA1", "SHA256", "SHA512"})) { |
latraccia/sd-dss-util | sd-dss-util-cli/src/main/java/it/latraccia/dss/util/cli/argument/converter/PackagingConverter.java | // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/util/AssertHelper.java
// public class AssertHelper {
// public static boolean stringMustEqual(String what, String string, String equalToThis) {
// if (!(string == null && equalToThis == null)
// || !string.equals(equalToThis)) {
// System.err.println(String.format("The %s has to be \"%s\" instead of \"%s\"",
// what, equalToThis, string));
// return false;
// }
// return true;
// }
//
// public static boolean stringMustNotEqual(String what, String string, String notEqualToThis) {
// if ((string == null && notEqualToThis == null)
// || string.equals(notEqualToThis)) {
// System.err.println(String.format("The %s has to be different than \"%s\" so it can't be \"%s\"",
// what, notEqualToThis, string));
// return false;
// }
// return true;
// }
//
// public static boolean stringMustBeInList(String what, String string, String[] list) {
// if (Util.isNullOrEmpty(string)) {
// System.err.println(String.format("The %s must be defined.", what));
// return false;
// }
//
// if (!isStringInList(string, list)) {System.err.println(String.format(
// "The %s can't be \"%s\". It must be one of \"%s\"",
// what, string,
// stringifyStringArray(list)));
// return false;
// }
//
// return true;
// }
//
// /**
// * Check if a {@link String} is in a {@link String} array.
// *
// * @param string The {@link String} to look for
// * @param list The array of {@link String}s to search in
// * @return true, if the {@link String} exists, false otherwise
// */
// public static boolean isStringInList(String string, String[] list) {
// if (Util.isNullOrEmpty(string)) {
// return false;
// }
//
// if (list != null) {
// for (String s : list) {
// if (s.equalsIgnoreCase(string)) {
// return true;
// }
// }
// }
//
// return false;
// }
//
// public static boolean packageMustBeInList(String what, SignaturePackaging packaging, SignaturePackaging[] list) {
// if (list != null) {
// for (SignaturePackaging e : list) {
// if (e == packaging) {
// return true;
// }
// }
// }
//
// HashMap<SignaturePackaging, String> packagingMap = new HashMap<SignaturePackaging, String>();
// packagingMap.put(SignaturePackaging.DETACHED, "DETACHED");
// packagingMap.put(SignaturePackaging.ENVELOPING, "ENVELOPING");
// packagingMap.put(SignaturePackaging.ENVELOPED, "ENVELOPED");
//
// String[] valuesArray = new String[0];
// valuesArray = packagingMap.values().toArray(valuesArray);
// System.err.println(String.format(
// "The %s can't be \"%s\". It must be one of \"%s\"",
// what,
// packagingMap.get(packaging),
// stringifySignaturePackagingArray(list)));
// return false;
// }
//
// public static String stringifyStringArray(String[] list) {
// String stringified = "";
// for (String s : list) {
// stringified += s + ", ";
// }
// stringified = stringified.substring(0, stringified.length() - 2);
// return stringified;
// }
//
// public static String stringifySignaturePackagingArray(SignaturePackaging[] list) {
// String[] stringList = new String[list.length];
// for (int i = 0; i < list.length; i++) {
// stringList[i] = list[i].name();
// }
// return stringifyStringArray(stringList);
// }
// }
| import it.latraccia.dss.util.util.AssertHelper;
import com.beust.jcommander.IStringConverter;
import com.beust.jcommander.ParameterException;
import eu.europa.ec.markt.dss.signature.SignaturePackaging; | /*
* SD-DSS-Util, a Utility Library and a Command Line Interface for SD-DSS.
* Copyright (C) 2013 La Traccia http://www.latraccia.it/en/
* Developed by Francesco Pontillo
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see [http://www.gnu.org/licenses/].
*/
package it.latraccia.dss.util.cli.argument.converter;
public class PackagingConverter implements IStringConverter<SignaturePackaging> {
@Override
public SignaturePackaging convert(String s) { | // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/util/AssertHelper.java
// public class AssertHelper {
// public static boolean stringMustEqual(String what, String string, String equalToThis) {
// if (!(string == null && equalToThis == null)
// || !string.equals(equalToThis)) {
// System.err.println(String.format("The %s has to be \"%s\" instead of \"%s\"",
// what, equalToThis, string));
// return false;
// }
// return true;
// }
//
// public static boolean stringMustNotEqual(String what, String string, String notEqualToThis) {
// if ((string == null && notEqualToThis == null)
// || string.equals(notEqualToThis)) {
// System.err.println(String.format("The %s has to be different than \"%s\" so it can't be \"%s\"",
// what, notEqualToThis, string));
// return false;
// }
// return true;
// }
//
// public static boolean stringMustBeInList(String what, String string, String[] list) {
// if (Util.isNullOrEmpty(string)) {
// System.err.println(String.format("The %s must be defined.", what));
// return false;
// }
//
// if (!isStringInList(string, list)) {System.err.println(String.format(
// "The %s can't be \"%s\". It must be one of \"%s\"",
// what, string,
// stringifyStringArray(list)));
// return false;
// }
//
// return true;
// }
//
// /**
// * Check if a {@link String} is in a {@link String} array.
// *
// * @param string The {@link String} to look for
// * @param list The array of {@link String}s to search in
// * @return true, if the {@link String} exists, false otherwise
// */
// public static boolean isStringInList(String string, String[] list) {
// if (Util.isNullOrEmpty(string)) {
// return false;
// }
//
// if (list != null) {
// for (String s : list) {
// if (s.equalsIgnoreCase(string)) {
// return true;
// }
// }
// }
//
// return false;
// }
//
// public static boolean packageMustBeInList(String what, SignaturePackaging packaging, SignaturePackaging[] list) {
// if (list != null) {
// for (SignaturePackaging e : list) {
// if (e == packaging) {
// return true;
// }
// }
// }
//
// HashMap<SignaturePackaging, String> packagingMap = new HashMap<SignaturePackaging, String>();
// packagingMap.put(SignaturePackaging.DETACHED, "DETACHED");
// packagingMap.put(SignaturePackaging.ENVELOPING, "ENVELOPING");
// packagingMap.put(SignaturePackaging.ENVELOPED, "ENVELOPED");
//
// String[] valuesArray = new String[0];
// valuesArray = packagingMap.values().toArray(valuesArray);
// System.err.println(String.format(
// "The %s can't be \"%s\". It must be one of \"%s\"",
// what,
// packagingMap.get(packaging),
// stringifySignaturePackagingArray(list)));
// return false;
// }
//
// public static String stringifyStringArray(String[] list) {
// String stringified = "";
// for (String s : list) {
// stringified += s + ", ";
// }
// stringified = stringified.substring(0, stringified.length() - 2);
// return stringified;
// }
//
// public static String stringifySignaturePackagingArray(SignaturePackaging[] list) {
// String[] stringList = new String[list.length];
// for (int i = 0; i < list.length; i++) {
// stringList[i] = list[i].name();
// }
// return stringifyStringArray(stringList);
// }
// }
// Path: sd-dss-util-cli/src/main/java/it/latraccia/dss/util/cli/argument/converter/PackagingConverter.java
import it.latraccia.dss.util.util.AssertHelper;
import com.beust.jcommander.IStringConverter;
import com.beust.jcommander.ParameterException;
import eu.europa.ec.markt.dss.signature.SignaturePackaging;
/*
* SD-DSS-Util, a Utility Library and a Command Line Interface for SD-DSS.
* Copyright (C) 2013 La Traccia http://www.latraccia.it/en/
* Developed by Francesco Pontillo
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see [http://www.gnu.org/licenses/].
*/
package it.latraccia.dss.util.cli.argument.converter;
public class PackagingConverter implements IStringConverter<SignaturePackaging> {
@Override
public SignaturePackaging convert(String s) { | if (!AssertHelper.stringMustBeInList("signature packaging", s, new String[]{"ENVELOPED", "ENVELOPING", "DETACHED"})) { |
latraccia/sd-dss-util | sd-dss-util-lib/src/main/java/it/latraccia/dss/util/builder/format/PAdESFormatBuilder.java | // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/format/SignatureFormat.java
// public class SignatureFormat extends GeneralEnum {
// public static final String XAdES_NAME = "XAdES";
// public static final String CAdES_NAME = "CAdES";
// public static final String PAdES_NAME = "PAdES";
//
// public static final SignatureFormat XAdES = new SignatureXAdESFormat(XAdES_NAME);
// public static final SignatureFormat CAdES = new SignatureCAdESFormat(CAdES_NAME);
// public static final SignatureFormat PAdES = new SignaturePAdESFormat(PAdES_NAME);
//
// public SignatureFormat(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/format/SignaturePAdESFormat.java
// public class SignaturePAdESFormat extends SignatureFormat {
// public SignaturePAdESFormat(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/level/SignaturePAdESLevel.java
// public class SignaturePAdESLevel extends SignatureLevel {
// public static SignaturePAdESLevel BES = new SignaturePAdESLevel(SignatureLevel.BES);
// public static SignaturePAdESLevel EPES = new SignaturePAdESLevel(SignatureLevel.EPES);
// public static SignaturePAdESLevel LTV = new SignaturePAdESLevel(SignatureLevel.LTV);
//
// public SignaturePAdESLevel(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/packaging/SignaturePAdESPackaging.java
// public class SignaturePAdESPackaging extends SignaturePackaging {
// public static SignaturePAdESPackaging ENVELOPED = new SignaturePAdESPackaging(SignaturePackaging.ENVELOPED);
//
// public SignaturePAdESPackaging(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/exception/SignatureServiceUrlException.java
// public class SignatureServiceUrlException extends SignatureException {
// public SignatureServiceUrlException() {
// }
// public SignatureServiceUrlException(Exception e) {
// super(e);
// }
//
// @Override
// public String getMessage() {
// return "The service URL was required but not specified!";
// }
// }
| import it.latraccia.dss.util.entity.format.SignatureFormat;
import it.latraccia.dss.util.entity.format.SignaturePAdESFormat;
import it.latraccia.dss.util.entity.level.SignaturePAdESLevel;
import it.latraccia.dss.util.entity.packaging.SignaturePAdESPackaging;
import it.latraccia.dss.util.exception.SignatureServiceUrlException; | /*
* SD-DSS-Util, a Utility Library and a Command Line Interface for SD-DSS.
* Copyright (C) 2013 La Traccia http://www.latraccia.it/en/
* Developed by Francesco Pontillo
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see [http://www.gnu.org/licenses/].
*/
package it.latraccia.dss.util.builder.format;
/**
* Date: 06/12/13
* Time: 11.10
*
* @author Francesco Pontillo
*/
public class PAdESFormatBuilder extends FormatBuilder<SignaturePAdESFormat> {
// FORMAT
public PAdESFormatBuilder() { | // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/format/SignatureFormat.java
// public class SignatureFormat extends GeneralEnum {
// public static final String XAdES_NAME = "XAdES";
// public static final String CAdES_NAME = "CAdES";
// public static final String PAdES_NAME = "PAdES";
//
// public static final SignatureFormat XAdES = new SignatureXAdESFormat(XAdES_NAME);
// public static final SignatureFormat CAdES = new SignatureCAdESFormat(CAdES_NAME);
// public static final SignatureFormat PAdES = new SignaturePAdESFormat(PAdES_NAME);
//
// public SignatureFormat(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/format/SignaturePAdESFormat.java
// public class SignaturePAdESFormat extends SignatureFormat {
// public SignaturePAdESFormat(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/level/SignaturePAdESLevel.java
// public class SignaturePAdESLevel extends SignatureLevel {
// public static SignaturePAdESLevel BES = new SignaturePAdESLevel(SignatureLevel.BES);
// public static SignaturePAdESLevel EPES = new SignaturePAdESLevel(SignatureLevel.EPES);
// public static SignaturePAdESLevel LTV = new SignaturePAdESLevel(SignatureLevel.LTV);
//
// public SignaturePAdESLevel(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/packaging/SignaturePAdESPackaging.java
// public class SignaturePAdESPackaging extends SignaturePackaging {
// public static SignaturePAdESPackaging ENVELOPED = new SignaturePAdESPackaging(SignaturePackaging.ENVELOPED);
//
// public SignaturePAdESPackaging(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/exception/SignatureServiceUrlException.java
// public class SignatureServiceUrlException extends SignatureException {
// public SignatureServiceUrlException() {
// }
// public SignatureServiceUrlException(Exception e) {
// super(e);
// }
//
// @Override
// public String getMessage() {
// return "The service URL was required but not specified!";
// }
// }
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/builder/format/PAdESFormatBuilder.java
import it.latraccia.dss.util.entity.format.SignatureFormat;
import it.latraccia.dss.util.entity.format.SignaturePAdESFormat;
import it.latraccia.dss.util.entity.level.SignaturePAdESLevel;
import it.latraccia.dss.util.entity.packaging.SignaturePAdESPackaging;
import it.latraccia.dss.util.exception.SignatureServiceUrlException;
/*
* SD-DSS-Util, a Utility Library and a Command Line Interface for SD-DSS.
* Copyright (C) 2013 La Traccia http://www.latraccia.it/en/
* Developed by Francesco Pontillo
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see [http://www.gnu.org/licenses/].
*/
package it.latraccia.dss.util.builder.format;
/**
* Date: 06/12/13
* Time: 11.10
*
* @author Francesco Pontillo
*/
public class PAdESFormatBuilder extends FormatBuilder<SignaturePAdESFormat> {
// FORMAT
public PAdESFormatBuilder() { | setFormat(SignatureFormat.PAdES); |
latraccia/sd-dss-util | sd-dss-util-lib/src/main/java/it/latraccia/dss/util/builder/format/PAdESFormatBuilder.java | // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/format/SignatureFormat.java
// public class SignatureFormat extends GeneralEnum {
// public static final String XAdES_NAME = "XAdES";
// public static final String CAdES_NAME = "CAdES";
// public static final String PAdES_NAME = "PAdES";
//
// public static final SignatureFormat XAdES = new SignatureXAdESFormat(XAdES_NAME);
// public static final SignatureFormat CAdES = new SignatureCAdESFormat(CAdES_NAME);
// public static final SignatureFormat PAdES = new SignaturePAdESFormat(PAdES_NAME);
//
// public SignatureFormat(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/format/SignaturePAdESFormat.java
// public class SignaturePAdESFormat extends SignatureFormat {
// public SignaturePAdESFormat(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/level/SignaturePAdESLevel.java
// public class SignaturePAdESLevel extends SignatureLevel {
// public static SignaturePAdESLevel BES = new SignaturePAdESLevel(SignatureLevel.BES);
// public static SignaturePAdESLevel EPES = new SignaturePAdESLevel(SignatureLevel.EPES);
// public static SignaturePAdESLevel LTV = new SignaturePAdESLevel(SignatureLevel.LTV);
//
// public SignaturePAdESLevel(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/packaging/SignaturePAdESPackaging.java
// public class SignaturePAdESPackaging extends SignaturePackaging {
// public static SignaturePAdESPackaging ENVELOPED = new SignaturePAdESPackaging(SignaturePackaging.ENVELOPED);
//
// public SignaturePAdESPackaging(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/exception/SignatureServiceUrlException.java
// public class SignatureServiceUrlException extends SignatureException {
// public SignatureServiceUrlException() {
// }
// public SignatureServiceUrlException(Exception e) {
// super(e);
// }
//
// @Override
// public String getMessage() {
// return "The service URL was required but not specified!";
// }
// }
| import it.latraccia.dss.util.entity.format.SignatureFormat;
import it.latraccia.dss.util.entity.format.SignaturePAdESFormat;
import it.latraccia.dss.util.entity.level.SignaturePAdESLevel;
import it.latraccia.dss.util.entity.packaging.SignaturePAdESPackaging;
import it.latraccia.dss.util.exception.SignatureServiceUrlException; | /*
* SD-DSS-Util, a Utility Library and a Command Line Interface for SD-DSS.
* Copyright (C) 2013 La Traccia http://www.latraccia.it/en/
* Developed by Francesco Pontillo
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see [http://www.gnu.org/licenses/].
*/
package it.latraccia.dss.util.builder.format;
/**
* Date: 06/12/13
* Time: 11.10
*
* @author Francesco Pontillo
*/
public class PAdESFormatBuilder extends FormatBuilder<SignaturePAdESFormat> {
// FORMAT
public PAdESFormatBuilder() {
setFormat(SignatureFormat.PAdES);
}
// LEVEL
| // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/format/SignatureFormat.java
// public class SignatureFormat extends GeneralEnum {
// public static final String XAdES_NAME = "XAdES";
// public static final String CAdES_NAME = "CAdES";
// public static final String PAdES_NAME = "PAdES";
//
// public static final SignatureFormat XAdES = new SignatureXAdESFormat(XAdES_NAME);
// public static final SignatureFormat CAdES = new SignatureCAdESFormat(CAdES_NAME);
// public static final SignatureFormat PAdES = new SignaturePAdESFormat(PAdES_NAME);
//
// public SignatureFormat(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/format/SignaturePAdESFormat.java
// public class SignaturePAdESFormat extends SignatureFormat {
// public SignaturePAdESFormat(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/level/SignaturePAdESLevel.java
// public class SignaturePAdESLevel extends SignatureLevel {
// public static SignaturePAdESLevel BES = new SignaturePAdESLevel(SignatureLevel.BES);
// public static SignaturePAdESLevel EPES = new SignaturePAdESLevel(SignatureLevel.EPES);
// public static SignaturePAdESLevel LTV = new SignaturePAdESLevel(SignatureLevel.LTV);
//
// public SignaturePAdESLevel(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/packaging/SignaturePAdESPackaging.java
// public class SignaturePAdESPackaging extends SignaturePackaging {
// public static SignaturePAdESPackaging ENVELOPED = new SignaturePAdESPackaging(SignaturePackaging.ENVELOPED);
//
// public SignaturePAdESPackaging(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/exception/SignatureServiceUrlException.java
// public class SignatureServiceUrlException extends SignatureException {
// public SignatureServiceUrlException() {
// }
// public SignatureServiceUrlException(Exception e) {
// super(e);
// }
//
// @Override
// public String getMessage() {
// return "The service URL was required but not specified!";
// }
// }
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/builder/format/PAdESFormatBuilder.java
import it.latraccia.dss.util.entity.format.SignatureFormat;
import it.latraccia.dss.util.entity.format.SignaturePAdESFormat;
import it.latraccia.dss.util.entity.level.SignaturePAdESLevel;
import it.latraccia.dss.util.entity.packaging.SignaturePAdESPackaging;
import it.latraccia.dss.util.exception.SignatureServiceUrlException;
/*
* SD-DSS-Util, a Utility Library and a Command Line Interface for SD-DSS.
* Copyright (C) 2013 La Traccia http://www.latraccia.it/en/
* Developed by Francesco Pontillo
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see [http://www.gnu.org/licenses/].
*/
package it.latraccia.dss.util.builder.format;
/**
* Date: 06/12/13
* Time: 11.10
*
* @author Francesco Pontillo
*/
public class PAdESFormatBuilder extends FormatBuilder<SignaturePAdESFormat> {
// FORMAT
public PAdESFormatBuilder() {
setFormat(SignatureFormat.PAdES);
}
// LEVEL
| public PAdESFormatBuilder BES(String serviceUrl) throws SignatureServiceUrlException { |
latraccia/sd-dss-util | sd-dss-util-lib/src/main/java/it/latraccia/dss/util/builder/format/PAdESFormatBuilder.java | // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/format/SignatureFormat.java
// public class SignatureFormat extends GeneralEnum {
// public static final String XAdES_NAME = "XAdES";
// public static final String CAdES_NAME = "CAdES";
// public static final String PAdES_NAME = "PAdES";
//
// public static final SignatureFormat XAdES = new SignatureXAdESFormat(XAdES_NAME);
// public static final SignatureFormat CAdES = new SignatureCAdESFormat(CAdES_NAME);
// public static final SignatureFormat PAdES = new SignaturePAdESFormat(PAdES_NAME);
//
// public SignatureFormat(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/format/SignaturePAdESFormat.java
// public class SignaturePAdESFormat extends SignatureFormat {
// public SignaturePAdESFormat(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/level/SignaturePAdESLevel.java
// public class SignaturePAdESLevel extends SignatureLevel {
// public static SignaturePAdESLevel BES = new SignaturePAdESLevel(SignatureLevel.BES);
// public static SignaturePAdESLevel EPES = new SignaturePAdESLevel(SignatureLevel.EPES);
// public static SignaturePAdESLevel LTV = new SignaturePAdESLevel(SignatureLevel.LTV);
//
// public SignaturePAdESLevel(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/packaging/SignaturePAdESPackaging.java
// public class SignaturePAdESPackaging extends SignaturePackaging {
// public static SignaturePAdESPackaging ENVELOPED = new SignaturePAdESPackaging(SignaturePackaging.ENVELOPED);
//
// public SignaturePAdESPackaging(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/exception/SignatureServiceUrlException.java
// public class SignatureServiceUrlException extends SignatureException {
// public SignatureServiceUrlException() {
// }
// public SignatureServiceUrlException(Exception e) {
// super(e);
// }
//
// @Override
// public String getMessage() {
// return "The service URL was required but not specified!";
// }
// }
| import it.latraccia.dss.util.entity.format.SignatureFormat;
import it.latraccia.dss.util.entity.format.SignaturePAdESFormat;
import it.latraccia.dss.util.entity.level.SignaturePAdESLevel;
import it.latraccia.dss.util.entity.packaging.SignaturePAdESPackaging;
import it.latraccia.dss.util.exception.SignatureServiceUrlException; | /*
* SD-DSS-Util, a Utility Library and a Command Line Interface for SD-DSS.
* Copyright (C) 2013 La Traccia http://www.latraccia.it/en/
* Developed by Francesco Pontillo
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see [http://www.gnu.org/licenses/].
*/
package it.latraccia.dss.util.builder.format;
/**
* Date: 06/12/13
* Time: 11.10
*
* @author Francesco Pontillo
*/
public class PAdESFormatBuilder extends FormatBuilder<SignaturePAdESFormat> {
// FORMAT
public PAdESFormatBuilder() {
setFormat(SignatureFormat.PAdES);
}
// LEVEL
public PAdESFormatBuilder BES(String serviceUrl) throws SignatureServiceUrlException { | // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/format/SignatureFormat.java
// public class SignatureFormat extends GeneralEnum {
// public static final String XAdES_NAME = "XAdES";
// public static final String CAdES_NAME = "CAdES";
// public static final String PAdES_NAME = "PAdES";
//
// public static final SignatureFormat XAdES = new SignatureXAdESFormat(XAdES_NAME);
// public static final SignatureFormat CAdES = new SignatureCAdESFormat(CAdES_NAME);
// public static final SignatureFormat PAdES = new SignaturePAdESFormat(PAdES_NAME);
//
// public SignatureFormat(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/format/SignaturePAdESFormat.java
// public class SignaturePAdESFormat extends SignatureFormat {
// public SignaturePAdESFormat(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/level/SignaturePAdESLevel.java
// public class SignaturePAdESLevel extends SignatureLevel {
// public static SignaturePAdESLevel BES = new SignaturePAdESLevel(SignatureLevel.BES);
// public static SignaturePAdESLevel EPES = new SignaturePAdESLevel(SignatureLevel.EPES);
// public static SignaturePAdESLevel LTV = new SignaturePAdESLevel(SignatureLevel.LTV);
//
// public SignaturePAdESLevel(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/packaging/SignaturePAdESPackaging.java
// public class SignaturePAdESPackaging extends SignaturePackaging {
// public static SignaturePAdESPackaging ENVELOPED = new SignaturePAdESPackaging(SignaturePackaging.ENVELOPED);
//
// public SignaturePAdESPackaging(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/exception/SignatureServiceUrlException.java
// public class SignatureServiceUrlException extends SignatureException {
// public SignatureServiceUrlException() {
// }
// public SignatureServiceUrlException(Exception e) {
// super(e);
// }
//
// @Override
// public String getMessage() {
// return "The service URL was required but not specified!";
// }
// }
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/builder/format/PAdESFormatBuilder.java
import it.latraccia.dss.util.entity.format.SignatureFormat;
import it.latraccia.dss.util.entity.format.SignaturePAdESFormat;
import it.latraccia.dss.util.entity.level.SignaturePAdESLevel;
import it.latraccia.dss.util.entity.packaging.SignaturePAdESPackaging;
import it.latraccia.dss.util.exception.SignatureServiceUrlException;
/*
* SD-DSS-Util, a Utility Library and a Command Line Interface for SD-DSS.
* Copyright (C) 2013 La Traccia http://www.latraccia.it/en/
* Developed by Francesco Pontillo
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see [http://www.gnu.org/licenses/].
*/
package it.latraccia.dss.util.builder.format;
/**
* Date: 06/12/13
* Time: 11.10
*
* @author Francesco Pontillo
*/
public class PAdESFormatBuilder extends FormatBuilder<SignaturePAdESFormat> {
// FORMAT
public PAdESFormatBuilder() {
setFormat(SignatureFormat.PAdES);
}
// LEVEL
public PAdESFormatBuilder BES(String serviceUrl) throws SignatureServiceUrlException { | setLevel(SignaturePAdESLevel.BES); |
latraccia/sd-dss-util | sd-dss-util-lib/src/main/java/it/latraccia/dss/util/builder/format/PAdESFormatBuilder.java | // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/format/SignatureFormat.java
// public class SignatureFormat extends GeneralEnum {
// public static final String XAdES_NAME = "XAdES";
// public static final String CAdES_NAME = "CAdES";
// public static final String PAdES_NAME = "PAdES";
//
// public static final SignatureFormat XAdES = new SignatureXAdESFormat(XAdES_NAME);
// public static final SignatureFormat CAdES = new SignatureCAdESFormat(CAdES_NAME);
// public static final SignatureFormat PAdES = new SignaturePAdESFormat(PAdES_NAME);
//
// public SignatureFormat(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/format/SignaturePAdESFormat.java
// public class SignaturePAdESFormat extends SignatureFormat {
// public SignaturePAdESFormat(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/level/SignaturePAdESLevel.java
// public class SignaturePAdESLevel extends SignatureLevel {
// public static SignaturePAdESLevel BES = new SignaturePAdESLevel(SignatureLevel.BES);
// public static SignaturePAdESLevel EPES = new SignaturePAdESLevel(SignatureLevel.EPES);
// public static SignaturePAdESLevel LTV = new SignaturePAdESLevel(SignatureLevel.LTV);
//
// public SignaturePAdESLevel(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/packaging/SignaturePAdESPackaging.java
// public class SignaturePAdESPackaging extends SignaturePackaging {
// public static SignaturePAdESPackaging ENVELOPED = new SignaturePAdESPackaging(SignaturePackaging.ENVELOPED);
//
// public SignaturePAdESPackaging(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/exception/SignatureServiceUrlException.java
// public class SignatureServiceUrlException extends SignatureException {
// public SignatureServiceUrlException() {
// }
// public SignatureServiceUrlException(Exception e) {
// super(e);
// }
//
// @Override
// public String getMessage() {
// return "The service URL was required but not specified!";
// }
// }
| import it.latraccia.dss.util.entity.format.SignatureFormat;
import it.latraccia.dss.util.entity.format.SignaturePAdESFormat;
import it.latraccia.dss.util.entity.level.SignaturePAdESLevel;
import it.latraccia.dss.util.entity.packaging.SignaturePAdESPackaging;
import it.latraccia.dss.util.exception.SignatureServiceUrlException; | /*
* SD-DSS-Util, a Utility Library and a Command Line Interface for SD-DSS.
* Copyright (C) 2013 La Traccia http://www.latraccia.it/en/
* Developed by Francesco Pontillo
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see [http://www.gnu.org/licenses/].
*/
package it.latraccia.dss.util.builder.format;
/**
* Date: 06/12/13
* Time: 11.10
*
* @author Francesco Pontillo
*/
public class PAdESFormatBuilder extends FormatBuilder<SignaturePAdESFormat> {
// FORMAT
public PAdESFormatBuilder() {
setFormat(SignatureFormat.PAdES);
}
// LEVEL
public PAdESFormatBuilder BES(String serviceUrl) throws SignatureServiceUrlException {
setLevel(SignaturePAdESLevel.BES);
setServiceUrl(serviceUrl);
return this;
}
public PAdESFormatBuilder EPES(String serviceUrl) throws SignatureServiceUrlException {
setLevel(SignaturePAdESLevel.EPES);
setServiceUrl(serviceUrl);
return this;
}
public PAdESFormatBuilder LTV(String serviceUrl) throws SignatureServiceUrlException {
setLevel(SignaturePAdESLevel.LTV);
setServiceUrl(serviceUrl);
return this;
}
// PACKAGING
public PAdESFormatBuilder enveloped() { | // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/format/SignatureFormat.java
// public class SignatureFormat extends GeneralEnum {
// public static final String XAdES_NAME = "XAdES";
// public static final String CAdES_NAME = "CAdES";
// public static final String PAdES_NAME = "PAdES";
//
// public static final SignatureFormat XAdES = new SignatureXAdESFormat(XAdES_NAME);
// public static final SignatureFormat CAdES = new SignatureCAdESFormat(CAdES_NAME);
// public static final SignatureFormat PAdES = new SignaturePAdESFormat(PAdES_NAME);
//
// public SignatureFormat(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/format/SignaturePAdESFormat.java
// public class SignaturePAdESFormat extends SignatureFormat {
// public SignaturePAdESFormat(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/level/SignaturePAdESLevel.java
// public class SignaturePAdESLevel extends SignatureLevel {
// public static SignaturePAdESLevel BES = new SignaturePAdESLevel(SignatureLevel.BES);
// public static SignaturePAdESLevel EPES = new SignaturePAdESLevel(SignatureLevel.EPES);
// public static SignaturePAdESLevel LTV = new SignaturePAdESLevel(SignatureLevel.LTV);
//
// public SignaturePAdESLevel(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/packaging/SignaturePAdESPackaging.java
// public class SignaturePAdESPackaging extends SignaturePackaging {
// public static SignaturePAdESPackaging ENVELOPED = new SignaturePAdESPackaging(SignaturePackaging.ENVELOPED);
//
// public SignaturePAdESPackaging(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/exception/SignatureServiceUrlException.java
// public class SignatureServiceUrlException extends SignatureException {
// public SignatureServiceUrlException() {
// }
// public SignatureServiceUrlException(Exception e) {
// super(e);
// }
//
// @Override
// public String getMessage() {
// return "The service URL was required but not specified!";
// }
// }
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/builder/format/PAdESFormatBuilder.java
import it.latraccia.dss.util.entity.format.SignatureFormat;
import it.latraccia.dss.util.entity.format.SignaturePAdESFormat;
import it.latraccia.dss.util.entity.level.SignaturePAdESLevel;
import it.latraccia.dss.util.entity.packaging.SignaturePAdESPackaging;
import it.latraccia.dss.util.exception.SignatureServiceUrlException;
/*
* SD-DSS-Util, a Utility Library and a Command Line Interface for SD-DSS.
* Copyright (C) 2013 La Traccia http://www.latraccia.it/en/
* Developed by Francesco Pontillo
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see [http://www.gnu.org/licenses/].
*/
package it.latraccia.dss.util.builder.format;
/**
* Date: 06/12/13
* Time: 11.10
*
* @author Francesco Pontillo
*/
public class PAdESFormatBuilder extends FormatBuilder<SignaturePAdESFormat> {
// FORMAT
public PAdESFormatBuilder() {
setFormat(SignatureFormat.PAdES);
}
// LEVEL
public PAdESFormatBuilder BES(String serviceUrl) throws SignatureServiceUrlException {
setLevel(SignaturePAdESLevel.BES);
setServiceUrl(serviceUrl);
return this;
}
public PAdESFormatBuilder EPES(String serviceUrl) throws SignatureServiceUrlException {
setLevel(SignaturePAdESLevel.EPES);
setServiceUrl(serviceUrl);
return this;
}
public PAdESFormatBuilder LTV(String serviceUrl) throws SignatureServiceUrlException {
setLevel(SignaturePAdESLevel.LTV);
setServiceUrl(serviceUrl);
return this;
}
// PACKAGING
public PAdESFormatBuilder enveloped() { | setPackaging(SignaturePAdESPackaging.ENVELOPED); |
latraccia/sd-dss-util | sd-dss-util-cli/src/test/java/it/latraccia/dss/util/cli/test/XADESSuccessfulGenericTest.java | // Path: sd-dss-util-cli/src/test/java/it/latraccia/dss/util/cli/test/util/SignatureArgsHelper.java
// public class SignatureArgsHelper {
//
// private static String resourceRoot;
//
// static {
// resourceRoot = "";
// }
//
// // All possibilities to be tested are listed here, then they are combined together
//
// public static class Url {
// public static String DSS = "http://localhost:8080/service";
// }
//
// public static class Input {
// public static String PDF_FILE = getFile("pdf");
//
// public static String DOC_FILE = getFile("doc");
//
// public static String DOCX_FILE = getFile("docx");
//
// public static String ODT_FILE = getFile("odt");
//
// public static String XML_FILE = getFile("xml");
//
// private static String getFile(String extension) {
// return "test." + extension;
// }
// }
//
// public static class Output {
// public static String ROOT = resourceRoot;
// }
//
// public static class PKCS12 {
// public static String KEY = FileHelper.getResource("0F.p12");
//
// public static String PASSWORD = "password";
// }
//
// public static class PKCS11 {
// public static String LIBRARY = FileHelper.getResource("drivers/bit4ipki.dll");
//
// public static String PASSWORD = "16061981";
// }
//
// public static class Format {
// public static String CADES = "CAdES";
//
// public static String PADES = "PAdES";
//
// public static String XADES = "XAdES";
//
// public static String ASICS = "ASiC-S";
// }
//
// public static class Level {
// public static String BES = "BES";
//
// public static String EPES = "EPES";
//
// public static String LTV = "LTV";
//
// public static String T = "T";
//
// public static String C = "C";
//
// public static String X = "X";
//
// public static String XL = "XL";
//
// public static String A = "A";
// }
//
// public static class Packaging {
// public static String ENVELOPED = "ENVELOPED";
//
// public static String ENVELOPING = "ENVELOPING";
//
// public static String DETACHED = "DETACHED";
// }
//
// public static class DigestAlgorithm {
// public static String SHA256 = "SHA256";
// }
//
// public static class KeyRegex {
// public static String MATCH_ALL = ".*";
// }
//
// public List<String> getBaseArgs() {
// List<String> arguments = new ArrayList<String>();
// Collections.addAll(arguments);
// return arguments;
// }
// }
| import it.latraccia.dss.util.cli.test.util.SignatureArgsHelper;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.util.Arrays;
import java.util.Collection; | /*
* SD-DSS-Util, a Utility Library and a Command Line Interface for SD-DSS.
* Copyright (C) 2013 La Traccia http://www.latraccia.it/en/
* Developed by Francesco Pontillo
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see [http://www.gnu.org/licenses/].
*/
package it.latraccia.dss.util.cli.test;
@RunWith(value = Parameterized.class)
public abstract class XADESSuccessfulGenericTest extends SuccessfulGenericTest {
public XADESSuccessfulGenericTest(String description, Object[] args) {
super(description, args);
}
@Parameterized.Parameters
public static Collection<Object[]> getSuccessfulTestParams() {
final Object[][] params =
{
// PDF, BES, ENVELOPING
{"PDF, BES, ENVELOPING", new String[] { | // Path: sd-dss-util-cli/src/test/java/it/latraccia/dss/util/cli/test/util/SignatureArgsHelper.java
// public class SignatureArgsHelper {
//
// private static String resourceRoot;
//
// static {
// resourceRoot = "";
// }
//
// // All possibilities to be tested are listed here, then they are combined together
//
// public static class Url {
// public static String DSS = "http://localhost:8080/service";
// }
//
// public static class Input {
// public static String PDF_FILE = getFile("pdf");
//
// public static String DOC_FILE = getFile("doc");
//
// public static String DOCX_FILE = getFile("docx");
//
// public static String ODT_FILE = getFile("odt");
//
// public static String XML_FILE = getFile("xml");
//
// private static String getFile(String extension) {
// return "test." + extension;
// }
// }
//
// public static class Output {
// public static String ROOT = resourceRoot;
// }
//
// public static class PKCS12 {
// public static String KEY = FileHelper.getResource("0F.p12");
//
// public static String PASSWORD = "password";
// }
//
// public static class PKCS11 {
// public static String LIBRARY = FileHelper.getResource("drivers/bit4ipki.dll");
//
// public static String PASSWORD = "16061981";
// }
//
// public static class Format {
// public static String CADES = "CAdES";
//
// public static String PADES = "PAdES";
//
// public static String XADES = "XAdES";
//
// public static String ASICS = "ASiC-S";
// }
//
// public static class Level {
// public static String BES = "BES";
//
// public static String EPES = "EPES";
//
// public static String LTV = "LTV";
//
// public static String T = "T";
//
// public static String C = "C";
//
// public static String X = "X";
//
// public static String XL = "XL";
//
// public static String A = "A";
// }
//
// public static class Packaging {
// public static String ENVELOPED = "ENVELOPED";
//
// public static String ENVELOPING = "ENVELOPING";
//
// public static String DETACHED = "DETACHED";
// }
//
// public static class DigestAlgorithm {
// public static String SHA256 = "SHA256";
// }
//
// public static class KeyRegex {
// public static String MATCH_ALL = ".*";
// }
//
// public List<String> getBaseArgs() {
// List<String> arguments = new ArrayList<String>();
// Collections.addAll(arguments);
// return arguments;
// }
// }
// Path: sd-dss-util-cli/src/test/java/it/latraccia/dss/util/cli/test/XADESSuccessfulGenericTest.java
import it.latraccia.dss.util.cli.test.util.SignatureArgsHelper;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.util.Arrays;
import java.util.Collection;
/*
* SD-DSS-Util, a Utility Library and a Command Line Interface for SD-DSS.
* Copyright (C) 2013 La Traccia http://www.latraccia.it/en/
* Developed by Francesco Pontillo
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see [http://www.gnu.org/licenses/].
*/
package it.latraccia.dss.util.cli.test;
@RunWith(value = Parameterized.class)
public abstract class XADESSuccessfulGenericTest extends SuccessfulGenericTest {
public XADESSuccessfulGenericTest(String description, Object[] args) {
super(description, args);
}
@Parameterized.Parameters
public static Collection<Object[]> getSuccessfulTestParams() {
final Object[][] params =
{
// PDF, BES, ENVELOPING
{"PDF, BES, ENVELOPING", new String[] { | SignatureArgsHelper.Input.PDF_FILE, |
latraccia/sd-dss-util | sd-dss-util-cli/src/test/java/it/latraccia/dss/util/cli/test/PADESSuccessfulGenericTest.java | // Path: sd-dss-util-cli/src/test/java/it/latraccia/dss/util/cli/test/util/SignatureArgsHelper.java
// public class SignatureArgsHelper {
//
// private static String resourceRoot;
//
// static {
// resourceRoot = "";
// }
//
// // All possibilities to be tested are listed here, then they are combined together
//
// public static class Url {
// public static String DSS = "http://localhost:8080/service";
// }
//
// public static class Input {
// public static String PDF_FILE = getFile("pdf");
//
// public static String DOC_FILE = getFile("doc");
//
// public static String DOCX_FILE = getFile("docx");
//
// public static String ODT_FILE = getFile("odt");
//
// public static String XML_FILE = getFile("xml");
//
// private static String getFile(String extension) {
// return "test." + extension;
// }
// }
//
// public static class Output {
// public static String ROOT = resourceRoot;
// }
//
// public static class PKCS12 {
// public static String KEY = FileHelper.getResource("0F.p12");
//
// public static String PASSWORD = "password";
// }
//
// public static class PKCS11 {
// public static String LIBRARY = FileHelper.getResource("drivers/bit4ipki.dll");
//
// public static String PASSWORD = "16061981";
// }
//
// public static class Format {
// public static String CADES = "CAdES";
//
// public static String PADES = "PAdES";
//
// public static String XADES = "XAdES";
//
// public static String ASICS = "ASiC-S";
// }
//
// public static class Level {
// public static String BES = "BES";
//
// public static String EPES = "EPES";
//
// public static String LTV = "LTV";
//
// public static String T = "T";
//
// public static String C = "C";
//
// public static String X = "X";
//
// public static String XL = "XL";
//
// public static String A = "A";
// }
//
// public static class Packaging {
// public static String ENVELOPED = "ENVELOPED";
//
// public static String ENVELOPING = "ENVELOPING";
//
// public static String DETACHED = "DETACHED";
// }
//
// public static class DigestAlgorithm {
// public static String SHA256 = "SHA256";
// }
//
// public static class KeyRegex {
// public static String MATCH_ALL = ".*";
// }
//
// public List<String> getBaseArgs() {
// List<String> arguments = new ArrayList<String>();
// Collections.addAll(arguments);
// return arguments;
// }
// }
| import it.latraccia.dss.util.cli.test.util.SignatureArgsHelper;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.util.Arrays;
import java.util.Collection; | /*
* SD-DSS-Util, a Utility Library and a Command Line Interface for SD-DSS.
* Copyright (C) 2013 La Traccia http://www.latraccia.it/en/
* Developed by Francesco Pontillo
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see [http://www.gnu.org/licenses/].
*/
package it.latraccia.dss.util.cli.test;
@RunWith(value = Parameterized.class)
public abstract class PADESSuccessfulGenericTest extends SuccessfulGenericTest {
public PADESSuccessfulGenericTest(String description, Object[] args) {
super(description, args);
}
@Parameterized.Parameters
public static Collection<Object[]> getSuccessfulTestParams() {
final Object[][] params =
{
// PDF, BES, ENVELOPED
{"PDF, BES, ENVELOPED", new String[] { | // Path: sd-dss-util-cli/src/test/java/it/latraccia/dss/util/cli/test/util/SignatureArgsHelper.java
// public class SignatureArgsHelper {
//
// private static String resourceRoot;
//
// static {
// resourceRoot = "";
// }
//
// // All possibilities to be tested are listed here, then they are combined together
//
// public static class Url {
// public static String DSS = "http://localhost:8080/service";
// }
//
// public static class Input {
// public static String PDF_FILE = getFile("pdf");
//
// public static String DOC_FILE = getFile("doc");
//
// public static String DOCX_FILE = getFile("docx");
//
// public static String ODT_FILE = getFile("odt");
//
// public static String XML_FILE = getFile("xml");
//
// private static String getFile(String extension) {
// return "test." + extension;
// }
// }
//
// public static class Output {
// public static String ROOT = resourceRoot;
// }
//
// public static class PKCS12 {
// public static String KEY = FileHelper.getResource("0F.p12");
//
// public static String PASSWORD = "password";
// }
//
// public static class PKCS11 {
// public static String LIBRARY = FileHelper.getResource("drivers/bit4ipki.dll");
//
// public static String PASSWORD = "16061981";
// }
//
// public static class Format {
// public static String CADES = "CAdES";
//
// public static String PADES = "PAdES";
//
// public static String XADES = "XAdES";
//
// public static String ASICS = "ASiC-S";
// }
//
// public static class Level {
// public static String BES = "BES";
//
// public static String EPES = "EPES";
//
// public static String LTV = "LTV";
//
// public static String T = "T";
//
// public static String C = "C";
//
// public static String X = "X";
//
// public static String XL = "XL";
//
// public static String A = "A";
// }
//
// public static class Packaging {
// public static String ENVELOPED = "ENVELOPED";
//
// public static String ENVELOPING = "ENVELOPING";
//
// public static String DETACHED = "DETACHED";
// }
//
// public static class DigestAlgorithm {
// public static String SHA256 = "SHA256";
// }
//
// public static class KeyRegex {
// public static String MATCH_ALL = ".*";
// }
//
// public List<String> getBaseArgs() {
// List<String> arguments = new ArrayList<String>();
// Collections.addAll(arguments);
// return arguments;
// }
// }
// Path: sd-dss-util-cli/src/test/java/it/latraccia/dss/util/cli/test/PADESSuccessfulGenericTest.java
import it.latraccia.dss.util.cli.test.util.SignatureArgsHelper;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.util.Arrays;
import java.util.Collection;
/*
* SD-DSS-Util, a Utility Library and a Command Line Interface for SD-DSS.
* Copyright (C) 2013 La Traccia http://www.latraccia.it/en/
* Developed by Francesco Pontillo
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see [http://www.gnu.org/licenses/].
*/
package it.latraccia.dss.util.cli.test;
@RunWith(value = Parameterized.class)
public abstract class PADESSuccessfulGenericTest extends SuccessfulGenericTest {
public PADESSuccessfulGenericTest(String description, Object[] args) {
super(description, args);
}
@Parameterized.Parameters
public static Collection<Object[]> getSuccessfulTestParams() {
final Object[][] params =
{
// PDF, BES, ENVELOPED
{"PDF, BES, ENVELOPED", new String[] { | SignatureArgsHelper.Input.PDF_FILE, |
latraccia/sd-dss-util | sd-dss-util-cli/src/main/java/it/latraccia/dss/util/cli/argument/SignatureArgs.java | // Path: sd-dss-util-cli/src/main/java/it/latraccia/dss/util/cli/argument/converter/DigestAlgorithmConverter.java
// public class DigestAlgorithmConverter implements IStringConverter<DigestAlgorithm> {
// @Override
// public DigestAlgorithm convert(String s) {
// if (!AssertHelper.stringMustBeInList("digest algorithm", s, new String[] {"SHA1", "SHA256", "SHA512"})) {
// throw new ParameterException(
// String.format("Could not recognize %s as a valid digest algorithm.", s));
// } else if ("SHA1".equalsIgnoreCase(s)) {
// return DigestAlgorithm.SHA1;
// } else if ("SHA256".equalsIgnoreCase(s)) {
// return DigestAlgorithm.SHA256;
// } else {
// return DigestAlgorithm.SHA512;
// }
// }
// }
//
// Path: sd-dss-util-cli/src/main/java/it/latraccia/dss/util/cli/argument/converter/PackagingConverter.java
// public class PackagingConverter implements IStringConverter<SignaturePackaging> {
// @Override
// public SignaturePackaging convert(String s) {
// if (!AssertHelper.stringMustBeInList("signature packaging", s, new String[]{"ENVELOPED", "ENVELOPING", "DETACHED"})) {
// throw new ParameterException(
// String.format("Could not recognize %s as a valid signature packaging.", s));
// } else if ("ENVELOPED".equalsIgnoreCase(s)) {
// return SignaturePackaging.ENVELOPED;
// } else if ("ENVELOPING".equalsIgnoreCase(s)) {
// return SignaturePackaging.ENVELOPING;
// } else {
// return SignaturePackaging.DETACHED;
// }
// }
// }
| import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters;
import eu.europa.ec.markt.dss.DigestAlgorithm;
import eu.europa.ec.markt.dss.signature.SignaturePackaging;
import it.latraccia.dss.util.cli.argument.converter.DigestAlgorithmConverter;
import it.latraccia.dss.util.cli.argument.converter.PackagingConverter;
import java.util.List; | /*
* SD-DSS-Util, a Utility Library and a Command Line Interface for SD-DSS.
* Copyright (C) 2013 La Traccia http://www.latraccia.it/en/
* Developed by Francesco Pontillo
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see [http://www.gnu.org/licenses/].
*/
package it.latraccia.dss.util.cli.argument;
@Parameters(separators = "=")
public class SignatureArgs {
/* MAIN PARAMETERS */
@Parameter(required = true,
description = "Source filenames of the files to be signed")
private List<String> source;
@Parameter(names = {"-o", "--output"},
description = "Destination path or file name for the signed document")
private String output;
@Parameter(names = {"-u", "--url"},
description = "URL of the DSS Web Service")
private String url;
@Parameter(names = {"-log", "--log"},
description = "Path for the output log file")
private String log;
/* END OF MAIN PARAMETERS */
/* SIGNATURE FORMAT PARAMETERS */
@Parameter(names = {"-f", "--format"}, required = true,
description = "Signature format, depending on the file type can be \"CAdES\", \"XAdES\", \"PAdES\" " +
"(for PDF files only), \"ASiC-S\"")
private String format;
@Parameter(names = {"-l", "--level"}, required = true,
description = "Signature level, depending on the format can be \"BES\", \"EPES\", \"LTV\", \"T\", \"C\", " +
"\"X\", \"XL\", \"A\"")
private String level;
@Parameter(names = {"-p", "--packaging"}, required = true,
description = "Signature packaging, the way it is related with the content being signed. " +
"Can be \"ENVELOPED\", \"ENVELOPING\", \"DETACHED\"", | // Path: sd-dss-util-cli/src/main/java/it/latraccia/dss/util/cli/argument/converter/DigestAlgorithmConverter.java
// public class DigestAlgorithmConverter implements IStringConverter<DigestAlgorithm> {
// @Override
// public DigestAlgorithm convert(String s) {
// if (!AssertHelper.stringMustBeInList("digest algorithm", s, new String[] {"SHA1", "SHA256", "SHA512"})) {
// throw new ParameterException(
// String.format("Could not recognize %s as a valid digest algorithm.", s));
// } else if ("SHA1".equalsIgnoreCase(s)) {
// return DigestAlgorithm.SHA1;
// } else if ("SHA256".equalsIgnoreCase(s)) {
// return DigestAlgorithm.SHA256;
// } else {
// return DigestAlgorithm.SHA512;
// }
// }
// }
//
// Path: sd-dss-util-cli/src/main/java/it/latraccia/dss/util/cli/argument/converter/PackagingConverter.java
// public class PackagingConverter implements IStringConverter<SignaturePackaging> {
// @Override
// public SignaturePackaging convert(String s) {
// if (!AssertHelper.stringMustBeInList("signature packaging", s, new String[]{"ENVELOPED", "ENVELOPING", "DETACHED"})) {
// throw new ParameterException(
// String.format("Could not recognize %s as a valid signature packaging.", s));
// } else if ("ENVELOPED".equalsIgnoreCase(s)) {
// return SignaturePackaging.ENVELOPED;
// } else if ("ENVELOPING".equalsIgnoreCase(s)) {
// return SignaturePackaging.ENVELOPING;
// } else {
// return SignaturePackaging.DETACHED;
// }
// }
// }
// Path: sd-dss-util-cli/src/main/java/it/latraccia/dss/util/cli/argument/SignatureArgs.java
import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters;
import eu.europa.ec.markt.dss.DigestAlgorithm;
import eu.europa.ec.markt.dss.signature.SignaturePackaging;
import it.latraccia.dss.util.cli.argument.converter.DigestAlgorithmConverter;
import it.latraccia.dss.util.cli.argument.converter.PackagingConverter;
import java.util.List;
/*
* SD-DSS-Util, a Utility Library and a Command Line Interface for SD-DSS.
* Copyright (C) 2013 La Traccia http://www.latraccia.it/en/
* Developed by Francesco Pontillo
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see [http://www.gnu.org/licenses/].
*/
package it.latraccia.dss.util.cli.argument;
@Parameters(separators = "=")
public class SignatureArgs {
/* MAIN PARAMETERS */
@Parameter(required = true,
description = "Source filenames of the files to be signed")
private List<String> source;
@Parameter(names = {"-o", "--output"},
description = "Destination path or file name for the signed document")
private String output;
@Parameter(names = {"-u", "--url"},
description = "URL of the DSS Web Service")
private String url;
@Parameter(names = {"-log", "--log"},
description = "Path for the output log file")
private String log;
/* END OF MAIN PARAMETERS */
/* SIGNATURE FORMAT PARAMETERS */
@Parameter(names = {"-f", "--format"}, required = true,
description = "Signature format, depending on the file type can be \"CAdES\", \"XAdES\", \"PAdES\" " +
"(for PDF files only), \"ASiC-S\"")
private String format;
@Parameter(names = {"-l", "--level"}, required = true,
description = "Signature level, depending on the format can be \"BES\", \"EPES\", \"LTV\", \"T\", \"C\", " +
"\"X\", \"XL\", \"A\"")
private String level;
@Parameter(names = {"-p", "--packaging"}, required = true,
description = "Signature packaging, the way it is related with the content being signed. " +
"Can be \"ENVELOPED\", \"ENVELOPING\", \"DETACHED\"", | converter = PackagingConverter.class) |
latraccia/sd-dss-util | sd-dss-util-cli/src/main/java/it/latraccia/dss/util/cli/argument/SignatureArgs.java | // Path: sd-dss-util-cli/src/main/java/it/latraccia/dss/util/cli/argument/converter/DigestAlgorithmConverter.java
// public class DigestAlgorithmConverter implements IStringConverter<DigestAlgorithm> {
// @Override
// public DigestAlgorithm convert(String s) {
// if (!AssertHelper.stringMustBeInList("digest algorithm", s, new String[] {"SHA1", "SHA256", "SHA512"})) {
// throw new ParameterException(
// String.format("Could not recognize %s as a valid digest algorithm.", s));
// } else if ("SHA1".equalsIgnoreCase(s)) {
// return DigestAlgorithm.SHA1;
// } else if ("SHA256".equalsIgnoreCase(s)) {
// return DigestAlgorithm.SHA256;
// } else {
// return DigestAlgorithm.SHA512;
// }
// }
// }
//
// Path: sd-dss-util-cli/src/main/java/it/latraccia/dss/util/cli/argument/converter/PackagingConverter.java
// public class PackagingConverter implements IStringConverter<SignaturePackaging> {
// @Override
// public SignaturePackaging convert(String s) {
// if (!AssertHelper.stringMustBeInList("signature packaging", s, new String[]{"ENVELOPED", "ENVELOPING", "DETACHED"})) {
// throw new ParameterException(
// String.format("Could not recognize %s as a valid signature packaging.", s));
// } else if ("ENVELOPED".equalsIgnoreCase(s)) {
// return SignaturePackaging.ENVELOPED;
// } else if ("ENVELOPING".equalsIgnoreCase(s)) {
// return SignaturePackaging.ENVELOPING;
// } else {
// return SignaturePackaging.DETACHED;
// }
// }
// }
| import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters;
import eu.europa.ec.markt.dss.DigestAlgorithm;
import eu.europa.ec.markt.dss.signature.SignaturePackaging;
import it.latraccia.dss.util.cli.argument.converter.DigestAlgorithmConverter;
import it.latraccia.dss.util.cli.argument.converter.PackagingConverter;
import java.util.List; | /*
* SD-DSS-Util, a Utility Library and a Command Line Interface for SD-DSS.
* Copyright (C) 2013 La Traccia http://www.latraccia.it/en/
* Developed by Francesco Pontillo
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see [http://www.gnu.org/licenses/].
*/
package it.latraccia.dss.util.cli.argument;
@Parameters(separators = "=")
public class SignatureArgs {
/* MAIN PARAMETERS */
@Parameter(required = true,
description = "Source filenames of the files to be signed")
private List<String> source;
@Parameter(names = {"-o", "--output"},
description = "Destination path or file name for the signed document")
private String output;
@Parameter(names = {"-u", "--url"},
description = "URL of the DSS Web Service")
private String url;
@Parameter(names = {"-log", "--log"},
description = "Path for the output log file")
private String log;
/* END OF MAIN PARAMETERS */
/* SIGNATURE FORMAT PARAMETERS */
@Parameter(names = {"-f", "--format"}, required = true,
description = "Signature format, depending on the file type can be \"CAdES\", \"XAdES\", \"PAdES\" " +
"(for PDF files only), \"ASiC-S\"")
private String format;
@Parameter(names = {"-l", "--level"}, required = true,
description = "Signature level, depending on the format can be \"BES\", \"EPES\", \"LTV\", \"T\", \"C\", " +
"\"X\", \"XL\", \"A\"")
private String level;
@Parameter(names = {"-p", "--packaging"}, required = true,
description = "Signature packaging, the way it is related with the content being signed. " +
"Can be \"ENVELOPED\", \"ENVELOPING\", \"DETACHED\"",
converter = PackagingConverter.class)
private SignaturePackaging packaging;
| // Path: sd-dss-util-cli/src/main/java/it/latraccia/dss/util/cli/argument/converter/DigestAlgorithmConverter.java
// public class DigestAlgorithmConverter implements IStringConverter<DigestAlgorithm> {
// @Override
// public DigestAlgorithm convert(String s) {
// if (!AssertHelper.stringMustBeInList("digest algorithm", s, new String[] {"SHA1", "SHA256", "SHA512"})) {
// throw new ParameterException(
// String.format("Could not recognize %s as a valid digest algorithm.", s));
// } else if ("SHA1".equalsIgnoreCase(s)) {
// return DigestAlgorithm.SHA1;
// } else if ("SHA256".equalsIgnoreCase(s)) {
// return DigestAlgorithm.SHA256;
// } else {
// return DigestAlgorithm.SHA512;
// }
// }
// }
//
// Path: sd-dss-util-cli/src/main/java/it/latraccia/dss/util/cli/argument/converter/PackagingConverter.java
// public class PackagingConverter implements IStringConverter<SignaturePackaging> {
// @Override
// public SignaturePackaging convert(String s) {
// if (!AssertHelper.stringMustBeInList("signature packaging", s, new String[]{"ENVELOPED", "ENVELOPING", "DETACHED"})) {
// throw new ParameterException(
// String.format("Could not recognize %s as a valid signature packaging.", s));
// } else if ("ENVELOPED".equalsIgnoreCase(s)) {
// return SignaturePackaging.ENVELOPED;
// } else if ("ENVELOPING".equalsIgnoreCase(s)) {
// return SignaturePackaging.ENVELOPING;
// } else {
// return SignaturePackaging.DETACHED;
// }
// }
// }
// Path: sd-dss-util-cli/src/main/java/it/latraccia/dss/util/cli/argument/SignatureArgs.java
import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters;
import eu.europa.ec.markt.dss.DigestAlgorithm;
import eu.europa.ec.markt.dss.signature.SignaturePackaging;
import it.latraccia.dss.util.cli.argument.converter.DigestAlgorithmConverter;
import it.latraccia.dss.util.cli.argument.converter.PackagingConverter;
import java.util.List;
/*
* SD-DSS-Util, a Utility Library and a Command Line Interface for SD-DSS.
* Copyright (C) 2013 La Traccia http://www.latraccia.it/en/
* Developed by Francesco Pontillo
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see [http://www.gnu.org/licenses/].
*/
package it.latraccia.dss.util.cli.argument;
@Parameters(separators = "=")
public class SignatureArgs {
/* MAIN PARAMETERS */
@Parameter(required = true,
description = "Source filenames of the files to be signed")
private List<String> source;
@Parameter(names = {"-o", "--output"},
description = "Destination path or file name for the signed document")
private String output;
@Parameter(names = {"-u", "--url"},
description = "URL of the DSS Web Service")
private String url;
@Parameter(names = {"-log", "--log"},
description = "Path for the output log file")
private String log;
/* END OF MAIN PARAMETERS */
/* SIGNATURE FORMAT PARAMETERS */
@Parameter(names = {"-f", "--format"}, required = true,
description = "Signature format, depending on the file type can be \"CAdES\", \"XAdES\", \"PAdES\" " +
"(for PDF files only), \"ASiC-S\"")
private String format;
@Parameter(names = {"-l", "--level"}, required = true,
description = "Signature level, depending on the format can be \"BES\", \"EPES\", \"LTV\", \"T\", \"C\", " +
"\"X\", \"XL\", \"A\"")
private String level;
@Parameter(names = {"-p", "--packaging"}, required = true,
description = "Signature packaging, the way it is related with the content being signed. " +
"Can be \"ENVELOPED\", \"ENVELOPING\", \"DETACHED\"",
converter = PackagingConverter.class)
private SignaturePackaging packaging;
| @Parameter(names = {"-d", "--digest-algorithm"}, converter = DigestAlgorithmConverter.class, |
latraccia/sd-dss-util | sd-dss-util-lib/src/main/java/it/latraccia/dss/util/builder/token/TokenBuilder.java | // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/builder/IBuilder.java
// public interface IBuilder<T> {
// public T build() throws IOException, SignatureException, KeyStoreException, NoSuchAlgorithmException;
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/MoccaAlgorithm.java
// public class MoccaAlgorithm extends GeneralEnum {
// public static MoccaAlgorithm SHA1 = new MoccaAlgorithm("SHA1");
//
// public MoccaAlgorithm(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/token/SignatureTokenType.java
// public class SignatureTokenType extends GeneralEnum {
// public static SignatureTokenType PKCS11 = new SignatureTokenType("PKCS11");
// public static SignatureTokenType PKCS12 = new SignatureTokenType("PKCS12");
// public static SignatureTokenType MOCCA = new SignatureTokenType("MOCCA");
// public static SignatureTokenType MSCAPI = new SignatureTokenType("MSCAPI");
//
// public SignatureTokenType(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/exception/SignatureMoccaAlgorithmMismatchException.java
// public class SignatureMoccaAlgorithmMismatchException extends SignatureException {
// public SignatureMoccaAlgorithmMismatchException() {
// }
// public SignatureMoccaAlgorithmMismatchException(Exception e) {
// super(e);
// }
//
// @Override
// public String getMessage() {
// return "The selected MOCCA algorithm is not valid!";
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/exception/SignatureMoccaUnavailabilityException.java
// public class SignatureMoccaUnavailabilityException extends SignatureException {
// public SignatureMoccaUnavailabilityException() {
// }
// public SignatureMoccaUnavailabilityException(Exception e) {
// super(e);
// }
//
// @Override
// public String getMessage() {
// return "MOCCA is not available!";
// }
// }
| import it.latraccia.dss.util.builder.IBuilder;
import it.latraccia.dss.util.entity.MoccaAlgorithm;
import it.latraccia.dss.util.entity.token.SignatureTokenType;
import it.latraccia.dss.util.exception.SignatureMoccaAlgorithmMismatchException;
import it.latraccia.dss.util.exception.SignatureMoccaUnavailabilityException;
import java.io.File;
import java.io.FileNotFoundException; | /*
* SD-DSS-Util, a Utility Library and a Command Line Interface for SD-DSS.
* Copyright (C) 2013 La Traccia http://www.latraccia.it/en/
* Developed by Francesco Pontillo
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see [http://www.gnu.org/licenses/].
*/
package it.latraccia.dss.util.builder.token;
/**
* Date: 07/12/13
* Time: 8.45
*
* @author Francesco Pontillo
*/
public abstract class TokenBuilder implements IBuilder<TokenBuilder.SignatureToken> {
protected SignatureTokenType tokenType;
public SignatureTokenType getTokenType() {
return tokenType;
}
@Override | // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/builder/IBuilder.java
// public interface IBuilder<T> {
// public T build() throws IOException, SignatureException, KeyStoreException, NoSuchAlgorithmException;
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/MoccaAlgorithm.java
// public class MoccaAlgorithm extends GeneralEnum {
// public static MoccaAlgorithm SHA1 = new MoccaAlgorithm("SHA1");
//
// public MoccaAlgorithm(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/token/SignatureTokenType.java
// public class SignatureTokenType extends GeneralEnum {
// public static SignatureTokenType PKCS11 = new SignatureTokenType("PKCS11");
// public static SignatureTokenType PKCS12 = new SignatureTokenType("PKCS12");
// public static SignatureTokenType MOCCA = new SignatureTokenType("MOCCA");
// public static SignatureTokenType MSCAPI = new SignatureTokenType("MSCAPI");
//
// public SignatureTokenType(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/exception/SignatureMoccaAlgorithmMismatchException.java
// public class SignatureMoccaAlgorithmMismatchException extends SignatureException {
// public SignatureMoccaAlgorithmMismatchException() {
// }
// public SignatureMoccaAlgorithmMismatchException(Exception e) {
// super(e);
// }
//
// @Override
// public String getMessage() {
// return "The selected MOCCA algorithm is not valid!";
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/exception/SignatureMoccaUnavailabilityException.java
// public class SignatureMoccaUnavailabilityException extends SignatureException {
// public SignatureMoccaUnavailabilityException() {
// }
// public SignatureMoccaUnavailabilityException(Exception e) {
// super(e);
// }
//
// @Override
// public String getMessage() {
// return "MOCCA is not available!";
// }
// }
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/builder/token/TokenBuilder.java
import it.latraccia.dss.util.builder.IBuilder;
import it.latraccia.dss.util.entity.MoccaAlgorithm;
import it.latraccia.dss.util.entity.token.SignatureTokenType;
import it.latraccia.dss.util.exception.SignatureMoccaAlgorithmMismatchException;
import it.latraccia.dss.util.exception.SignatureMoccaUnavailabilityException;
import java.io.File;
import java.io.FileNotFoundException;
/*
* SD-DSS-Util, a Utility Library and a Command Line Interface for SD-DSS.
* Copyright (C) 2013 La Traccia http://www.latraccia.it/en/
* Developed by Francesco Pontillo
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see [http://www.gnu.org/licenses/].
*/
package it.latraccia.dss.util.builder.token;
/**
* Date: 07/12/13
* Time: 8.45
*
* @author Francesco Pontillo
*/
public abstract class TokenBuilder implements IBuilder<TokenBuilder.SignatureToken> {
protected SignatureTokenType tokenType;
public SignatureTokenType getTokenType() {
return tokenType;
}
@Override | public SignatureToken build() throws SignatureMoccaAlgorithmMismatchException, SignatureMoccaUnavailabilityException, FileNotFoundException { |
latraccia/sd-dss-util | sd-dss-util-lib/src/main/java/it/latraccia/dss/util/builder/token/TokenBuilder.java | // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/builder/IBuilder.java
// public interface IBuilder<T> {
// public T build() throws IOException, SignatureException, KeyStoreException, NoSuchAlgorithmException;
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/MoccaAlgorithm.java
// public class MoccaAlgorithm extends GeneralEnum {
// public static MoccaAlgorithm SHA1 = new MoccaAlgorithm("SHA1");
//
// public MoccaAlgorithm(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/token/SignatureTokenType.java
// public class SignatureTokenType extends GeneralEnum {
// public static SignatureTokenType PKCS11 = new SignatureTokenType("PKCS11");
// public static SignatureTokenType PKCS12 = new SignatureTokenType("PKCS12");
// public static SignatureTokenType MOCCA = new SignatureTokenType("MOCCA");
// public static SignatureTokenType MSCAPI = new SignatureTokenType("MSCAPI");
//
// public SignatureTokenType(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/exception/SignatureMoccaAlgorithmMismatchException.java
// public class SignatureMoccaAlgorithmMismatchException extends SignatureException {
// public SignatureMoccaAlgorithmMismatchException() {
// }
// public SignatureMoccaAlgorithmMismatchException(Exception e) {
// super(e);
// }
//
// @Override
// public String getMessage() {
// return "The selected MOCCA algorithm is not valid!";
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/exception/SignatureMoccaUnavailabilityException.java
// public class SignatureMoccaUnavailabilityException extends SignatureException {
// public SignatureMoccaUnavailabilityException() {
// }
// public SignatureMoccaUnavailabilityException(Exception e) {
// super(e);
// }
//
// @Override
// public String getMessage() {
// return "MOCCA is not available!";
// }
// }
| import it.latraccia.dss.util.builder.IBuilder;
import it.latraccia.dss.util.entity.MoccaAlgorithm;
import it.latraccia.dss.util.entity.token.SignatureTokenType;
import it.latraccia.dss.util.exception.SignatureMoccaAlgorithmMismatchException;
import it.latraccia.dss.util.exception.SignatureMoccaUnavailabilityException;
import java.io.File;
import java.io.FileNotFoundException; | /*
* SD-DSS-Util, a Utility Library and a Command Line Interface for SD-DSS.
* Copyright (C) 2013 La Traccia http://www.latraccia.it/en/
* Developed by Francesco Pontillo
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see [http://www.gnu.org/licenses/].
*/
package it.latraccia.dss.util.builder.token;
/**
* Date: 07/12/13
* Time: 8.45
*
* @author Francesco Pontillo
*/
public abstract class TokenBuilder implements IBuilder<TokenBuilder.SignatureToken> {
protected SignatureTokenType tokenType;
public SignatureTokenType getTokenType() {
return tokenType;
}
@Override | // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/builder/IBuilder.java
// public interface IBuilder<T> {
// public T build() throws IOException, SignatureException, KeyStoreException, NoSuchAlgorithmException;
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/MoccaAlgorithm.java
// public class MoccaAlgorithm extends GeneralEnum {
// public static MoccaAlgorithm SHA1 = new MoccaAlgorithm("SHA1");
//
// public MoccaAlgorithm(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/token/SignatureTokenType.java
// public class SignatureTokenType extends GeneralEnum {
// public static SignatureTokenType PKCS11 = new SignatureTokenType("PKCS11");
// public static SignatureTokenType PKCS12 = new SignatureTokenType("PKCS12");
// public static SignatureTokenType MOCCA = new SignatureTokenType("MOCCA");
// public static SignatureTokenType MSCAPI = new SignatureTokenType("MSCAPI");
//
// public SignatureTokenType(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/exception/SignatureMoccaAlgorithmMismatchException.java
// public class SignatureMoccaAlgorithmMismatchException extends SignatureException {
// public SignatureMoccaAlgorithmMismatchException() {
// }
// public SignatureMoccaAlgorithmMismatchException(Exception e) {
// super(e);
// }
//
// @Override
// public String getMessage() {
// return "The selected MOCCA algorithm is not valid!";
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/exception/SignatureMoccaUnavailabilityException.java
// public class SignatureMoccaUnavailabilityException extends SignatureException {
// public SignatureMoccaUnavailabilityException() {
// }
// public SignatureMoccaUnavailabilityException(Exception e) {
// super(e);
// }
//
// @Override
// public String getMessage() {
// return "MOCCA is not available!";
// }
// }
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/builder/token/TokenBuilder.java
import it.latraccia.dss.util.builder.IBuilder;
import it.latraccia.dss.util.entity.MoccaAlgorithm;
import it.latraccia.dss.util.entity.token.SignatureTokenType;
import it.latraccia.dss.util.exception.SignatureMoccaAlgorithmMismatchException;
import it.latraccia.dss.util.exception.SignatureMoccaUnavailabilityException;
import java.io.File;
import java.io.FileNotFoundException;
/*
* SD-DSS-Util, a Utility Library and a Command Line Interface for SD-DSS.
* Copyright (C) 2013 La Traccia http://www.latraccia.it/en/
* Developed by Francesco Pontillo
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see [http://www.gnu.org/licenses/].
*/
package it.latraccia.dss.util.builder.token;
/**
* Date: 07/12/13
* Time: 8.45
*
* @author Francesco Pontillo
*/
public abstract class TokenBuilder implements IBuilder<TokenBuilder.SignatureToken> {
protected SignatureTokenType tokenType;
public SignatureTokenType getTokenType() {
return tokenType;
}
@Override | public SignatureToken build() throws SignatureMoccaAlgorithmMismatchException, SignatureMoccaUnavailabilityException, FileNotFoundException { |
latraccia/sd-dss-util | sd-dss-util-lib/src/main/java/it/latraccia/dss/util/builder/token/TokenBuilder.java | // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/builder/IBuilder.java
// public interface IBuilder<T> {
// public T build() throws IOException, SignatureException, KeyStoreException, NoSuchAlgorithmException;
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/MoccaAlgorithm.java
// public class MoccaAlgorithm extends GeneralEnum {
// public static MoccaAlgorithm SHA1 = new MoccaAlgorithm("SHA1");
//
// public MoccaAlgorithm(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/token/SignatureTokenType.java
// public class SignatureTokenType extends GeneralEnum {
// public static SignatureTokenType PKCS11 = new SignatureTokenType("PKCS11");
// public static SignatureTokenType PKCS12 = new SignatureTokenType("PKCS12");
// public static SignatureTokenType MOCCA = new SignatureTokenType("MOCCA");
// public static SignatureTokenType MSCAPI = new SignatureTokenType("MSCAPI");
//
// public SignatureTokenType(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/exception/SignatureMoccaAlgorithmMismatchException.java
// public class SignatureMoccaAlgorithmMismatchException extends SignatureException {
// public SignatureMoccaAlgorithmMismatchException() {
// }
// public SignatureMoccaAlgorithmMismatchException(Exception e) {
// super(e);
// }
//
// @Override
// public String getMessage() {
// return "The selected MOCCA algorithm is not valid!";
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/exception/SignatureMoccaUnavailabilityException.java
// public class SignatureMoccaUnavailabilityException extends SignatureException {
// public SignatureMoccaUnavailabilityException() {
// }
// public SignatureMoccaUnavailabilityException(Exception e) {
// super(e);
// }
//
// @Override
// public String getMessage() {
// return "MOCCA is not available!";
// }
// }
| import it.latraccia.dss.util.builder.IBuilder;
import it.latraccia.dss.util.entity.MoccaAlgorithm;
import it.latraccia.dss.util.entity.token.SignatureTokenType;
import it.latraccia.dss.util.exception.SignatureMoccaAlgorithmMismatchException;
import it.latraccia.dss.util.exception.SignatureMoccaUnavailabilityException;
import java.io.File;
import java.io.FileNotFoundException; | /*
* SD-DSS-Util, a Utility Library and a Command Line Interface for SD-DSS.
* Copyright (C) 2013 La Traccia http://www.latraccia.it/en/
* Developed by Francesco Pontillo
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see [http://www.gnu.org/licenses/].
*/
package it.latraccia.dss.util.builder.token;
/**
* Date: 07/12/13
* Time: 8.45
*
* @author Francesco Pontillo
*/
public abstract class TokenBuilder implements IBuilder<TokenBuilder.SignatureToken> {
protected SignatureTokenType tokenType;
public SignatureTokenType getTokenType() {
return tokenType;
}
@Override
public SignatureToken build() throws SignatureMoccaAlgorithmMismatchException, SignatureMoccaUnavailabilityException, FileNotFoundException {
SignatureToken signatureToken = new SignatureToken();
signatureToken.setTokenType(tokenType);
return signatureToken;
}
protected void setTokenType(SignatureTokenType tokenType) {
this.tokenType = tokenType;
}
public class SignatureToken {
protected File tokenAsset;
protected SignatureTokenType tokenType;
protected String file;
protected String password; | // Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/builder/IBuilder.java
// public interface IBuilder<T> {
// public T build() throws IOException, SignatureException, KeyStoreException, NoSuchAlgorithmException;
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/MoccaAlgorithm.java
// public class MoccaAlgorithm extends GeneralEnum {
// public static MoccaAlgorithm SHA1 = new MoccaAlgorithm("SHA1");
//
// public MoccaAlgorithm(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/entity/token/SignatureTokenType.java
// public class SignatureTokenType extends GeneralEnum {
// public static SignatureTokenType PKCS11 = new SignatureTokenType("PKCS11");
// public static SignatureTokenType PKCS12 = new SignatureTokenType("PKCS12");
// public static SignatureTokenType MOCCA = new SignatureTokenType("MOCCA");
// public static SignatureTokenType MSCAPI = new SignatureTokenType("MSCAPI");
//
// public SignatureTokenType(String value) {
// super(value);
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/exception/SignatureMoccaAlgorithmMismatchException.java
// public class SignatureMoccaAlgorithmMismatchException extends SignatureException {
// public SignatureMoccaAlgorithmMismatchException() {
// }
// public SignatureMoccaAlgorithmMismatchException(Exception e) {
// super(e);
// }
//
// @Override
// public String getMessage() {
// return "The selected MOCCA algorithm is not valid!";
// }
// }
//
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/exception/SignatureMoccaUnavailabilityException.java
// public class SignatureMoccaUnavailabilityException extends SignatureException {
// public SignatureMoccaUnavailabilityException() {
// }
// public SignatureMoccaUnavailabilityException(Exception e) {
// super(e);
// }
//
// @Override
// public String getMessage() {
// return "MOCCA is not available!";
// }
// }
// Path: sd-dss-util-lib/src/main/java/it/latraccia/dss/util/builder/token/TokenBuilder.java
import it.latraccia.dss.util.builder.IBuilder;
import it.latraccia.dss.util.entity.MoccaAlgorithm;
import it.latraccia.dss.util.entity.token.SignatureTokenType;
import it.latraccia.dss.util.exception.SignatureMoccaAlgorithmMismatchException;
import it.latraccia.dss.util.exception.SignatureMoccaUnavailabilityException;
import java.io.File;
import java.io.FileNotFoundException;
/*
* SD-DSS-Util, a Utility Library and a Command Line Interface for SD-DSS.
* Copyright (C) 2013 La Traccia http://www.latraccia.it/en/
* Developed by Francesco Pontillo
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see [http://www.gnu.org/licenses/].
*/
package it.latraccia.dss.util.builder.token;
/**
* Date: 07/12/13
* Time: 8.45
*
* @author Francesco Pontillo
*/
public abstract class TokenBuilder implements IBuilder<TokenBuilder.SignatureToken> {
protected SignatureTokenType tokenType;
public SignatureTokenType getTokenType() {
return tokenType;
}
@Override
public SignatureToken build() throws SignatureMoccaAlgorithmMismatchException, SignatureMoccaUnavailabilityException, FileNotFoundException {
SignatureToken signatureToken = new SignatureToken();
signatureToken.setTokenType(tokenType);
return signatureToken;
}
protected void setTokenType(SignatureTokenType tokenType) {
this.tokenType = tokenType;
}
public class SignatureToken {
protected File tokenAsset;
protected SignatureTokenType tokenType;
protected String file;
protected String password; | protected MoccaAlgorithm moccaAlgorithm; |
latraccia/sd-dss-util | sd-dss-util-cli/src/test/java/it/latraccia/dss/util/cli/test/integration/PKCS11PADESSuccessfulIntegrationTest.java | // Path: sd-dss-util-cli/src/test/java/it/latraccia/dss/util/cli/test/PADESSuccessfulGenericTest.java
// @RunWith(value = Parameterized.class)
// public abstract class PADESSuccessfulGenericTest extends SuccessfulGenericTest {
//
// public PADESSuccessfulGenericTest(String description, Object[] args) {
// super(description, args);
// }
//
// @Parameterized.Parameters
// public static Collection<Object[]> getSuccessfulTestParams() {
// final Object[][] params =
// {
// // PDF, BES, ENVELOPED
// {"PDF, BES, ENVELOPED", new String[] {
// SignatureArgsHelper.Input.PDF_FILE,
// "-u=" + SignatureArgsHelper.Url.DSS,
// "-f=" + SignatureArgsHelper.Format.PADES,
// "-l=" + SignatureArgsHelper.Level.BES,
// "-p=" + SignatureArgsHelper.Packaging.ENVELOPED,
// "-o=\"" + SignatureArgsHelper.Output.ROOT + "\"",
// "-d=" + SignatureArgsHelper.DigestAlgorithm.SHA256,
// "-icn=\"" + SignatureArgsHelper.KeyRegex.MATCH_ALL + "\""
// }},
// // PDF, EPES, ENVELOPED
// {"PDF, EPES, ENVELOPED", new String[] {
// SignatureArgsHelper.Input.PDF_FILE,
// "-u=" + SignatureArgsHelper.Url.DSS,
// "-f=" + SignatureArgsHelper.Format.PADES,
// "-l=" + SignatureArgsHelper.Level.EPES,
// "-p=" + SignatureArgsHelper.Packaging.ENVELOPED,
// "-o=\"" + SignatureArgsHelper.Output.ROOT + "\"",
// "-d=" + SignatureArgsHelper.DigestAlgorithm.SHA256,
// "-icn=\"" + SignatureArgsHelper.KeyRegex.MATCH_ALL + "\""
// }}
// };
//
// return Arrays.asList(params);
// }
// }
//
// Path: sd-dss-util-cli/src/test/java/it/latraccia/dss/util/cli/test/util/SignatureArgsHelper.java
// public class SignatureArgsHelper {
//
// private static String resourceRoot;
//
// static {
// resourceRoot = "";
// }
//
// // All possibilities to be tested are listed here, then they are combined together
//
// public static class Url {
// public static String DSS = "http://localhost:8080/service";
// }
//
// public static class Input {
// public static String PDF_FILE = getFile("pdf");
//
// public static String DOC_FILE = getFile("doc");
//
// public static String DOCX_FILE = getFile("docx");
//
// public static String ODT_FILE = getFile("odt");
//
// public static String XML_FILE = getFile("xml");
//
// private static String getFile(String extension) {
// return "test." + extension;
// }
// }
//
// public static class Output {
// public static String ROOT = resourceRoot;
// }
//
// public static class PKCS12 {
// public static String KEY = FileHelper.getResource("0F.p12");
//
// public static String PASSWORD = "password";
// }
//
// public static class PKCS11 {
// public static String LIBRARY = FileHelper.getResource("drivers/bit4ipki.dll");
//
// public static String PASSWORD = "16061981";
// }
//
// public static class Format {
// public static String CADES = "CAdES";
//
// public static String PADES = "PAdES";
//
// public static String XADES = "XAdES";
//
// public static String ASICS = "ASiC-S";
// }
//
// public static class Level {
// public static String BES = "BES";
//
// public static String EPES = "EPES";
//
// public static String LTV = "LTV";
//
// public static String T = "T";
//
// public static String C = "C";
//
// public static String X = "X";
//
// public static String XL = "XL";
//
// public static String A = "A";
// }
//
// public static class Packaging {
// public static String ENVELOPED = "ENVELOPED";
//
// public static String ENVELOPING = "ENVELOPING";
//
// public static String DETACHED = "DETACHED";
// }
//
// public static class DigestAlgorithm {
// public static String SHA256 = "SHA256";
// }
//
// public static class KeyRegex {
// public static String MATCH_ALL = ".*";
// }
//
// public List<String> getBaseArgs() {
// List<String> arguments = new ArrayList<String>();
// Collections.addAll(arguments);
// return arguments;
// }
// }
| import it.latraccia.dss.util.cli.test.PADESSuccessfulGenericTest;
import it.latraccia.dss.util.cli.test.util.SignatureArgsHelper;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized; | /*
* SD-DSS-Util, a Utility Library and a Command Line Interface for SD-DSS.
* Copyright (C) 2013 La Traccia http://www.latraccia.it/en/
* Developed by Francesco Pontillo
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see [http://www.gnu.org/licenses/].
*/
package it.latraccia.dss.util.cli.test.integration;
@RunWith(value = Parameterized.class)
@Category(value = it.latraccia.dss.util.cli.test.integration.PKCS11IntegrationTest.class) | // Path: sd-dss-util-cli/src/test/java/it/latraccia/dss/util/cli/test/PADESSuccessfulGenericTest.java
// @RunWith(value = Parameterized.class)
// public abstract class PADESSuccessfulGenericTest extends SuccessfulGenericTest {
//
// public PADESSuccessfulGenericTest(String description, Object[] args) {
// super(description, args);
// }
//
// @Parameterized.Parameters
// public static Collection<Object[]> getSuccessfulTestParams() {
// final Object[][] params =
// {
// // PDF, BES, ENVELOPED
// {"PDF, BES, ENVELOPED", new String[] {
// SignatureArgsHelper.Input.PDF_FILE,
// "-u=" + SignatureArgsHelper.Url.DSS,
// "-f=" + SignatureArgsHelper.Format.PADES,
// "-l=" + SignatureArgsHelper.Level.BES,
// "-p=" + SignatureArgsHelper.Packaging.ENVELOPED,
// "-o=\"" + SignatureArgsHelper.Output.ROOT + "\"",
// "-d=" + SignatureArgsHelper.DigestAlgorithm.SHA256,
// "-icn=\"" + SignatureArgsHelper.KeyRegex.MATCH_ALL + "\""
// }},
// // PDF, EPES, ENVELOPED
// {"PDF, EPES, ENVELOPED", new String[] {
// SignatureArgsHelper.Input.PDF_FILE,
// "-u=" + SignatureArgsHelper.Url.DSS,
// "-f=" + SignatureArgsHelper.Format.PADES,
// "-l=" + SignatureArgsHelper.Level.EPES,
// "-p=" + SignatureArgsHelper.Packaging.ENVELOPED,
// "-o=\"" + SignatureArgsHelper.Output.ROOT + "\"",
// "-d=" + SignatureArgsHelper.DigestAlgorithm.SHA256,
// "-icn=\"" + SignatureArgsHelper.KeyRegex.MATCH_ALL + "\""
// }}
// };
//
// return Arrays.asList(params);
// }
// }
//
// Path: sd-dss-util-cli/src/test/java/it/latraccia/dss/util/cli/test/util/SignatureArgsHelper.java
// public class SignatureArgsHelper {
//
// private static String resourceRoot;
//
// static {
// resourceRoot = "";
// }
//
// // All possibilities to be tested are listed here, then they are combined together
//
// public static class Url {
// public static String DSS = "http://localhost:8080/service";
// }
//
// public static class Input {
// public static String PDF_FILE = getFile("pdf");
//
// public static String DOC_FILE = getFile("doc");
//
// public static String DOCX_FILE = getFile("docx");
//
// public static String ODT_FILE = getFile("odt");
//
// public static String XML_FILE = getFile("xml");
//
// private static String getFile(String extension) {
// return "test." + extension;
// }
// }
//
// public static class Output {
// public static String ROOT = resourceRoot;
// }
//
// public static class PKCS12 {
// public static String KEY = FileHelper.getResource("0F.p12");
//
// public static String PASSWORD = "password";
// }
//
// public static class PKCS11 {
// public static String LIBRARY = FileHelper.getResource("drivers/bit4ipki.dll");
//
// public static String PASSWORD = "16061981";
// }
//
// public static class Format {
// public static String CADES = "CAdES";
//
// public static String PADES = "PAdES";
//
// public static String XADES = "XAdES";
//
// public static String ASICS = "ASiC-S";
// }
//
// public static class Level {
// public static String BES = "BES";
//
// public static String EPES = "EPES";
//
// public static String LTV = "LTV";
//
// public static String T = "T";
//
// public static String C = "C";
//
// public static String X = "X";
//
// public static String XL = "XL";
//
// public static String A = "A";
// }
//
// public static class Packaging {
// public static String ENVELOPED = "ENVELOPED";
//
// public static String ENVELOPING = "ENVELOPING";
//
// public static String DETACHED = "DETACHED";
// }
//
// public static class DigestAlgorithm {
// public static String SHA256 = "SHA256";
// }
//
// public static class KeyRegex {
// public static String MATCH_ALL = ".*";
// }
//
// public List<String> getBaseArgs() {
// List<String> arguments = new ArrayList<String>();
// Collections.addAll(arguments);
// return arguments;
// }
// }
// Path: sd-dss-util-cli/src/test/java/it/latraccia/dss/util/cli/test/integration/PKCS11PADESSuccessfulIntegrationTest.java
import it.latraccia.dss.util.cli.test.PADESSuccessfulGenericTest;
import it.latraccia.dss.util.cli.test.util.SignatureArgsHelper;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
/*
* SD-DSS-Util, a Utility Library and a Command Line Interface for SD-DSS.
* Copyright (C) 2013 La Traccia http://www.latraccia.it/en/
* Developed by Francesco Pontillo
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see [http://www.gnu.org/licenses/].
*/
package it.latraccia.dss.util.cli.test.integration;
@RunWith(value = Parameterized.class)
@Category(value = it.latraccia.dss.util.cli.test.integration.PKCS11IntegrationTest.class) | public class PKCS11PADESSuccessfulIntegrationTest extends PADESSuccessfulGenericTest { |
latraccia/sd-dss-util | sd-dss-util-cli/src/test/java/it/latraccia/dss/util/cli/test/integration/PKCS11PADESSuccessfulIntegrationTest.java | // Path: sd-dss-util-cli/src/test/java/it/latraccia/dss/util/cli/test/PADESSuccessfulGenericTest.java
// @RunWith(value = Parameterized.class)
// public abstract class PADESSuccessfulGenericTest extends SuccessfulGenericTest {
//
// public PADESSuccessfulGenericTest(String description, Object[] args) {
// super(description, args);
// }
//
// @Parameterized.Parameters
// public static Collection<Object[]> getSuccessfulTestParams() {
// final Object[][] params =
// {
// // PDF, BES, ENVELOPED
// {"PDF, BES, ENVELOPED", new String[] {
// SignatureArgsHelper.Input.PDF_FILE,
// "-u=" + SignatureArgsHelper.Url.DSS,
// "-f=" + SignatureArgsHelper.Format.PADES,
// "-l=" + SignatureArgsHelper.Level.BES,
// "-p=" + SignatureArgsHelper.Packaging.ENVELOPED,
// "-o=\"" + SignatureArgsHelper.Output.ROOT + "\"",
// "-d=" + SignatureArgsHelper.DigestAlgorithm.SHA256,
// "-icn=\"" + SignatureArgsHelper.KeyRegex.MATCH_ALL + "\""
// }},
// // PDF, EPES, ENVELOPED
// {"PDF, EPES, ENVELOPED", new String[] {
// SignatureArgsHelper.Input.PDF_FILE,
// "-u=" + SignatureArgsHelper.Url.DSS,
// "-f=" + SignatureArgsHelper.Format.PADES,
// "-l=" + SignatureArgsHelper.Level.EPES,
// "-p=" + SignatureArgsHelper.Packaging.ENVELOPED,
// "-o=\"" + SignatureArgsHelper.Output.ROOT + "\"",
// "-d=" + SignatureArgsHelper.DigestAlgorithm.SHA256,
// "-icn=\"" + SignatureArgsHelper.KeyRegex.MATCH_ALL + "\""
// }}
// };
//
// return Arrays.asList(params);
// }
// }
//
// Path: sd-dss-util-cli/src/test/java/it/latraccia/dss/util/cli/test/util/SignatureArgsHelper.java
// public class SignatureArgsHelper {
//
// private static String resourceRoot;
//
// static {
// resourceRoot = "";
// }
//
// // All possibilities to be tested are listed here, then they are combined together
//
// public static class Url {
// public static String DSS = "http://localhost:8080/service";
// }
//
// public static class Input {
// public static String PDF_FILE = getFile("pdf");
//
// public static String DOC_FILE = getFile("doc");
//
// public static String DOCX_FILE = getFile("docx");
//
// public static String ODT_FILE = getFile("odt");
//
// public static String XML_FILE = getFile("xml");
//
// private static String getFile(String extension) {
// return "test." + extension;
// }
// }
//
// public static class Output {
// public static String ROOT = resourceRoot;
// }
//
// public static class PKCS12 {
// public static String KEY = FileHelper.getResource("0F.p12");
//
// public static String PASSWORD = "password";
// }
//
// public static class PKCS11 {
// public static String LIBRARY = FileHelper.getResource("drivers/bit4ipki.dll");
//
// public static String PASSWORD = "16061981";
// }
//
// public static class Format {
// public static String CADES = "CAdES";
//
// public static String PADES = "PAdES";
//
// public static String XADES = "XAdES";
//
// public static String ASICS = "ASiC-S";
// }
//
// public static class Level {
// public static String BES = "BES";
//
// public static String EPES = "EPES";
//
// public static String LTV = "LTV";
//
// public static String T = "T";
//
// public static String C = "C";
//
// public static String X = "X";
//
// public static String XL = "XL";
//
// public static String A = "A";
// }
//
// public static class Packaging {
// public static String ENVELOPED = "ENVELOPED";
//
// public static String ENVELOPING = "ENVELOPING";
//
// public static String DETACHED = "DETACHED";
// }
//
// public static class DigestAlgorithm {
// public static String SHA256 = "SHA256";
// }
//
// public static class KeyRegex {
// public static String MATCH_ALL = ".*";
// }
//
// public List<String> getBaseArgs() {
// List<String> arguments = new ArrayList<String>();
// Collections.addAll(arguments);
// return arguments;
// }
// }
| import it.latraccia.dss.util.cli.test.PADESSuccessfulGenericTest;
import it.latraccia.dss.util.cli.test.util.SignatureArgsHelper;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized; | /*
* SD-DSS-Util, a Utility Library and a Command Line Interface for SD-DSS.
* Copyright (C) 2013 La Traccia http://www.latraccia.it/en/
* Developed by Francesco Pontillo
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see [http://www.gnu.org/licenses/].
*/
package it.latraccia.dss.util.cli.test.integration;
@RunWith(value = Parameterized.class)
@Category(value = it.latraccia.dss.util.cli.test.integration.PKCS11IntegrationTest.class)
public class PKCS11PADESSuccessfulIntegrationTest extends PADESSuccessfulGenericTest {
public PKCS11PADESSuccessfulIntegrationTest(String description, Object[] args) {
super(description, args);
}
@Override
public boolean getSimulate() {
return false;
}
@Override
public String[] getClassArgs() {
return new String[] { | // Path: sd-dss-util-cli/src/test/java/it/latraccia/dss/util/cli/test/PADESSuccessfulGenericTest.java
// @RunWith(value = Parameterized.class)
// public abstract class PADESSuccessfulGenericTest extends SuccessfulGenericTest {
//
// public PADESSuccessfulGenericTest(String description, Object[] args) {
// super(description, args);
// }
//
// @Parameterized.Parameters
// public static Collection<Object[]> getSuccessfulTestParams() {
// final Object[][] params =
// {
// // PDF, BES, ENVELOPED
// {"PDF, BES, ENVELOPED", new String[] {
// SignatureArgsHelper.Input.PDF_FILE,
// "-u=" + SignatureArgsHelper.Url.DSS,
// "-f=" + SignatureArgsHelper.Format.PADES,
// "-l=" + SignatureArgsHelper.Level.BES,
// "-p=" + SignatureArgsHelper.Packaging.ENVELOPED,
// "-o=\"" + SignatureArgsHelper.Output.ROOT + "\"",
// "-d=" + SignatureArgsHelper.DigestAlgorithm.SHA256,
// "-icn=\"" + SignatureArgsHelper.KeyRegex.MATCH_ALL + "\""
// }},
// // PDF, EPES, ENVELOPED
// {"PDF, EPES, ENVELOPED", new String[] {
// SignatureArgsHelper.Input.PDF_FILE,
// "-u=" + SignatureArgsHelper.Url.DSS,
// "-f=" + SignatureArgsHelper.Format.PADES,
// "-l=" + SignatureArgsHelper.Level.EPES,
// "-p=" + SignatureArgsHelper.Packaging.ENVELOPED,
// "-o=\"" + SignatureArgsHelper.Output.ROOT + "\"",
// "-d=" + SignatureArgsHelper.DigestAlgorithm.SHA256,
// "-icn=\"" + SignatureArgsHelper.KeyRegex.MATCH_ALL + "\""
// }}
// };
//
// return Arrays.asList(params);
// }
// }
//
// Path: sd-dss-util-cli/src/test/java/it/latraccia/dss/util/cli/test/util/SignatureArgsHelper.java
// public class SignatureArgsHelper {
//
// private static String resourceRoot;
//
// static {
// resourceRoot = "";
// }
//
// // All possibilities to be tested are listed here, then they are combined together
//
// public static class Url {
// public static String DSS = "http://localhost:8080/service";
// }
//
// public static class Input {
// public static String PDF_FILE = getFile("pdf");
//
// public static String DOC_FILE = getFile("doc");
//
// public static String DOCX_FILE = getFile("docx");
//
// public static String ODT_FILE = getFile("odt");
//
// public static String XML_FILE = getFile("xml");
//
// private static String getFile(String extension) {
// return "test." + extension;
// }
// }
//
// public static class Output {
// public static String ROOT = resourceRoot;
// }
//
// public static class PKCS12 {
// public static String KEY = FileHelper.getResource("0F.p12");
//
// public static String PASSWORD = "password";
// }
//
// public static class PKCS11 {
// public static String LIBRARY = FileHelper.getResource("drivers/bit4ipki.dll");
//
// public static String PASSWORD = "16061981";
// }
//
// public static class Format {
// public static String CADES = "CAdES";
//
// public static String PADES = "PAdES";
//
// public static String XADES = "XAdES";
//
// public static String ASICS = "ASiC-S";
// }
//
// public static class Level {
// public static String BES = "BES";
//
// public static String EPES = "EPES";
//
// public static String LTV = "LTV";
//
// public static String T = "T";
//
// public static String C = "C";
//
// public static String X = "X";
//
// public static String XL = "XL";
//
// public static String A = "A";
// }
//
// public static class Packaging {
// public static String ENVELOPED = "ENVELOPED";
//
// public static String ENVELOPING = "ENVELOPING";
//
// public static String DETACHED = "DETACHED";
// }
//
// public static class DigestAlgorithm {
// public static String SHA256 = "SHA256";
// }
//
// public static class KeyRegex {
// public static String MATCH_ALL = ".*";
// }
//
// public List<String> getBaseArgs() {
// List<String> arguments = new ArrayList<String>();
// Collections.addAll(arguments);
// return arguments;
// }
// }
// Path: sd-dss-util-cli/src/test/java/it/latraccia/dss/util/cli/test/integration/PKCS11PADESSuccessfulIntegrationTest.java
import it.latraccia.dss.util.cli.test.PADESSuccessfulGenericTest;
import it.latraccia.dss.util.cli.test.util.SignatureArgsHelper;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
/*
* SD-DSS-Util, a Utility Library and a Command Line Interface for SD-DSS.
* Copyright (C) 2013 La Traccia http://www.latraccia.it/en/
* Developed by Francesco Pontillo
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see [http://www.gnu.org/licenses/].
*/
package it.latraccia.dss.util.cli.test.integration;
@RunWith(value = Parameterized.class)
@Category(value = it.latraccia.dss.util.cli.test.integration.PKCS11IntegrationTest.class)
public class PKCS11PADESSuccessfulIntegrationTest extends PADESSuccessfulGenericTest {
public PKCS11PADESSuccessfulIntegrationTest(String description, Object[] args) {
super(description, args);
}
@Override
public boolean getSimulate() {
return false;
}
@Override
public String[] getClassArgs() {
return new String[] { | "-p11=\"" + SignatureArgsHelper.PKCS11.LIBRARY + "\"", |
latraccia/sd-dss-util | sd-dss-util-cli/src/test/java/it/latraccia/dss/util/cli/test/integration/PKCS12PADESSuccessfulIntegrationTest.java | // Path: sd-dss-util-cli/src/test/java/it/latraccia/dss/util/cli/test/PADESSuccessfulGenericTest.java
// @RunWith(value = Parameterized.class)
// public abstract class PADESSuccessfulGenericTest extends SuccessfulGenericTest {
//
// public PADESSuccessfulGenericTest(String description, Object[] args) {
// super(description, args);
// }
//
// @Parameterized.Parameters
// public static Collection<Object[]> getSuccessfulTestParams() {
// final Object[][] params =
// {
// // PDF, BES, ENVELOPED
// {"PDF, BES, ENVELOPED", new String[] {
// SignatureArgsHelper.Input.PDF_FILE,
// "-u=" + SignatureArgsHelper.Url.DSS,
// "-f=" + SignatureArgsHelper.Format.PADES,
// "-l=" + SignatureArgsHelper.Level.BES,
// "-p=" + SignatureArgsHelper.Packaging.ENVELOPED,
// "-o=\"" + SignatureArgsHelper.Output.ROOT + "\"",
// "-d=" + SignatureArgsHelper.DigestAlgorithm.SHA256,
// "-icn=\"" + SignatureArgsHelper.KeyRegex.MATCH_ALL + "\""
// }},
// // PDF, EPES, ENVELOPED
// {"PDF, EPES, ENVELOPED", new String[] {
// SignatureArgsHelper.Input.PDF_FILE,
// "-u=" + SignatureArgsHelper.Url.DSS,
// "-f=" + SignatureArgsHelper.Format.PADES,
// "-l=" + SignatureArgsHelper.Level.EPES,
// "-p=" + SignatureArgsHelper.Packaging.ENVELOPED,
// "-o=\"" + SignatureArgsHelper.Output.ROOT + "\"",
// "-d=" + SignatureArgsHelper.DigestAlgorithm.SHA256,
// "-icn=\"" + SignatureArgsHelper.KeyRegex.MATCH_ALL + "\""
// }}
// };
//
// return Arrays.asList(params);
// }
// }
//
// Path: sd-dss-util-cli/src/test/java/it/latraccia/dss/util/cli/test/util/SignatureArgsHelper.java
// public class SignatureArgsHelper {
//
// private static String resourceRoot;
//
// static {
// resourceRoot = "";
// }
//
// // All possibilities to be tested are listed here, then they are combined together
//
// public static class Url {
// public static String DSS = "http://localhost:8080/service";
// }
//
// public static class Input {
// public static String PDF_FILE = getFile("pdf");
//
// public static String DOC_FILE = getFile("doc");
//
// public static String DOCX_FILE = getFile("docx");
//
// public static String ODT_FILE = getFile("odt");
//
// public static String XML_FILE = getFile("xml");
//
// private static String getFile(String extension) {
// return "test." + extension;
// }
// }
//
// public static class Output {
// public static String ROOT = resourceRoot;
// }
//
// public static class PKCS12 {
// public static String KEY = FileHelper.getResource("0F.p12");
//
// public static String PASSWORD = "password";
// }
//
// public static class PKCS11 {
// public static String LIBRARY = FileHelper.getResource("drivers/bit4ipki.dll");
//
// public static String PASSWORD = "16061981";
// }
//
// public static class Format {
// public static String CADES = "CAdES";
//
// public static String PADES = "PAdES";
//
// public static String XADES = "XAdES";
//
// public static String ASICS = "ASiC-S";
// }
//
// public static class Level {
// public static String BES = "BES";
//
// public static String EPES = "EPES";
//
// public static String LTV = "LTV";
//
// public static String T = "T";
//
// public static String C = "C";
//
// public static String X = "X";
//
// public static String XL = "XL";
//
// public static String A = "A";
// }
//
// public static class Packaging {
// public static String ENVELOPED = "ENVELOPED";
//
// public static String ENVELOPING = "ENVELOPING";
//
// public static String DETACHED = "DETACHED";
// }
//
// public static class DigestAlgorithm {
// public static String SHA256 = "SHA256";
// }
//
// public static class KeyRegex {
// public static String MATCH_ALL = ".*";
// }
//
// public List<String> getBaseArgs() {
// List<String> arguments = new ArrayList<String>();
// Collections.addAll(arguments);
// return arguments;
// }
// }
| import it.latraccia.dss.util.cli.test.PADESSuccessfulGenericTest;
import it.latraccia.dss.util.cli.test.util.SignatureArgsHelper;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized; | /*
* SD-DSS-Util, a Utility Library and a Command Line Interface for SD-DSS.
* Copyright (C) 2013 La Traccia http://www.latraccia.it/en/
* Developed by Francesco Pontillo
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see [http://www.gnu.org/licenses/].
*/
package it.latraccia.dss.util.cli.test.integration;
@RunWith(value = Parameterized.class)
@Category(value = it.latraccia.dss.util.cli.test.integration.PKCS12IntegrationTest.class) | // Path: sd-dss-util-cli/src/test/java/it/latraccia/dss/util/cli/test/PADESSuccessfulGenericTest.java
// @RunWith(value = Parameterized.class)
// public abstract class PADESSuccessfulGenericTest extends SuccessfulGenericTest {
//
// public PADESSuccessfulGenericTest(String description, Object[] args) {
// super(description, args);
// }
//
// @Parameterized.Parameters
// public static Collection<Object[]> getSuccessfulTestParams() {
// final Object[][] params =
// {
// // PDF, BES, ENVELOPED
// {"PDF, BES, ENVELOPED", new String[] {
// SignatureArgsHelper.Input.PDF_FILE,
// "-u=" + SignatureArgsHelper.Url.DSS,
// "-f=" + SignatureArgsHelper.Format.PADES,
// "-l=" + SignatureArgsHelper.Level.BES,
// "-p=" + SignatureArgsHelper.Packaging.ENVELOPED,
// "-o=\"" + SignatureArgsHelper.Output.ROOT + "\"",
// "-d=" + SignatureArgsHelper.DigestAlgorithm.SHA256,
// "-icn=\"" + SignatureArgsHelper.KeyRegex.MATCH_ALL + "\""
// }},
// // PDF, EPES, ENVELOPED
// {"PDF, EPES, ENVELOPED", new String[] {
// SignatureArgsHelper.Input.PDF_FILE,
// "-u=" + SignatureArgsHelper.Url.DSS,
// "-f=" + SignatureArgsHelper.Format.PADES,
// "-l=" + SignatureArgsHelper.Level.EPES,
// "-p=" + SignatureArgsHelper.Packaging.ENVELOPED,
// "-o=\"" + SignatureArgsHelper.Output.ROOT + "\"",
// "-d=" + SignatureArgsHelper.DigestAlgorithm.SHA256,
// "-icn=\"" + SignatureArgsHelper.KeyRegex.MATCH_ALL + "\""
// }}
// };
//
// return Arrays.asList(params);
// }
// }
//
// Path: sd-dss-util-cli/src/test/java/it/latraccia/dss/util/cli/test/util/SignatureArgsHelper.java
// public class SignatureArgsHelper {
//
// private static String resourceRoot;
//
// static {
// resourceRoot = "";
// }
//
// // All possibilities to be tested are listed here, then they are combined together
//
// public static class Url {
// public static String DSS = "http://localhost:8080/service";
// }
//
// public static class Input {
// public static String PDF_FILE = getFile("pdf");
//
// public static String DOC_FILE = getFile("doc");
//
// public static String DOCX_FILE = getFile("docx");
//
// public static String ODT_FILE = getFile("odt");
//
// public static String XML_FILE = getFile("xml");
//
// private static String getFile(String extension) {
// return "test." + extension;
// }
// }
//
// public static class Output {
// public static String ROOT = resourceRoot;
// }
//
// public static class PKCS12 {
// public static String KEY = FileHelper.getResource("0F.p12");
//
// public static String PASSWORD = "password";
// }
//
// public static class PKCS11 {
// public static String LIBRARY = FileHelper.getResource("drivers/bit4ipki.dll");
//
// public static String PASSWORD = "16061981";
// }
//
// public static class Format {
// public static String CADES = "CAdES";
//
// public static String PADES = "PAdES";
//
// public static String XADES = "XAdES";
//
// public static String ASICS = "ASiC-S";
// }
//
// public static class Level {
// public static String BES = "BES";
//
// public static String EPES = "EPES";
//
// public static String LTV = "LTV";
//
// public static String T = "T";
//
// public static String C = "C";
//
// public static String X = "X";
//
// public static String XL = "XL";
//
// public static String A = "A";
// }
//
// public static class Packaging {
// public static String ENVELOPED = "ENVELOPED";
//
// public static String ENVELOPING = "ENVELOPING";
//
// public static String DETACHED = "DETACHED";
// }
//
// public static class DigestAlgorithm {
// public static String SHA256 = "SHA256";
// }
//
// public static class KeyRegex {
// public static String MATCH_ALL = ".*";
// }
//
// public List<String> getBaseArgs() {
// List<String> arguments = new ArrayList<String>();
// Collections.addAll(arguments);
// return arguments;
// }
// }
// Path: sd-dss-util-cli/src/test/java/it/latraccia/dss/util/cli/test/integration/PKCS12PADESSuccessfulIntegrationTest.java
import it.latraccia.dss.util.cli.test.PADESSuccessfulGenericTest;
import it.latraccia.dss.util.cli.test.util.SignatureArgsHelper;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
/*
* SD-DSS-Util, a Utility Library and a Command Line Interface for SD-DSS.
* Copyright (C) 2013 La Traccia http://www.latraccia.it/en/
* Developed by Francesco Pontillo
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see [http://www.gnu.org/licenses/].
*/
package it.latraccia.dss.util.cli.test.integration;
@RunWith(value = Parameterized.class)
@Category(value = it.latraccia.dss.util.cli.test.integration.PKCS12IntegrationTest.class) | public class PKCS12PADESSuccessfulIntegrationTest extends PADESSuccessfulGenericTest { |
latraccia/sd-dss-util | sd-dss-util-cli/src/test/java/it/latraccia/dss/util/cli/test/integration/PKCS12PADESSuccessfulIntegrationTest.java | // Path: sd-dss-util-cli/src/test/java/it/latraccia/dss/util/cli/test/PADESSuccessfulGenericTest.java
// @RunWith(value = Parameterized.class)
// public abstract class PADESSuccessfulGenericTest extends SuccessfulGenericTest {
//
// public PADESSuccessfulGenericTest(String description, Object[] args) {
// super(description, args);
// }
//
// @Parameterized.Parameters
// public static Collection<Object[]> getSuccessfulTestParams() {
// final Object[][] params =
// {
// // PDF, BES, ENVELOPED
// {"PDF, BES, ENVELOPED", new String[] {
// SignatureArgsHelper.Input.PDF_FILE,
// "-u=" + SignatureArgsHelper.Url.DSS,
// "-f=" + SignatureArgsHelper.Format.PADES,
// "-l=" + SignatureArgsHelper.Level.BES,
// "-p=" + SignatureArgsHelper.Packaging.ENVELOPED,
// "-o=\"" + SignatureArgsHelper.Output.ROOT + "\"",
// "-d=" + SignatureArgsHelper.DigestAlgorithm.SHA256,
// "-icn=\"" + SignatureArgsHelper.KeyRegex.MATCH_ALL + "\""
// }},
// // PDF, EPES, ENVELOPED
// {"PDF, EPES, ENVELOPED", new String[] {
// SignatureArgsHelper.Input.PDF_FILE,
// "-u=" + SignatureArgsHelper.Url.DSS,
// "-f=" + SignatureArgsHelper.Format.PADES,
// "-l=" + SignatureArgsHelper.Level.EPES,
// "-p=" + SignatureArgsHelper.Packaging.ENVELOPED,
// "-o=\"" + SignatureArgsHelper.Output.ROOT + "\"",
// "-d=" + SignatureArgsHelper.DigestAlgorithm.SHA256,
// "-icn=\"" + SignatureArgsHelper.KeyRegex.MATCH_ALL + "\""
// }}
// };
//
// return Arrays.asList(params);
// }
// }
//
// Path: sd-dss-util-cli/src/test/java/it/latraccia/dss/util/cli/test/util/SignatureArgsHelper.java
// public class SignatureArgsHelper {
//
// private static String resourceRoot;
//
// static {
// resourceRoot = "";
// }
//
// // All possibilities to be tested are listed here, then they are combined together
//
// public static class Url {
// public static String DSS = "http://localhost:8080/service";
// }
//
// public static class Input {
// public static String PDF_FILE = getFile("pdf");
//
// public static String DOC_FILE = getFile("doc");
//
// public static String DOCX_FILE = getFile("docx");
//
// public static String ODT_FILE = getFile("odt");
//
// public static String XML_FILE = getFile("xml");
//
// private static String getFile(String extension) {
// return "test." + extension;
// }
// }
//
// public static class Output {
// public static String ROOT = resourceRoot;
// }
//
// public static class PKCS12 {
// public static String KEY = FileHelper.getResource("0F.p12");
//
// public static String PASSWORD = "password";
// }
//
// public static class PKCS11 {
// public static String LIBRARY = FileHelper.getResource("drivers/bit4ipki.dll");
//
// public static String PASSWORD = "16061981";
// }
//
// public static class Format {
// public static String CADES = "CAdES";
//
// public static String PADES = "PAdES";
//
// public static String XADES = "XAdES";
//
// public static String ASICS = "ASiC-S";
// }
//
// public static class Level {
// public static String BES = "BES";
//
// public static String EPES = "EPES";
//
// public static String LTV = "LTV";
//
// public static String T = "T";
//
// public static String C = "C";
//
// public static String X = "X";
//
// public static String XL = "XL";
//
// public static String A = "A";
// }
//
// public static class Packaging {
// public static String ENVELOPED = "ENVELOPED";
//
// public static String ENVELOPING = "ENVELOPING";
//
// public static String DETACHED = "DETACHED";
// }
//
// public static class DigestAlgorithm {
// public static String SHA256 = "SHA256";
// }
//
// public static class KeyRegex {
// public static String MATCH_ALL = ".*";
// }
//
// public List<String> getBaseArgs() {
// List<String> arguments = new ArrayList<String>();
// Collections.addAll(arguments);
// return arguments;
// }
// }
| import it.latraccia.dss.util.cli.test.PADESSuccessfulGenericTest;
import it.latraccia.dss.util.cli.test.util.SignatureArgsHelper;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized; | /*
* SD-DSS-Util, a Utility Library and a Command Line Interface for SD-DSS.
* Copyright (C) 2013 La Traccia http://www.latraccia.it/en/
* Developed by Francesco Pontillo
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see [http://www.gnu.org/licenses/].
*/
package it.latraccia.dss.util.cli.test.integration;
@RunWith(value = Parameterized.class)
@Category(value = it.latraccia.dss.util.cli.test.integration.PKCS12IntegrationTest.class)
public class PKCS12PADESSuccessfulIntegrationTest extends PADESSuccessfulGenericTest {
public PKCS12PADESSuccessfulIntegrationTest(String description, Object[] args) {
super(description, args);
}
@Override
public boolean getSimulate() {
return false;
}
@Override
public String[] getClassArgs() {
return new String[] { | // Path: sd-dss-util-cli/src/test/java/it/latraccia/dss/util/cli/test/PADESSuccessfulGenericTest.java
// @RunWith(value = Parameterized.class)
// public abstract class PADESSuccessfulGenericTest extends SuccessfulGenericTest {
//
// public PADESSuccessfulGenericTest(String description, Object[] args) {
// super(description, args);
// }
//
// @Parameterized.Parameters
// public static Collection<Object[]> getSuccessfulTestParams() {
// final Object[][] params =
// {
// // PDF, BES, ENVELOPED
// {"PDF, BES, ENVELOPED", new String[] {
// SignatureArgsHelper.Input.PDF_FILE,
// "-u=" + SignatureArgsHelper.Url.DSS,
// "-f=" + SignatureArgsHelper.Format.PADES,
// "-l=" + SignatureArgsHelper.Level.BES,
// "-p=" + SignatureArgsHelper.Packaging.ENVELOPED,
// "-o=\"" + SignatureArgsHelper.Output.ROOT + "\"",
// "-d=" + SignatureArgsHelper.DigestAlgorithm.SHA256,
// "-icn=\"" + SignatureArgsHelper.KeyRegex.MATCH_ALL + "\""
// }},
// // PDF, EPES, ENVELOPED
// {"PDF, EPES, ENVELOPED", new String[] {
// SignatureArgsHelper.Input.PDF_FILE,
// "-u=" + SignatureArgsHelper.Url.DSS,
// "-f=" + SignatureArgsHelper.Format.PADES,
// "-l=" + SignatureArgsHelper.Level.EPES,
// "-p=" + SignatureArgsHelper.Packaging.ENVELOPED,
// "-o=\"" + SignatureArgsHelper.Output.ROOT + "\"",
// "-d=" + SignatureArgsHelper.DigestAlgorithm.SHA256,
// "-icn=\"" + SignatureArgsHelper.KeyRegex.MATCH_ALL + "\""
// }}
// };
//
// return Arrays.asList(params);
// }
// }
//
// Path: sd-dss-util-cli/src/test/java/it/latraccia/dss/util/cli/test/util/SignatureArgsHelper.java
// public class SignatureArgsHelper {
//
// private static String resourceRoot;
//
// static {
// resourceRoot = "";
// }
//
// // All possibilities to be tested are listed here, then they are combined together
//
// public static class Url {
// public static String DSS = "http://localhost:8080/service";
// }
//
// public static class Input {
// public static String PDF_FILE = getFile("pdf");
//
// public static String DOC_FILE = getFile("doc");
//
// public static String DOCX_FILE = getFile("docx");
//
// public static String ODT_FILE = getFile("odt");
//
// public static String XML_FILE = getFile("xml");
//
// private static String getFile(String extension) {
// return "test." + extension;
// }
// }
//
// public static class Output {
// public static String ROOT = resourceRoot;
// }
//
// public static class PKCS12 {
// public static String KEY = FileHelper.getResource("0F.p12");
//
// public static String PASSWORD = "password";
// }
//
// public static class PKCS11 {
// public static String LIBRARY = FileHelper.getResource("drivers/bit4ipki.dll");
//
// public static String PASSWORD = "16061981";
// }
//
// public static class Format {
// public static String CADES = "CAdES";
//
// public static String PADES = "PAdES";
//
// public static String XADES = "XAdES";
//
// public static String ASICS = "ASiC-S";
// }
//
// public static class Level {
// public static String BES = "BES";
//
// public static String EPES = "EPES";
//
// public static String LTV = "LTV";
//
// public static String T = "T";
//
// public static String C = "C";
//
// public static String X = "X";
//
// public static String XL = "XL";
//
// public static String A = "A";
// }
//
// public static class Packaging {
// public static String ENVELOPED = "ENVELOPED";
//
// public static String ENVELOPING = "ENVELOPING";
//
// public static String DETACHED = "DETACHED";
// }
//
// public static class DigestAlgorithm {
// public static String SHA256 = "SHA256";
// }
//
// public static class KeyRegex {
// public static String MATCH_ALL = ".*";
// }
//
// public List<String> getBaseArgs() {
// List<String> arguments = new ArrayList<String>();
// Collections.addAll(arguments);
// return arguments;
// }
// }
// Path: sd-dss-util-cli/src/test/java/it/latraccia/dss/util/cli/test/integration/PKCS12PADESSuccessfulIntegrationTest.java
import it.latraccia.dss.util.cli.test.PADESSuccessfulGenericTest;
import it.latraccia.dss.util.cli.test.util.SignatureArgsHelper;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
/*
* SD-DSS-Util, a Utility Library and a Command Line Interface for SD-DSS.
* Copyright (C) 2013 La Traccia http://www.latraccia.it/en/
* Developed by Francesco Pontillo
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see [http://www.gnu.org/licenses/].
*/
package it.latraccia.dss.util.cli.test.integration;
@RunWith(value = Parameterized.class)
@Category(value = it.latraccia.dss.util.cli.test.integration.PKCS12IntegrationTest.class)
public class PKCS12PADESSuccessfulIntegrationTest extends PADESSuccessfulGenericTest {
public PKCS12PADESSuccessfulIntegrationTest(String description, Object[] args) {
super(description, args);
}
@Override
public boolean getSimulate() {
return false;
}
@Override
public String[] getClassArgs() {
return new String[] { | "-p12=\"" + SignatureArgsHelper.PKCS12.KEY + "\"", |
abego/treelayout | org.abego.treelayout/src/main/java/org/abego/treelayout/util/FixedNodeExtentProvider.java | // Path: org.abego.treelayout/src/main/java/org/abego/treelayout/internal/util/Contract.java
// public static void checkArg(boolean isOK, String s) {
// if (!isOK) {
// throw new IllegalArgumentException(s);
// }
// }
//
// Path: org.abego.treelayout/src/main/java/org/abego/treelayout/NodeExtentProvider.java
// public interface NodeExtentProvider<TreeNode> {
// /**
// * Returns the width of the given treeNode.
// *
// * @param treeNode
// * @return [result >= 0]
// */
// double getWidth(TreeNode treeNode);
//
// /**
// * Returns the height of the given treeNode.
// *
// * @param treeNode
// * @return [result >= 0]
// */
// double getHeight(TreeNode treeNode);
// }
| import org.abego.treelayout.NodeExtentProvider;
import static org.abego.treelayout.internal.util.Contract.checkArg; | /*
* [The "BSD license"]
* Copyright (c) 2011, abego Software GmbH, Germany (http://www.abego.org)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of the abego Software GmbH nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package org.abego.treelayout.util;
/**
* A {@link NodeExtentProvider} returning the same width and height for each
* node.
*
* @author Udo Borkowski ([email protected])
*
* @param <T> Type of elements used as nodes in the tree
*/
public class FixedNodeExtentProvider<T> implements NodeExtentProvider<T> {
private final double width;
private final double height;
/**
* Specifies the constants to be used as the width and height of the nodes.
*
* @param width
* [default=0]
*
* @param height
* [default=0]
*/
public FixedNodeExtentProvider(double width, double height) { | // Path: org.abego.treelayout/src/main/java/org/abego/treelayout/internal/util/Contract.java
// public static void checkArg(boolean isOK, String s) {
// if (!isOK) {
// throw new IllegalArgumentException(s);
// }
// }
//
// Path: org.abego.treelayout/src/main/java/org/abego/treelayout/NodeExtentProvider.java
// public interface NodeExtentProvider<TreeNode> {
// /**
// * Returns the width of the given treeNode.
// *
// * @param treeNode
// * @return [result >= 0]
// */
// double getWidth(TreeNode treeNode);
//
// /**
// * Returns the height of the given treeNode.
// *
// * @param treeNode
// * @return [result >= 0]
// */
// double getHeight(TreeNode treeNode);
// }
// Path: org.abego.treelayout/src/main/java/org/abego/treelayout/util/FixedNodeExtentProvider.java
import org.abego.treelayout.NodeExtentProvider;
import static org.abego.treelayout.internal.util.Contract.checkArg;
/*
* [The "BSD license"]
* Copyright (c) 2011, abego Software GmbH, Germany (http://www.abego.org)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of the abego Software GmbH nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package org.abego.treelayout.util;
/**
* A {@link NodeExtentProvider} returning the same width and height for each
* node.
*
* @author Udo Borkowski ([email protected])
*
* @param <T> Type of elements used as nodes in the tree
*/
public class FixedNodeExtentProvider<T> implements NodeExtentProvider<T> {
private final double width;
private final double height;
/**
* Specifies the constants to be used as the width and height of the nodes.
*
* @param width
* [default=0]
*
* @param height
* [default=0]
*/
public FixedNodeExtentProvider(double width, double height) { | checkArg(width >= 0, "width must be >= 0"); |
abego/treelayout | org.abego.treelayout/src/test/java/org/abego/treelayout/util/DefaultTreeLayoutConfigurationTest.java | // Path: org.abego.treelayout/src/main/java/org/abego/treelayout/Configuration.java
// public enum AlignmentInLevel {
// Center, TowardsRoot, AwayFromRoot
// }
//
// Path: org.abego.treelayout/src/main/java/org/abego/treelayout/Configuration.java
// public enum Location {
// Top, Left, Bottom, Right
// }
//
// Path: org.abego.treelayout/src/main/java/org/abego/treelayout/util/DefaultConfiguration.java
// public class DefaultConfiguration<TreeNode> implements
// Configuration<TreeNode> {
//
// /**
// * Specifies the constants to be used for this Configuration.
// *
// * @param gapBetweenLevels
// * @param gapBetweenNodes
// * @param location
// * [default: {@link org.abego.treelayout.Configuration.Location#Top Top}]
// * @param alignmentInLevel
// * [default: {@link org.abego.treelayout.Configuration.AlignmentInLevel#Center Center}]
// */
// public DefaultConfiguration(double gapBetweenLevels,
// double gapBetweenNodes, Location location,
// AlignmentInLevel alignmentInLevel) {
// checkArg(gapBetweenLevels >= 0, "gapBetweenLevels must be >= 0");
// checkArg(gapBetweenNodes >= 0, "gapBetweenNodes must be >= 0");
//
// this.gapBetweenLevels = gapBetweenLevels;
// this.gapBetweenNodes = gapBetweenNodes;
// this.location = location;
// this.alignmentInLevel = alignmentInLevel;
// }
//
// /**
// * Convenience constructor, using a default for the alignmentInLevel.
// * <p>
// * see
// * {@link #DefaultConfiguration(double, double, org.abego.treelayout.Configuration.Location, org.abego.treelayout.Configuration.AlignmentInLevel)}
// * </p>
// * @param gapBetweenLevels
// * @param gapBetweenNodes
// * @param location
// */
// public DefaultConfiguration(double gapBetweenLevels,
// double gapBetweenNodes, Location location) {
// this(gapBetweenLevels, gapBetweenNodes, location,
// AlignmentInLevel.Center);
// }
//
// /**
// * Convenience constructor, using a default for the rootLocation and the
// * alignmentInLevel.
// * <p>
// * see
// * {@link #DefaultConfiguration(double, double, org.abego.treelayout.Configuration.Location, org.abego.treelayout.Configuration.AlignmentInLevel)}
// * </p>
// * @param gapBetweenLevels
// * @param gapBetweenNodes
// */
// public DefaultConfiguration(double gapBetweenLevels,
// double gapBetweenNodes) {
// this(gapBetweenLevels, gapBetweenNodes, Location.Top,
// AlignmentInLevel.Center);
// }
//
// // -----------------------------------------------------------------------
// // gapBetweenLevels
//
// private final double gapBetweenLevels;
//
// @Override
// public double getGapBetweenLevels(int nextLevel) {
// return gapBetweenLevels;
// }
//
// // -----------------------------------------------------------------------
// // gapBetweenNodes
//
// private final double gapBetweenNodes;
//
// @Override
// public double getGapBetweenNodes(TreeNode node1, TreeNode node2) {
// return gapBetweenNodes;
// }
//
// // -----------------------------------------------------------------------
// // location
//
// private final Location location;
//
// @Override
// public Location getRootLocation() {
// return location;
// }
//
// // -----------------------------------------------------------------------
// // alignmentInLevel
//
// private AlignmentInLevel alignmentInLevel;
//
// @Override
// public AlignmentInLevel getAlignmentInLevel() {
// return alignmentInLevel;
// }
//
// }
| import org.abego.treelayout.Configuration.Location;
import org.abego.treelayout.util.DefaultConfiguration;
import org.junit.Test;
import static org.junit.Assert.*;
import org.abego.treelayout.Configuration.AlignmentInLevel; | /*
* [The "BSD license"]
* Copyright (c) 2011, abego Software GmbH, Germany (http://www.abego.org)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of the abego Software GmbH nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package org.abego.treelayout.util;
/**
*
* @author Udo Borkowski ([email protected])
*
*
*/
public class DefaultTreeLayoutConfigurationTest {
@Test
public void testConstructor() throws Exception { | // Path: org.abego.treelayout/src/main/java/org/abego/treelayout/Configuration.java
// public enum AlignmentInLevel {
// Center, TowardsRoot, AwayFromRoot
// }
//
// Path: org.abego.treelayout/src/main/java/org/abego/treelayout/Configuration.java
// public enum Location {
// Top, Left, Bottom, Right
// }
//
// Path: org.abego.treelayout/src/main/java/org/abego/treelayout/util/DefaultConfiguration.java
// public class DefaultConfiguration<TreeNode> implements
// Configuration<TreeNode> {
//
// /**
// * Specifies the constants to be used for this Configuration.
// *
// * @param gapBetweenLevels
// * @param gapBetweenNodes
// * @param location
// * [default: {@link org.abego.treelayout.Configuration.Location#Top Top}]
// * @param alignmentInLevel
// * [default: {@link org.abego.treelayout.Configuration.AlignmentInLevel#Center Center}]
// */
// public DefaultConfiguration(double gapBetweenLevels,
// double gapBetweenNodes, Location location,
// AlignmentInLevel alignmentInLevel) {
// checkArg(gapBetweenLevels >= 0, "gapBetweenLevels must be >= 0");
// checkArg(gapBetweenNodes >= 0, "gapBetweenNodes must be >= 0");
//
// this.gapBetweenLevels = gapBetweenLevels;
// this.gapBetweenNodes = gapBetweenNodes;
// this.location = location;
// this.alignmentInLevel = alignmentInLevel;
// }
//
// /**
// * Convenience constructor, using a default for the alignmentInLevel.
// * <p>
// * see
// * {@link #DefaultConfiguration(double, double, org.abego.treelayout.Configuration.Location, org.abego.treelayout.Configuration.AlignmentInLevel)}
// * </p>
// * @param gapBetweenLevels
// * @param gapBetweenNodes
// * @param location
// */
// public DefaultConfiguration(double gapBetweenLevels,
// double gapBetweenNodes, Location location) {
// this(gapBetweenLevels, gapBetweenNodes, location,
// AlignmentInLevel.Center);
// }
//
// /**
// * Convenience constructor, using a default for the rootLocation and the
// * alignmentInLevel.
// * <p>
// * see
// * {@link #DefaultConfiguration(double, double, org.abego.treelayout.Configuration.Location, org.abego.treelayout.Configuration.AlignmentInLevel)}
// * </p>
// * @param gapBetweenLevels
// * @param gapBetweenNodes
// */
// public DefaultConfiguration(double gapBetweenLevels,
// double gapBetweenNodes) {
// this(gapBetweenLevels, gapBetweenNodes, Location.Top,
// AlignmentInLevel.Center);
// }
//
// // -----------------------------------------------------------------------
// // gapBetweenLevels
//
// private final double gapBetweenLevels;
//
// @Override
// public double getGapBetweenLevels(int nextLevel) {
// return gapBetweenLevels;
// }
//
// // -----------------------------------------------------------------------
// // gapBetweenNodes
//
// private final double gapBetweenNodes;
//
// @Override
// public double getGapBetweenNodes(TreeNode node1, TreeNode node2) {
// return gapBetweenNodes;
// }
//
// // -----------------------------------------------------------------------
// // location
//
// private final Location location;
//
// @Override
// public Location getRootLocation() {
// return location;
// }
//
// // -----------------------------------------------------------------------
// // alignmentInLevel
//
// private AlignmentInLevel alignmentInLevel;
//
// @Override
// public AlignmentInLevel getAlignmentInLevel() {
// return alignmentInLevel;
// }
//
// }
// Path: org.abego.treelayout/src/test/java/org/abego/treelayout/util/DefaultTreeLayoutConfigurationTest.java
import org.abego.treelayout.Configuration.Location;
import org.abego.treelayout.util.DefaultConfiguration;
import org.junit.Test;
import static org.junit.Assert.*;
import org.abego.treelayout.Configuration.AlignmentInLevel;
/*
* [The "BSD license"]
* Copyright (c) 2011, abego Software GmbH, Germany (http://www.abego.org)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of the abego Software GmbH nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package org.abego.treelayout.util;
/**
*
* @author Udo Borkowski ([email protected])
*
*
*/
public class DefaultTreeLayoutConfigurationTest {
@Test
public void testConstructor() throws Exception { | DefaultConfiguration config = new DefaultConfiguration( |
abego/treelayout | org.abego.treelayout/src/test/java/org/abego/treelayout/util/DefaultTreeLayoutConfigurationTest.java | // Path: org.abego.treelayout/src/main/java/org/abego/treelayout/Configuration.java
// public enum AlignmentInLevel {
// Center, TowardsRoot, AwayFromRoot
// }
//
// Path: org.abego.treelayout/src/main/java/org/abego/treelayout/Configuration.java
// public enum Location {
// Top, Left, Bottom, Right
// }
//
// Path: org.abego.treelayout/src/main/java/org/abego/treelayout/util/DefaultConfiguration.java
// public class DefaultConfiguration<TreeNode> implements
// Configuration<TreeNode> {
//
// /**
// * Specifies the constants to be used for this Configuration.
// *
// * @param gapBetweenLevels
// * @param gapBetweenNodes
// * @param location
// * [default: {@link org.abego.treelayout.Configuration.Location#Top Top}]
// * @param alignmentInLevel
// * [default: {@link org.abego.treelayout.Configuration.AlignmentInLevel#Center Center}]
// */
// public DefaultConfiguration(double gapBetweenLevels,
// double gapBetweenNodes, Location location,
// AlignmentInLevel alignmentInLevel) {
// checkArg(gapBetweenLevels >= 0, "gapBetweenLevels must be >= 0");
// checkArg(gapBetweenNodes >= 0, "gapBetweenNodes must be >= 0");
//
// this.gapBetweenLevels = gapBetweenLevels;
// this.gapBetweenNodes = gapBetweenNodes;
// this.location = location;
// this.alignmentInLevel = alignmentInLevel;
// }
//
// /**
// * Convenience constructor, using a default for the alignmentInLevel.
// * <p>
// * see
// * {@link #DefaultConfiguration(double, double, org.abego.treelayout.Configuration.Location, org.abego.treelayout.Configuration.AlignmentInLevel)}
// * </p>
// * @param gapBetweenLevels
// * @param gapBetweenNodes
// * @param location
// */
// public DefaultConfiguration(double gapBetweenLevels,
// double gapBetweenNodes, Location location) {
// this(gapBetweenLevels, gapBetweenNodes, location,
// AlignmentInLevel.Center);
// }
//
// /**
// * Convenience constructor, using a default for the rootLocation and the
// * alignmentInLevel.
// * <p>
// * see
// * {@link #DefaultConfiguration(double, double, org.abego.treelayout.Configuration.Location, org.abego.treelayout.Configuration.AlignmentInLevel)}
// * </p>
// * @param gapBetweenLevels
// * @param gapBetweenNodes
// */
// public DefaultConfiguration(double gapBetweenLevels,
// double gapBetweenNodes) {
// this(gapBetweenLevels, gapBetweenNodes, Location.Top,
// AlignmentInLevel.Center);
// }
//
// // -----------------------------------------------------------------------
// // gapBetweenLevels
//
// private final double gapBetweenLevels;
//
// @Override
// public double getGapBetweenLevels(int nextLevel) {
// return gapBetweenLevels;
// }
//
// // -----------------------------------------------------------------------
// // gapBetweenNodes
//
// private final double gapBetweenNodes;
//
// @Override
// public double getGapBetweenNodes(TreeNode node1, TreeNode node2) {
// return gapBetweenNodes;
// }
//
// // -----------------------------------------------------------------------
// // location
//
// private final Location location;
//
// @Override
// public Location getRootLocation() {
// return location;
// }
//
// // -----------------------------------------------------------------------
// // alignmentInLevel
//
// private AlignmentInLevel alignmentInLevel;
//
// @Override
// public AlignmentInLevel getAlignmentInLevel() {
// return alignmentInLevel;
// }
//
// }
| import org.abego.treelayout.Configuration.Location;
import org.abego.treelayout.util.DefaultConfiguration;
import org.junit.Test;
import static org.junit.Assert.*;
import org.abego.treelayout.Configuration.AlignmentInLevel; | /*
* [The "BSD license"]
* Copyright (c) 2011, abego Software GmbH, Germany (http://www.abego.org)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of the abego Software GmbH nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package org.abego.treelayout.util;
/**
*
* @author Udo Borkowski ([email protected])
*
*
*/
public class DefaultTreeLayoutConfigurationTest {
@Test
public void testConstructor() throws Exception {
DefaultConfiguration config = new DefaultConfiguration( | // Path: org.abego.treelayout/src/main/java/org/abego/treelayout/Configuration.java
// public enum AlignmentInLevel {
// Center, TowardsRoot, AwayFromRoot
// }
//
// Path: org.abego.treelayout/src/main/java/org/abego/treelayout/Configuration.java
// public enum Location {
// Top, Left, Bottom, Right
// }
//
// Path: org.abego.treelayout/src/main/java/org/abego/treelayout/util/DefaultConfiguration.java
// public class DefaultConfiguration<TreeNode> implements
// Configuration<TreeNode> {
//
// /**
// * Specifies the constants to be used for this Configuration.
// *
// * @param gapBetweenLevels
// * @param gapBetweenNodes
// * @param location
// * [default: {@link org.abego.treelayout.Configuration.Location#Top Top}]
// * @param alignmentInLevel
// * [default: {@link org.abego.treelayout.Configuration.AlignmentInLevel#Center Center}]
// */
// public DefaultConfiguration(double gapBetweenLevels,
// double gapBetweenNodes, Location location,
// AlignmentInLevel alignmentInLevel) {
// checkArg(gapBetweenLevels >= 0, "gapBetweenLevels must be >= 0");
// checkArg(gapBetweenNodes >= 0, "gapBetweenNodes must be >= 0");
//
// this.gapBetweenLevels = gapBetweenLevels;
// this.gapBetweenNodes = gapBetweenNodes;
// this.location = location;
// this.alignmentInLevel = alignmentInLevel;
// }
//
// /**
// * Convenience constructor, using a default for the alignmentInLevel.
// * <p>
// * see
// * {@link #DefaultConfiguration(double, double, org.abego.treelayout.Configuration.Location, org.abego.treelayout.Configuration.AlignmentInLevel)}
// * </p>
// * @param gapBetweenLevels
// * @param gapBetweenNodes
// * @param location
// */
// public DefaultConfiguration(double gapBetweenLevels,
// double gapBetweenNodes, Location location) {
// this(gapBetweenLevels, gapBetweenNodes, location,
// AlignmentInLevel.Center);
// }
//
// /**
// * Convenience constructor, using a default for the rootLocation and the
// * alignmentInLevel.
// * <p>
// * see
// * {@link #DefaultConfiguration(double, double, org.abego.treelayout.Configuration.Location, org.abego.treelayout.Configuration.AlignmentInLevel)}
// * </p>
// * @param gapBetweenLevels
// * @param gapBetweenNodes
// */
// public DefaultConfiguration(double gapBetweenLevels,
// double gapBetweenNodes) {
// this(gapBetweenLevels, gapBetweenNodes, Location.Top,
// AlignmentInLevel.Center);
// }
//
// // -----------------------------------------------------------------------
// // gapBetweenLevels
//
// private final double gapBetweenLevels;
//
// @Override
// public double getGapBetweenLevels(int nextLevel) {
// return gapBetweenLevels;
// }
//
// // -----------------------------------------------------------------------
// // gapBetweenNodes
//
// private final double gapBetweenNodes;
//
// @Override
// public double getGapBetweenNodes(TreeNode node1, TreeNode node2) {
// return gapBetweenNodes;
// }
//
// // -----------------------------------------------------------------------
// // location
//
// private final Location location;
//
// @Override
// public Location getRootLocation() {
// return location;
// }
//
// // -----------------------------------------------------------------------
// // alignmentInLevel
//
// private AlignmentInLevel alignmentInLevel;
//
// @Override
// public AlignmentInLevel getAlignmentInLevel() {
// return alignmentInLevel;
// }
//
// }
// Path: org.abego.treelayout/src/test/java/org/abego/treelayout/util/DefaultTreeLayoutConfigurationTest.java
import org.abego.treelayout.Configuration.Location;
import org.abego.treelayout.util.DefaultConfiguration;
import org.junit.Test;
import static org.junit.Assert.*;
import org.abego.treelayout.Configuration.AlignmentInLevel;
/*
* [The "BSD license"]
* Copyright (c) 2011, abego Software GmbH, Germany (http://www.abego.org)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of the abego Software GmbH nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package org.abego.treelayout.util;
/**
*
* @author Udo Borkowski ([email protected])
*
*
*/
public class DefaultTreeLayoutConfigurationTest {
@Test
public void testConstructor() throws Exception {
DefaultConfiguration config = new DefaultConfiguration( | 1, 2, Location.Right, AlignmentInLevel.AwayFromRoot); |
abego/treelayout | org.abego.treelayout/src/test/java/org/abego/treelayout/util/DefaultTreeLayoutConfigurationTest.java | // Path: org.abego.treelayout/src/main/java/org/abego/treelayout/Configuration.java
// public enum AlignmentInLevel {
// Center, TowardsRoot, AwayFromRoot
// }
//
// Path: org.abego.treelayout/src/main/java/org/abego/treelayout/Configuration.java
// public enum Location {
// Top, Left, Bottom, Right
// }
//
// Path: org.abego.treelayout/src/main/java/org/abego/treelayout/util/DefaultConfiguration.java
// public class DefaultConfiguration<TreeNode> implements
// Configuration<TreeNode> {
//
// /**
// * Specifies the constants to be used for this Configuration.
// *
// * @param gapBetweenLevels
// * @param gapBetweenNodes
// * @param location
// * [default: {@link org.abego.treelayout.Configuration.Location#Top Top}]
// * @param alignmentInLevel
// * [default: {@link org.abego.treelayout.Configuration.AlignmentInLevel#Center Center}]
// */
// public DefaultConfiguration(double gapBetweenLevels,
// double gapBetweenNodes, Location location,
// AlignmentInLevel alignmentInLevel) {
// checkArg(gapBetweenLevels >= 0, "gapBetweenLevels must be >= 0");
// checkArg(gapBetweenNodes >= 0, "gapBetweenNodes must be >= 0");
//
// this.gapBetweenLevels = gapBetweenLevels;
// this.gapBetweenNodes = gapBetweenNodes;
// this.location = location;
// this.alignmentInLevel = alignmentInLevel;
// }
//
// /**
// * Convenience constructor, using a default for the alignmentInLevel.
// * <p>
// * see
// * {@link #DefaultConfiguration(double, double, org.abego.treelayout.Configuration.Location, org.abego.treelayout.Configuration.AlignmentInLevel)}
// * </p>
// * @param gapBetweenLevels
// * @param gapBetweenNodes
// * @param location
// */
// public DefaultConfiguration(double gapBetweenLevels,
// double gapBetweenNodes, Location location) {
// this(gapBetweenLevels, gapBetweenNodes, location,
// AlignmentInLevel.Center);
// }
//
// /**
// * Convenience constructor, using a default for the rootLocation and the
// * alignmentInLevel.
// * <p>
// * see
// * {@link #DefaultConfiguration(double, double, org.abego.treelayout.Configuration.Location, org.abego.treelayout.Configuration.AlignmentInLevel)}
// * </p>
// * @param gapBetweenLevels
// * @param gapBetweenNodes
// */
// public DefaultConfiguration(double gapBetweenLevels,
// double gapBetweenNodes) {
// this(gapBetweenLevels, gapBetweenNodes, Location.Top,
// AlignmentInLevel.Center);
// }
//
// // -----------------------------------------------------------------------
// // gapBetweenLevels
//
// private final double gapBetweenLevels;
//
// @Override
// public double getGapBetweenLevels(int nextLevel) {
// return gapBetweenLevels;
// }
//
// // -----------------------------------------------------------------------
// // gapBetweenNodes
//
// private final double gapBetweenNodes;
//
// @Override
// public double getGapBetweenNodes(TreeNode node1, TreeNode node2) {
// return gapBetweenNodes;
// }
//
// // -----------------------------------------------------------------------
// // location
//
// private final Location location;
//
// @Override
// public Location getRootLocation() {
// return location;
// }
//
// // -----------------------------------------------------------------------
// // alignmentInLevel
//
// private AlignmentInLevel alignmentInLevel;
//
// @Override
// public AlignmentInLevel getAlignmentInLevel() {
// return alignmentInLevel;
// }
//
// }
| import org.abego.treelayout.Configuration.Location;
import org.abego.treelayout.util.DefaultConfiguration;
import org.junit.Test;
import static org.junit.Assert.*;
import org.abego.treelayout.Configuration.AlignmentInLevel; | /*
* [The "BSD license"]
* Copyright (c) 2011, abego Software GmbH, Germany (http://www.abego.org)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of the abego Software GmbH nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package org.abego.treelayout.util;
/**
*
* @author Udo Borkowski ([email protected])
*
*
*/
public class DefaultTreeLayoutConfigurationTest {
@Test
public void testConstructor() throws Exception {
DefaultConfiguration config = new DefaultConfiguration( | // Path: org.abego.treelayout/src/main/java/org/abego/treelayout/Configuration.java
// public enum AlignmentInLevel {
// Center, TowardsRoot, AwayFromRoot
// }
//
// Path: org.abego.treelayout/src/main/java/org/abego/treelayout/Configuration.java
// public enum Location {
// Top, Left, Bottom, Right
// }
//
// Path: org.abego.treelayout/src/main/java/org/abego/treelayout/util/DefaultConfiguration.java
// public class DefaultConfiguration<TreeNode> implements
// Configuration<TreeNode> {
//
// /**
// * Specifies the constants to be used for this Configuration.
// *
// * @param gapBetweenLevels
// * @param gapBetweenNodes
// * @param location
// * [default: {@link org.abego.treelayout.Configuration.Location#Top Top}]
// * @param alignmentInLevel
// * [default: {@link org.abego.treelayout.Configuration.AlignmentInLevel#Center Center}]
// */
// public DefaultConfiguration(double gapBetweenLevels,
// double gapBetweenNodes, Location location,
// AlignmentInLevel alignmentInLevel) {
// checkArg(gapBetweenLevels >= 0, "gapBetweenLevels must be >= 0");
// checkArg(gapBetweenNodes >= 0, "gapBetweenNodes must be >= 0");
//
// this.gapBetweenLevels = gapBetweenLevels;
// this.gapBetweenNodes = gapBetweenNodes;
// this.location = location;
// this.alignmentInLevel = alignmentInLevel;
// }
//
// /**
// * Convenience constructor, using a default for the alignmentInLevel.
// * <p>
// * see
// * {@link #DefaultConfiguration(double, double, org.abego.treelayout.Configuration.Location, org.abego.treelayout.Configuration.AlignmentInLevel)}
// * </p>
// * @param gapBetweenLevels
// * @param gapBetweenNodes
// * @param location
// */
// public DefaultConfiguration(double gapBetweenLevels,
// double gapBetweenNodes, Location location) {
// this(gapBetweenLevels, gapBetweenNodes, location,
// AlignmentInLevel.Center);
// }
//
// /**
// * Convenience constructor, using a default for the rootLocation and the
// * alignmentInLevel.
// * <p>
// * see
// * {@link #DefaultConfiguration(double, double, org.abego.treelayout.Configuration.Location, org.abego.treelayout.Configuration.AlignmentInLevel)}
// * </p>
// * @param gapBetweenLevels
// * @param gapBetweenNodes
// */
// public DefaultConfiguration(double gapBetweenLevels,
// double gapBetweenNodes) {
// this(gapBetweenLevels, gapBetweenNodes, Location.Top,
// AlignmentInLevel.Center);
// }
//
// // -----------------------------------------------------------------------
// // gapBetweenLevels
//
// private final double gapBetweenLevels;
//
// @Override
// public double getGapBetweenLevels(int nextLevel) {
// return gapBetweenLevels;
// }
//
// // -----------------------------------------------------------------------
// // gapBetweenNodes
//
// private final double gapBetweenNodes;
//
// @Override
// public double getGapBetweenNodes(TreeNode node1, TreeNode node2) {
// return gapBetweenNodes;
// }
//
// // -----------------------------------------------------------------------
// // location
//
// private final Location location;
//
// @Override
// public Location getRootLocation() {
// return location;
// }
//
// // -----------------------------------------------------------------------
// // alignmentInLevel
//
// private AlignmentInLevel alignmentInLevel;
//
// @Override
// public AlignmentInLevel getAlignmentInLevel() {
// return alignmentInLevel;
// }
//
// }
// Path: org.abego.treelayout/src/test/java/org/abego/treelayout/util/DefaultTreeLayoutConfigurationTest.java
import org.abego.treelayout.Configuration.Location;
import org.abego.treelayout.util.DefaultConfiguration;
import org.junit.Test;
import static org.junit.Assert.*;
import org.abego.treelayout.Configuration.AlignmentInLevel;
/*
* [The "BSD license"]
* Copyright (c) 2011, abego Software GmbH, Germany (http://www.abego.org)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of the abego Software GmbH nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package org.abego.treelayout.util;
/**
*
* @author Udo Borkowski ([email protected])
*
*
*/
public class DefaultTreeLayoutConfigurationTest {
@Test
public void testConstructor() throws Exception {
DefaultConfiguration config = new DefaultConfiguration( | 1, 2, Location.Right, AlignmentInLevel.AwayFromRoot); |
abego/treelayout | org.abego.treelayout/src/main/java/org/abego/treelayout/TreeLayout.java | // Path: org.abego.treelayout/src/main/java/org/abego/treelayout/internal/util/Contract.java
// public static void checkArg(boolean isOK, String s) {
// if (!isOK) {
// throw new IllegalArgumentException(s);
// }
// }
//
// Path: org.abego.treelayout/src/main/java/org/abego/treelayout/Configuration.java
// public enum AlignmentInLevel {
// Center, TowardsRoot, AwayFromRoot
// }
//
// Path: org.abego.treelayout/src/main/java/org/abego/treelayout/Configuration.java
// public enum Location {
// Top, Left, Bottom, Right
// }
//
// Path: org.abego.treelayout/src/main/java/org/abego/treelayout/internal/util/java/lang/string/StringUtil.java
// public class StringUtil {
// /**
// * Returns a quoted version of a given string, i.e. as a Java String
// * Literal.
// *
// * @param s
// * [nullable] the string to quote
// * @param nullResult
// * [default="null"] the String to be returned for null values.
// * @return the nullResult when s is null, otherwise s as a quoted string
// * (i.e. Java String Literal)
// *
// */
// public static String quote(String s, String nullResult) {
// if (s == null) {
// return nullResult;
// }
// StringBuffer result = new StringBuffer();
// result.append('"');
// int length = s.length();
// for (int i = 0; i < length; i++) {
// char c = s.charAt(i);
// switch (c) {
// case '\b': {
// result.append("\\b");
// break;
// }
// case '\f': {
// result.append("\\f");
// break;
// }
// case '\n': {
// result.append("\\n");
// break;
// }
// case '\r': {
// result.append("\\r");
// break;
// }
// case '\t': {
// result.append("\\t");
// break;
// }
// case '\\': {
// result.append("\\\\");
// break;
// }
// case '"': {
// result.append("\\\"");
// break;
// }
// default: {
// if (c < ' ' || c >= '\u0080') {
// String n = Integer.toHexString(c);
// result.append("\\u");
// result.append("0000".substring(n.length()));
// result.append(n);
// } else {
// result.append(c);
// }
// }
// }
// }
// result.append('"');
// return result.toString();
// }
//
// /**
// * see {@link #quote(String, String)}
// *
// * @param s the string to quote
// * @return nullable
// */
// public static String quote(String s) {
// return quote(s, "null");
// }
// }
| import static org.abego.treelayout.internal.util.Contract.checkArg;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.IdentityHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.abego.treelayout.Configuration.AlignmentInLevel;
import org.abego.treelayout.Configuration.Location;
import org.abego.treelayout.internal.util.java.lang.string.StringUtil; | }
if (!tree.isLeaf(node)) {
for (TreeNode child : tree.getChildren(node)) {
calcSizeOfLevels(child, level + 1);
}
}
}
/**
* Returns the number of levels of the tree.
*
* @return [level > 0]
*/
public int getLevelCount() {
return sizeOfLevel.size();
}
/**
* Returns the size of a level.
* <p>
* When the root is located at the top or bottom the size of a level is the
* maximal height of the nodes of that level. When the root is located at
* the left or right the size of a level is the maximal width of the nodes
* of that level.
*
* @param level
* @return the size of the level [level >= 0 && level < levelCount]
*/
public double getSizeOfLevel(int level) { | // Path: org.abego.treelayout/src/main/java/org/abego/treelayout/internal/util/Contract.java
// public static void checkArg(boolean isOK, String s) {
// if (!isOK) {
// throw new IllegalArgumentException(s);
// }
// }
//
// Path: org.abego.treelayout/src/main/java/org/abego/treelayout/Configuration.java
// public enum AlignmentInLevel {
// Center, TowardsRoot, AwayFromRoot
// }
//
// Path: org.abego.treelayout/src/main/java/org/abego/treelayout/Configuration.java
// public enum Location {
// Top, Left, Bottom, Right
// }
//
// Path: org.abego.treelayout/src/main/java/org/abego/treelayout/internal/util/java/lang/string/StringUtil.java
// public class StringUtil {
// /**
// * Returns a quoted version of a given string, i.e. as a Java String
// * Literal.
// *
// * @param s
// * [nullable] the string to quote
// * @param nullResult
// * [default="null"] the String to be returned for null values.
// * @return the nullResult when s is null, otherwise s as a quoted string
// * (i.e. Java String Literal)
// *
// */
// public static String quote(String s, String nullResult) {
// if (s == null) {
// return nullResult;
// }
// StringBuffer result = new StringBuffer();
// result.append('"');
// int length = s.length();
// for (int i = 0; i < length; i++) {
// char c = s.charAt(i);
// switch (c) {
// case '\b': {
// result.append("\\b");
// break;
// }
// case '\f': {
// result.append("\\f");
// break;
// }
// case '\n': {
// result.append("\\n");
// break;
// }
// case '\r': {
// result.append("\\r");
// break;
// }
// case '\t': {
// result.append("\\t");
// break;
// }
// case '\\': {
// result.append("\\\\");
// break;
// }
// case '"': {
// result.append("\\\"");
// break;
// }
// default: {
// if (c < ' ' || c >= '\u0080') {
// String n = Integer.toHexString(c);
// result.append("\\u");
// result.append("0000".substring(n.length()));
// result.append(n);
// } else {
// result.append(c);
// }
// }
// }
// }
// result.append('"');
// return result.toString();
// }
//
// /**
// * see {@link #quote(String, String)}
// *
// * @param s the string to quote
// * @return nullable
// */
// public static String quote(String s) {
// return quote(s, "null");
// }
// }
// Path: org.abego.treelayout/src/main/java/org/abego/treelayout/TreeLayout.java
import static org.abego.treelayout.internal.util.Contract.checkArg;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.IdentityHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.abego.treelayout.Configuration.AlignmentInLevel;
import org.abego.treelayout.Configuration.Location;
import org.abego.treelayout.internal.util.java.lang.string.StringUtil;
}
if (!tree.isLeaf(node)) {
for (TreeNode child : tree.getChildren(node)) {
calcSizeOfLevels(child, level + 1);
}
}
}
/**
* Returns the number of levels of the tree.
*
* @return [level > 0]
*/
public int getLevelCount() {
return sizeOfLevel.size();
}
/**
* Returns the size of a level.
* <p>
* When the root is located at the top or bottom the size of a level is the
* maximal height of the nodes of that level. When the root is located at
* the left or right the size of a level is the maximal width of the nodes
* of that level.
*
* @param level
* @return the size of the level [level >= 0 && level < levelCount]
*/
public double getSizeOfLevel(int level) { | checkArg(level >= 0, "level must be >= 0"); |
abego/treelayout | org.abego.treelayout/src/main/java/org/abego/treelayout/TreeLayout.java | // Path: org.abego.treelayout/src/main/java/org/abego/treelayout/internal/util/Contract.java
// public static void checkArg(boolean isOK, String s) {
// if (!isOK) {
// throw new IllegalArgumentException(s);
// }
// }
//
// Path: org.abego.treelayout/src/main/java/org/abego/treelayout/Configuration.java
// public enum AlignmentInLevel {
// Center, TowardsRoot, AwayFromRoot
// }
//
// Path: org.abego.treelayout/src/main/java/org/abego/treelayout/Configuration.java
// public enum Location {
// Top, Left, Bottom, Right
// }
//
// Path: org.abego.treelayout/src/main/java/org/abego/treelayout/internal/util/java/lang/string/StringUtil.java
// public class StringUtil {
// /**
// * Returns a quoted version of a given string, i.e. as a Java String
// * Literal.
// *
// * @param s
// * [nullable] the string to quote
// * @param nullResult
// * [default="null"] the String to be returned for null values.
// * @return the nullResult when s is null, otherwise s as a quoted string
// * (i.e. Java String Literal)
// *
// */
// public static String quote(String s, String nullResult) {
// if (s == null) {
// return nullResult;
// }
// StringBuffer result = new StringBuffer();
// result.append('"');
// int length = s.length();
// for (int i = 0; i < length; i++) {
// char c = s.charAt(i);
// switch (c) {
// case '\b': {
// result.append("\\b");
// break;
// }
// case '\f': {
// result.append("\\f");
// break;
// }
// case '\n': {
// result.append("\\n");
// break;
// }
// case '\r': {
// result.append("\\r");
// break;
// }
// case '\t': {
// result.append("\\t");
// break;
// }
// case '\\': {
// result.append("\\\\");
// break;
// }
// case '"': {
// result.append("\\\"");
// break;
// }
// default: {
// if (c < ' ' || c >= '\u0080') {
// String n = Integer.toHexString(c);
// result.append("\\u");
// result.append("0000".substring(n.length()));
// result.append(n);
// } else {
// result.append(c);
// }
// }
// }
// }
// result.append('"');
// return result.toString();
// }
//
// /**
// * see {@link #quote(String, String)}
// *
// * @param s the string to quote
// * @return nullable
// */
// public static String quote(String s) {
// return quote(s, "null");
// }
// }
| import static org.abego.treelayout.internal.util.Contract.checkArg;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.IdentityHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.abego.treelayout.Configuration.AlignmentInLevel;
import org.abego.treelayout.Configuration.Location;
import org.abego.treelayout.internal.util.java.lang.string.StringUtil; |
} else {
// v has no left sibling
setPrelim(v, midpoint);
}
}
}
/**
* In difference to the original algorithm we also pass in extra level
* information.
*
* @param v
* @param m
* @param level
* @param levelStart
*/
private void secondWalk(TreeNode v, double m, int level, double levelStart) {
// construct the position from the prelim and the level information
// The rootLocation affects the way how x and y are changed and in what
// direction.
double levelChangeSign = getLevelChangeSign();
boolean levelChangeOnYAxis = isLevelChangeInYAxis();
double levelSize = getSizeOfLevel(level);
double x = getPrelim(v) + m;
double y; | // Path: org.abego.treelayout/src/main/java/org/abego/treelayout/internal/util/Contract.java
// public static void checkArg(boolean isOK, String s) {
// if (!isOK) {
// throw new IllegalArgumentException(s);
// }
// }
//
// Path: org.abego.treelayout/src/main/java/org/abego/treelayout/Configuration.java
// public enum AlignmentInLevel {
// Center, TowardsRoot, AwayFromRoot
// }
//
// Path: org.abego.treelayout/src/main/java/org/abego/treelayout/Configuration.java
// public enum Location {
// Top, Left, Bottom, Right
// }
//
// Path: org.abego.treelayout/src/main/java/org/abego/treelayout/internal/util/java/lang/string/StringUtil.java
// public class StringUtil {
// /**
// * Returns a quoted version of a given string, i.e. as a Java String
// * Literal.
// *
// * @param s
// * [nullable] the string to quote
// * @param nullResult
// * [default="null"] the String to be returned for null values.
// * @return the nullResult when s is null, otherwise s as a quoted string
// * (i.e. Java String Literal)
// *
// */
// public static String quote(String s, String nullResult) {
// if (s == null) {
// return nullResult;
// }
// StringBuffer result = new StringBuffer();
// result.append('"');
// int length = s.length();
// for (int i = 0; i < length; i++) {
// char c = s.charAt(i);
// switch (c) {
// case '\b': {
// result.append("\\b");
// break;
// }
// case '\f': {
// result.append("\\f");
// break;
// }
// case '\n': {
// result.append("\\n");
// break;
// }
// case '\r': {
// result.append("\\r");
// break;
// }
// case '\t': {
// result.append("\\t");
// break;
// }
// case '\\': {
// result.append("\\\\");
// break;
// }
// case '"': {
// result.append("\\\"");
// break;
// }
// default: {
// if (c < ' ' || c >= '\u0080') {
// String n = Integer.toHexString(c);
// result.append("\\u");
// result.append("0000".substring(n.length()));
// result.append(n);
// } else {
// result.append(c);
// }
// }
// }
// }
// result.append('"');
// return result.toString();
// }
//
// /**
// * see {@link #quote(String, String)}
// *
// * @param s the string to quote
// * @return nullable
// */
// public static String quote(String s) {
// return quote(s, "null");
// }
// }
// Path: org.abego.treelayout/src/main/java/org/abego/treelayout/TreeLayout.java
import static org.abego.treelayout.internal.util.Contract.checkArg;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.IdentityHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.abego.treelayout.Configuration.AlignmentInLevel;
import org.abego.treelayout.Configuration.Location;
import org.abego.treelayout.internal.util.java.lang.string.StringUtil;
} else {
// v has no left sibling
setPrelim(v, midpoint);
}
}
}
/**
* In difference to the original algorithm we also pass in extra level
* information.
*
* @param v
* @param m
* @param level
* @param levelStart
*/
private void secondWalk(TreeNode v, double m, int level, double levelStart) {
// construct the position from the prelim and the level information
// The rootLocation affects the way how x and y are changed and in what
// direction.
double levelChangeSign = getLevelChangeSign();
boolean levelChangeOnYAxis = isLevelChangeInYAxis();
double levelSize = getSizeOfLevel(level);
double x = getPrelim(v) + m;
double y; | AlignmentInLevel alignment = configuration.getAlignmentInLevel(); |
abego/treelayout | org.abego.treelayout/src/main/java/org/abego/treelayout/TreeLayout.java | // Path: org.abego.treelayout/src/main/java/org/abego/treelayout/internal/util/Contract.java
// public static void checkArg(boolean isOK, String s) {
// if (!isOK) {
// throw new IllegalArgumentException(s);
// }
// }
//
// Path: org.abego.treelayout/src/main/java/org/abego/treelayout/Configuration.java
// public enum AlignmentInLevel {
// Center, TowardsRoot, AwayFromRoot
// }
//
// Path: org.abego.treelayout/src/main/java/org/abego/treelayout/Configuration.java
// public enum Location {
// Top, Left, Bottom, Right
// }
//
// Path: org.abego.treelayout/src/main/java/org/abego/treelayout/internal/util/java/lang/string/StringUtil.java
// public class StringUtil {
// /**
// * Returns a quoted version of a given string, i.e. as a Java String
// * Literal.
// *
// * @param s
// * [nullable] the string to quote
// * @param nullResult
// * [default="null"] the String to be returned for null values.
// * @return the nullResult when s is null, otherwise s as a quoted string
// * (i.e. Java String Literal)
// *
// */
// public static String quote(String s, String nullResult) {
// if (s == null) {
// return nullResult;
// }
// StringBuffer result = new StringBuffer();
// result.append('"');
// int length = s.length();
// for (int i = 0; i < length; i++) {
// char c = s.charAt(i);
// switch (c) {
// case '\b': {
// result.append("\\b");
// break;
// }
// case '\f': {
// result.append("\\f");
// break;
// }
// case '\n': {
// result.append("\\n");
// break;
// }
// case '\r': {
// result.append("\\r");
// break;
// }
// case '\t': {
// result.append("\\t");
// break;
// }
// case '\\': {
// result.append("\\\\");
// break;
// }
// case '"': {
// result.append("\\\"");
// break;
// }
// default: {
// if (c < ' ' || c >= '\u0080') {
// String n = Integer.toHexString(c);
// result.append("\\u");
// result.append("0000".substring(n.length()));
// result.append(n);
// } else {
// result.append(c);
// }
// }
// }
// }
// result.append('"');
// return result.toString();
// }
//
// /**
// * see {@link #quote(String, String)}
// *
// * @param s the string to quote
// * @return nullable
// */
// public static String quote(String s) {
// return quote(s, "null");
// }
// }
| import static org.abego.treelayout.internal.util.Contract.checkArg;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.IdentityHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.abego.treelayout.Configuration.AlignmentInLevel;
import org.abego.treelayout.Configuration.Location;
import org.abego.treelayout.internal.util.java.lang.string.StringUtil; | */
public void checkTree() {
Map<TreeNode, TreeNode> nodes = this.useIdentity ? new IdentityHashMap<TreeNode, TreeNode>()
:new HashMap<TreeNode,TreeNode>();
// Traverse the tree and check if each node is only used once.
addUniqueNodes(nodes,tree.getRoot());
}
// ------------------------------------------------------------------------
// dumpTree
private void dumpTree(PrintStream output, TreeNode node, int indent,
DumpConfiguration dumpConfiguration) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < indent; i++) {
sb.append(dumpConfiguration.indent);
}
if (dumpConfiguration.includeObjectToString) {
sb.append("[");
sb.append(node.getClass().getName() + "@"
+ Integer.toHexString(node.hashCode()));
if (node.hashCode() != System.identityHashCode(node)) {
sb.append("/identityHashCode:");
sb.append(Integer.toHexString(System.identityHashCode(node)));
}
sb.append("]");
}
| // Path: org.abego.treelayout/src/main/java/org/abego/treelayout/internal/util/Contract.java
// public static void checkArg(boolean isOK, String s) {
// if (!isOK) {
// throw new IllegalArgumentException(s);
// }
// }
//
// Path: org.abego.treelayout/src/main/java/org/abego/treelayout/Configuration.java
// public enum AlignmentInLevel {
// Center, TowardsRoot, AwayFromRoot
// }
//
// Path: org.abego.treelayout/src/main/java/org/abego/treelayout/Configuration.java
// public enum Location {
// Top, Left, Bottom, Right
// }
//
// Path: org.abego.treelayout/src/main/java/org/abego/treelayout/internal/util/java/lang/string/StringUtil.java
// public class StringUtil {
// /**
// * Returns a quoted version of a given string, i.e. as a Java String
// * Literal.
// *
// * @param s
// * [nullable] the string to quote
// * @param nullResult
// * [default="null"] the String to be returned for null values.
// * @return the nullResult when s is null, otherwise s as a quoted string
// * (i.e. Java String Literal)
// *
// */
// public static String quote(String s, String nullResult) {
// if (s == null) {
// return nullResult;
// }
// StringBuffer result = new StringBuffer();
// result.append('"');
// int length = s.length();
// for (int i = 0; i < length; i++) {
// char c = s.charAt(i);
// switch (c) {
// case '\b': {
// result.append("\\b");
// break;
// }
// case '\f': {
// result.append("\\f");
// break;
// }
// case '\n': {
// result.append("\\n");
// break;
// }
// case '\r': {
// result.append("\\r");
// break;
// }
// case '\t': {
// result.append("\\t");
// break;
// }
// case '\\': {
// result.append("\\\\");
// break;
// }
// case '"': {
// result.append("\\\"");
// break;
// }
// default: {
// if (c < ' ' || c >= '\u0080') {
// String n = Integer.toHexString(c);
// result.append("\\u");
// result.append("0000".substring(n.length()));
// result.append(n);
// } else {
// result.append(c);
// }
// }
// }
// }
// result.append('"');
// return result.toString();
// }
//
// /**
// * see {@link #quote(String, String)}
// *
// * @param s the string to quote
// * @return nullable
// */
// public static String quote(String s) {
// return quote(s, "null");
// }
// }
// Path: org.abego.treelayout/src/main/java/org/abego/treelayout/TreeLayout.java
import static org.abego.treelayout.internal.util.Contract.checkArg;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.IdentityHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.abego.treelayout.Configuration.AlignmentInLevel;
import org.abego.treelayout.Configuration.Location;
import org.abego.treelayout.internal.util.java.lang.string.StringUtil;
*/
public void checkTree() {
Map<TreeNode, TreeNode> nodes = this.useIdentity ? new IdentityHashMap<TreeNode, TreeNode>()
:new HashMap<TreeNode,TreeNode>();
// Traverse the tree and check if each node is only used once.
addUniqueNodes(nodes,tree.getRoot());
}
// ------------------------------------------------------------------------
// dumpTree
private void dumpTree(PrintStream output, TreeNode node, int indent,
DumpConfiguration dumpConfiguration) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < indent; i++) {
sb.append(dumpConfiguration.indent);
}
if (dumpConfiguration.includeObjectToString) {
sb.append("[");
sb.append(node.getClass().getName() + "@"
+ Integer.toHexString(node.hashCode()));
if (node.hashCode() != System.identityHashCode(node)) {
sb.append("/identityHashCode:");
sb.append(Integer.toHexString(System.identityHashCode(node)));
}
sb.append("]");
}
| sb.append(StringUtil.quote(node != null ? node.toString() : null)); |
abego/treelayout | org.abego.treelayout/src/test/java/org/abego/treelayout/util/FixedNodeExtentProviderTest.java | // Path: org.abego.treelayout/src/test/java/org/abego/treelayout/StringTreeNode.java
// public class StringTreeNode {
// private boolean useTextForEquals;
//
// public StringTreeNode(String text, boolean useTextForEquals) {
// this.text = text;
// this.useTextForEquals = useTextForEquals;
// }
//
// public StringTreeNode(String text) {
// this(text, false);
// }
//
// // ------------------------------------------------------------------------
// // children
//
// private final List<StringTreeNode> children = new ArrayList<StringTreeNode>();
//
// public List<StringTreeNode> getChildren() {
// return children;
// }
//
// /**
// * @param child
// * @param checkConsistency [default: true]
// */
// public void addChild(StringTreeNode child, boolean checkConsistency) {
// child.setParent(this, checkConsistency);
// this.getChildren().add(child);
// }
//
// public void addChild(StringTreeNode child) {
// addChild(child, true);
// }
//
// public void addChildren(StringTreeNode... children) {
// for (StringTreeNode child : children) {
// addChild(child);
// }
// }
//
// // ------------------------------------------------------------------------
// // parent
//
// private StringTreeNode parent;
//
// private void setParent(StringTreeNode parent, boolean checkConsistency) {
// if (checkConsistency) {
// checkState(this.parent == null, "parent already defined");
// }
//
// this.parent = parent;
// }
//
// public StringTreeNode getParent() {
// return parent;
// }
//
// // ------------------------------------------------------------------------
// // text
//
// private final String text;
//
// public String getText() {
// return text;
// }
//
// // ------------------------------------------------------------------------
// // equals/hashCode
//
// @Override
// public boolean equals(Object obj) {
// if (useTextForEquals && obj instanceof StringTreeNode) {
// return text.equals(((StringTreeNode) obj).getText());
// }
// return super.equals(obj);
// }
//
// @Override
// public int hashCode() {
// return useTextForEquals ? text.hashCode() : super.hashCode();
// }
//
//
// // ------------------------------------------------------------------------
// // toString
//
// @Override
// public String toString() {
// return String.valueOf(getText());
// }
// }
//
// Path: org.abego.treelayout/src/main/java/org/abego/treelayout/util/FixedNodeExtentProvider.java
// public class FixedNodeExtentProvider<T> implements NodeExtentProvider<T> {
//
// private final double width;
// private final double height;
//
// /**
// * Specifies the constants to be used as the width and height of the nodes.
// *
// * @param width
// * [default=0]
// *
// * @param height
// * [default=0]
// */
// public FixedNodeExtentProvider(double width, double height) {
// checkArg(width >= 0, "width must be >= 0");
// checkArg(height >= 0, "height must be >= 0");
//
// this.width = width;
// this.height = height;
// }
//
// /**
// * see {@link #FixedNodeExtentProvider(double, double)}
// */
// public FixedNodeExtentProvider() {
// this(0, 0);
// }
//
// @Override
// public double getWidth(T treeNode) {
// return width;
// }
//
// @Override
// public double getHeight(T treeNode) {
// return height;
// }
//
// }
| import static org.junit.Assert.fail;
import org.abego.treelayout.StringTreeNode;
import org.abego.treelayout.util.FixedNodeExtentProvider;
import org.junit.Test;
import static org.junit.Assert.assertEquals; | /*
* [The "BSD license"]
* Copyright (c) 2011, abego Software GmbH, Germany (http://www.abego.org)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of the abego Software GmbH nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package org.abego.treelayout.util;
/**
*
* @author Udo Borkowski ([email protected])
*
*
*/
public class FixedNodeExtentProviderTest {
@Test
public void testConstructor() throws Exception { | // Path: org.abego.treelayout/src/test/java/org/abego/treelayout/StringTreeNode.java
// public class StringTreeNode {
// private boolean useTextForEquals;
//
// public StringTreeNode(String text, boolean useTextForEquals) {
// this.text = text;
// this.useTextForEquals = useTextForEquals;
// }
//
// public StringTreeNode(String text) {
// this(text, false);
// }
//
// // ------------------------------------------------------------------------
// // children
//
// private final List<StringTreeNode> children = new ArrayList<StringTreeNode>();
//
// public List<StringTreeNode> getChildren() {
// return children;
// }
//
// /**
// * @param child
// * @param checkConsistency [default: true]
// */
// public void addChild(StringTreeNode child, boolean checkConsistency) {
// child.setParent(this, checkConsistency);
// this.getChildren().add(child);
// }
//
// public void addChild(StringTreeNode child) {
// addChild(child, true);
// }
//
// public void addChildren(StringTreeNode... children) {
// for (StringTreeNode child : children) {
// addChild(child);
// }
// }
//
// // ------------------------------------------------------------------------
// // parent
//
// private StringTreeNode parent;
//
// private void setParent(StringTreeNode parent, boolean checkConsistency) {
// if (checkConsistency) {
// checkState(this.parent == null, "parent already defined");
// }
//
// this.parent = parent;
// }
//
// public StringTreeNode getParent() {
// return parent;
// }
//
// // ------------------------------------------------------------------------
// // text
//
// private final String text;
//
// public String getText() {
// return text;
// }
//
// // ------------------------------------------------------------------------
// // equals/hashCode
//
// @Override
// public boolean equals(Object obj) {
// if (useTextForEquals && obj instanceof StringTreeNode) {
// return text.equals(((StringTreeNode) obj).getText());
// }
// return super.equals(obj);
// }
//
// @Override
// public int hashCode() {
// return useTextForEquals ? text.hashCode() : super.hashCode();
// }
//
//
// // ------------------------------------------------------------------------
// // toString
//
// @Override
// public String toString() {
// return String.valueOf(getText());
// }
// }
//
// Path: org.abego.treelayout/src/main/java/org/abego/treelayout/util/FixedNodeExtentProvider.java
// public class FixedNodeExtentProvider<T> implements NodeExtentProvider<T> {
//
// private final double width;
// private final double height;
//
// /**
// * Specifies the constants to be used as the width and height of the nodes.
// *
// * @param width
// * [default=0]
// *
// * @param height
// * [default=0]
// */
// public FixedNodeExtentProvider(double width, double height) {
// checkArg(width >= 0, "width must be >= 0");
// checkArg(height >= 0, "height must be >= 0");
//
// this.width = width;
// this.height = height;
// }
//
// /**
// * see {@link #FixedNodeExtentProvider(double, double)}
// */
// public FixedNodeExtentProvider() {
// this(0, 0);
// }
//
// @Override
// public double getWidth(T treeNode) {
// return width;
// }
//
// @Override
// public double getHeight(T treeNode) {
// return height;
// }
//
// }
// Path: org.abego.treelayout/src/test/java/org/abego/treelayout/util/FixedNodeExtentProviderTest.java
import static org.junit.Assert.fail;
import org.abego.treelayout.StringTreeNode;
import org.abego.treelayout.util.FixedNodeExtentProvider;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
/*
* [The "BSD license"]
* Copyright (c) 2011, abego Software GmbH, Germany (http://www.abego.org)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of the abego Software GmbH nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package org.abego.treelayout.util;
/**
*
* @author Udo Borkowski ([email protected])
*
*
*/
public class FixedNodeExtentProviderTest {
@Test
public void testConstructor() throws Exception { | FixedNodeExtentProvider<StringTreeNode> provider = new FixedNodeExtentProvider<StringTreeNode>( |
abego/treelayout | org.abego.treelayout/src/test/java/org/abego/treelayout/util/FixedNodeExtentProviderTest.java | // Path: org.abego.treelayout/src/test/java/org/abego/treelayout/StringTreeNode.java
// public class StringTreeNode {
// private boolean useTextForEquals;
//
// public StringTreeNode(String text, boolean useTextForEquals) {
// this.text = text;
// this.useTextForEquals = useTextForEquals;
// }
//
// public StringTreeNode(String text) {
// this(text, false);
// }
//
// // ------------------------------------------------------------------------
// // children
//
// private final List<StringTreeNode> children = new ArrayList<StringTreeNode>();
//
// public List<StringTreeNode> getChildren() {
// return children;
// }
//
// /**
// * @param child
// * @param checkConsistency [default: true]
// */
// public void addChild(StringTreeNode child, boolean checkConsistency) {
// child.setParent(this, checkConsistency);
// this.getChildren().add(child);
// }
//
// public void addChild(StringTreeNode child) {
// addChild(child, true);
// }
//
// public void addChildren(StringTreeNode... children) {
// for (StringTreeNode child : children) {
// addChild(child);
// }
// }
//
// // ------------------------------------------------------------------------
// // parent
//
// private StringTreeNode parent;
//
// private void setParent(StringTreeNode parent, boolean checkConsistency) {
// if (checkConsistency) {
// checkState(this.parent == null, "parent already defined");
// }
//
// this.parent = parent;
// }
//
// public StringTreeNode getParent() {
// return parent;
// }
//
// // ------------------------------------------------------------------------
// // text
//
// private final String text;
//
// public String getText() {
// return text;
// }
//
// // ------------------------------------------------------------------------
// // equals/hashCode
//
// @Override
// public boolean equals(Object obj) {
// if (useTextForEquals && obj instanceof StringTreeNode) {
// return text.equals(((StringTreeNode) obj).getText());
// }
// return super.equals(obj);
// }
//
// @Override
// public int hashCode() {
// return useTextForEquals ? text.hashCode() : super.hashCode();
// }
//
//
// // ------------------------------------------------------------------------
// // toString
//
// @Override
// public String toString() {
// return String.valueOf(getText());
// }
// }
//
// Path: org.abego.treelayout/src/main/java/org/abego/treelayout/util/FixedNodeExtentProvider.java
// public class FixedNodeExtentProvider<T> implements NodeExtentProvider<T> {
//
// private final double width;
// private final double height;
//
// /**
// * Specifies the constants to be used as the width and height of the nodes.
// *
// * @param width
// * [default=0]
// *
// * @param height
// * [default=0]
// */
// public FixedNodeExtentProvider(double width, double height) {
// checkArg(width >= 0, "width must be >= 0");
// checkArg(height >= 0, "height must be >= 0");
//
// this.width = width;
// this.height = height;
// }
//
// /**
// * see {@link #FixedNodeExtentProvider(double, double)}
// */
// public FixedNodeExtentProvider() {
// this(0, 0);
// }
//
// @Override
// public double getWidth(T treeNode) {
// return width;
// }
//
// @Override
// public double getHeight(T treeNode) {
// return height;
// }
//
// }
| import static org.junit.Assert.fail;
import org.abego.treelayout.StringTreeNode;
import org.abego.treelayout.util.FixedNodeExtentProvider;
import org.junit.Test;
import static org.junit.Assert.assertEquals; | /*
* [The "BSD license"]
* Copyright (c) 2011, abego Software GmbH, Germany (http://www.abego.org)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of the abego Software GmbH nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package org.abego.treelayout.util;
/**
*
* @author Udo Borkowski ([email protected])
*
*
*/
public class FixedNodeExtentProviderTest {
@Test
public void testConstructor() throws Exception { | // Path: org.abego.treelayout/src/test/java/org/abego/treelayout/StringTreeNode.java
// public class StringTreeNode {
// private boolean useTextForEquals;
//
// public StringTreeNode(String text, boolean useTextForEquals) {
// this.text = text;
// this.useTextForEquals = useTextForEquals;
// }
//
// public StringTreeNode(String text) {
// this(text, false);
// }
//
// // ------------------------------------------------------------------------
// // children
//
// private final List<StringTreeNode> children = new ArrayList<StringTreeNode>();
//
// public List<StringTreeNode> getChildren() {
// return children;
// }
//
// /**
// * @param child
// * @param checkConsistency [default: true]
// */
// public void addChild(StringTreeNode child, boolean checkConsistency) {
// child.setParent(this, checkConsistency);
// this.getChildren().add(child);
// }
//
// public void addChild(StringTreeNode child) {
// addChild(child, true);
// }
//
// public void addChildren(StringTreeNode... children) {
// for (StringTreeNode child : children) {
// addChild(child);
// }
// }
//
// // ------------------------------------------------------------------------
// // parent
//
// private StringTreeNode parent;
//
// private void setParent(StringTreeNode parent, boolean checkConsistency) {
// if (checkConsistency) {
// checkState(this.parent == null, "parent already defined");
// }
//
// this.parent = parent;
// }
//
// public StringTreeNode getParent() {
// return parent;
// }
//
// // ------------------------------------------------------------------------
// // text
//
// private final String text;
//
// public String getText() {
// return text;
// }
//
// // ------------------------------------------------------------------------
// // equals/hashCode
//
// @Override
// public boolean equals(Object obj) {
// if (useTextForEquals && obj instanceof StringTreeNode) {
// return text.equals(((StringTreeNode) obj).getText());
// }
// return super.equals(obj);
// }
//
// @Override
// public int hashCode() {
// return useTextForEquals ? text.hashCode() : super.hashCode();
// }
//
//
// // ------------------------------------------------------------------------
// // toString
//
// @Override
// public String toString() {
// return String.valueOf(getText());
// }
// }
//
// Path: org.abego.treelayout/src/main/java/org/abego/treelayout/util/FixedNodeExtentProvider.java
// public class FixedNodeExtentProvider<T> implements NodeExtentProvider<T> {
//
// private final double width;
// private final double height;
//
// /**
// * Specifies the constants to be used as the width and height of the nodes.
// *
// * @param width
// * [default=0]
// *
// * @param height
// * [default=0]
// */
// public FixedNodeExtentProvider(double width, double height) {
// checkArg(width >= 0, "width must be >= 0");
// checkArg(height >= 0, "height must be >= 0");
//
// this.width = width;
// this.height = height;
// }
//
// /**
// * see {@link #FixedNodeExtentProvider(double, double)}
// */
// public FixedNodeExtentProvider() {
// this(0, 0);
// }
//
// @Override
// public double getWidth(T treeNode) {
// return width;
// }
//
// @Override
// public double getHeight(T treeNode) {
// return height;
// }
//
// }
// Path: org.abego.treelayout/src/test/java/org/abego/treelayout/util/FixedNodeExtentProviderTest.java
import static org.junit.Assert.fail;
import org.abego.treelayout.StringTreeNode;
import org.abego.treelayout.util.FixedNodeExtentProvider;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
/*
* [The "BSD license"]
* Copyright (c) 2011, abego Software GmbH, Germany (http://www.abego.org)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of the abego Software GmbH nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package org.abego.treelayout.util;
/**
*
* @author Udo Borkowski ([email protected])
*
*
*/
public class FixedNodeExtentProviderTest {
@Test
public void testConstructor() throws Exception { | FixedNodeExtentProvider<StringTreeNode> provider = new FixedNodeExtentProvider<StringTreeNode>( |
abego/treelayout | org.abego.treelayout/src/test/java/org/abego/treelayout/TreeLayoutPerformanceReport.java | // Path: org.abego.treelayout/src/main/java/org/abego/treelayout/util/DefaultConfiguration.java
// public class DefaultConfiguration<TreeNode> implements
// Configuration<TreeNode> {
//
// /**
// * Specifies the constants to be used for this Configuration.
// *
// * @param gapBetweenLevels
// * @param gapBetweenNodes
// * @param location
// * [default: {@link org.abego.treelayout.Configuration.Location#Top Top}]
// * @param alignmentInLevel
// * [default: {@link org.abego.treelayout.Configuration.AlignmentInLevel#Center Center}]
// */
// public DefaultConfiguration(double gapBetweenLevels,
// double gapBetweenNodes, Location location,
// AlignmentInLevel alignmentInLevel) {
// checkArg(gapBetweenLevels >= 0, "gapBetweenLevels must be >= 0");
// checkArg(gapBetweenNodes >= 0, "gapBetweenNodes must be >= 0");
//
// this.gapBetweenLevels = gapBetweenLevels;
// this.gapBetweenNodes = gapBetweenNodes;
// this.location = location;
// this.alignmentInLevel = alignmentInLevel;
// }
//
// /**
// * Convenience constructor, using a default for the alignmentInLevel.
// * <p>
// * see
// * {@link #DefaultConfiguration(double, double, org.abego.treelayout.Configuration.Location, org.abego.treelayout.Configuration.AlignmentInLevel)}
// * </p>
// * @param gapBetweenLevels
// * @param gapBetweenNodes
// * @param location
// */
// public DefaultConfiguration(double gapBetweenLevels,
// double gapBetweenNodes, Location location) {
// this(gapBetweenLevels, gapBetweenNodes, location,
// AlignmentInLevel.Center);
// }
//
// /**
// * Convenience constructor, using a default for the rootLocation and the
// * alignmentInLevel.
// * <p>
// * see
// * {@link #DefaultConfiguration(double, double, org.abego.treelayout.Configuration.Location, org.abego.treelayout.Configuration.AlignmentInLevel)}
// * </p>
// * @param gapBetweenLevels
// * @param gapBetweenNodes
// */
// public DefaultConfiguration(double gapBetweenLevels,
// double gapBetweenNodes) {
// this(gapBetweenLevels, gapBetweenNodes, Location.Top,
// AlignmentInLevel.Center);
// }
//
// // -----------------------------------------------------------------------
// // gapBetweenLevels
//
// private final double gapBetweenLevels;
//
// @Override
// public double getGapBetweenLevels(int nextLevel) {
// return gapBetweenLevels;
// }
//
// // -----------------------------------------------------------------------
// // gapBetweenNodes
//
// private final double gapBetweenNodes;
//
// @Override
// public double getGapBetweenNodes(TreeNode node1, TreeNode node2) {
// return gapBetweenNodes;
// }
//
// // -----------------------------------------------------------------------
// // location
//
// private final Location location;
//
// @Override
// public Location getRootLocation() {
// return location;
// }
//
// // -----------------------------------------------------------------------
// // alignmentInLevel
//
// private AlignmentInLevel alignmentInLevel;
//
// @Override
// public AlignmentInLevel getAlignmentInLevel() {
// return alignmentInLevel;
// }
//
// }
//
// Path: org.abego.treelayout/src/main/java/org/abego/treelayout/util/FixedNodeExtentProvider.java
// public class FixedNodeExtentProvider<T> implements NodeExtentProvider<T> {
//
// private final double width;
// private final double height;
//
// /**
// * Specifies the constants to be used as the width and height of the nodes.
// *
// * @param width
// * [default=0]
// *
// * @param height
// * [default=0]
// */
// public FixedNodeExtentProvider(double width, double height) {
// checkArg(width >= 0, "width must be >= 0");
// checkArg(height >= 0, "height must be >= 0");
//
// this.width = width;
// this.height = height;
// }
//
// /**
// * see {@link #FixedNodeExtentProvider(double, double)}
// */
// public FixedNodeExtentProvider() {
// this(0, 0);
// }
//
// @Override
// public double getWidth(T treeNode) {
// return width;
// }
//
// @Override
// public double getHeight(T treeNode) {
// return height;
// }
//
// }
| import org.abego.treelayout.util.DefaultConfiguration;
import org.abego.treelayout.util.FixedNodeExtentProvider;
import java.util.Random; | int i = 0;
while (remainingNodesCount > 0) {
int n = random.nextInt(remainingNodesCount) + 1;
result.addChild(createRandomTree(n, maxChildrenCount, random));
remainingNodesCount -= n;
i++;
if (i >= (childrenCount - 1) && remainingNodesCount > 0) {
result.addChild(createRandomTree(remainingNodesCount,
maxChildrenCount, random));
remainingNodesCount = 0;
}
}
return result;
}
/**
*
* @param n
* @return the number of milliseconds to create the tree layout (Time for
* creating the tree not included)
*/
private static long layoutRandomTree(int n, int maxChildrenCount,
Random random) {
StringTreeNode root = createRandomTree(n, maxChildrenCount, random);
StringTreeAsTreeForTreeLayout treeForTreeLayout = new StringTreeAsTreeForTreeLayout(
root);
long start = System.currentTimeMillis();
new TreeLayout<StringTreeNode>(treeForTreeLayout, | // Path: org.abego.treelayout/src/main/java/org/abego/treelayout/util/DefaultConfiguration.java
// public class DefaultConfiguration<TreeNode> implements
// Configuration<TreeNode> {
//
// /**
// * Specifies the constants to be used for this Configuration.
// *
// * @param gapBetweenLevels
// * @param gapBetweenNodes
// * @param location
// * [default: {@link org.abego.treelayout.Configuration.Location#Top Top}]
// * @param alignmentInLevel
// * [default: {@link org.abego.treelayout.Configuration.AlignmentInLevel#Center Center}]
// */
// public DefaultConfiguration(double gapBetweenLevels,
// double gapBetweenNodes, Location location,
// AlignmentInLevel alignmentInLevel) {
// checkArg(gapBetweenLevels >= 0, "gapBetweenLevels must be >= 0");
// checkArg(gapBetweenNodes >= 0, "gapBetweenNodes must be >= 0");
//
// this.gapBetweenLevels = gapBetweenLevels;
// this.gapBetweenNodes = gapBetweenNodes;
// this.location = location;
// this.alignmentInLevel = alignmentInLevel;
// }
//
// /**
// * Convenience constructor, using a default for the alignmentInLevel.
// * <p>
// * see
// * {@link #DefaultConfiguration(double, double, org.abego.treelayout.Configuration.Location, org.abego.treelayout.Configuration.AlignmentInLevel)}
// * </p>
// * @param gapBetweenLevels
// * @param gapBetweenNodes
// * @param location
// */
// public DefaultConfiguration(double gapBetweenLevels,
// double gapBetweenNodes, Location location) {
// this(gapBetweenLevels, gapBetweenNodes, location,
// AlignmentInLevel.Center);
// }
//
// /**
// * Convenience constructor, using a default for the rootLocation and the
// * alignmentInLevel.
// * <p>
// * see
// * {@link #DefaultConfiguration(double, double, org.abego.treelayout.Configuration.Location, org.abego.treelayout.Configuration.AlignmentInLevel)}
// * </p>
// * @param gapBetweenLevels
// * @param gapBetweenNodes
// */
// public DefaultConfiguration(double gapBetweenLevels,
// double gapBetweenNodes) {
// this(gapBetweenLevels, gapBetweenNodes, Location.Top,
// AlignmentInLevel.Center);
// }
//
// // -----------------------------------------------------------------------
// // gapBetweenLevels
//
// private final double gapBetweenLevels;
//
// @Override
// public double getGapBetweenLevels(int nextLevel) {
// return gapBetweenLevels;
// }
//
// // -----------------------------------------------------------------------
// // gapBetweenNodes
//
// private final double gapBetweenNodes;
//
// @Override
// public double getGapBetweenNodes(TreeNode node1, TreeNode node2) {
// return gapBetweenNodes;
// }
//
// // -----------------------------------------------------------------------
// // location
//
// private final Location location;
//
// @Override
// public Location getRootLocation() {
// return location;
// }
//
// // -----------------------------------------------------------------------
// // alignmentInLevel
//
// private AlignmentInLevel alignmentInLevel;
//
// @Override
// public AlignmentInLevel getAlignmentInLevel() {
// return alignmentInLevel;
// }
//
// }
//
// Path: org.abego.treelayout/src/main/java/org/abego/treelayout/util/FixedNodeExtentProvider.java
// public class FixedNodeExtentProvider<T> implements NodeExtentProvider<T> {
//
// private final double width;
// private final double height;
//
// /**
// * Specifies the constants to be used as the width and height of the nodes.
// *
// * @param width
// * [default=0]
// *
// * @param height
// * [default=0]
// */
// public FixedNodeExtentProvider(double width, double height) {
// checkArg(width >= 0, "width must be >= 0");
// checkArg(height >= 0, "height must be >= 0");
//
// this.width = width;
// this.height = height;
// }
//
// /**
// * see {@link #FixedNodeExtentProvider(double, double)}
// */
// public FixedNodeExtentProvider() {
// this(0, 0);
// }
//
// @Override
// public double getWidth(T treeNode) {
// return width;
// }
//
// @Override
// public double getHeight(T treeNode) {
// return height;
// }
//
// }
// Path: org.abego.treelayout/src/test/java/org/abego/treelayout/TreeLayoutPerformanceReport.java
import org.abego.treelayout.util.DefaultConfiguration;
import org.abego.treelayout.util.FixedNodeExtentProvider;
import java.util.Random;
int i = 0;
while (remainingNodesCount > 0) {
int n = random.nextInt(remainingNodesCount) + 1;
result.addChild(createRandomTree(n, maxChildrenCount, random));
remainingNodesCount -= n;
i++;
if (i >= (childrenCount - 1) && remainingNodesCount > 0) {
result.addChild(createRandomTree(remainingNodesCount,
maxChildrenCount, random));
remainingNodesCount = 0;
}
}
return result;
}
/**
*
* @param n
* @return the number of milliseconds to create the tree layout (Time for
* creating the tree not included)
*/
private static long layoutRandomTree(int n, int maxChildrenCount,
Random random) {
StringTreeNode root = createRandomTree(n, maxChildrenCount, random);
StringTreeAsTreeForTreeLayout treeForTreeLayout = new StringTreeAsTreeForTreeLayout(
root);
long start = System.currentTimeMillis();
new TreeLayout<StringTreeNode>(treeForTreeLayout, | new FixedNodeExtentProvider<StringTreeNode>(60, 20), |
abego/treelayout | org.abego.treelayout/src/test/java/org/abego/treelayout/TreeLayoutPerformanceReport.java | // Path: org.abego.treelayout/src/main/java/org/abego/treelayout/util/DefaultConfiguration.java
// public class DefaultConfiguration<TreeNode> implements
// Configuration<TreeNode> {
//
// /**
// * Specifies the constants to be used for this Configuration.
// *
// * @param gapBetweenLevels
// * @param gapBetweenNodes
// * @param location
// * [default: {@link org.abego.treelayout.Configuration.Location#Top Top}]
// * @param alignmentInLevel
// * [default: {@link org.abego.treelayout.Configuration.AlignmentInLevel#Center Center}]
// */
// public DefaultConfiguration(double gapBetweenLevels,
// double gapBetweenNodes, Location location,
// AlignmentInLevel alignmentInLevel) {
// checkArg(gapBetweenLevels >= 0, "gapBetweenLevels must be >= 0");
// checkArg(gapBetweenNodes >= 0, "gapBetweenNodes must be >= 0");
//
// this.gapBetweenLevels = gapBetweenLevels;
// this.gapBetweenNodes = gapBetweenNodes;
// this.location = location;
// this.alignmentInLevel = alignmentInLevel;
// }
//
// /**
// * Convenience constructor, using a default for the alignmentInLevel.
// * <p>
// * see
// * {@link #DefaultConfiguration(double, double, org.abego.treelayout.Configuration.Location, org.abego.treelayout.Configuration.AlignmentInLevel)}
// * </p>
// * @param gapBetweenLevels
// * @param gapBetweenNodes
// * @param location
// */
// public DefaultConfiguration(double gapBetweenLevels,
// double gapBetweenNodes, Location location) {
// this(gapBetweenLevels, gapBetweenNodes, location,
// AlignmentInLevel.Center);
// }
//
// /**
// * Convenience constructor, using a default for the rootLocation and the
// * alignmentInLevel.
// * <p>
// * see
// * {@link #DefaultConfiguration(double, double, org.abego.treelayout.Configuration.Location, org.abego.treelayout.Configuration.AlignmentInLevel)}
// * </p>
// * @param gapBetweenLevels
// * @param gapBetweenNodes
// */
// public DefaultConfiguration(double gapBetweenLevels,
// double gapBetweenNodes) {
// this(gapBetweenLevels, gapBetweenNodes, Location.Top,
// AlignmentInLevel.Center);
// }
//
// // -----------------------------------------------------------------------
// // gapBetweenLevels
//
// private final double gapBetweenLevels;
//
// @Override
// public double getGapBetweenLevels(int nextLevel) {
// return gapBetweenLevels;
// }
//
// // -----------------------------------------------------------------------
// // gapBetweenNodes
//
// private final double gapBetweenNodes;
//
// @Override
// public double getGapBetweenNodes(TreeNode node1, TreeNode node2) {
// return gapBetweenNodes;
// }
//
// // -----------------------------------------------------------------------
// // location
//
// private final Location location;
//
// @Override
// public Location getRootLocation() {
// return location;
// }
//
// // -----------------------------------------------------------------------
// // alignmentInLevel
//
// private AlignmentInLevel alignmentInLevel;
//
// @Override
// public AlignmentInLevel getAlignmentInLevel() {
// return alignmentInLevel;
// }
//
// }
//
// Path: org.abego.treelayout/src/main/java/org/abego/treelayout/util/FixedNodeExtentProvider.java
// public class FixedNodeExtentProvider<T> implements NodeExtentProvider<T> {
//
// private final double width;
// private final double height;
//
// /**
// * Specifies the constants to be used as the width and height of the nodes.
// *
// * @param width
// * [default=0]
// *
// * @param height
// * [default=0]
// */
// public FixedNodeExtentProvider(double width, double height) {
// checkArg(width >= 0, "width must be >= 0");
// checkArg(height >= 0, "height must be >= 0");
//
// this.width = width;
// this.height = height;
// }
//
// /**
// * see {@link #FixedNodeExtentProvider(double, double)}
// */
// public FixedNodeExtentProvider() {
// this(0, 0);
// }
//
// @Override
// public double getWidth(T treeNode) {
// return width;
// }
//
// @Override
// public double getHeight(T treeNode) {
// return height;
// }
//
// }
| import org.abego.treelayout.util.DefaultConfiguration;
import org.abego.treelayout.util.FixedNodeExtentProvider;
import java.util.Random; | while (remainingNodesCount > 0) {
int n = random.nextInt(remainingNodesCount) + 1;
result.addChild(createRandomTree(n, maxChildrenCount, random));
remainingNodesCount -= n;
i++;
if (i >= (childrenCount - 1) && remainingNodesCount > 0) {
result.addChild(createRandomTree(remainingNodesCount,
maxChildrenCount, random));
remainingNodesCount = 0;
}
}
return result;
}
/**
*
* @param n
* @return the number of milliseconds to create the tree layout (Time for
* creating the tree not included)
*/
private static long layoutRandomTree(int n, int maxChildrenCount,
Random random) {
StringTreeNode root = createRandomTree(n, maxChildrenCount, random);
StringTreeAsTreeForTreeLayout treeForTreeLayout = new StringTreeAsTreeForTreeLayout(
root);
long start = System.currentTimeMillis();
new TreeLayout<StringTreeNode>(treeForTreeLayout,
new FixedNodeExtentProvider<StringTreeNode>(60, 20), | // Path: org.abego.treelayout/src/main/java/org/abego/treelayout/util/DefaultConfiguration.java
// public class DefaultConfiguration<TreeNode> implements
// Configuration<TreeNode> {
//
// /**
// * Specifies the constants to be used for this Configuration.
// *
// * @param gapBetweenLevels
// * @param gapBetweenNodes
// * @param location
// * [default: {@link org.abego.treelayout.Configuration.Location#Top Top}]
// * @param alignmentInLevel
// * [default: {@link org.abego.treelayout.Configuration.AlignmentInLevel#Center Center}]
// */
// public DefaultConfiguration(double gapBetweenLevels,
// double gapBetweenNodes, Location location,
// AlignmentInLevel alignmentInLevel) {
// checkArg(gapBetweenLevels >= 0, "gapBetweenLevels must be >= 0");
// checkArg(gapBetweenNodes >= 0, "gapBetweenNodes must be >= 0");
//
// this.gapBetweenLevels = gapBetweenLevels;
// this.gapBetweenNodes = gapBetweenNodes;
// this.location = location;
// this.alignmentInLevel = alignmentInLevel;
// }
//
// /**
// * Convenience constructor, using a default for the alignmentInLevel.
// * <p>
// * see
// * {@link #DefaultConfiguration(double, double, org.abego.treelayout.Configuration.Location, org.abego.treelayout.Configuration.AlignmentInLevel)}
// * </p>
// * @param gapBetweenLevels
// * @param gapBetweenNodes
// * @param location
// */
// public DefaultConfiguration(double gapBetweenLevels,
// double gapBetweenNodes, Location location) {
// this(gapBetweenLevels, gapBetweenNodes, location,
// AlignmentInLevel.Center);
// }
//
// /**
// * Convenience constructor, using a default for the rootLocation and the
// * alignmentInLevel.
// * <p>
// * see
// * {@link #DefaultConfiguration(double, double, org.abego.treelayout.Configuration.Location, org.abego.treelayout.Configuration.AlignmentInLevel)}
// * </p>
// * @param gapBetweenLevels
// * @param gapBetweenNodes
// */
// public DefaultConfiguration(double gapBetweenLevels,
// double gapBetweenNodes) {
// this(gapBetweenLevels, gapBetweenNodes, Location.Top,
// AlignmentInLevel.Center);
// }
//
// // -----------------------------------------------------------------------
// // gapBetweenLevels
//
// private final double gapBetweenLevels;
//
// @Override
// public double getGapBetweenLevels(int nextLevel) {
// return gapBetweenLevels;
// }
//
// // -----------------------------------------------------------------------
// // gapBetweenNodes
//
// private final double gapBetweenNodes;
//
// @Override
// public double getGapBetweenNodes(TreeNode node1, TreeNode node2) {
// return gapBetweenNodes;
// }
//
// // -----------------------------------------------------------------------
// // location
//
// private final Location location;
//
// @Override
// public Location getRootLocation() {
// return location;
// }
//
// // -----------------------------------------------------------------------
// // alignmentInLevel
//
// private AlignmentInLevel alignmentInLevel;
//
// @Override
// public AlignmentInLevel getAlignmentInLevel() {
// return alignmentInLevel;
// }
//
// }
//
// Path: org.abego.treelayout/src/main/java/org/abego/treelayout/util/FixedNodeExtentProvider.java
// public class FixedNodeExtentProvider<T> implements NodeExtentProvider<T> {
//
// private final double width;
// private final double height;
//
// /**
// * Specifies the constants to be used as the width and height of the nodes.
// *
// * @param width
// * [default=0]
// *
// * @param height
// * [default=0]
// */
// public FixedNodeExtentProvider(double width, double height) {
// checkArg(width >= 0, "width must be >= 0");
// checkArg(height >= 0, "height must be >= 0");
//
// this.width = width;
// this.height = height;
// }
//
// /**
// * see {@link #FixedNodeExtentProvider(double, double)}
// */
// public FixedNodeExtentProvider() {
// this(0, 0);
// }
//
// @Override
// public double getWidth(T treeNode) {
// return width;
// }
//
// @Override
// public double getHeight(T treeNode) {
// return height;
// }
//
// }
// Path: org.abego.treelayout/src/test/java/org/abego/treelayout/TreeLayoutPerformanceReport.java
import org.abego.treelayout.util.DefaultConfiguration;
import org.abego.treelayout.util.FixedNodeExtentProvider;
import java.util.Random;
while (remainingNodesCount > 0) {
int n = random.nextInt(remainingNodesCount) + 1;
result.addChild(createRandomTree(n, maxChildrenCount, random));
remainingNodesCount -= n;
i++;
if (i >= (childrenCount - 1) && remainingNodesCount > 0) {
result.addChild(createRandomTree(remainingNodesCount,
maxChildrenCount, random));
remainingNodesCount = 0;
}
}
return result;
}
/**
*
* @param n
* @return the number of milliseconds to create the tree layout (Time for
* creating the tree not included)
*/
private static long layoutRandomTree(int n, int maxChildrenCount,
Random random) {
StringTreeNode root = createRandomTree(n, maxChildrenCount, random);
StringTreeAsTreeForTreeLayout treeForTreeLayout = new StringTreeAsTreeForTreeLayout(
root);
long start = System.currentTimeMillis();
new TreeLayout<StringTreeNode>(treeForTreeLayout,
new FixedNodeExtentProvider<StringTreeNode>(60, 20), | new DefaultConfiguration<StringTreeNode>(10, 10)); |
abego/treelayout | org.abego.treelayout/src/test/java/org/abego/treelayout/util/DefaultTreeForTreeLayoutTest.java | // Path: org.abego.treelayout/src/main/java/org/abego/treelayout/util/DefaultTreeForTreeLayout.java
// public class DefaultTreeForTreeLayout<TreeNode> extends
// AbstractTreeForTreeLayout<TreeNode> {
//
// private List<TreeNode> emptyList;
//
// private List<TreeNode> getEmptyList() {
// if (emptyList == null) {
// emptyList = new ArrayList<TreeNode>();
// }
// return emptyList;
// }
//
// private Map<TreeNode, List<TreeNode>> childrenMap = new HashMap<TreeNode, List<TreeNode>>();
// private Map<TreeNode, TreeNode> parents = new HashMap<TreeNode, TreeNode>();
//
// /**
// * Creates a new instance with a given node as the root
// *
// * @param root
// * the node to be used as the root.
// */
// public DefaultTreeForTreeLayout(TreeNode root) {
// super(root);
// }
//
// @Override
// public TreeNode getParent(TreeNode node) {
// return parents.get(node);
// }
//
// @Override
// public List<TreeNode> getChildrenList(TreeNode node) {
// List<TreeNode> result = childrenMap.get(node);
// return result == null ? getEmptyList() : result;
// }
//
// /**
// *
// * @param node
// * @return true iff the node is in the tree
// */
// public boolean hasNode(TreeNode node) {
// return node == getRoot() || parents.containsKey(node);
// }
//
// /**
// * @param parentNode
// * [hasNode(parentNode)]
// * @param node
// * [!hasNode(node)]
// */
// public void addChild(TreeNode parentNode, TreeNode node) {
// checkArg(hasNode(parentNode), "parentNode is not in the tree");
// checkArg(!hasNode(node), "node is already in the tree");
//
// List<TreeNode> list = childrenMap.get(parentNode);
// if (list == null) {
// list = new ArrayList<TreeNode>();
// childrenMap.put(parentNode, list);
// }
// list.add(node);
// parents.put(node, parentNode);
// }
//
// public void addChildren(TreeNode parentNode, TreeNode... nodes) {
// for (TreeNode node : nodes) {
// addChild(parentNode, node);
// }
// }
//
// }
| import java.util.List;
import org.abego.treelayout.util.DefaultTreeForTreeLayout;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;
import java.util.Iterator; | /*
* [The "BSD license"]
* Copyright (c) 2011, abego Software GmbH, Germany (http://www.abego.org)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of the abego Software GmbH nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package org.abego.treelayout.util;
/**
*
* @author Udo Borkowski ([email protected])
*
*
*/
public class DefaultTreeForTreeLayoutTest {
String root = "root";
String n1 = "n1";
String n2 = "n2"; | // Path: org.abego.treelayout/src/main/java/org/abego/treelayout/util/DefaultTreeForTreeLayout.java
// public class DefaultTreeForTreeLayout<TreeNode> extends
// AbstractTreeForTreeLayout<TreeNode> {
//
// private List<TreeNode> emptyList;
//
// private List<TreeNode> getEmptyList() {
// if (emptyList == null) {
// emptyList = new ArrayList<TreeNode>();
// }
// return emptyList;
// }
//
// private Map<TreeNode, List<TreeNode>> childrenMap = new HashMap<TreeNode, List<TreeNode>>();
// private Map<TreeNode, TreeNode> parents = new HashMap<TreeNode, TreeNode>();
//
// /**
// * Creates a new instance with a given node as the root
// *
// * @param root
// * the node to be used as the root.
// */
// public DefaultTreeForTreeLayout(TreeNode root) {
// super(root);
// }
//
// @Override
// public TreeNode getParent(TreeNode node) {
// return parents.get(node);
// }
//
// @Override
// public List<TreeNode> getChildrenList(TreeNode node) {
// List<TreeNode> result = childrenMap.get(node);
// return result == null ? getEmptyList() : result;
// }
//
// /**
// *
// * @param node
// * @return true iff the node is in the tree
// */
// public boolean hasNode(TreeNode node) {
// return node == getRoot() || parents.containsKey(node);
// }
//
// /**
// * @param parentNode
// * [hasNode(parentNode)]
// * @param node
// * [!hasNode(node)]
// */
// public void addChild(TreeNode parentNode, TreeNode node) {
// checkArg(hasNode(parentNode), "parentNode is not in the tree");
// checkArg(!hasNode(node), "node is already in the tree");
//
// List<TreeNode> list = childrenMap.get(parentNode);
// if (list == null) {
// list = new ArrayList<TreeNode>();
// childrenMap.put(parentNode, list);
// }
// list.add(node);
// parents.put(node, parentNode);
// }
//
// public void addChildren(TreeNode parentNode, TreeNode... nodes) {
// for (TreeNode node : nodes) {
// addChild(parentNode, node);
// }
// }
//
// }
// Path: org.abego.treelayout/src/test/java/org/abego/treelayout/util/DefaultTreeForTreeLayoutTest.java
import java.util.List;
import org.abego.treelayout.util.DefaultTreeForTreeLayout;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;
import java.util.Iterator;
/*
* [The "BSD license"]
* Copyright (c) 2011, abego Software GmbH, Germany (http://www.abego.org)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of the abego Software GmbH nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package org.abego.treelayout.util;
/**
*
* @author Udo Borkowski ([email protected])
*
*
*/
public class DefaultTreeForTreeLayoutTest {
String root = "root";
String n1 = "n1";
String n2 = "n2"; | DefaultTreeForTreeLayout<String> tree; |
abego/treelayout | org.abego.treelayout/src/main/java/org/abego/treelayout/util/AbstractTreeForTreeLayout.java | // Path: org.abego.treelayout/src/main/java/org/abego/treelayout/TreeForTreeLayout.java
// public interface TreeForTreeLayout<TreeNode> {
//
// /**
// * Returns the the root of the tree.
// * <p>
// * Time Complexity: O(1)
// *
// * @return the root of the tree
// */
// TreeNode getRoot();
//
// /**
// * Tells if a node is a leaf in the tree.
// * <p>
// * Time Complexity: O(1)
// *
// * @param node
// * @return true iff node is a leaf in the tree, i.e. has no children.
// */
// boolean isLeaf(TreeNode node);
//
// /**
// * Tells if a node is a child of a given parentNode.
// * <p>
// * Time Complexity: O(1)
// *
// * @param node
// * @param parentNode
// * @return true iff the node is a child of the given parentNode
// */
// boolean isChildOfParent(TreeNode node, TreeNode parentNode);
//
// /**
// * Returns the children of a parent node.
// * <p>
// * Time Complexity: O(1)
// *
// * @param parentNode
// * [!isLeaf(parentNode)]
// * @return the children of the given parentNode, from first to last
// */
// Iterable<TreeNode> getChildren(TreeNode parentNode);
//
// /**
// * Returns the children of a parent node, in reverse order.
// * <p>
// * Time Complexity: O(1)
// *
// * @param parentNode
// * [!isLeaf(parentNode)]
// * @return the children of given parentNode, from last to first
// */
// Iterable<TreeNode> getChildrenReverse(TreeNode parentNode);
//
// /**
// * Returns the first child of a parent node.
// * <p>
// * Time Complexity: O(1)
// *
// * @param parentNode
// * [!isLeaf(parentNode)]
// * @return the first child of the parentNode
// */
// TreeNode getFirstChild(TreeNode parentNode);
//
// /**
// * Returns the last child of a parent node.
// * <p>
// *
// * Time Complexity: O(1)
// *
// * @param parentNode
// * [!isLeaf(parentNode)]
// * @return the last child of the parentNode
// */
// TreeNode getLastChild(TreeNode parentNode);
// }
//
// Path: org.abego.treelayout/src/main/java/org/abego/treelayout/internal/util/java/lang/IterableUtil.java
// public class IterableUtil {
// private static class ReverseIterable<T> implements Iterable<T> {
// private List<T> list;
//
// public ReverseIterable(List<T> list) {
// this.list = list;
// }
//
// @Override
// public Iterator<T> iterator() {
// return IteratorUtil.createReverseIterator(list);
// }
// };
//
// /**
// * Returns an {@link Iterable} with an iterator iterating the given list
// * from the end to the start.
// * <p>
// * I.e. the iterator does the reverse of the {@link List#iterator()}.
// *
// * @param <T> Type of elements in the list
// * @param list
// * @return a reverse {@link Iterable} of the list
// */
// public static <T> Iterable<T> createReverseIterable(List<T> list) {
// // When the list is empty we can use the "forward" iterable (i.e. the
// // list itself) also as the reverseIterable as it will do nothing.
// if (list.size() == 0) {
// return list;
// }
//
// return new ReverseIterable<T>(list);
// }
// }
//
// Path: org.abego.treelayout/src/main/java/org/abego/treelayout/internal/util/java/util/ListUtil.java
// public class ListUtil {
//
// /**
// *
// * @param <T> Type of elements in the list
// * @param list [!list.isEmpty()]
// * @return the last element of the list
// */
// public static <T> T getLast(List<T> list) {
// return list.get(list.size() - 1);
// }
//
// }
| import org.abego.treelayout.TreeForTreeLayout;
import org.abego.treelayout.internal.util.java.lang.IterableUtil;
import org.abego.treelayout.internal.util.java.util.ListUtil;
import java.util.List; | return root;
}
@Override
public boolean isLeaf(TreeNode node) {
return getChildrenList(node).isEmpty();
}
@Override
public boolean isChildOfParent(TreeNode node, TreeNode parentNode) {
return getParent(node) == parentNode;
}
@Override
public Iterable<TreeNode> getChildren(TreeNode node) {
return getChildrenList(node);
}
@Override
public Iterable<TreeNode> getChildrenReverse(TreeNode node) {
return IterableUtil.createReverseIterable(getChildrenList(node));
}
@Override
public TreeNode getFirstChild(TreeNode parentNode) {
return getChildrenList(parentNode).get(0);
}
@Override
public TreeNode getLastChild(TreeNode parentNode) { | // Path: org.abego.treelayout/src/main/java/org/abego/treelayout/TreeForTreeLayout.java
// public interface TreeForTreeLayout<TreeNode> {
//
// /**
// * Returns the the root of the tree.
// * <p>
// * Time Complexity: O(1)
// *
// * @return the root of the tree
// */
// TreeNode getRoot();
//
// /**
// * Tells if a node is a leaf in the tree.
// * <p>
// * Time Complexity: O(1)
// *
// * @param node
// * @return true iff node is a leaf in the tree, i.e. has no children.
// */
// boolean isLeaf(TreeNode node);
//
// /**
// * Tells if a node is a child of a given parentNode.
// * <p>
// * Time Complexity: O(1)
// *
// * @param node
// * @param parentNode
// * @return true iff the node is a child of the given parentNode
// */
// boolean isChildOfParent(TreeNode node, TreeNode parentNode);
//
// /**
// * Returns the children of a parent node.
// * <p>
// * Time Complexity: O(1)
// *
// * @param parentNode
// * [!isLeaf(parentNode)]
// * @return the children of the given parentNode, from first to last
// */
// Iterable<TreeNode> getChildren(TreeNode parentNode);
//
// /**
// * Returns the children of a parent node, in reverse order.
// * <p>
// * Time Complexity: O(1)
// *
// * @param parentNode
// * [!isLeaf(parentNode)]
// * @return the children of given parentNode, from last to first
// */
// Iterable<TreeNode> getChildrenReverse(TreeNode parentNode);
//
// /**
// * Returns the first child of a parent node.
// * <p>
// * Time Complexity: O(1)
// *
// * @param parentNode
// * [!isLeaf(parentNode)]
// * @return the first child of the parentNode
// */
// TreeNode getFirstChild(TreeNode parentNode);
//
// /**
// * Returns the last child of a parent node.
// * <p>
// *
// * Time Complexity: O(1)
// *
// * @param parentNode
// * [!isLeaf(parentNode)]
// * @return the last child of the parentNode
// */
// TreeNode getLastChild(TreeNode parentNode);
// }
//
// Path: org.abego.treelayout/src/main/java/org/abego/treelayout/internal/util/java/lang/IterableUtil.java
// public class IterableUtil {
// private static class ReverseIterable<T> implements Iterable<T> {
// private List<T> list;
//
// public ReverseIterable(List<T> list) {
// this.list = list;
// }
//
// @Override
// public Iterator<T> iterator() {
// return IteratorUtil.createReverseIterator(list);
// }
// };
//
// /**
// * Returns an {@link Iterable} with an iterator iterating the given list
// * from the end to the start.
// * <p>
// * I.e. the iterator does the reverse of the {@link List#iterator()}.
// *
// * @param <T> Type of elements in the list
// * @param list
// * @return a reverse {@link Iterable} of the list
// */
// public static <T> Iterable<T> createReverseIterable(List<T> list) {
// // When the list is empty we can use the "forward" iterable (i.e. the
// // list itself) also as the reverseIterable as it will do nothing.
// if (list.size() == 0) {
// return list;
// }
//
// return new ReverseIterable<T>(list);
// }
// }
//
// Path: org.abego.treelayout/src/main/java/org/abego/treelayout/internal/util/java/util/ListUtil.java
// public class ListUtil {
//
// /**
// *
// * @param <T> Type of elements in the list
// * @param list [!list.isEmpty()]
// * @return the last element of the list
// */
// public static <T> T getLast(List<T> list) {
// return list.get(list.size() - 1);
// }
//
// }
// Path: org.abego.treelayout/src/main/java/org/abego/treelayout/util/AbstractTreeForTreeLayout.java
import org.abego.treelayout.TreeForTreeLayout;
import org.abego.treelayout.internal.util.java.lang.IterableUtil;
import org.abego.treelayout.internal.util.java.util.ListUtil;
import java.util.List;
return root;
}
@Override
public boolean isLeaf(TreeNode node) {
return getChildrenList(node).isEmpty();
}
@Override
public boolean isChildOfParent(TreeNode node, TreeNode parentNode) {
return getParent(node) == parentNode;
}
@Override
public Iterable<TreeNode> getChildren(TreeNode node) {
return getChildrenList(node);
}
@Override
public Iterable<TreeNode> getChildrenReverse(TreeNode node) {
return IterableUtil.createReverseIterable(getChildrenList(node));
}
@Override
public TreeNode getFirstChild(TreeNode parentNode) {
return getChildrenList(parentNode).get(0);
}
@Override
public TreeNode getLastChild(TreeNode parentNode) { | return ListUtil.getLast(getChildrenList(parentNode)); |
abego/treelayout | org.abego.treelayout/src/main/java/org/abego/treelayout/util/DefaultTreeForTreeLayout.java | // Path: org.abego.treelayout/src/main/java/org/abego/treelayout/internal/util/Contract.java
// public static void checkArg(boolean isOK, String s) {
// if (!isOK) {
// throw new IllegalArgumentException(s);
// }
// }
| import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static org.abego.treelayout.internal.util.Contract.checkArg; | /*
* [The "BSD license"]
* Copyright (c) 2011, abego Software GmbH, Germany (http://www.abego.org)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of the abego Software GmbH nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package org.abego.treelayout.util;
/**
* Provides a generic implementation for the {@link org.abego.treelayout.TreeForTreeLayout}
* interface, applicable to any type of tree node.
* <p>
* It allows you to create a tree "from scratch", without creating any new
* class.
* <p>
* To create a tree you must provide the root of the tree (see
* {@link #DefaultTreeForTreeLayout(Object)}. Then you can incrementally
* construct the tree by adding children to the root or other nodes of the tree
* (see {@link #addChild(Object, Object)} and
* {@link #addChildren(Object, Object...)}).
*
* @author Udo Borkowski ([email protected])
*
* @param <TreeNode> Type of elements used as nodes in the tree
*/
public class DefaultTreeForTreeLayout<TreeNode> extends
AbstractTreeForTreeLayout<TreeNode> {
private List<TreeNode> emptyList;
private List<TreeNode> getEmptyList() {
if (emptyList == null) {
emptyList = new ArrayList<TreeNode>();
}
return emptyList;
}
private Map<TreeNode, List<TreeNode>> childrenMap = new HashMap<TreeNode, List<TreeNode>>();
private Map<TreeNode, TreeNode> parents = new HashMap<TreeNode, TreeNode>();
/**
* Creates a new instance with a given node as the root
*
* @param root
* the node to be used as the root.
*/
public DefaultTreeForTreeLayout(TreeNode root) {
super(root);
}
@Override
public TreeNode getParent(TreeNode node) {
return parents.get(node);
}
@Override
public List<TreeNode> getChildrenList(TreeNode node) {
List<TreeNode> result = childrenMap.get(node);
return result == null ? getEmptyList() : result;
}
/**
*
* @param node
* @return true iff the node is in the tree
*/
public boolean hasNode(TreeNode node) {
return node == getRoot() || parents.containsKey(node);
}
/**
* @param parentNode
* [hasNode(parentNode)]
* @param node
* [!hasNode(node)]
*/
public void addChild(TreeNode parentNode, TreeNode node) { | // Path: org.abego.treelayout/src/main/java/org/abego/treelayout/internal/util/Contract.java
// public static void checkArg(boolean isOK, String s) {
// if (!isOK) {
// throw new IllegalArgumentException(s);
// }
// }
// Path: org.abego.treelayout/src/main/java/org/abego/treelayout/util/DefaultTreeForTreeLayout.java
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static org.abego.treelayout.internal.util.Contract.checkArg;
/*
* [The "BSD license"]
* Copyright (c) 2011, abego Software GmbH, Germany (http://www.abego.org)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of the abego Software GmbH nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package org.abego.treelayout.util;
/**
* Provides a generic implementation for the {@link org.abego.treelayout.TreeForTreeLayout}
* interface, applicable to any type of tree node.
* <p>
* It allows you to create a tree "from scratch", without creating any new
* class.
* <p>
* To create a tree you must provide the root of the tree (see
* {@link #DefaultTreeForTreeLayout(Object)}. Then you can incrementally
* construct the tree by adding children to the root or other nodes of the tree
* (see {@link #addChild(Object, Object)} and
* {@link #addChildren(Object, Object...)}).
*
* @author Udo Borkowski ([email protected])
*
* @param <TreeNode> Type of elements used as nodes in the tree
*/
public class DefaultTreeForTreeLayout<TreeNode> extends
AbstractTreeForTreeLayout<TreeNode> {
private List<TreeNode> emptyList;
private List<TreeNode> getEmptyList() {
if (emptyList == null) {
emptyList = new ArrayList<TreeNode>();
}
return emptyList;
}
private Map<TreeNode, List<TreeNode>> childrenMap = new HashMap<TreeNode, List<TreeNode>>();
private Map<TreeNode, TreeNode> parents = new HashMap<TreeNode, TreeNode>();
/**
* Creates a new instance with a given node as the root
*
* @param root
* the node to be used as the root.
*/
public DefaultTreeForTreeLayout(TreeNode root) {
super(root);
}
@Override
public TreeNode getParent(TreeNode node) {
return parents.get(node);
}
@Override
public List<TreeNode> getChildrenList(TreeNode node) {
List<TreeNode> result = childrenMap.get(node);
return result == null ? getEmptyList() : result;
}
/**
*
* @param node
* @return true iff the node is in the tree
*/
public boolean hasNode(TreeNode node) {
return node == getRoot() || parents.containsKey(node);
}
/**
* @param parentNode
* [hasNode(parentNode)]
* @param node
* [!hasNode(node)]
*/
public void addChild(TreeNode parentNode, TreeNode node) { | checkArg(hasNode(parentNode), "parentNode is not in the tree"); |
abego/treelayout | org.abego.treelayout/src/main/java/org/abego/treelayout/internal/util/java/lang/IterableUtil.java | // Path: org.abego.treelayout/src/main/java/org/abego/treelayout/internal/util/java/util/IteratorUtil.java
// public class IteratorUtil {
//
// private static class ReverseIterator<T> implements Iterator<T> {
// private ListIterator<T> listIterator;
//
// public ReverseIterator(List<T> list) {
// this.listIterator = list.listIterator(list.size());
// }
//
// @Override
// public boolean hasNext() {
// return listIterator.hasPrevious();
// }
//
// @Override
// public T next() {
// return listIterator.previous();
// }
//
// @Override
// public void remove() {
// listIterator.remove();
// }
// }
//
// /**
// * Returns an {@link Iterator} iterating the given list from the end to the
// * start.
// * <p>
// * I.e. the iterator does the reverse of the {@link List#iterator()}.
// *
// * @param <T> Type of elements in the list
// * @param list
// * @return a reverse {@link Iterator} of the list
// */
// public static <T> Iterator<T> createReverseIterator(List<T> list) {
// return new ReverseIterator<T>(list);
// }
// }
| import java.util.List;
import org.abego.treelayout.internal.util.java.util.IteratorUtil;
import java.util.Iterator; | /*
* [The "BSD license"]
* Copyright (c) 2011, abego Software GmbH, Germany (http://www.abego.org)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of the abego Software GmbH nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package org.abego.treelayout.internal.util.java.lang;
/**
* Util (general purpose) methods dealing with {@link Iterable}.
*
* @author Udo Borkowski ([email protected])
*
*
*/
public class IterableUtil {
private static class ReverseIterable<T> implements Iterable<T> {
private List<T> list;
public ReverseIterable(List<T> list) {
this.list = list;
}
@Override
public Iterator<T> iterator() { | // Path: org.abego.treelayout/src/main/java/org/abego/treelayout/internal/util/java/util/IteratorUtil.java
// public class IteratorUtil {
//
// private static class ReverseIterator<T> implements Iterator<T> {
// private ListIterator<T> listIterator;
//
// public ReverseIterator(List<T> list) {
// this.listIterator = list.listIterator(list.size());
// }
//
// @Override
// public boolean hasNext() {
// return listIterator.hasPrevious();
// }
//
// @Override
// public T next() {
// return listIterator.previous();
// }
//
// @Override
// public void remove() {
// listIterator.remove();
// }
// }
//
// /**
// * Returns an {@link Iterator} iterating the given list from the end to the
// * start.
// * <p>
// * I.e. the iterator does the reverse of the {@link List#iterator()}.
// *
// * @param <T> Type of elements in the list
// * @param list
// * @return a reverse {@link Iterator} of the list
// */
// public static <T> Iterator<T> createReverseIterator(List<T> list) {
// return new ReverseIterator<T>(list);
// }
// }
// Path: org.abego.treelayout/src/main/java/org/abego/treelayout/internal/util/java/lang/IterableUtil.java
import java.util.List;
import org.abego.treelayout.internal.util.java.util.IteratorUtil;
import java.util.Iterator;
/*
* [The "BSD license"]
* Copyright (c) 2011, abego Software GmbH, Germany (http://www.abego.org)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of the abego Software GmbH nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package org.abego.treelayout.internal.util.java.lang;
/**
* Util (general purpose) methods dealing with {@link Iterable}.
*
* @author Udo Borkowski ([email protected])
*
*
*/
public class IterableUtil {
private static class ReverseIterable<T> implements Iterable<T> {
private List<T> list;
public ReverseIterable(List<T> list) {
this.list = list;
}
@Override
public Iterator<T> iterator() { | return IteratorUtil.createReverseIterator(list); |
kyawswa/myanmarlottery | src/main/java/com/ksa/myanmarlottery/model/Result.java | // Path: src/main/java/com/ksa/myanmarlottery/util/ConstantUtil.java
// public class ConstantUtil {
// public static final MediaType JSON = MediaType.parse("application/json; charset=utf-8");
// @Deprecated
// public static final int OLD_LOTTERY_TYPE= 1; // for 500 ks lottery
// public static final int NEW_LOTTERY_TYPE = 2; // for 1k ks lottery
//
// public static final String ACTION_TYPING_ON = "typing_on";
// public static final String ACTION_TYPING_OFF = "typing_off";
//
// public static final String WEB = "web";
// public static final String FACEBOOK = "Facebook";
//
// public static final int NORMAL_QUERY = 0;
// public static final int CODE_RANGE_QUERY = 1;
// public static final int POINT_RANGE_QUERY = 2;
//
// public static boolean isCodePointValid(String[] codeNo) {
// // if(codeNo == null || codeNo.isEmpty()) {
// // return false;
// // }
//
// // String[] arr = codeNo.split(" ");
// // if(arr.length != 2) {
// // return false;
// // }
//
// String character = codeNo[0];
// if(character.isEmpty() || character.length() > 2 || character.length() < 1) {
// return false;
// }
//
// // check digit or not.
// String number = codeNo[1];
// if(number.isEmpty() || number.length() != 6)
// return false;
//
// for(int i=0; i< number.length(); i++) {
// if(!Character.isDigit(number.charAt(i)))
// return false; // assume it is character.
// }
// return true;
// }
//
// /**
// * 0= false, greater than 0=true
// * 1 is findPrizeByCodeRange
// * 2 is findPrizeByPointRange
// * @param codeNo
// * @return
// */
// public static int getCodePointRangeType(String[] codeNo) {
// String character = codeNo[0];
// if(character.isEmpty() || character.length() > 2 || character.length() < 1) {
// return 0;
// }
//
// String secondChar = codeNo[1];
// String thirdChar = codeNo[2];
// // check second element is digit
// if(!secondChar.isEmpty() && secondChar.length() == 6) {
// for(int i=0; i< secondChar.length(); i++) {
// if(!Character.isDigit(secondChar.charAt(i)))
// return 0; // assume it is character.
// }
// // check third part
// if(thirdChar.isEmpty() || thirdChar.length() != 6) // length should not be greater than 6 or less than 1.
// return 0;
//
// // third part must be digit
// for(int i=0; i< thirdChar.length(); i++) {
// if(!Character.isDigit(thirdChar.charAt(i)))
// return 0; // assume it is character.
// }
// return POINT_RANGE_QUERY; // 2 for findPrizeByPointRange: point mean number
//
// // check second element is character
// } else if(!secondChar.isEmpty() && secondChar.length() <= 2 && secondChar.length() >= 1){
// for(int i=0; i< secondChar.length(); i++) {
// if(Character.isDigit(secondChar.charAt(i)))
// return 0; // assume it is digit.
// }
// // check third part
// if(thirdChar.isEmpty() || thirdChar.length() != 6)
// return 0;
//
// // third part must be digit
// for(int i=0; i< thirdChar.length(); i++) {
// if(!Character.isDigit(thirdChar.charAt(i)))
// return 0; // assume it is character.
// }
// return CODE_RANGE_QUERY; // 1 for findPrizeByCodeRange: code means character
// }
// return 0;
// }
// }
| import com.ksa.myanmarlottery.util.ConstantUtil;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType; | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.ksa.myanmarlottery.model;
/**
*
* @author kyawswar
*/
@Entity
@NamedQueries({
@NamedQuery(
name = "result.findLatestResult",
query = "from Result r where r.resultFor in (select max(rr.resultFor) from Result rr where rr.type = :type)"
),
@NamedQuery(
name = "result.findLatestResultSummary",
query = "Select r.numberOfTimes as numberOfTimes, r.resultFor as resultFor, r.type as type from Result r where r.type = :type"
),
@NamedQuery(
name = "result.findByType",
query = "from Result r where r.type = :type"
)
})
@Table(name = "Lottery_result")
public class Result implements Serializable {
@Id
@Column(name = "RESULT_TYPE") | // Path: src/main/java/com/ksa/myanmarlottery/util/ConstantUtil.java
// public class ConstantUtil {
// public static final MediaType JSON = MediaType.parse("application/json; charset=utf-8");
// @Deprecated
// public static final int OLD_LOTTERY_TYPE= 1; // for 500 ks lottery
// public static final int NEW_LOTTERY_TYPE = 2; // for 1k ks lottery
//
// public static final String ACTION_TYPING_ON = "typing_on";
// public static final String ACTION_TYPING_OFF = "typing_off";
//
// public static final String WEB = "web";
// public static final String FACEBOOK = "Facebook";
//
// public static final int NORMAL_QUERY = 0;
// public static final int CODE_RANGE_QUERY = 1;
// public static final int POINT_RANGE_QUERY = 2;
//
// public static boolean isCodePointValid(String[] codeNo) {
// // if(codeNo == null || codeNo.isEmpty()) {
// // return false;
// // }
//
// // String[] arr = codeNo.split(" ");
// // if(arr.length != 2) {
// // return false;
// // }
//
// String character = codeNo[0];
// if(character.isEmpty() || character.length() > 2 || character.length() < 1) {
// return false;
// }
//
// // check digit or not.
// String number = codeNo[1];
// if(number.isEmpty() || number.length() != 6)
// return false;
//
// for(int i=0; i< number.length(); i++) {
// if(!Character.isDigit(number.charAt(i)))
// return false; // assume it is character.
// }
// return true;
// }
//
// /**
// * 0= false, greater than 0=true
// * 1 is findPrizeByCodeRange
// * 2 is findPrizeByPointRange
// * @param codeNo
// * @return
// */
// public static int getCodePointRangeType(String[] codeNo) {
// String character = codeNo[0];
// if(character.isEmpty() || character.length() > 2 || character.length() < 1) {
// return 0;
// }
//
// String secondChar = codeNo[1];
// String thirdChar = codeNo[2];
// // check second element is digit
// if(!secondChar.isEmpty() && secondChar.length() == 6) {
// for(int i=0; i< secondChar.length(); i++) {
// if(!Character.isDigit(secondChar.charAt(i)))
// return 0; // assume it is character.
// }
// // check third part
// if(thirdChar.isEmpty() || thirdChar.length() != 6) // length should not be greater than 6 or less than 1.
// return 0;
//
// // third part must be digit
// for(int i=0; i< thirdChar.length(); i++) {
// if(!Character.isDigit(thirdChar.charAt(i)))
// return 0; // assume it is character.
// }
// return POINT_RANGE_QUERY; // 2 for findPrizeByPointRange: point mean number
//
// // check second element is character
// } else if(!secondChar.isEmpty() && secondChar.length() <= 2 && secondChar.length() >= 1){
// for(int i=0; i< secondChar.length(); i++) {
// if(Character.isDigit(secondChar.charAt(i)))
// return 0; // assume it is digit.
// }
// // check third part
// if(thirdChar.isEmpty() || thirdChar.length() != 6)
// return 0;
//
// // third part must be digit
// for(int i=0; i< thirdChar.length(); i++) {
// if(!Character.isDigit(thirdChar.charAt(i)))
// return 0; // assume it is character.
// }
// return CODE_RANGE_QUERY; // 1 for findPrizeByCodeRange: code means character
// }
// return 0;
// }
// }
// Path: src/main/java/com/ksa/myanmarlottery/model/Result.java
import com.ksa.myanmarlottery.util.ConstantUtil;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.ksa.myanmarlottery.model;
/**
*
* @author kyawswar
*/
@Entity
@NamedQueries({
@NamedQuery(
name = "result.findLatestResult",
query = "from Result r where r.resultFor in (select max(rr.resultFor) from Result rr where rr.type = :type)"
),
@NamedQuery(
name = "result.findLatestResultSummary",
query = "Select r.numberOfTimes as numberOfTimes, r.resultFor as resultFor, r.type as type from Result r where r.type = :type"
),
@NamedQuery(
name = "result.findByType",
query = "from Result r where r.type = :type"
)
})
@Table(name = "Lottery_result")
public class Result implements Serializable {
@Id
@Column(name = "RESULT_TYPE") | private int type = ConstantUtil.OLD_LOTTERY_TYPE;; |
kyawswa/myanmarlottery | src/main/java/com/ksa/myanmarlottery/repository/LogRepositoryImpl.java | // Path: src/main/java/com/ksa/myanmarlottery/model/LogInfo.java
// @Entity
// public class LogInfo {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
// private String userID;
// private String userType; // facebook user or other.
// private String parameter;
// private String url;
//
// @Temporal(TemporalType.TIMESTAMP)
// private Date date;
//
// public static final String FACEBOOK_USER = "Facebook User";
// public static final String WEB_CLIENT_USER = "Web Client User";
//
// public LogInfo() {}
//
// public LogInfo(Date date, String userID, String userType, String parameter, String url) {
// this.userID = userID;
// this.userType = userType;
// this.parameter = parameter;
// this.date = date;
// this.url = url;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getUserID() {
// return userID;
// }
//
// public void setUserID(String userID) {
// this.userID = userID;
// }
//
// public String getUserType() {
// return userType;
// }
//
// public void setUserType(String userType) {
// this.userType = userType;
// }
//
// public String getParameter() {
// return parameter;
// }
//
// public void setParameter(String parameter) {
// this.parameter = parameter;
// }
//
// public Date getDate() {
// return date;
// }
//
// public void setDate(Date date) {
// this.date = date;
// }
//
// public String getUrl() {
// return url;
// }
//
// public void setUrl(String url) {
// this.url = url;
// }
// }
| import com.ksa.myanmarlottery.model.LogInfo;
import javax.persistence.EntityManager;
import javax.transaction.Transactional;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository; | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.ksa.myanmarlottery.repository;
/**
*
* @author Kyawswar
*/
@Repository
@Transactional
public class LogRepositoryImpl implements LogRepository {
@Autowired
private EntityManager em;
private Log log = LogFactory.getLog(LogRepositoryImpl.class);
@Override | // Path: src/main/java/com/ksa/myanmarlottery/model/LogInfo.java
// @Entity
// public class LogInfo {
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// private int id;
// private String userID;
// private String userType; // facebook user or other.
// private String parameter;
// private String url;
//
// @Temporal(TemporalType.TIMESTAMP)
// private Date date;
//
// public static final String FACEBOOK_USER = "Facebook User";
// public static final String WEB_CLIENT_USER = "Web Client User";
//
// public LogInfo() {}
//
// public LogInfo(Date date, String userID, String userType, String parameter, String url) {
// this.userID = userID;
// this.userType = userType;
// this.parameter = parameter;
// this.date = date;
// this.url = url;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getUserID() {
// return userID;
// }
//
// public void setUserID(String userID) {
// this.userID = userID;
// }
//
// public String getUserType() {
// return userType;
// }
//
// public void setUserType(String userType) {
// this.userType = userType;
// }
//
// public String getParameter() {
// return parameter;
// }
//
// public void setParameter(String parameter) {
// this.parameter = parameter;
// }
//
// public Date getDate() {
// return date;
// }
//
// public void setDate(Date date) {
// this.date = date;
// }
//
// public String getUrl() {
// return url;
// }
//
// public void setUrl(String url) {
// this.url = url;
// }
// }
// Path: src/main/java/com/ksa/myanmarlottery/repository/LogRepositoryImpl.java
import com.ksa.myanmarlottery.model.LogInfo;
import javax.persistence.EntityManager;
import javax.transaction.Transactional;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.ksa.myanmarlottery.repository;
/**
*
* @author Kyawswar
*/
@Repository
@Transactional
public class LogRepositoryImpl implements LogRepository {
@Autowired
private EntityManager em;
private Log log = LogFactory.getLog(LogRepositoryImpl.class);
@Override | public void inserLog(LogInfo logInfo) { |
kyawswa/myanmarlottery | src/main/java/com/hyurumi/fb_bot_boilerplate/models/webhook/Message.java | // Path: src/main/java/com/hyurumi/fb_bot_boilerplate/models/send/QuickReply.java
// public class QuickReply {
// @SerializedName("content_type")
// public String contentType;
// @SerializedName("title")
// public String title;
// @SerializedName("payload")
// public String payload;
// @SerializedName("image_url")
// public String imageUrl;
//
// public QuickReply(String contentType, String title, String payload, String imageUrl) {
// this.contentType = contentType;
// this.title = title;
// this.payload = payload;
// this.imageUrl = imageUrl;
// }
//
// public QuickReply() {}
// }
| import com.hyurumi.fb_bot_boilerplate.models.send.QuickReply;
import java.util.List; | package com.hyurumi.fb_bot_boilerplate.models.webhook;
/**
* Created by genki.furumi on 4/14/16.
*/
public class Message {
public String mid;
public int seq;
public List<Attachment> attachments;
public String text; | // Path: src/main/java/com/hyurumi/fb_bot_boilerplate/models/send/QuickReply.java
// public class QuickReply {
// @SerializedName("content_type")
// public String contentType;
// @SerializedName("title")
// public String title;
// @SerializedName("payload")
// public String payload;
// @SerializedName("image_url")
// public String imageUrl;
//
// public QuickReply(String contentType, String title, String payload, String imageUrl) {
// this.contentType = contentType;
// this.title = title;
// this.payload = payload;
// this.imageUrl = imageUrl;
// }
//
// public QuickReply() {}
// }
// Path: src/main/java/com/hyurumi/fb_bot_boilerplate/models/webhook/Message.java
import com.hyurumi.fb_bot_boilerplate.models.send.QuickReply;
import java.util.List;
package com.hyurumi.fb_bot_boilerplate.models.webhook;
/**
* Created by genki.furumi on 4/14/16.
*/
public class Message {
public String mid;
public int seq;
public List<Attachment> attachments;
public String text; | public QuickReply quick_reply; |
kyawswa/myanmarlottery | src/main/java/com/ksa/myanmarlottery/dto/ItemDTO.java | // Path: src/main/java/com/ksa/myanmarlottery/util/ConstantUtil.java
// public class ConstantUtil {
// public static final MediaType JSON = MediaType.parse("application/json; charset=utf-8");
// @Deprecated
// public static final int OLD_LOTTERY_TYPE= 1; // for 500 ks lottery
// public static final int NEW_LOTTERY_TYPE = 2; // for 1k ks lottery
//
// public static final String ACTION_TYPING_ON = "typing_on";
// public static final String ACTION_TYPING_OFF = "typing_off";
//
// public static final String WEB = "web";
// public static final String FACEBOOK = "Facebook";
//
// public static final int NORMAL_QUERY = 0;
// public static final int CODE_RANGE_QUERY = 1;
// public static final int POINT_RANGE_QUERY = 2;
//
// public static boolean isCodePointValid(String[] codeNo) {
// // if(codeNo == null || codeNo.isEmpty()) {
// // return false;
// // }
//
// // String[] arr = codeNo.split(" ");
// // if(arr.length != 2) {
// // return false;
// // }
//
// String character = codeNo[0];
// if(character.isEmpty() || character.length() > 2 || character.length() < 1) {
// return false;
// }
//
// // check digit or not.
// String number = codeNo[1];
// if(number.isEmpty() || number.length() != 6)
// return false;
//
// for(int i=0; i< number.length(); i++) {
// if(!Character.isDigit(number.charAt(i)))
// return false; // assume it is character.
// }
// return true;
// }
//
// /**
// * 0= false, greater than 0=true
// * 1 is findPrizeByCodeRange
// * 2 is findPrizeByPointRange
// * @param codeNo
// * @return
// */
// public static int getCodePointRangeType(String[] codeNo) {
// String character = codeNo[0];
// if(character.isEmpty() || character.length() > 2 || character.length() < 1) {
// return 0;
// }
//
// String secondChar = codeNo[1];
// String thirdChar = codeNo[2];
// // check second element is digit
// if(!secondChar.isEmpty() && secondChar.length() == 6) {
// for(int i=0; i< secondChar.length(); i++) {
// if(!Character.isDigit(secondChar.charAt(i)))
// return 0; // assume it is character.
// }
// // check third part
// if(thirdChar.isEmpty() || thirdChar.length() != 6) // length should not be greater than 6 or less than 1.
// return 0;
//
// // third part must be digit
// for(int i=0; i< thirdChar.length(); i++) {
// if(!Character.isDigit(thirdChar.charAt(i)))
// return 0; // assume it is character.
// }
// return POINT_RANGE_QUERY; // 2 for findPrizeByPointRange: point mean number
//
// // check second element is character
// } else if(!secondChar.isEmpty() && secondChar.length() <= 2 && secondChar.length() >= 1){
// for(int i=0; i< secondChar.length(); i++) {
// if(Character.isDigit(secondChar.charAt(i)))
// return 0; // assume it is digit.
// }
// // check third part
// if(thirdChar.isEmpty() || thirdChar.length() != 6)
// return 0;
//
// // third part must be digit
// for(int i=0; i< thirdChar.length(); i++) {
// if(!Character.isDigit(thirdChar.charAt(i)))
// return 0; // assume it is character.
// }
// return CODE_RANGE_QUERY; // 1 for findPrizeByCodeRange: code means character
// }
// return 0;
// }
// }
| import java.util.List;
import com.ksa.myanmarlottery.util.ConstantUtil; | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.ksa.myanmarlottery.dto;
/**
*
* @author Kyawswar
*/
public class ItemDTO {
public List<String> codePoints;
public int queryType; | // Path: src/main/java/com/ksa/myanmarlottery/util/ConstantUtil.java
// public class ConstantUtil {
// public static final MediaType JSON = MediaType.parse("application/json; charset=utf-8");
// @Deprecated
// public static final int OLD_LOTTERY_TYPE= 1; // for 500 ks lottery
// public static final int NEW_LOTTERY_TYPE = 2; // for 1k ks lottery
//
// public static final String ACTION_TYPING_ON = "typing_on";
// public static final String ACTION_TYPING_OFF = "typing_off";
//
// public static final String WEB = "web";
// public static final String FACEBOOK = "Facebook";
//
// public static final int NORMAL_QUERY = 0;
// public static final int CODE_RANGE_QUERY = 1;
// public static final int POINT_RANGE_QUERY = 2;
//
// public static boolean isCodePointValid(String[] codeNo) {
// // if(codeNo == null || codeNo.isEmpty()) {
// // return false;
// // }
//
// // String[] arr = codeNo.split(" ");
// // if(arr.length != 2) {
// // return false;
// // }
//
// String character = codeNo[0];
// if(character.isEmpty() || character.length() > 2 || character.length() < 1) {
// return false;
// }
//
// // check digit or not.
// String number = codeNo[1];
// if(number.isEmpty() || number.length() != 6)
// return false;
//
// for(int i=0; i< number.length(); i++) {
// if(!Character.isDigit(number.charAt(i)))
// return false; // assume it is character.
// }
// return true;
// }
//
// /**
// * 0= false, greater than 0=true
// * 1 is findPrizeByCodeRange
// * 2 is findPrizeByPointRange
// * @param codeNo
// * @return
// */
// public static int getCodePointRangeType(String[] codeNo) {
// String character = codeNo[0];
// if(character.isEmpty() || character.length() > 2 || character.length() < 1) {
// return 0;
// }
//
// String secondChar = codeNo[1];
// String thirdChar = codeNo[2];
// // check second element is digit
// if(!secondChar.isEmpty() && secondChar.length() == 6) {
// for(int i=0; i< secondChar.length(); i++) {
// if(!Character.isDigit(secondChar.charAt(i)))
// return 0; // assume it is character.
// }
// // check third part
// if(thirdChar.isEmpty() || thirdChar.length() != 6) // length should not be greater than 6 or less than 1.
// return 0;
//
// // third part must be digit
// for(int i=0; i< thirdChar.length(); i++) {
// if(!Character.isDigit(thirdChar.charAt(i)))
// return 0; // assume it is character.
// }
// return POINT_RANGE_QUERY; // 2 for findPrizeByPointRange: point mean number
//
// // check second element is character
// } else if(!secondChar.isEmpty() && secondChar.length() <= 2 && secondChar.length() >= 1){
// for(int i=0; i< secondChar.length(); i++) {
// if(Character.isDigit(secondChar.charAt(i)))
// return 0; // assume it is digit.
// }
// // check third part
// if(thirdChar.isEmpty() || thirdChar.length() != 6)
// return 0;
//
// // third part must be digit
// for(int i=0; i< thirdChar.length(); i++) {
// if(!Character.isDigit(thirdChar.charAt(i)))
// return 0; // assume it is character.
// }
// return CODE_RANGE_QUERY; // 1 for findPrizeByCodeRange: code means character
// }
// return 0;
// }
// }
// Path: src/main/java/com/ksa/myanmarlottery/dto/ItemDTO.java
import java.util.List;
import com.ksa.myanmarlottery.util.ConstantUtil;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.ksa.myanmarlottery.dto;
/**
*
* @author Kyawswar
*/
public class ItemDTO {
public List<String> codePoints;
public int queryType; | public int type = ConstantUtil.OLD_LOTTERY_TYPE; |
kyawswa/myanmarlottery | src/main/java/com/ksa/myanmarlottery/controller/FBResultController.java | // Path: src/main/java/com/ksa/myanmarlottery/service/fb/FBResultService.java
// public interface FBResultService {
// void manageRequst(String receiveMessage);
// }
| import com.ksa.myanmarlottery.service.fb.FBResultService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam; | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.ksa.myanmarlottery.controller;
/**
*
* @author Kyawswa
*/
@Controller
public class FBResultController {
@Autowired
private Environment env;
@Autowired | // Path: src/main/java/com/ksa/myanmarlottery/service/fb/FBResultService.java
// public interface FBResultService {
// void manageRequst(String receiveMessage);
// }
// Path: src/main/java/com/ksa/myanmarlottery/controller/FBResultController.java
import com.ksa.myanmarlottery.service.fb.FBResultService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.ksa.myanmarlottery.controller;
/**
*
* @author Kyawswa
*/
@Controller
public class FBResultController {
@Autowired
private Environment env;
@Autowired | private FBResultService fbResultService; |
kyawswa/myanmarlottery | src/test/java/com/ksa/myanmarlottery/parser/TestExcelPraser.java | // Path: src/main/java/com/ksa/myanmarlottery/model/Result.java
// @Entity
// @NamedQueries({
// @NamedQuery(
// name = "result.findLatestResult",
// query = "from Result r where r.resultFor in (select max(rr.resultFor) from Result rr where rr.type = :type)"
// ),
// @NamedQuery(
// name = "result.findLatestResultSummary",
// query = "Select r.numberOfTimes as numberOfTimes, r.resultFor as resultFor, r.type as type from Result r where r.type = :type"
// ),
// @NamedQuery(
// name = "result.findByType",
// query = "from Result r where r.type = :type"
// )
// })
// @Table(name = "Lottery_result")
// public class Result implements Serializable {
//
// @Id
// @Column(name = "RESULT_TYPE")
// private int type = ConstantUtil.OLD_LOTTERY_TYPE;;
//
// private int numberOfTimes;
//
// @Temporal(TemporalType.DATE)
// private Date createdDate = new Date();
//
// @Temporal(TemporalType.DATE)
// private Date resultFor = new Date();
//
// private String dataProvider;
//
// private String companyName;
//
// @OneToMany(mappedBy = "result",fetch = FetchType.EAGER)
// @Cascade(CascadeType.ALL)
// private List<Prize> prizes = new ArrayList<Prize>();
//
// public Result() {
// }
//
// public Result(int type, int numberOfTimes, Date createdDate, Date resultFor) {
// this.type = type;
// this.numberOfTimes = numberOfTimes;
// this.resultFor = resultFor;
// }
//
// public Result(int numberOfTimes, Date resultFor, int type) {
// this.numberOfTimes = numberOfTimes;
// this.resultFor = resultFor;
// this.type = type;
// }
//
// public int getNumberOfTimes() {
// return numberOfTimes;
// }
//
// public void setNumberOfTimes(int numberOfTimes) {
// this.numberOfTimes = numberOfTimes;
// }
//
// public Date getCreatedDate() {
// return createdDate;
// }
//
// public void setCreatedDate(Date createdDate) {
// this.createdDate = createdDate;
// }
//
// public Date getResultFor() {
// return resultFor;
// }
//
// public void setResultFor(Date resultFor) {
// this.resultFor = resultFor;
// }
//
// public List<Prize> getPrizes() {
// return prizes;
// }
//
// public void setPrizes(List<Prize> prizes) {
// this.prizes = prizes;
// }
//
// public int getType() {
// return type;
// }
//
// public void setType(int type) {
// this.type = type;
// }
//
// public String getDataProvider() {
// return dataProvider;
// }
//
// public void setDataProvider(String dataProvider) {
// this.dataProvider = dataProvider;
// }
//
// public String getCompanyName() {
// return companyName;
// }
//
// public void setCompanyName(String companyName) {
// this.companyName = companyName;
// }
//
// @Override
// public String toString() {
// return "Result{" +"numberOfTimes=" + numberOfTimes + ", createdDate=" + createdDate + ", type=" + type + ", resultFor=" + resultFor + ", prizes=" + prizes + '}';
// }
// }
//
// Path: src/main/java/com/ksa/myanmarlottery/service/parser/FileParser.java
// public interface FileParser {
// List<Result> getResult(InputStream in) throws FileNotFoundException, IOException, ParseException;
// }
| import com.google.common.io.Files;
import com.ksa.myanmarlottery.model.Result;
import com.ksa.myanmarlottery.service.parser.FileParser;
import java.io.File;
import java.io.FileInputStream;
import java.util.List;
import org.junit.Assert;
import static org.junit.Assert.assertEquals;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner; | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.ksa.myanmarlottery.parser;
/**
*
* @author Admin
*/
//@Ignore
@RunWith(SpringRunner.class)
@SpringBootTest
public class TestExcelPraser {
private static final String FILE_NAME = "D:\\Myanma Lottery\\project\\MyanmarLotteryV1.4\\Copy of Lottery_result (1).xlsx";
@Autowired | // Path: src/main/java/com/ksa/myanmarlottery/model/Result.java
// @Entity
// @NamedQueries({
// @NamedQuery(
// name = "result.findLatestResult",
// query = "from Result r where r.resultFor in (select max(rr.resultFor) from Result rr where rr.type = :type)"
// ),
// @NamedQuery(
// name = "result.findLatestResultSummary",
// query = "Select r.numberOfTimes as numberOfTimes, r.resultFor as resultFor, r.type as type from Result r where r.type = :type"
// ),
// @NamedQuery(
// name = "result.findByType",
// query = "from Result r where r.type = :type"
// )
// })
// @Table(name = "Lottery_result")
// public class Result implements Serializable {
//
// @Id
// @Column(name = "RESULT_TYPE")
// private int type = ConstantUtil.OLD_LOTTERY_TYPE;;
//
// private int numberOfTimes;
//
// @Temporal(TemporalType.DATE)
// private Date createdDate = new Date();
//
// @Temporal(TemporalType.DATE)
// private Date resultFor = new Date();
//
// private String dataProvider;
//
// private String companyName;
//
// @OneToMany(mappedBy = "result",fetch = FetchType.EAGER)
// @Cascade(CascadeType.ALL)
// private List<Prize> prizes = new ArrayList<Prize>();
//
// public Result() {
// }
//
// public Result(int type, int numberOfTimes, Date createdDate, Date resultFor) {
// this.type = type;
// this.numberOfTimes = numberOfTimes;
// this.resultFor = resultFor;
// }
//
// public Result(int numberOfTimes, Date resultFor, int type) {
// this.numberOfTimes = numberOfTimes;
// this.resultFor = resultFor;
// this.type = type;
// }
//
// public int getNumberOfTimes() {
// return numberOfTimes;
// }
//
// public void setNumberOfTimes(int numberOfTimes) {
// this.numberOfTimes = numberOfTimes;
// }
//
// public Date getCreatedDate() {
// return createdDate;
// }
//
// public void setCreatedDate(Date createdDate) {
// this.createdDate = createdDate;
// }
//
// public Date getResultFor() {
// return resultFor;
// }
//
// public void setResultFor(Date resultFor) {
// this.resultFor = resultFor;
// }
//
// public List<Prize> getPrizes() {
// return prizes;
// }
//
// public void setPrizes(List<Prize> prizes) {
// this.prizes = prizes;
// }
//
// public int getType() {
// return type;
// }
//
// public void setType(int type) {
// this.type = type;
// }
//
// public String getDataProvider() {
// return dataProvider;
// }
//
// public void setDataProvider(String dataProvider) {
// this.dataProvider = dataProvider;
// }
//
// public String getCompanyName() {
// return companyName;
// }
//
// public void setCompanyName(String companyName) {
// this.companyName = companyName;
// }
//
// @Override
// public String toString() {
// return "Result{" +"numberOfTimes=" + numberOfTimes + ", createdDate=" + createdDate + ", type=" + type + ", resultFor=" + resultFor + ", prizes=" + prizes + '}';
// }
// }
//
// Path: src/main/java/com/ksa/myanmarlottery/service/parser/FileParser.java
// public interface FileParser {
// List<Result> getResult(InputStream in) throws FileNotFoundException, IOException, ParseException;
// }
// Path: src/test/java/com/ksa/myanmarlottery/parser/TestExcelPraser.java
import com.google.common.io.Files;
import com.ksa.myanmarlottery.model.Result;
import com.ksa.myanmarlottery.service.parser.FileParser;
import java.io.File;
import java.io.FileInputStream;
import java.util.List;
import org.junit.Assert;
import static org.junit.Assert.assertEquals;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.ksa.myanmarlottery.parser;
/**
*
* @author Admin
*/
//@Ignore
@RunWith(SpringRunner.class)
@SpringBootTest
public class TestExcelPraser {
private static final String FILE_NAME = "D:\\Myanma Lottery\\project\\MyanmarLotteryV1.4\\Copy of Lottery_result (1).xlsx";
@Autowired | private FileParser excelFileParser; |
kyawswa/myanmarlottery | src/test/java/com/ksa/myanmarlottery/parser/TestExcelPraser.java | // Path: src/main/java/com/ksa/myanmarlottery/model/Result.java
// @Entity
// @NamedQueries({
// @NamedQuery(
// name = "result.findLatestResult",
// query = "from Result r where r.resultFor in (select max(rr.resultFor) from Result rr where rr.type = :type)"
// ),
// @NamedQuery(
// name = "result.findLatestResultSummary",
// query = "Select r.numberOfTimes as numberOfTimes, r.resultFor as resultFor, r.type as type from Result r where r.type = :type"
// ),
// @NamedQuery(
// name = "result.findByType",
// query = "from Result r where r.type = :type"
// )
// })
// @Table(name = "Lottery_result")
// public class Result implements Serializable {
//
// @Id
// @Column(name = "RESULT_TYPE")
// private int type = ConstantUtil.OLD_LOTTERY_TYPE;;
//
// private int numberOfTimes;
//
// @Temporal(TemporalType.DATE)
// private Date createdDate = new Date();
//
// @Temporal(TemporalType.DATE)
// private Date resultFor = new Date();
//
// private String dataProvider;
//
// private String companyName;
//
// @OneToMany(mappedBy = "result",fetch = FetchType.EAGER)
// @Cascade(CascadeType.ALL)
// private List<Prize> prizes = new ArrayList<Prize>();
//
// public Result() {
// }
//
// public Result(int type, int numberOfTimes, Date createdDate, Date resultFor) {
// this.type = type;
// this.numberOfTimes = numberOfTimes;
// this.resultFor = resultFor;
// }
//
// public Result(int numberOfTimes, Date resultFor, int type) {
// this.numberOfTimes = numberOfTimes;
// this.resultFor = resultFor;
// this.type = type;
// }
//
// public int getNumberOfTimes() {
// return numberOfTimes;
// }
//
// public void setNumberOfTimes(int numberOfTimes) {
// this.numberOfTimes = numberOfTimes;
// }
//
// public Date getCreatedDate() {
// return createdDate;
// }
//
// public void setCreatedDate(Date createdDate) {
// this.createdDate = createdDate;
// }
//
// public Date getResultFor() {
// return resultFor;
// }
//
// public void setResultFor(Date resultFor) {
// this.resultFor = resultFor;
// }
//
// public List<Prize> getPrizes() {
// return prizes;
// }
//
// public void setPrizes(List<Prize> prizes) {
// this.prizes = prizes;
// }
//
// public int getType() {
// return type;
// }
//
// public void setType(int type) {
// this.type = type;
// }
//
// public String getDataProvider() {
// return dataProvider;
// }
//
// public void setDataProvider(String dataProvider) {
// this.dataProvider = dataProvider;
// }
//
// public String getCompanyName() {
// return companyName;
// }
//
// public void setCompanyName(String companyName) {
// this.companyName = companyName;
// }
//
// @Override
// public String toString() {
// return "Result{" +"numberOfTimes=" + numberOfTimes + ", createdDate=" + createdDate + ", type=" + type + ", resultFor=" + resultFor + ", prizes=" + prizes + '}';
// }
// }
//
// Path: src/main/java/com/ksa/myanmarlottery/service/parser/FileParser.java
// public interface FileParser {
// List<Result> getResult(InputStream in) throws FileNotFoundException, IOException, ParseException;
// }
| import com.google.common.io.Files;
import com.ksa.myanmarlottery.model.Result;
import com.ksa.myanmarlottery.service.parser.FileParser;
import java.io.File;
import java.io.FileInputStream;
import java.util.List;
import org.junit.Assert;
import static org.junit.Assert.assertEquals;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner; | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.ksa.myanmarlottery.parser;
/**
*
* @author Admin
*/
//@Ignore
@RunWith(SpringRunner.class)
@SpringBootTest
public class TestExcelPraser {
private static final String FILE_NAME = "D:\\Myanma Lottery\\project\\MyanmarLotteryV1.4\\Copy of Lottery_result (1).xlsx";
@Autowired
private FileParser excelFileParser;
@Test
public void testParser() throws Exception {
System.out.println(">>>"+Files.getFileExtension(FILE_NAME));
FileInputStream excelFile = new FileInputStream(new File(FILE_NAME)); | // Path: src/main/java/com/ksa/myanmarlottery/model/Result.java
// @Entity
// @NamedQueries({
// @NamedQuery(
// name = "result.findLatestResult",
// query = "from Result r where r.resultFor in (select max(rr.resultFor) from Result rr where rr.type = :type)"
// ),
// @NamedQuery(
// name = "result.findLatestResultSummary",
// query = "Select r.numberOfTimes as numberOfTimes, r.resultFor as resultFor, r.type as type from Result r where r.type = :type"
// ),
// @NamedQuery(
// name = "result.findByType",
// query = "from Result r where r.type = :type"
// )
// })
// @Table(name = "Lottery_result")
// public class Result implements Serializable {
//
// @Id
// @Column(name = "RESULT_TYPE")
// private int type = ConstantUtil.OLD_LOTTERY_TYPE;;
//
// private int numberOfTimes;
//
// @Temporal(TemporalType.DATE)
// private Date createdDate = new Date();
//
// @Temporal(TemporalType.DATE)
// private Date resultFor = new Date();
//
// private String dataProvider;
//
// private String companyName;
//
// @OneToMany(mappedBy = "result",fetch = FetchType.EAGER)
// @Cascade(CascadeType.ALL)
// private List<Prize> prizes = new ArrayList<Prize>();
//
// public Result() {
// }
//
// public Result(int type, int numberOfTimes, Date createdDate, Date resultFor) {
// this.type = type;
// this.numberOfTimes = numberOfTimes;
// this.resultFor = resultFor;
// }
//
// public Result(int numberOfTimes, Date resultFor, int type) {
// this.numberOfTimes = numberOfTimes;
// this.resultFor = resultFor;
// this.type = type;
// }
//
// public int getNumberOfTimes() {
// return numberOfTimes;
// }
//
// public void setNumberOfTimes(int numberOfTimes) {
// this.numberOfTimes = numberOfTimes;
// }
//
// public Date getCreatedDate() {
// return createdDate;
// }
//
// public void setCreatedDate(Date createdDate) {
// this.createdDate = createdDate;
// }
//
// public Date getResultFor() {
// return resultFor;
// }
//
// public void setResultFor(Date resultFor) {
// this.resultFor = resultFor;
// }
//
// public List<Prize> getPrizes() {
// return prizes;
// }
//
// public void setPrizes(List<Prize> prizes) {
// this.prizes = prizes;
// }
//
// public int getType() {
// return type;
// }
//
// public void setType(int type) {
// this.type = type;
// }
//
// public String getDataProvider() {
// return dataProvider;
// }
//
// public void setDataProvider(String dataProvider) {
// this.dataProvider = dataProvider;
// }
//
// public String getCompanyName() {
// return companyName;
// }
//
// public void setCompanyName(String companyName) {
// this.companyName = companyName;
// }
//
// @Override
// public String toString() {
// return "Result{" +"numberOfTimes=" + numberOfTimes + ", createdDate=" + createdDate + ", type=" + type + ", resultFor=" + resultFor + ", prizes=" + prizes + '}';
// }
// }
//
// Path: src/main/java/com/ksa/myanmarlottery/service/parser/FileParser.java
// public interface FileParser {
// List<Result> getResult(InputStream in) throws FileNotFoundException, IOException, ParseException;
// }
// Path: src/test/java/com/ksa/myanmarlottery/parser/TestExcelPraser.java
import com.google.common.io.Files;
import com.ksa.myanmarlottery.model.Result;
import com.ksa.myanmarlottery.service.parser.FileParser;
import java.io.File;
import java.io.FileInputStream;
import java.util.List;
import org.junit.Assert;
import static org.junit.Assert.assertEquals;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.ksa.myanmarlottery.parser;
/**
*
* @author Admin
*/
//@Ignore
@RunWith(SpringRunner.class)
@SpringBootTest
public class TestExcelPraser {
private static final String FILE_NAME = "D:\\Myanma Lottery\\project\\MyanmarLotteryV1.4\\Copy of Lottery_result (1).xlsx";
@Autowired
private FileParser excelFileParser;
@Test
public void testParser() throws Exception {
System.out.println(">>>"+Files.getFileExtension(FILE_NAME));
FileInputStream excelFile = new FileInputStream(new File(FILE_NAME)); | List<Result> resultList = excelFileParser.getResult(excelFile); |
kyawswa/myanmarlottery | src/main/java/com/ksa/myanmarlottery/service/ScheduleService.java | // Path: src/main/java/com/ksa/myanmarlottery/dto/GetPrizeDTO.java
// public class GetPrizeDTO {
//
// private int numberOfTimes;
// private String result;
// private String code;
// private String description;
//
// public GetPrizeDTO() {
// }
//
// public GetPrizeDTO(int numberOfTimes, String result, String code, String description) {
// this.numberOfTimes = numberOfTimes;
// this.result = result;
// this.code = code;
// this.description = description;
// }
//
// public String getResult() {
// return result;
// }
//
// public void setResult(String result) {
// this.result = result;
// }
//
// public String getCode() {
// return code;
// }
//
// public void setCode(String code) {
// this.code = code;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public int getNumberOfTimes() {
// return numberOfTimes;
// }
//
// public void setNumberOfTimes(int numberOfTimes) {
// this.numberOfTimes = numberOfTimes;
// }
//
// @Override
// public String toString() {
// return "GetPrizeDTO{" + "result=" + result + ", code=" + code + ", description=" + description + '}';
// }
// }
//
// Path: src/main/java/com/ksa/myanmarlottery/model/ScheduleItem.java
// @Entity
// @NamedQueries({
// @NamedQuery(
// name = "scheduleItem.findAll",
// query = "from ScheduleItem s"
// )}
// )
// public class ScheduleItem implements Serializable {
//
// @Id
// private String recipientID;
//
// // 500 or 200
// private int lotteryType;
//
// // query by range or specific query
// private int queryType;
//
// @ElementCollection
// @CollectionTable(name="param_table", joinColumns=@JoinColumn(name="recipient_id"))
// @Column(name="params")
// @OrderColumn(name="param_index")
// private List<String> param = new ArrayList<>();
//
// private String originParam;
//
// @Temporal(TemporalType.TIMESTAMP)
// private Date creationDate = new Date();
//
// public ScheduleItem() {}
//
// public ScheduleItem(String recipientID, int lotteryType, int queryType, String originParam) {
// this.recipientID = recipientID;
// this.lotteryType = lotteryType;
// this.queryType = queryType;
// this.originParam = originParam;
// }
//
// public String getOriginParam() {
// return originParam;
// }
//
// public void setOriginParam(String originParam) {
// this.originParam = originParam;
// }
//
// public String getRecipientID() {
// return recipientID;
// }
//
// public void setRecipientID(String recipientID) {
// this.recipientID = recipientID;
// }
//
// public int getLotteryType() {
// return lotteryType;
// }
//
// public void setLotteryType(int lotteryType) {
// this.lotteryType = lotteryType;
// }
//
// public int getQueryType() {
// return queryType;
// }
//
// public void setQueryType(int queryType) {
// this.queryType = queryType;
// }
//
// public List<String> getParam() {
// return param;
// }
//
// public void setParam(List<String> param) {
// this.param = param;
// }
//
// public Date getCreationDate() {
// return creationDate;
// }
//
// public void setCreationDate(Date creationDate) {
// this.creationDate = creationDate;
// }
//
// }
| import com.ksa.myanmarlottery.model.ScheduleItem;
import java.util.List;
import java.util.concurrent.Future;
import com.ksa.myanmarlottery.dto.GetPrizeDTO; | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.ksa.myanmarlottery.service;
/**
*
* @author Kyawswa
*/
public interface ScheduleService {
List<ScheduleItem> findAll();
ScheduleItem insertOrUpdateItem(ScheduleItem item);
ScheduleItem findItemBySenderID(String senderID);
public void deleteScheduleItem(String id); | // Path: src/main/java/com/ksa/myanmarlottery/dto/GetPrizeDTO.java
// public class GetPrizeDTO {
//
// private int numberOfTimes;
// private String result;
// private String code;
// private String description;
//
// public GetPrizeDTO() {
// }
//
// public GetPrizeDTO(int numberOfTimes, String result, String code, String description) {
// this.numberOfTimes = numberOfTimes;
// this.result = result;
// this.code = code;
// this.description = description;
// }
//
// public String getResult() {
// return result;
// }
//
// public void setResult(String result) {
// this.result = result;
// }
//
// public String getCode() {
// return code;
// }
//
// public void setCode(String code) {
// this.code = code;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public int getNumberOfTimes() {
// return numberOfTimes;
// }
//
// public void setNumberOfTimes(int numberOfTimes) {
// this.numberOfTimes = numberOfTimes;
// }
//
// @Override
// public String toString() {
// return "GetPrizeDTO{" + "result=" + result + ", code=" + code + ", description=" + description + '}';
// }
// }
//
// Path: src/main/java/com/ksa/myanmarlottery/model/ScheduleItem.java
// @Entity
// @NamedQueries({
// @NamedQuery(
// name = "scheduleItem.findAll",
// query = "from ScheduleItem s"
// )}
// )
// public class ScheduleItem implements Serializable {
//
// @Id
// private String recipientID;
//
// // 500 or 200
// private int lotteryType;
//
// // query by range or specific query
// private int queryType;
//
// @ElementCollection
// @CollectionTable(name="param_table", joinColumns=@JoinColumn(name="recipient_id"))
// @Column(name="params")
// @OrderColumn(name="param_index")
// private List<String> param = new ArrayList<>();
//
// private String originParam;
//
// @Temporal(TemporalType.TIMESTAMP)
// private Date creationDate = new Date();
//
// public ScheduleItem() {}
//
// public ScheduleItem(String recipientID, int lotteryType, int queryType, String originParam) {
// this.recipientID = recipientID;
// this.lotteryType = lotteryType;
// this.queryType = queryType;
// this.originParam = originParam;
// }
//
// public String getOriginParam() {
// return originParam;
// }
//
// public void setOriginParam(String originParam) {
// this.originParam = originParam;
// }
//
// public String getRecipientID() {
// return recipientID;
// }
//
// public void setRecipientID(String recipientID) {
// this.recipientID = recipientID;
// }
//
// public int getLotteryType() {
// return lotteryType;
// }
//
// public void setLotteryType(int lotteryType) {
// this.lotteryType = lotteryType;
// }
//
// public int getQueryType() {
// return queryType;
// }
//
// public void setQueryType(int queryType) {
// this.queryType = queryType;
// }
//
// public List<String> getParam() {
// return param;
// }
//
// public void setParam(List<String> param) {
// this.param = param;
// }
//
// public Date getCreationDate() {
// return creationDate;
// }
//
// public void setCreationDate(Date creationDate) {
// this.creationDate = creationDate;
// }
//
// }
// Path: src/main/java/com/ksa/myanmarlottery/service/ScheduleService.java
import com.ksa.myanmarlottery.model.ScheduleItem;
import java.util.List;
import java.util.concurrent.Future;
import com.ksa.myanmarlottery.dto.GetPrizeDTO;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.ksa.myanmarlottery.service;
/**
*
* @author Kyawswa
*/
public interface ScheduleService {
List<ScheduleItem> findAll();
ScheduleItem insertOrUpdateItem(ScheduleItem item);
ScheduleItem findItemBySenderID(String senderID);
public void deleteScheduleItem(String id); | public Future<List<GetPrizeDTO>> scheduleItems(ScheduleItem item) throws InterruptedException; |
kyawswa/myanmarlottery | src/test/java/com/ksa/myanmarlottery/service/ScheduleConfigruation.java | // Path: src/main/java/com/ksa/myanmarlottery/repository/ScheduleRepository.java
// public interface ScheduleRepository {
// List<ScheduleItem> findAll();
// ScheduleItem insertOrUpdateItem(ScheduleItem item);
// ScheduleItem findItemByID(String senderID);
// void deleteItem(String id);
// }
//
// Path: src/main/java/com/ksa/myanmarlottery/service/ResultService.java
// public interface ResultService {
// Result insert(Result result);
// public void deleteByType(int type);
// public Result findResultByType(int type);
// /**
// * find only latest result information WITHOUT prize list.
// * @param type
// * @return
// */
// public Result findLatestResultSummary(int type);
//
// List<GetPrizeDTO> findPrizeByResultType(int type, String... codeNo);
//
// /**
// *
// * @param startCode
// * @param endCode
// * @param point
// * @param type
// * @return
// */
// public List<GetPrizeDTO> findPrizesByCode(String startCode, String endCode, String point, int type);
//
// /**
// *
// * @param code
// * @param startPoint
// * @param endPoint
// * @param type
// * @return
// */
// public List<GetPrizeDTO> findPrizesByPoints(String code, String startPoint, String endPoint, int type);
// }
| import com.ksa.myanmarlottery.repository.ScheduleRepository;
import com.ksa.myanmarlottery.service.ResultService;
import org.mockito.Mockito;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.context.annotation.Profile; | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.ksa.myanmarlottery.service;
/**
*
* @author Kyawswa
*/
@Profile("test")
@Configuration
public class ScheduleConfigruation {
@Bean
@Primary | // Path: src/main/java/com/ksa/myanmarlottery/repository/ScheduleRepository.java
// public interface ScheduleRepository {
// List<ScheduleItem> findAll();
// ScheduleItem insertOrUpdateItem(ScheduleItem item);
// ScheduleItem findItemByID(String senderID);
// void deleteItem(String id);
// }
//
// Path: src/main/java/com/ksa/myanmarlottery/service/ResultService.java
// public interface ResultService {
// Result insert(Result result);
// public void deleteByType(int type);
// public Result findResultByType(int type);
// /**
// * find only latest result information WITHOUT prize list.
// * @param type
// * @return
// */
// public Result findLatestResultSummary(int type);
//
// List<GetPrizeDTO> findPrizeByResultType(int type, String... codeNo);
//
// /**
// *
// * @param startCode
// * @param endCode
// * @param point
// * @param type
// * @return
// */
// public List<GetPrizeDTO> findPrizesByCode(String startCode, String endCode, String point, int type);
//
// /**
// *
// * @param code
// * @param startPoint
// * @param endPoint
// * @param type
// * @return
// */
// public List<GetPrizeDTO> findPrizesByPoints(String code, String startPoint, String endPoint, int type);
// }
// Path: src/test/java/com/ksa/myanmarlottery/service/ScheduleConfigruation.java
import com.ksa.myanmarlottery.repository.ScheduleRepository;
import com.ksa.myanmarlottery.service.ResultService;
import org.mockito.Mockito;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.context.annotation.Profile;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.ksa.myanmarlottery.service;
/**
*
* @author Kyawswa
*/
@Profile("test")
@Configuration
public class ScheduleConfigruation {
@Bean
@Primary | public ResultService resultService() { |
kyawswa/myanmarlottery | src/test/java/com/ksa/myanmarlottery/service/ScheduleConfigruation.java | // Path: src/main/java/com/ksa/myanmarlottery/repository/ScheduleRepository.java
// public interface ScheduleRepository {
// List<ScheduleItem> findAll();
// ScheduleItem insertOrUpdateItem(ScheduleItem item);
// ScheduleItem findItemByID(String senderID);
// void deleteItem(String id);
// }
//
// Path: src/main/java/com/ksa/myanmarlottery/service/ResultService.java
// public interface ResultService {
// Result insert(Result result);
// public void deleteByType(int type);
// public Result findResultByType(int type);
// /**
// * find only latest result information WITHOUT prize list.
// * @param type
// * @return
// */
// public Result findLatestResultSummary(int type);
//
// List<GetPrizeDTO> findPrizeByResultType(int type, String... codeNo);
//
// /**
// *
// * @param startCode
// * @param endCode
// * @param point
// * @param type
// * @return
// */
// public List<GetPrizeDTO> findPrizesByCode(String startCode, String endCode, String point, int type);
//
// /**
// *
// * @param code
// * @param startPoint
// * @param endPoint
// * @param type
// * @return
// */
// public List<GetPrizeDTO> findPrizesByPoints(String code, String startPoint, String endPoint, int type);
// }
| import com.ksa.myanmarlottery.repository.ScheduleRepository;
import com.ksa.myanmarlottery.service.ResultService;
import org.mockito.Mockito;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.context.annotation.Profile; | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.ksa.myanmarlottery.service;
/**
*
* @author Kyawswa
*/
@Profile("test")
@Configuration
public class ScheduleConfigruation {
@Bean
@Primary
public ResultService resultService() {
return Mockito.mock(ResultService.class);
}
@Bean
@Primary | // Path: src/main/java/com/ksa/myanmarlottery/repository/ScheduleRepository.java
// public interface ScheduleRepository {
// List<ScheduleItem> findAll();
// ScheduleItem insertOrUpdateItem(ScheduleItem item);
// ScheduleItem findItemByID(String senderID);
// void deleteItem(String id);
// }
//
// Path: src/main/java/com/ksa/myanmarlottery/service/ResultService.java
// public interface ResultService {
// Result insert(Result result);
// public void deleteByType(int type);
// public Result findResultByType(int type);
// /**
// * find only latest result information WITHOUT prize list.
// * @param type
// * @return
// */
// public Result findLatestResultSummary(int type);
//
// List<GetPrizeDTO> findPrizeByResultType(int type, String... codeNo);
//
// /**
// *
// * @param startCode
// * @param endCode
// * @param point
// * @param type
// * @return
// */
// public List<GetPrizeDTO> findPrizesByCode(String startCode, String endCode, String point, int type);
//
// /**
// *
// * @param code
// * @param startPoint
// * @param endPoint
// * @param type
// * @return
// */
// public List<GetPrizeDTO> findPrizesByPoints(String code, String startPoint, String endPoint, int type);
// }
// Path: src/test/java/com/ksa/myanmarlottery/service/ScheduleConfigruation.java
import com.ksa.myanmarlottery.repository.ScheduleRepository;
import com.ksa.myanmarlottery.service.ResultService;
import org.mockito.Mockito;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.context.annotation.Profile;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.ksa.myanmarlottery.service;
/**
*
* @author Kyawswa
*/
@Profile("test")
@Configuration
public class ScheduleConfigruation {
@Bean
@Primary
public ResultService resultService() {
return Mockito.mock(ResultService.class);
}
@Bean
@Primary | public ScheduleRepository scheduleRepository() { |
kyawswa/myanmarlottery | src/main/java/com/ksa/myanmarlottery/repository/ScheduleRepositoryImpl.java | // Path: src/main/java/com/ksa/myanmarlottery/model/ScheduleItem.java
// @Entity
// @NamedQueries({
// @NamedQuery(
// name = "scheduleItem.findAll",
// query = "from ScheduleItem s"
// )}
// )
// public class ScheduleItem implements Serializable {
//
// @Id
// private String recipientID;
//
// // 500 or 200
// private int lotteryType;
//
// // query by range or specific query
// private int queryType;
//
// @ElementCollection
// @CollectionTable(name="param_table", joinColumns=@JoinColumn(name="recipient_id"))
// @Column(name="params")
// @OrderColumn(name="param_index")
// private List<String> param = new ArrayList<>();
//
// private String originParam;
//
// @Temporal(TemporalType.TIMESTAMP)
// private Date creationDate = new Date();
//
// public ScheduleItem() {}
//
// public ScheduleItem(String recipientID, int lotteryType, int queryType, String originParam) {
// this.recipientID = recipientID;
// this.lotteryType = lotteryType;
// this.queryType = queryType;
// this.originParam = originParam;
// }
//
// public String getOriginParam() {
// return originParam;
// }
//
// public void setOriginParam(String originParam) {
// this.originParam = originParam;
// }
//
// public String getRecipientID() {
// return recipientID;
// }
//
// public void setRecipientID(String recipientID) {
// this.recipientID = recipientID;
// }
//
// public int getLotteryType() {
// return lotteryType;
// }
//
// public void setLotteryType(int lotteryType) {
// this.lotteryType = lotteryType;
// }
//
// public int getQueryType() {
// return queryType;
// }
//
// public void setQueryType(int queryType) {
// this.queryType = queryType;
// }
//
// public List<String> getParam() {
// return param;
// }
//
// public void setParam(List<String> param) {
// this.param = param;
// }
//
// public Date getCreationDate() {
// return creationDate;
// }
//
// public void setCreationDate(Date creationDate) {
// this.creationDate = creationDate;
// }
//
// }
| import com.ksa.myanmarlottery.model.ScheduleItem;
import java.util.List;
import javax.persistence.EntityManager;
import javax.transaction.Transactional;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.Session;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository; | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.ksa.myanmarlottery.repository;
/**
*
* @author Kyawswa
*/
@Repository
@Transactional
public class ScheduleRepositoryImpl implements ScheduleRepository {
private final Log log = LogFactory.getLog(ScheduleRepositoryImpl.class);
@Autowired
private EntityManager em;
@Override | // Path: src/main/java/com/ksa/myanmarlottery/model/ScheduleItem.java
// @Entity
// @NamedQueries({
// @NamedQuery(
// name = "scheduleItem.findAll",
// query = "from ScheduleItem s"
// )}
// )
// public class ScheduleItem implements Serializable {
//
// @Id
// private String recipientID;
//
// // 500 or 200
// private int lotteryType;
//
// // query by range or specific query
// private int queryType;
//
// @ElementCollection
// @CollectionTable(name="param_table", joinColumns=@JoinColumn(name="recipient_id"))
// @Column(name="params")
// @OrderColumn(name="param_index")
// private List<String> param = new ArrayList<>();
//
// private String originParam;
//
// @Temporal(TemporalType.TIMESTAMP)
// private Date creationDate = new Date();
//
// public ScheduleItem() {}
//
// public ScheduleItem(String recipientID, int lotteryType, int queryType, String originParam) {
// this.recipientID = recipientID;
// this.lotteryType = lotteryType;
// this.queryType = queryType;
// this.originParam = originParam;
// }
//
// public String getOriginParam() {
// return originParam;
// }
//
// public void setOriginParam(String originParam) {
// this.originParam = originParam;
// }
//
// public String getRecipientID() {
// return recipientID;
// }
//
// public void setRecipientID(String recipientID) {
// this.recipientID = recipientID;
// }
//
// public int getLotteryType() {
// return lotteryType;
// }
//
// public void setLotteryType(int lotteryType) {
// this.lotteryType = lotteryType;
// }
//
// public int getQueryType() {
// return queryType;
// }
//
// public void setQueryType(int queryType) {
// this.queryType = queryType;
// }
//
// public List<String> getParam() {
// return param;
// }
//
// public void setParam(List<String> param) {
// this.param = param;
// }
//
// public Date getCreationDate() {
// return creationDate;
// }
//
// public void setCreationDate(Date creationDate) {
// this.creationDate = creationDate;
// }
//
// }
// Path: src/main/java/com/ksa/myanmarlottery/repository/ScheduleRepositoryImpl.java
import com.ksa.myanmarlottery.model.ScheduleItem;
import java.util.List;
import javax.persistence.EntityManager;
import javax.transaction.Transactional;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.Session;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.ksa.myanmarlottery.repository;
/**
*
* @author Kyawswa
*/
@Repository
@Transactional
public class ScheduleRepositoryImpl implements ScheduleRepository {
private final Log log = LogFactory.getLog(ScheduleRepositoryImpl.class);
@Autowired
private EntityManager em;
@Override | public List<ScheduleItem> findAll() { |
kyawswa/myanmarlottery | src/test/java/com/ksa/myanmarlottery/service/ScheduleServiceTest.java | // Path: src/main/java/com/ksa/myanmarlottery/dto/GetPrizeDTO.java
// public class GetPrizeDTO {
//
// private int numberOfTimes;
// private String result;
// private String code;
// private String description;
//
// public GetPrizeDTO() {
// }
//
// public GetPrizeDTO(int numberOfTimes, String result, String code, String description) {
// this.numberOfTimes = numberOfTimes;
// this.result = result;
// this.code = code;
// this.description = description;
// }
//
// public String getResult() {
// return result;
// }
//
// public void setResult(String result) {
// this.result = result;
// }
//
// public String getCode() {
// return code;
// }
//
// public void setCode(String code) {
// this.code = code;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public int getNumberOfTimes() {
// return numberOfTimes;
// }
//
// public void setNumberOfTimes(int numberOfTimes) {
// this.numberOfTimes = numberOfTimes;
// }
//
// @Override
// public String toString() {
// return "GetPrizeDTO{" + "result=" + result + ", code=" + code + ", description=" + description + '}';
// }
// }
//
// Path: src/main/java/com/ksa/myanmarlottery/model/ScheduleItem.java
// @Entity
// @NamedQueries({
// @NamedQuery(
// name = "scheduleItem.findAll",
// query = "from ScheduleItem s"
// )}
// )
// public class ScheduleItem implements Serializable {
//
// @Id
// private String recipientID;
//
// // 500 or 200
// private int lotteryType;
//
// // query by range or specific query
// private int queryType;
//
// @ElementCollection
// @CollectionTable(name="param_table", joinColumns=@JoinColumn(name="recipient_id"))
// @Column(name="params")
// @OrderColumn(name="param_index")
// private List<String> param = new ArrayList<>();
//
// private String originParam;
//
// @Temporal(TemporalType.TIMESTAMP)
// private Date creationDate = new Date();
//
// public ScheduleItem() {}
//
// public ScheduleItem(String recipientID, int lotteryType, int queryType, String originParam) {
// this.recipientID = recipientID;
// this.lotteryType = lotteryType;
// this.queryType = queryType;
// this.originParam = originParam;
// }
//
// public String getOriginParam() {
// return originParam;
// }
//
// public void setOriginParam(String originParam) {
// this.originParam = originParam;
// }
//
// public String getRecipientID() {
// return recipientID;
// }
//
// public void setRecipientID(String recipientID) {
// this.recipientID = recipientID;
// }
//
// public int getLotteryType() {
// return lotteryType;
// }
//
// public void setLotteryType(int lotteryType) {
// this.lotteryType = lotteryType;
// }
//
// public int getQueryType() {
// return queryType;
// }
//
// public void setQueryType(int queryType) {
// this.queryType = queryType;
// }
//
// public List<String> getParam() {
// return param;
// }
//
// public void setParam(List<String> param) {
// this.param = param;
// }
//
// public Date getCreationDate() {
// return creationDate;
// }
//
// public void setCreationDate(Date creationDate) {
// this.creationDate = creationDate;
// }
//
// }
//
// Path: src/main/java/com/ksa/myanmarlottery/repository/ScheduleRepository.java
// public interface ScheduleRepository {
// List<ScheduleItem> findAll();
// ScheduleItem insertOrUpdateItem(ScheduleItem item);
// ScheduleItem findItemByID(String senderID);
// void deleteItem(String id);
// }
| import com.ksa.myanmarlottery.dto.GetPrizeDTO;
import com.ksa.myanmarlottery.model.ScheduleItem;
import com.ksa.myanmarlottery.repository.ScheduleRepository;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Future;
import org.junit.Assert;
import static org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner; | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.ksa.myanmarlottery.service;
/**
*
* @author Kyawswa
*/
@Ignore
@ActiveProfiles("test")
@RunWith(SpringRunner.class)
@SpringBootTest
public class ScheduleServiceTest {
@Autowired
private ResultService resultService ;
@Autowired | // Path: src/main/java/com/ksa/myanmarlottery/dto/GetPrizeDTO.java
// public class GetPrizeDTO {
//
// private int numberOfTimes;
// private String result;
// private String code;
// private String description;
//
// public GetPrizeDTO() {
// }
//
// public GetPrizeDTO(int numberOfTimes, String result, String code, String description) {
// this.numberOfTimes = numberOfTimes;
// this.result = result;
// this.code = code;
// this.description = description;
// }
//
// public String getResult() {
// return result;
// }
//
// public void setResult(String result) {
// this.result = result;
// }
//
// public String getCode() {
// return code;
// }
//
// public void setCode(String code) {
// this.code = code;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public int getNumberOfTimes() {
// return numberOfTimes;
// }
//
// public void setNumberOfTimes(int numberOfTimes) {
// this.numberOfTimes = numberOfTimes;
// }
//
// @Override
// public String toString() {
// return "GetPrizeDTO{" + "result=" + result + ", code=" + code + ", description=" + description + '}';
// }
// }
//
// Path: src/main/java/com/ksa/myanmarlottery/model/ScheduleItem.java
// @Entity
// @NamedQueries({
// @NamedQuery(
// name = "scheduleItem.findAll",
// query = "from ScheduleItem s"
// )}
// )
// public class ScheduleItem implements Serializable {
//
// @Id
// private String recipientID;
//
// // 500 or 200
// private int lotteryType;
//
// // query by range or specific query
// private int queryType;
//
// @ElementCollection
// @CollectionTable(name="param_table", joinColumns=@JoinColumn(name="recipient_id"))
// @Column(name="params")
// @OrderColumn(name="param_index")
// private List<String> param = new ArrayList<>();
//
// private String originParam;
//
// @Temporal(TemporalType.TIMESTAMP)
// private Date creationDate = new Date();
//
// public ScheduleItem() {}
//
// public ScheduleItem(String recipientID, int lotteryType, int queryType, String originParam) {
// this.recipientID = recipientID;
// this.lotteryType = lotteryType;
// this.queryType = queryType;
// this.originParam = originParam;
// }
//
// public String getOriginParam() {
// return originParam;
// }
//
// public void setOriginParam(String originParam) {
// this.originParam = originParam;
// }
//
// public String getRecipientID() {
// return recipientID;
// }
//
// public void setRecipientID(String recipientID) {
// this.recipientID = recipientID;
// }
//
// public int getLotteryType() {
// return lotteryType;
// }
//
// public void setLotteryType(int lotteryType) {
// this.lotteryType = lotteryType;
// }
//
// public int getQueryType() {
// return queryType;
// }
//
// public void setQueryType(int queryType) {
// this.queryType = queryType;
// }
//
// public List<String> getParam() {
// return param;
// }
//
// public void setParam(List<String> param) {
// this.param = param;
// }
//
// public Date getCreationDate() {
// return creationDate;
// }
//
// public void setCreationDate(Date creationDate) {
// this.creationDate = creationDate;
// }
//
// }
//
// Path: src/main/java/com/ksa/myanmarlottery/repository/ScheduleRepository.java
// public interface ScheduleRepository {
// List<ScheduleItem> findAll();
// ScheduleItem insertOrUpdateItem(ScheduleItem item);
// ScheduleItem findItemByID(String senderID);
// void deleteItem(String id);
// }
// Path: src/test/java/com/ksa/myanmarlottery/service/ScheduleServiceTest.java
import com.ksa.myanmarlottery.dto.GetPrizeDTO;
import com.ksa.myanmarlottery.model.ScheduleItem;
import com.ksa.myanmarlottery.repository.ScheduleRepository;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Future;
import org.junit.Assert;
import static org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.ksa.myanmarlottery.service;
/**
*
* @author Kyawswa
*/
@Ignore
@ActiveProfiles("test")
@RunWith(SpringRunner.class)
@SpringBootTest
public class ScheduleServiceTest {
@Autowired
private ResultService resultService ;
@Autowired | private ScheduleRepository scheduleRepository ; |
kyawswa/myanmarlottery | src/test/java/com/ksa/myanmarlottery/service/ScheduleServiceTest.java | // Path: src/main/java/com/ksa/myanmarlottery/dto/GetPrizeDTO.java
// public class GetPrizeDTO {
//
// private int numberOfTimes;
// private String result;
// private String code;
// private String description;
//
// public GetPrizeDTO() {
// }
//
// public GetPrizeDTO(int numberOfTimes, String result, String code, String description) {
// this.numberOfTimes = numberOfTimes;
// this.result = result;
// this.code = code;
// this.description = description;
// }
//
// public String getResult() {
// return result;
// }
//
// public void setResult(String result) {
// this.result = result;
// }
//
// public String getCode() {
// return code;
// }
//
// public void setCode(String code) {
// this.code = code;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public int getNumberOfTimes() {
// return numberOfTimes;
// }
//
// public void setNumberOfTimes(int numberOfTimes) {
// this.numberOfTimes = numberOfTimes;
// }
//
// @Override
// public String toString() {
// return "GetPrizeDTO{" + "result=" + result + ", code=" + code + ", description=" + description + '}';
// }
// }
//
// Path: src/main/java/com/ksa/myanmarlottery/model/ScheduleItem.java
// @Entity
// @NamedQueries({
// @NamedQuery(
// name = "scheduleItem.findAll",
// query = "from ScheduleItem s"
// )}
// )
// public class ScheduleItem implements Serializable {
//
// @Id
// private String recipientID;
//
// // 500 or 200
// private int lotteryType;
//
// // query by range or specific query
// private int queryType;
//
// @ElementCollection
// @CollectionTable(name="param_table", joinColumns=@JoinColumn(name="recipient_id"))
// @Column(name="params")
// @OrderColumn(name="param_index")
// private List<String> param = new ArrayList<>();
//
// private String originParam;
//
// @Temporal(TemporalType.TIMESTAMP)
// private Date creationDate = new Date();
//
// public ScheduleItem() {}
//
// public ScheduleItem(String recipientID, int lotteryType, int queryType, String originParam) {
// this.recipientID = recipientID;
// this.lotteryType = lotteryType;
// this.queryType = queryType;
// this.originParam = originParam;
// }
//
// public String getOriginParam() {
// return originParam;
// }
//
// public void setOriginParam(String originParam) {
// this.originParam = originParam;
// }
//
// public String getRecipientID() {
// return recipientID;
// }
//
// public void setRecipientID(String recipientID) {
// this.recipientID = recipientID;
// }
//
// public int getLotteryType() {
// return lotteryType;
// }
//
// public void setLotteryType(int lotteryType) {
// this.lotteryType = lotteryType;
// }
//
// public int getQueryType() {
// return queryType;
// }
//
// public void setQueryType(int queryType) {
// this.queryType = queryType;
// }
//
// public List<String> getParam() {
// return param;
// }
//
// public void setParam(List<String> param) {
// this.param = param;
// }
//
// public Date getCreationDate() {
// return creationDate;
// }
//
// public void setCreationDate(Date creationDate) {
// this.creationDate = creationDate;
// }
//
// }
//
// Path: src/main/java/com/ksa/myanmarlottery/repository/ScheduleRepository.java
// public interface ScheduleRepository {
// List<ScheduleItem> findAll();
// ScheduleItem insertOrUpdateItem(ScheduleItem item);
// ScheduleItem findItemByID(String senderID);
// void deleteItem(String id);
// }
| import com.ksa.myanmarlottery.dto.GetPrizeDTO;
import com.ksa.myanmarlottery.model.ScheduleItem;
import com.ksa.myanmarlottery.repository.ScheduleRepository;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Future;
import org.junit.Assert;
import static org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner; | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.ksa.myanmarlottery.service;
/**
*
* @author Kyawswa
*/
@Ignore
@ActiveProfiles("test")
@RunWith(SpringRunner.class)
@SpringBootTest
public class ScheduleServiceTest {
@Autowired
private ResultService resultService ;
@Autowired
private ScheduleRepository scheduleRepository ;
@Autowired
private ScheduleService service;
@Test
public void testSchedule() throws Exception {
| // Path: src/main/java/com/ksa/myanmarlottery/dto/GetPrizeDTO.java
// public class GetPrizeDTO {
//
// private int numberOfTimes;
// private String result;
// private String code;
// private String description;
//
// public GetPrizeDTO() {
// }
//
// public GetPrizeDTO(int numberOfTimes, String result, String code, String description) {
// this.numberOfTimes = numberOfTimes;
// this.result = result;
// this.code = code;
// this.description = description;
// }
//
// public String getResult() {
// return result;
// }
//
// public void setResult(String result) {
// this.result = result;
// }
//
// public String getCode() {
// return code;
// }
//
// public void setCode(String code) {
// this.code = code;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public int getNumberOfTimes() {
// return numberOfTimes;
// }
//
// public void setNumberOfTimes(int numberOfTimes) {
// this.numberOfTimes = numberOfTimes;
// }
//
// @Override
// public String toString() {
// return "GetPrizeDTO{" + "result=" + result + ", code=" + code + ", description=" + description + '}';
// }
// }
//
// Path: src/main/java/com/ksa/myanmarlottery/model/ScheduleItem.java
// @Entity
// @NamedQueries({
// @NamedQuery(
// name = "scheduleItem.findAll",
// query = "from ScheduleItem s"
// )}
// )
// public class ScheduleItem implements Serializable {
//
// @Id
// private String recipientID;
//
// // 500 or 200
// private int lotteryType;
//
// // query by range or specific query
// private int queryType;
//
// @ElementCollection
// @CollectionTable(name="param_table", joinColumns=@JoinColumn(name="recipient_id"))
// @Column(name="params")
// @OrderColumn(name="param_index")
// private List<String> param = new ArrayList<>();
//
// private String originParam;
//
// @Temporal(TemporalType.TIMESTAMP)
// private Date creationDate = new Date();
//
// public ScheduleItem() {}
//
// public ScheduleItem(String recipientID, int lotteryType, int queryType, String originParam) {
// this.recipientID = recipientID;
// this.lotteryType = lotteryType;
// this.queryType = queryType;
// this.originParam = originParam;
// }
//
// public String getOriginParam() {
// return originParam;
// }
//
// public void setOriginParam(String originParam) {
// this.originParam = originParam;
// }
//
// public String getRecipientID() {
// return recipientID;
// }
//
// public void setRecipientID(String recipientID) {
// this.recipientID = recipientID;
// }
//
// public int getLotteryType() {
// return lotteryType;
// }
//
// public void setLotteryType(int lotteryType) {
// this.lotteryType = lotteryType;
// }
//
// public int getQueryType() {
// return queryType;
// }
//
// public void setQueryType(int queryType) {
// this.queryType = queryType;
// }
//
// public List<String> getParam() {
// return param;
// }
//
// public void setParam(List<String> param) {
// this.param = param;
// }
//
// public Date getCreationDate() {
// return creationDate;
// }
//
// public void setCreationDate(Date creationDate) {
// this.creationDate = creationDate;
// }
//
// }
//
// Path: src/main/java/com/ksa/myanmarlottery/repository/ScheduleRepository.java
// public interface ScheduleRepository {
// List<ScheduleItem> findAll();
// ScheduleItem insertOrUpdateItem(ScheduleItem item);
// ScheduleItem findItemByID(String senderID);
// void deleteItem(String id);
// }
// Path: src/test/java/com/ksa/myanmarlottery/service/ScheduleServiceTest.java
import com.ksa.myanmarlottery.dto.GetPrizeDTO;
import com.ksa.myanmarlottery.model.ScheduleItem;
import com.ksa.myanmarlottery.repository.ScheduleRepository;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Future;
import org.junit.Assert;
import static org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.ksa.myanmarlottery.service;
/**
*
* @author Kyawswa
*/
@Ignore
@ActiveProfiles("test")
@RunWith(SpringRunner.class)
@SpringBootTest
public class ScheduleServiceTest {
@Autowired
private ResultService resultService ;
@Autowired
private ScheduleRepository scheduleRepository ;
@Autowired
private ScheduleService service;
@Test
public void testSchedule() throws Exception {
| GetPrizeDTO dto1 = new GetPrizeDTO(1, "result1", "001", "description"); |
kyawswa/myanmarlottery | src/main/java/com/hyurumi/fb_bot_boilerplate/Main.java | // Path: src/main/java/com/hyurumi/fb_bot_boilerplate/models/send/Button.java
// public class Button {
// private enum Type {
// @SerializedName("postback")
// Postback,
// @SerializedName("web_url")
// WebUrl
// }
// private final Type type;
// private final String title;
// private final Action payload;
// private final String url;
// private final boolean messenger_extensions;
//
// private Button(Type type, String title, String url, Action action){
// this.type = type;
// this.title = title;
// this.url = url;
// this.payload = action;
// this.messenger_extensions = false;
// }
//
// private Button(Type type, String title, String url, boolean messenger_extensions){
// this.type = type;
// this.title = title;
// this.url = url;
// this.payload = null;
// this.messenger_extensions = messenger_extensions;
// }
//
// public static Button Url(String title, String url){
// return new Button(Type.WebUrl, title, url, null);
// }
//
// public static Button Postback(String title, Action action){
// return new Button(Type.Postback, title, null, action);
// }
//
// public static Button Url(String title, String url, boolean messenger_extensions){
// return new Button(Type.WebUrl, title, url, messenger_extensions);
// }
// }
//
// Path: src/main/java/com/hyurumi/fb_bot_boilerplate/models/send/Message.java
// public class Message {
//
// private transient final OkHttpClient HTTP_CLIENT;
// private transient final Gson GSON;
//
// {
// HTTP_CLIENT = new OkHttpClient();
// GSON = new Gson();
// }
//
// final private Attachment attachment;
// final private String text;
//
// // add by kyawswar
// @SerializedName("quick_replies")
// final private List<QuickReply> quickReplies;
//
// private Message(Attachment attachment, String text) {
// this.attachment = attachment;
// this.text = text;
// this.quickReplies = null;
// }
//
// private Message(String text, QuickReply... quickReplies) {
// this.attachment = null;
// this.text = text;
// this.quickReplies = Arrays.asList(quickReplies);
// }
//
// public static Message Text(String text) {
// return new Message(null, text);
// }
//
// public static Message QuickReply(String text, QuickReply... quickReplies) {
// return new Message(text, quickReplies);
// }
//
// public static Message Image(String url) {
// return new Message(Attachment.Image(url), null);
// }
//
// public static Message Button(String text) {
// return new Message(Attachment.Template(Payload.Button(text)), null);
// }
//
// public static Message Generic() {
// return new Message(Attachment.Template(Payload.Generic()), null);
// }
//
// public boolean addQuickReply(QuickReply reply) {
// return quickReplies.add(reply);
// }
//
// public boolean addElement(Element element) {
// return attachment.addElement(element);
// }
//
// public boolean addButton(Button button) {
// return attachment.addButton(button);
// }
//
// public Response sendTo(String recipientId) throws IOException {
//
// RequestBody body = RequestBody.create(Main.JSON, GSON.toJson(new MessageWrapper(recipientId, this)));
// Request request = new Request.Builder()
// .url(Main.END_POINT + "?access_token=" + sAccessToken)
// .header("Content-Type", "application/json; charset=UTF-8")
// .post(body)
// .build();
// okhttp3.Response response = HTTP_CLIENT.newCall(request).execute();
// final int code = response.code();
// Response returnValue = null;
// if (code == 200) {
// System.out.println("WORK!");
// returnValue = GSON.fromJson(response.body().string(), Response.class);
// }else {
// System.out.println("ERROR: " + response.body().string());
// }
// response.body().close();
// return returnValue;
// }
//
// class MessageWrapper {
// private final Recipient recipient;
// private final Message message;
// MessageWrapper(String recipientId, Message message) {
// this.recipient = new Recipient(recipientId);
// this.message = message;
// }
// }
// }
//
// Path: src/main/java/com/hyurumi/fb_bot_boilerplate/models/webhook/ReceivedMessage.java
// public class ReceivedMessage {
// public String object;
// public List<Entry> entry;
// }
| import com.google.gson.Gson;
import com.hyurumi.fb_bot_boilerplate.models.common.Action;
import com.hyurumi.fb_bot_boilerplate.models.send.Button;
import com.hyurumi.fb_bot_boilerplate.models.send.Element;
import com.hyurumi.fb_bot_boilerplate.models.send.Message;
import com.hyurumi.fb_bot_boilerplate.models.webhook.Messaging;
import com.hyurumi.fb_bot_boilerplate.models.webhook.ReceivedMessage;
import okhttp3.*;
import java.util.List;
import java.util.Random;
import static spark.Spark.get;
import static spark.Spark.post;
import static spark.SparkBase.port; | Message.Image("https://unsplash.it/764/400?image=200").sendTo(senderId);
break;
case 2:
sendSampleGenericMessage(senderId);
break;
default:
sendSamplePostBackMessage(senderId);
break;
}
} else if (messaging.postback != null) {
// Receiving postback message
if (messaging.postback.payload == Action.ACTION_A) {
Message.Text("Action A").sendTo(senderId);
}else {
Message.Text("Action B").sendTo(senderId);
}
} else if (messaging.delivery != null) {
// when the message is delivered, this webhook will be triggered.
} else {
// sticker may not be supported for now.
System.out.println(request.body());
}
}
System.out.println(request.body());
return "";
});
}
static private void sendSamplePostBackMessage(String senderId) throws Exception { | // Path: src/main/java/com/hyurumi/fb_bot_boilerplate/models/send/Button.java
// public class Button {
// private enum Type {
// @SerializedName("postback")
// Postback,
// @SerializedName("web_url")
// WebUrl
// }
// private final Type type;
// private final String title;
// private final Action payload;
// private final String url;
// private final boolean messenger_extensions;
//
// private Button(Type type, String title, String url, Action action){
// this.type = type;
// this.title = title;
// this.url = url;
// this.payload = action;
// this.messenger_extensions = false;
// }
//
// private Button(Type type, String title, String url, boolean messenger_extensions){
// this.type = type;
// this.title = title;
// this.url = url;
// this.payload = null;
// this.messenger_extensions = messenger_extensions;
// }
//
// public static Button Url(String title, String url){
// return new Button(Type.WebUrl, title, url, null);
// }
//
// public static Button Postback(String title, Action action){
// return new Button(Type.Postback, title, null, action);
// }
//
// public static Button Url(String title, String url, boolean messenger_extensions){
// return new Button(Type.WebUrl, title, url, messenger_extensions);
// }
// }
//
// Path: src/main/java/com/hyurumi/fb_bot_boilerplate/models/send/Message.java
// public class Message {
//
// private transient final OkHttpClient HTTP_CLIENT;
// private transient final Gson GSON;
//
// {
// HTTP_CLIENT = new OkHttpClient();
// GSON = new Gson();
// }
//
// final private Attachment attachment;
// final private String text;
//
// // add by kyawswar
// @SerializedName("quick_replies")
// final private List<QuickReply> quickReplies;
//
// private Message(Attachment attachment, String text) {
// this.attachment = attachment;
// this.text = text;
// this.quickReplies = null;
// }
//
// private Message(String text, QuickReply... quickReplies) {
// this.attachment = null;
// this.text = text;
// this.quickReplies = Arrays.asList(quickReplies);
// }
//
// public static Message Text(String text) {
// return new Message(null, text);
// }
//
// public static Message QuickReply(String text, QuickReply... quickReplies) {
// return new Message(text, quickReplies);
// }
//
// public static Message Image(String url) {
// return new Message(Attachment.Image(url), null);
// }
//
// public static Message Button(String text) {
// return new Message(Attachment.Template(Payload.Button(text)), null);
// }
//
// public static Message Generic() {
// return new Message(Attachment.Template(Payload.Generic()), null);
// }
//
// public boolean addQuickReply(QuickReply reply) {
// return quickReplies.add(reply);
// }
//
// public boolean addElement(Element element) {
// return attachment.addElement(element);
// }
//
// public boolean addButton(Button button) {
// return attachment.addButton(button);
// }
//
// public Response sendTo(String recipientId) throws IOException {
//
// RequestBody body = RequestBody.create(Main.JSON, GSON.toJson(new MessageWrapper(recipientId, this)));
// Request request = new Request.Builder()
// .url(Main.END_POINT + "?access_token=" + sAccessToken)
// .header("Content-Type", "application/json; charset=UTF-8")
// .post(body)
// .build();
// okhttp3.Response response = HTTP_CLIENT.newCall(request).execute();
// final int code = response.code();
// Response returnValue = null;
// if (code == 200) {
// System.out.println("WORK!");
// returnValue = GSON.fromJson(response.body().string(), Response.class);
// }else {
// System.out.println("ERROR: " + response.body().string());
// }
// response.body().close();
// return returnValue;
// }
//
// class MessageWrapper {
// private final Recipient recipient;
// private final Message message;
// MessageWrapper(String recipientId, Message message) {
// this.recipient = new Recipient(recipientId);
// this.message = message;
// }
// }
// }
//
// Path: src/main/java/com/hyurumi/fb_bot_boilerplate/models/webhook/ReceivedMessage.java
// public class ReceivedMessage {
// public String object;
// public List<Entry> entry;
// }
// Path: src/main/java/com/hyurumi/fb_bot_boilerplate/Main.java
import com.google.gson.Gson;
import com.hyurumi.fb_bot_boilerplate.models.common.Action;
import com.hyurumi.fb_bot_boilerplate.models.send.Button;
import com.hyurumi.fb_bot_boilerplate.models.send.Element;
import com.hyurumi.fb_bot_boilerplate.models.send.Message;
import com.hyurumi.fb_bot_boilerplate.models.webhook.Messaging;
import com.hyurumi.fb_bot_boilerplate.models.webhook.ReceivedMessage;
import okhttp3.*;
import java.util.List;
import java.util.Random;
import static spark.Spark.get;
import static spark.Spark.post;
import static spark.SparkBase.port;
Message.Image("https://unsplash.it/764/400?image=200").sendTo(senderId);
break;
case 2:
sendSampleGenericMessage(senderId);
break;
default:
sendSamplePostBackMessage(senderId);
break;
}
} else if (messaging.postback != null) {
// Receiving postback message
if (messaging.postback.payload == Action.ACTION_A) {
Message.Text("Action A").sendTo(senderId);
}else {
Message.Text("Action B").sendTo(senderId);
}
} else if (messaging.delivery != null) {
// when the message is delivered, this webhook will be triggered.
} else {
// sticker may not be supported for now.
System.out.println(request.body());
}
}
System.out.println(request.body());
return "";
});
}
static private void sendSamplePostBackMessage(String senderId) throws Exception { | Message message = Message.Button("This is a postback message; please choose the action below"); |
kyawswa/myanmarlottery | src/main/java/com/ksa/myanmarlottery/Playground.java | // Path: src/main/java/com/ksa/myanmarlottery/util/ConstantUtil.java
// public class ConstantUtil {
// public static final MediaType JSON = MediaType.parse("application/json; charset=utf-8");
// @Deprecated
// public static final int OLD_LOTTERY_TYPE= 1; // for 500 ks lottery
// public static final int NEW_LOTTERY_TYPE = 2; // for 1k ks lottery
//
// public static final String ACTION_TYPING_ON = "typing_on";
// public static final String ACTION_TYPING_OFF = "typing_off";
//
// public static final String WEB = "web";
// public static final String FACEBOOK = "Facebook";
//
// public static final int NORMAL_QUERY = 0;
// public static final int CODE_RANGE_QUERY = 1;
// public static final int POINT_RANGE_QUERY = 2;
//
// public static boolean isCodePointValid(String[] codeNo) {
// // if(codeNo == null || codeNo.isEmpty()) {
// // return false;
// // }
//
// // String[] arr = codeNo.split(" ");
// // if(arr.length != 2) {
// // return false;
// // }
//
// String character = codeNo[0];
// if(character.isEmpty() || character.length() > 2 || character.length() < 1) {
// return false;
// }
//
// // check digit or not.
// String number = codeNo[1];
// if(number.isEmpty() || number.length() != 6)
// return false;
//
// for(int i=0; i< number.length(); i++) {
// if(!Character.isDigit(number.charAt(i)))
// return false; // assume it is character.
// }
// return true;
// }
//
// /**
// * 0= false, greater than 0=true
// * 1 is findPrizeByCodeRange
// * 2 is findPrizeByPointRange
// * @param codeNo
// * @return
// */
// public static int getCodePointRangeType(String[] codeNo) {
// String character = codeNo[0];
// if(character.isEmpty() || character.length() > 2 || character.length() < 1) {
// return 0;
// }
//
// String secondChar = codeNo[1];
// String thirdChar = codeNo[2];
// // check second element is digit
// if(!secondChar.isEmpty() && secondChar.length() == 6) {
// for(int i=0; i< secondChar.length(); i++) {
// if(!Character.isDigit(secondChar.charAt(i)))
// return 0; // assume it is character.
// }
// // check third part
// if(thirdChar.isEmpty() || thirdChar.length() != 6) // length should not be greater than 6 or less than 1.
// return 0;
//
// // third part must be digit
// for(int i=0; i< thirdChar.length(); i++) {
// if(!Character.isDigit(thirdChar.charAt(i)))
// return 0; // assume it is character.
// }
// return POINT_RANGE_QUERY; // 2 for findPrizeByPointRange: point mean number
//
// // check second element is character
// } else if(!secondChar.isEmpty() && secondChar.length() <= 2 && secondChar.length() >= 1){
// for(int i=0; i< secondChar.length(); i++) {
// if(Character.isDigit(secondChar.charAt(i)))
// return 0; // assume it is digit.
// }
// // check third part
// if(thirdChar.isEmpty() || thirdChar.length() != 6)
// return 0;
//
// // third part must be digit
// for(int i=0; i< thirdChar.length(); i++) {
// if(!Character.isDigit(thirdChar.charAt(i)))
// return 0; // assume it is character.
// }
// return CODE_RANGE_QUERY; // 1 for findPrizeByCodeRange: code means character
// }
// return 0;
// }
// }
| import com.google.common.base.CharMatcher;
import com.google.common.collect.Iterables;
import com.google.common.primitives.Ints;
import com.ksa.myanmarlottery.util.ConstantUtil;
import java.text.Normalizer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map; | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.ksa.myanmarlottery;
/**
*
* @author Kyawswa
*/
public class Playground {
public static void main(String[] args) {
// String are = "ကu 1၂၃၄၅၆";
//
// if (Character.UnicodeBlock.of(are.charAt(3)) != Character.UnicodeBlock.BASIC_LATIN) {
// if (Character.isDigit(are.charAt(1))) {
// System.out.println("Yes");
// } else {
// System.out.println("NO");
// }
// String[] ar = are.split(" ");
// Integer i = new Integer(ar[1]);
// System.out.println(i);
// System.out.println(ar.length);
// char[] arr = {'က', 'ခ', 'ဂ', 'ဃ', 'င',
// 'စ', 'ဆ', 'ဇ', 'ဈ', 'ည',
// 'ဋ', 'ဌ', 'ဍ', 'ဎ', 'ဏ',
// 'တ', 'ထ', 'ဒ', 'ဓ', 'န',
// 'ပ', 'ဖ', 'ဗ', 'ဘ', 'မ',
// 'ယ', 'ရ', 'လ', 'ဝ', 'သ',
// 'ဟ', 'ဠ', 'အ'};
// for(char c : arr) {
// System.out.println(Integer.toHexString(c));
// if(c == '\u1017') {
// System.out.println("found index ");
// }
// }
String str = "@ 200 a 123456, b 123456,c 234569 , a 090909";
String typeStr = str.substring(0, 4);
str = str.substring(2); | // Path: src/main/java/com/ksa/myanmarlottery/util/ConstantUtil.java
// public class ConstantUtil {
// public static final MediaType JSON = MediaType.parse("application/json; charset=utf-8");
// @Deprecated
// public static final int OLD_LOTTERY_TYPE= 1; // for 500 ks lottery
// public static final int NEW_LOTTERY_TYPE = 2; // for 1k ks lottery
//
// public static final String ACTION_TYPING_ON = "typing_on";
// public static final String ACTION_TYPING_OFF = "typing_off";
//
// public static final String WEB = "web";
// public static final String FACEBOOK = "Facebook";
//
// public static final int NORMAL_QUERY = 0;
// public static final int CODE_RANGE_QUERY = 1;
// public static final int POINT_RANGE_QUERY = 2;
//
// public static boolean isCodePointValid(String[] codeNo) {
// // if(codeNo == null || codeNo.isEmpty()) {
// // return false;
// // }
//
// // String[] arr = codeNo.split(" ");
// // if(arr.length != 2) {
// // return false;
// // }
//
// String character = codeNo[0];
// if(character.isEmpty() || character.length() > 2 || character.length() < 1) {
// return false;
// }
//
// // check digit or not.
// String number = codeNo[1];
// if(number.isEmpty() || number.length() != 6)
// return false;
//
// for(int i=0; i< number.length(); i++) {
// if(!Character.isDigit(number.charAt(i)))
// return false; // assume it is character.
// }
// return true;
// }
//
// /**
// * 0= false, greater than 0=true
// * 1 is findPrizeByCodeRange
// * 2 is findPrizeByPointRange
// * @param codeNo
// * @return
// */
// public static int getCodePointRangeType(String[] codeNo) {
// String character = codeNo[0];
// if(character.isEmpty() || character.length() > 2 || character.length() < 1) {
// return 0;
// }
//
// String secondChar = codeNo[1];
// String thirdChar = codeNo[2];
// // check second element is digit
// if(!secondChar.isEmpty() && secondChar.length() == 6) {
// for(int i=0; i< secondChar.length(); i++) {
// if(!Character.isDigit(secondChar.charAt(i)))
// return 0; // assume it is character.
// }
// // check third part
// if(thirdChar.isEmpty() || thirdChar.length() != 6) // length should not be greater than 6 or less than 1.
// return 0;
//
// // third part must be digit
// for(int i=0; i< thirdChar.length(); i++) {
// if(!Character.isDigit(thirdChar.charAt(i)))
// return 0; // assume it is character.
// }
// return POINT_RANGE_QUERY; // 2 for findPrizeByPointRange: point mean number
//
// // check second element is character
// } else if(!secondChar.isEmpty() && secondChar.length() <= 2 && secondChar.length() >= 1){
// for(int i=0; i< secondChar.length(); i++) {
// if(Character.isDigit(secondChar.charAt(i)))
// return 0; // assume it is digit.
// }
// // check third part
// if(thirdChar.isEmpty() || thirdChar.length() != 6)
// return 0;
//
// // third part must be digit
// for(int i=0; i< thirdChar.length(); i++) {
// if(!Character.isDigit(thirdChar.charAt(i)))
// return 0; // assume it is character.
// }
// return CODE_RANGE_QUERY; // 1 for findPrizeByCodeRange: code means character
// }
// return 0;
// }
// }
// Path: src/main/java/com/ksa/myanmarlottery/Playground.java
import com.google.common.base.CharMatcher;
import com.google.common.collect.Iterables;
import com.google.common.primitives.Ints;
import com.ksa.myanmarlottery.util.ConstantUtil;
import java.text.Normalizer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.ksa.myanmarlottery;
/**
*
* @author Kyawswa
*/
public class Playground {
public static void main(String[] args) {
// String are = "ကu 1၂၃၄၅၆";
//
// if (Character.UnicodeBlock.of(are.charAt(3)) != Character.UnicodeBlock.BASIC_LATIN) {
// if (Character.isDigit(are.charAt(1))) {
// System.out.println("Yes");
// } else {
// System.out.println("NO");
// }
// String[] ar = are.split(" ");
// Integer i = new Integer(ar[1]);
// System.out.println(i);
// System.out.println(ar.length);
// char[] arr = {'က', 'ခ', 'ဂ', 'ဃ', 'င',
// 'စ', 'ဆ', 'ဇ', 'ဈ', 'ည',
// 'ဋ', 'ဌ', 'ဍ', 'ဎ', 'ဏ',
// 'တ', 'ထ', 'ဒ', 'ဓ', 'န',
// 'ပ', 'ဖ', 'ဗ', 'ဘ', 'မ',
// 'ယ', 'ရ', 'လ', 'ဝ', 'သ',
// 'ဟ', 'ဠ', 'အ'};
// for(char c : arr) {
// System.out.println(Integer.toHexString(c));
// if(c == '\u1017') {
// System.out.println("found index ");
// }
// }
String str = "@ 200 a 123456, b 123456,c 234569 , a 090909";
String typeStr = str.substring(0, 4);
str = str.substring(2); | int lotteryType = ConstantUtil.NEW_LOTTERY_TYPE; |
kyawswa/myanmarlottery | src/main/java/com/ksa/myanmarlottery/service/ResultService.java | // Path: src/main/java/com/ksa/myanmarlottery/dto/GetPrizeDTO.java
// public class GetPrizeDTO {
//
// private int numberOfTimes;
// private String result;
// private String code;
// private String description;
//
// public GetPrizeDTO() {
// }
//
// public GetPrizeDTO(int numberOfTimes, String result, String code, String description) {
// this.numberOfTimes = numberOfTimes;
// this.result = result;
// this.code = code;
// this.description = description;
// }
//
// public String getResult() {
// return result;
// }
//
// public void setResult(String result) {
// this.result = result;
// }
//
// public String getCode() {
// return code;
// }
//
// public void setCode(String code) {
// this.code = code;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public int getNumberOfTimes() {
// return numberOfTimes;
// }
//
// public void setNumberOfTimes(int numberOfTimes) {
// this.numberOfTimes = numberOfTimes;
// }
//
// @Override
// public String toString() {
// return "GetPrizeDTO{" + "result=" + result + ", code=" + code + ", description=" + description + '}';
// }
// }
//
// Path: src/main/java/com/ksa/myanmarlottery/model/Result.java
// @Entity
// @NamedQueries({
// @NamedQuery(
// name = "result.findLatestResult",
// query = "from Result r where r.resultFor in (select max(rr.resultFor) from Result rr where rr.type = :type)"
// ),
// @NamedQuery(
// name = "result.findLatestResultSummary",
// query = "Select r.numberOfTimes as numberOfTimes, r.resultFor as resultFor, r.type as type from Result r where r.type = :type"
// ),
// @NamedQuery(
// name = "result.findByType",
// query = "from Result r where r.type = :type"
// )
// })
// @Table(name = "Lottery_result")
// public class Result implements Serializable {
//
// @Id
// @Column(name = "RESULT_TYPE")
// private int type = ConstantUtil.OLD_LOTTERY_TYPE;;
//
// private int numberOfTimes;
//
// @Temporal(TemporalType.DATE)
// private Date createdDate = new Date();
//
// @Temporal(TemporalType.DATE)
// private Date resultFor = new Date();
//
// private String dataProvider;
//
// private String companyName;
//
// @OneToMany(mappedBy = "result",fetch = FetchType.EAGER)
// @Cascade(CascadeType.ALL)
// private List<Prize> prizes = new ArrayList<Prize>();
//
// public Result() {
// }
//
// public Result(int type, int numberOfTimes, Date createdDate, Date resultFor) {
// this.type = type;
// this.numberOfTimes = numberOfTimes;
// this.resultFor = resultFor;
// }
//
// public Result(int numberOfTimes, Date resultFor, int type) {
// this.numberOfTimes = numberOfTimes;
// this.resultFor = resultFor;
// this.type = type;
// }
//
// public int getNumberOfTimes() {
// return numberOfTimes;
// }
//
// public void setNumberOfTimes(int numberOfTimes) {
// this.numberOfTimes = numberOfTimes;
// }
//
// public Date getCreatedDate() {
// return createdDate;
// }
//
// public void setCreatedDate(Date createdDate) {
// this.createdDate = createdDate;
// }
//
// public Date getResultFor() {
// return resultFor;
// }
//
// public void setResultFor(Date resultFor) {
// this.resultFor = resultFor;
// }
//
// public List<Prize> getPrizes() {
// return prizes;
// }
//
// public void setPrizes(List<Prize> prizes) {
// this.prizes = prizes;
// }
//
// public int getType() {
// return type;
// }
//
// public void setType(int type) {
// this.type = type;
// }
//
// public String getDataProvider() {
// return dataProvider;
// }
//
// public void setDataProvider(String dataProvider) {
// this.dataProvider = dataProvider;
// }
//
// public String getCompanyName() {
// return companyName;
// }
//
// public void setCompanyName(String companyName) {
// this.companyName = companyName;
// }
//
// @Override
// public String toString() {
// return "Result{" +"numberOfTimes=" + numberOfTimes + ", createdDate=" + createdDate + ", type=" + type + ", resultFor=" + resultFor + ", prizes=" + prizes + '}';
// }
// }
| import com.ksa.myanmarlottery.model.Result;
import java.util.List;
import com.ksa.myanmarlottery.dto.GetPrizeDTO; | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.ksa.myanmarlottery.service;
/**
*
* @author Kyawswar
*/
public interface ResultService {
Result insert(Result result);
public void deleteByType(int type);
public Result findResultByType(int type);
/**
* find only latest result information WITHOUT prize list.
* @param type
* @return
*/
public Result findLatestResultSummary(int type);
| // Path: src/main/java/com/ksa/myanmarlottery/dto/GetPrizeDTO.java
// public class GetPrizeDTO {
//
// private int numberOfTimes;
// private String result;
// private String code;
// private String description;
//
// public GetPrizeDTO() {
// }
//
// public GetPrizeDTO(int numberOfTimes, String result, String code, String description) {
// this.numberOfTimes = numberOfTimes;
// this.result = result;
// this.code = code;
// this.description = description;
// }
//
// public String getResult() {
// return result;
// }
//
// public void setResult(String result) {
// this.result = result;
// }
//
// public String getCode() {
// return code;
// }
//
// public void setCode(String code) {
// this.code = code;
// }
//
// public String getDescription() {
// return description;
// }
//
// public void setDescription(String description) {
// this.description = description;
// }
//
// public int getNumberOfTimes() {
// return numberOfTimes;
// }
//
// public void setNumberOfTimes(int numberOfTimes) {
// this.numberOfTimes = numberOfTimes;
// }
//
// @Override
// public String toString() {
// return "GetPrizeDTO{" + "result=" + result + ", code=" + code + ", description=" + description + '}';
// }
// }
//
// Path: src/main/java/com/ksa/myanmarlottery/model/Result.java
// @Entity
// @NamedQueries({
// @NamedQuery(
// name = "result.findLatestResult",
// query = "from Result r where r.resultFor in (select max(rr.resultFor) from Result rr where rr.type = :type)"
// ),
// @NamedQuery(
// name = "result.findLatestResultSummary",
// query = "Select r.numberOfTimes as numberOfTimes, r.resultFor as resultFor, r.type as type from Result r where r.type = :type"
// ),
// @NamedQuery(
// name = "result.findByType",
// query = "from Result r where r.type = :type"
// )
// })
// @Table(name = "Lottery_result")
// public class Result implements Serializable {
//
// @Id
// @Column(name = "RESULT_TYPE")
// private int type = ConstantUtil.OLD_LOTTERY_TYPE;;
//
// private int numberOfTimes;
//
// @Temporal(TemporalType.DATE)
// private Date createdDate = new Date();
//
// @Temporal(TemporalType.DATE)
// private Date resultFor = new Date();
//
// private String dataProvider;
//
// private String companyName;
//
// @OneToMany(mappedBy = "result",fetch = FetchType.EAGER)
// @Cascade(CascadeType.ALL)
// private List<Prize> prizes = new ArrayList<Prize>();
//
// public Result() {
// }
//
// public Result(int type, int numberOfTimes, Date createdDate, Date resultFor) {
// this.type = type;
// this.numberOfTimes = numberOfTimes;
// this.resultFor = resultFor;
// }
//
// public Result(int numberOfTimes, Date resultFor, int type) {
// this.numberOfTimes = numberOfTimes;
// this.resultFor = resultFor;
// this.type = type;
// }
//
// public int getNumberOfTimes() {
// return numberOfTimes;
// }
//
// public void setNumberOfTimes(int numberOfTimes) {
// this.numberOfTimes = numberOfTimes;
// }
//
// public Date getCreatedDate() {
// return createdDate;
// }
//
// public void setCreatedDate(Date createdDate) {
// this.createdDate = createdDate;
// }
//
// public Date getResultFor() {
// return resultFor;
// }
//
// public void setResultFor(Date resultFor) {
// this.resultFor = resultFor;
// }
//
// public List<Prize> getPrizes() {
// return prizes;
// }
//
// public void setPrizes(List<Prize> prizes) {
// this.prizes = prizes;
// }
//
// public int getType() {
// return type;
// }
//
// public void setType(int type) {
// this.type = type;
// }
//
// public String getDataProvider() {
// return dataProvider;
// }
//
// public void setDataProvider(String dataProvider) {
// this.dataProvider = dataProvider;
// }
//
// public String getCompanyName() {
// return companyName;
// }
//
// public void setCompanyName(String companyName) {
// this.companyName = companyName;
// }
//
// @Override
// public String toString() {
// return "Result{" +"numberOfTimes=" + numberOfTimes + ", createdDate=" + createdDate + ", type=" + type + ", resultFor=" + resultFor + ", prizes=" + prizes + '}';
// }
// }
// Path: src/main/java/com/ksa/myanmarlottery/service/ResultService.java
import com.ksa.myanmarlottery.model.Result;
import java.util.List;
import com.ksa.myanmarlottery.dto.GetPrizeDTO;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.ksa.myanmarlottery.service;
/**
*
* @author Kyawswar
*/
public interface ResultService {
Result insert(Result result);
public void deleteByType(int type);
public Result findResultByType(int type);
/**
* find only latest result information WITHOUT prize list.
* @param type
* @return
*/
public Result findLatestResultSummary(int type);
| List<GetPrizeDTO> findPrizeByResultType(int type, String... codeNo); |
kyawswa/myanmarlottery | src/main/java/com/hyurumi/fb_bot_boilerplate/models/send/Message.java | // Path: src/main/java/com/hyurumi/fb_bot_boilerplate/Main.java
// public class Main {
// public static String sAccessToken;
// private static String sValidationToken;
// public static final String END_POINT;
// public static final MediaType JSON;
// private static final Random sRandom;
// private static final Gson GSON;
// private static final String PORT = "8181";
//
// static {
// JSON = MediaType.parse("application/json; charset=utf-8");
// END_POINT = "https://graph.facebook.com/v2.6/me/messages";
// GSON = new Gson();
// sRandom = new Random();
// sAccessToken = "EAAC6CoQsmOQBALDgvNuFAuEytTOZBjrUJVUodqGZBF620fInZByyBDqfx4A6XvDgnxIgXGZAX1nv2WJJSKVxolgPeNF2kdbGqvdp9h6wtGMCwecryr5bL4G7SPPbBWmbl1kWruiPIWJkdoed9cdgTyO5BrfZAzgWIdsmFK9dZCWgZDZD";//System.getenv("ACCESS_TOKEN");
// sValidationToken = "EAAC6CoQsmOQBALDgvNuFAuEytTOZBjrUJVUodqGZBF620fInZByyBDqfx4A6XvDgnxIgXGZAX1nv2WJJSKVxolgPeNF2kdbGqvdp9h6wtGMCwecryr5bL4G7SPPbBWmbl1kWruiPIWJkdoed9cdgTyO5BrfZAzgWIdsmFK9dZCWgZDZD";//System.getenv("VALIDATION_TOKEN");
// }
//
// public static void main(String[] args) {
//
// port(Integer.valueOf(PORT)); //System.getenv("PORT")
//
// get("/webhook", (request, response) -> {
// if (request.queryMap("hub.verify_token").value().equals(sValidationToken)) {
// return request.queryMap("hub.challenge").value();
// }
// return "Error, wrong validation token";
// });
//
// post("/webhook", (request, response) -> {
// ReceivedMessage receivedMessage = GSON.fromJson(request.body(), ReceivedMessage.class);
// List<Messaging> messagings = receivedMessage.entry.get(0).messaging;
// for (Messaging messaging : messagings) {
// String senderId = messaging.sender.id;
// if (messaging.message !=null) {
// // Receiving text message
// switch (sRandom.nextInt(4)){
// case 0:
// if (messaging.message.text != null)
// Message.Text(messaging.message.text).sendTo(senderId);
// else
// sendSampleGenericMessage(senderId);
// break;
// case 1:
// Message.Image("https://unsplash.it/764/400?image=200").sendTo(senderId);
// break;
// case 2:
// sendSampleGenericMessage(senderId);
// break;
// default:
// sendSamplePostBackMessage(senderId);
// break;
// }
//
// } else if (messaging.postback != null) {
// // Receiving postback message
// if (messaging.postback.payload == Action.ACTION_A) {
// Message.Text("Action A").sendTo(senderId);
// }else {
// Message.Text("Action B").sendTo(senderId);
// }
// } else if (messaging.delivery != null) {
// // when the message is delivered, this webhook will be triggered.
// } else {
// // sticker may not be supported for now.
// System.out.println(request.body());
// }
// }
// System.out.println(request.body());
// return "";
// });
// }
//
// static private void sendSamplePostBackMessage(String senderId) throws Exception {
// Message message = Message.Button("This is a postback message; please choose the action below");
// message.addButton(Button.Postback("action A", Action.ACTION_A));
// message.addButton(Button.Postback("action B", Action.ACTION_B));
// message.addButton(Button.Url("open Google", "https://google.com"));
// message.sendTo(senderId);
// }
//
// static private void sendSampleGenericMessage(String senderId) throws Exception {
// Message message = Message.Generic();
// Element element = new Element("Generic Message Sample", "https://unsplash.it/764/400?image=400", "subtitle");
// message.addElement(element);
// element = new Element("Yay Yay", "https://unsplash.it/764/400?image=500", "subtitle");
// element.addButton(Button.Postback("action A", Action.ACTION_A));
// element.addButton(Button.Url("jump to FB", "https://facebook.com/"));
// message.addElement(element);
// message.sendTo(senderId);
// }
// }
//
// Path: src/main/java/com/hyurumi/fb_bot_boilerplate/Main.java
// public static String sAccessToken;
| import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName;
import com.hyurumi.fb_bot_boilerplate.Main;
import com.hyurumi.fb_bot_boilerplate.models.common.Recipient;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import java.io.IOException;
import static com.hyurumi.fb_bot_boilerplate.Main.sAccessToken;
import java.util.Arrays;
import java.util.List; | public static Message QuickReply(String text, QuickReply... quickReplies) {
return new Message(text, quickReplies);
}
public static Message Image(String url) {
return new Message(Attachment.Image(url), null);
}
public static Message Button(String text) {
return new Message(Attachment.Template(Payload.Button(text)), null);
}
public static Message Generic() {
return new Message(Attachment.Template(Payload.Generic()), null);
}
public boolean addQuickReply(QuickReply reply) {
return quickReplies.add(reply);
}
public boolean addElement(Element element) {
return attachment.addElement(element);
}
public boolean addButton(Button button) {
return attachment.addButton(button);
}
public Response sendTo(String recipientId) throws IOException {
| // Path: src/main/java/com/hyurumi/fb_bot_boilerplate/Main.java
// public class Main {
// public static String sAccessToken;
// private static String sValidationToken;
// public static final String END_POINT;
// public static final MediaType JSON;
// private static final Random sRandom;
// private static final Gson GSON;
// private static final String PORT = "8181";
//
// static {
// JSON = MediaType.parse("application/json; charset=utf-8");
// END_POINT = "https://graph.facebook.com/v2.6/me/messages";
// GSON = new Gson();
// sRandom = new Random();
// sAccessToken = "EAAC6CoQsmOQBALDgvNuFAuEytTOZBjrUJVUodqGZBF620fInZByyBDqfx4A6XvDgnxIgXGZAX1nv2WJJSKVxolgPeNF2kdbGqvdp9h6wtGMCwecryr5bL4G7SPPbBWmbl1kWruiPIWJkdoed9cdgTyO5BrfZAzgWIdsmFK9dZCWgZDZD";//System.getenv("ACCESS_TOKEN");
// sValidationToken = "EAAC6CoQsmOQBALDgvNuFAuEytTOZBjrUJVUodqGZBF620fInZByyBDqfx4A6XvDgnxIgXGZAX1nv2WJJSKVxolgPeNF2kdbGqvdp9h6wtGMCwecryr5bL4G7SPPbBWmbl1kWruiPIWJkdoed9cdgTyO5BrfZAzgWIdsmFK9dZCWgZDZD";//System.getenv("VALIDATION_TOKEN");
// }
//
// public static void main(String[] args) {
//
// port(Integer.valueOf(PORT)); //System.getenv("PORT")
//
// get("/webhook", (request, response) -> {
// if (request.queryMap("hub.verify_token").value().equals(sValidationToken)) {
// return request.queryMap("hub.challenge").value();
// }
// return "Error, wrong validation token";
// });
//
// post("/webhook", (request, response) -> {
// ReceivedMessage receivedMessage = GSON.fromJson(request.body(), ReceivedMessage.class);
// List<Messaging> messagings = receivedMessage.entry.get(0).messaging;
// for (Messaging messaging : messagings) {
// String senderId = messaging.sender.id;
// if (messaging.message !=null) {
// // Receiving text message
// switch (sRandom.nextInt(4)){
// case 0:
// if (messaging.message.text != null)
// Message.Text(messaging.message.text).sendTo(senderId);
// else
// sendSampleGenericMessage(senderId);
// break;
// case 1:
// Message.Image("https://unsplash.it/764/400?image=200").sendTo(senderId);
// break;
// case 2:
// sendSampleGenericMessage(senderId);
// break;
// default:
// sendSamplePostBackMessage(senderId);
// break;
// }
//
// } else if (messaging.postback != null) {
// // Receiving postback message
// if (messaging.postback.payload == Action.ACTION_A) {
// Message.Text("Action A").sendTo(senderId);
// }else {
// Message.Text("Action B").sendTo(senderId);
// }
// } else if (messaging.delivery != null) {
// // when the message is delivered, this webhook will be triggered.
// } else {
// // sticker may not be supported for now.
// System.out.println(request.body());
// }
// }
// System.out.println(request.body());
// return "";
// });
// }
//
// static private void sendSamplePostBackMessage(String senderId) throws Exception {
// Message message = Message.Button("This is a postback message; please choose the action below");
// message.addButton(Button.Postback("action A", Action.ACTION_A));
// message.addButton(Button.Postback("action B", Action.ACTION_B));
// message.addButton(Button.Url("open Google", "https://google.com"));
// message.sendTo(senderId);
// }
//
// static private void sendSampleGenericMessage(String senderId) throws Exception {
// Message message = Message.Generic();
// Element element = new Element("Generic Message Sample", "https://unsplash.it/764/400?image=400", "subtitle");
// message.addElement(element);
// element = new Element("Yay Yay", "https://unsplash.it/764/400?image=500", "subtitle");
// element.addButton(Button.Postback("action A", Action.ACTION_A));
// element.addButton(Button.Url("jump to FB", "https://facebook.com/"));
// message.addElement(element);
// message.sendTo(senderId);
// }
// }
//
// Path: src/main/java/com/hyurumi/fb_bot_boilerplate/Main.java
// public static String sAccessToken;
// Path: src/main/java/com/hyurumi/fb_bot_boilerplate/models/send/Message.java
import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName;
import com.hyurumi.fb_bot_boilerplate.Main;
import com.hyurumi.fb_bot_boilerplate.models.common.Recipient;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import java.io.IOException;
import static com.hyurumi.fb_bot_boilerplate.Main.sAccessToken;
import java.util.Arrays;
import java.util.List;
public static Message QuickReply(String text, QuickReply... quickReplies) {
return new Message(text, quickReplies);
}
public static Message Image(String url) {
return new Message(Attachment.Image(url), null);
}
public static Message Button(String text) {
return new Message(Attachment.Template(Payload.Button(text)), null);
}
public static Message Generic() {
return new Message(Attachment.Template(Payload.Generic()), null);
}
public boolean addQuickReply(QuickReply reply) {
return quickReplies.add(reply);
}
public boolean addElement(Element element) {
return attachment.addElement(element);
}
public boolean addButton(Button button) {
return attachment.addButton(button);
}
public Response sendTo(String recipientId) throws IOException {
| RequestBody body = RequestBody.create(Main.JSON, GSON.toJson(new MessageWrapper(recipientId, this))); |
kyawswa/myanmarlottery | src/main/java/com/hyurumi/fb_bot_boilerplate/models/send/Message.java | // Path: src/main/java/com/hyurumi/fb_bot_boilerplate/Main.java
// public class Main {
// public static String sAccessToken;
// private static String sValidationToken;
// public static final String END_POINT;
// public static final MediaType JSON;
// private static final Random sRandom;
// private static final Gson GSON;
// private static final String PORT = "8181";
//
// static {
// JSON = MediaType.parse("application/json; charset=utf-8");
// END_POINT = "https://graph.facebook.com/v2.6/me/messages";
// GSON = new Gson();
// sRandom = new Random();
// sAccessToken = "EAAC6CoQsmOQBALDgvNuFAuEytTOZBjrUJVUodqGZBF620fInZByyBDqfx4A6XvDgnxIgXGZAX1nv2WJJSKVxolgPeNF2kdbGqvdp9h6wtGMCwecryr5bL4G7SPPbBWmbl1kWruiPIWJkdoed9cdgTyO5BrfZAzgWIdsmFK9dZCWgZDZD";//System.getenv("ACCESS_TOKEN");
// sValidationToken = "EAAC6CoQsmOQBALDgvNuFAuEytTOZBjrUJVUodqGZBF620fInZByyBDqfx4A6XvDgnxIgXGZAX1nv2WJJSKVxolgPeNF2kdbGqvdp9h6wtGMCwecryr5bL4G7SPPbBWmbl1kWruiPIWJkdoed9cdgTyO5BrfZAzgWIdsmFK9dZCWgZDZD";//System.getenv("VALIDATION_TOKEN");
// }
//
// public static void main(String[] args) {
//
// port(Integer.valueOf(PORT)); //System.getenv("PORT")
//
// get("/webhook", (request, response) -> {
// if (request.queryMap("hub.verify_token").value().equals(sValidationToken)) {
// return request.queryMap("hub.challenge").value();
// }
// return "Error, wrong validation token";
// });
//
// post("/webhook", (request, response) -> {
// ReceivedMessage receivedMessage = GSON.fromJson(request.body(), ReceivedMessage.class);
// List<Messaging> messagings = receivedMessage.entry.get(0).messaging;
// for (Messaging messaging : messagings) {
// String senderId = messaging.sender.id;
// if (messaging.message !=null) {
// // Receiving text message
// switch (sRandom.nextInt(4)){
// case 0:
// if (messaging.message.text != null)
// Message.Text(messaging.message.text).sendTo(senderId);
// else
// sendSampleGenericMessage(senderId);
// break;
// case 1:
// Message.Image("https://unsplash.it/764/400?image=200").sendTo(senderId);
// break;
// case 2:
// sendSampleGenericMessage(senderId);
// break;
// default:
// sendSamplePostBackMessage(senderId);
// break;
// }
//
// } else if (messaging.postback != null) {
// // Receiving postback message
// if (messaging.postback.payload == Action.ACTION_A) {
// Message.Text("Action A").sendTo(senderId);
// }else {
// Message.Text("Action B").sendTo(senderId);
// }
// } else if (messaging.delivery != null) {
// // when the message is delivered, this webhook will be triggered.
// } else {
// // sticker may not be supported for now.
// System.out.println(request.body());
// }
// }
// System.out.println(request.body());
// return "";
// });
// }
//
// static private void sendSamplePostBackMessage(String senderId) throws Exception {
// Message message = Message.Button("This is a postback message; please choose the action below");
// message.addButton(Button.Postback("action A", Action.ACTION_A));
// message.addButton(Button.Postback("action B", Action.ACTION_B));
// message.addButton(Button.Url("open Google", "https://google.com"));
// message.sendTo(senderId);
// }
//
// static private void sendSampleGenericMessage(String senderId) throws Exception {
// Message message = Message.Generic();
// Element element = new Element("Generic Message Sample", "https://unsplash.it/764/400?image=400", "subtitle");
// message.addElement(element);
// element = new Element("Yay Yay", "https://unsplash.it/764/400?image=500", "subtitle");
// element.addButton(Button.Postback("action A", Action.ACTION_A));
// element.addButton(Button.Url("jump to FB", "https://facebook.com/"));
// message.addElement(element);
// message.sendTo(senderId);
// }
// }
//
// Path: src/main/java/com/hyurumi/fb_bot_boilerplate/Main.java
// public static String sAccessToken;
| import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName;
import com.hyurumi.fb_bot_boilerplate.Main;
import com.hyurumi.fb_bot_boilerplate.models.common.Recipient;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import java.io.IOException;
import static com.hyurumi.fb_bot_boilerplate.Main.sAccessToken;
import java.util.Arrays;
import java.util.List; | }
public static Message Image(String url) {
return new Message(Attachment.Image(url), null);
}
public static Message Button(String text) {
return new Message(Attachment.Template(Payload.Button(text)), null);
}
public static Message Generic() {
return new Message(Attachment.Template(Payload.Generic()), null);
}
public boolean addQuickReply(QuickReply reply) {
return quickReplies.add(reply);
}
public boolean addElement(Element element) {
return attachment.addElement(element);
}
public boolean addButton(Button button) {
return attachment.addButton(button);
}
public Response sendTo(String recipientId) throws IOException {
RequestBody body = RequestBody.create(Main.JSON, GSON.toJson(new MessageWrapper(recipientId, this)));
Request request = new Request.Builder() | // Path: src/main/java/com/hyurumi/fb_bot_boilerplate/Main.java
// public class Main {
// public static String sAccessToken;
// private static String sValidationToken;
// public static final String END_POINT;
// public static final MediaType JSON;
// private static final Random sRandom;
// private static final Gson GSON;
// private static final String PORT = "8181";
//
// static {
// JSON = MediaType.parse("application/json; charset=utf-8");
// END_POINT = "https://graph.facebook.com/v2.6/me/messages";
// GSON = new Gson();
// sRandom = new Random();
// sAccessToken = "EAAC6CoQsmOQBALDgvNuFAuEytTOZBjrUJVUodqGZBF620fInZByyBDqfx4A6XvDgnxIgXGZAX1nv2WJJSKVxolgPeNF2kdbGqvdp9h6wtGMCwecryr5bL4G7SPPbBWmbl1kWruiPIWJkdoed9cdgTyO5BrfZAzgWIdsmFK9dZCWgZDZD";//System.getenv("ACCESS_TOKEN");
// sValidationToken = "EAAC6CoQsmOQBALDgvNuFAuEytTOZBjrUJVUodqGZBF620fInZByyBDqfx4A6XvDgnxIgXGZAX1nv2WJJSKVxolgPeNF2kdbGqvdp9h6wtGMCwecryr5bL4G7SPPbBWmbl1kWruiPIWJkdoed9cdgTyO5BrfZAzgWIdsmFK9dZCWgZDZD";//System.getenv("VALIDATION_TOKEN");
// }
//
// public static void main(String[] args) {
//
// port(Integer.valueOf(PORT)); //System.getenv("PORT")
//
// get("/webhook", (request, response) -> {
// if (request.queryMap("hub.verify_token").value().equals(sValidationToken)) {
// return request.queryMap("hub.challenge").value();
// }
// return "Error, wrong validation token";
// });
//
// post("/webhook", (request, response) -> {
// ReceivedMessage receivedMessage = GSON.fromJson(request.body(), ReceivedMessage.class);
// List<Messaging> messagings = receivedMessage.entry.get(0).messaging;
// for (Messaging messaging : messagings) {
// String senderId = messaging.sender.id;
// if (messaging.message !=null) {
// // Receiving text message
// switch (sRandom.nextInt(4)){
// case 0:
// if (messaging.message.text != null)
// Message.Text(messaging.message.text).sendTo(senderId);
// else
// sendSampleGenericMessage(senderId);
// break;
// case 1:
// Message.Image("https://unsplash.it/764/400?image=200").sendTo(senderId);
// break;
// case 2:
// sendSampleGenericMessage(senderId);
// break;
// default:
// sendSamplePostBackMessage(senderId);
// break;
// }
//
// } else if (messaging.postback != null) {
// // Receiving postback message
// if (messaging.postback.payload == Action.ACTION_A) {
// Message.Text("Action A").sendTo(senderId);
// }else {
// Message.Text("Action B").sendTo(senderId);
// }
// } else if (messaging.delivery != null) {
// // when the message is delivered, this webhook will be triggered.
// } else {
// // sticker may not be supported for now.
// System.out.println(request.body());
// }
// }
// System.out.println(request.body());
// return "";
// });
// }
//
// static private void sendSamplePostBackMessage(String senderId) throws Exception {
// Message message = Message.Button("This is a postback message; please choose the action below");
// message.addButton(Button.Postback("action A", Action.ACTION_A));
// message.addButton(Button.Postback("action B", Action.ACTION_B));
// message.addButton(Button.Url("open Google", "https://google.com"));
// message.sendTo(senderId);
// }
//
// static private void sendSampleGenericMessage(String senderId) throws Exception {
// Message message = Message.Generic();
// Element element = new Element("Generic Message Sample", "https://unsplash.it/764/400?image=400", "subtitle");
// message.addElement(element);
// element = new Element("Yay Yay", "https://unsplash.it/764/400?image=500", "subtitle");
// element.addButton(Button.Postback("action A", Action.ACTION_A));
// element.addButton(Button.Url("jump to FB", "https://facebook.com/"));
// message.addElement(element);
// message.sendTo(senderId);
// }
// }
//
// Path: src/main/java/com/hyurumi/fb_bot_boilerplate/Main.java
// public static String sAccessToken;
// Path: src/main/java/com/hyurumi/fb_bot_boilerplate/models/send/Message.java
import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName;
import com.hyurumi.fb_bot_boilerplate.Main;
import com.hyurumi.fb_bot_boilerplate.models.common.Recipient;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import java.io.IOException;
import static com.hyurumi.fb_bot_boilerplate.Main.sAccessToken;
import java.util.Arrays;
import java.util.List;
}
public static Message Image(String url) {
return new Message(Attachment.Image(url), null);
}
public static Message Button(String text) {
return new Message(Attachment.Template(Payload.Button(text)), null);
}
public static Message Generic() {
return new Message(Attachment.Template(Payload.Generic()), null);
}
public boolean addQuickReply(QuickReply reply) {
return quickReplies.add(reply);
}
public boolean addElement(Element element) {
return attachment.addElement(element);
}
public boolean addButton(Button button) {
return attachment.addButton(button);
}
public Response sendTo(String recipientId) throws IOException {
RequestBody body = RequestBody.create(Main.JSON, GSON.toJson(new MessageWrapper(recipientId, this)));
Request request = new Request.Builder() | .url(Main.END_POINT + "?access_token=" + sAccessToken) |
kyawswa/myanmarlottery | src/test/java/com/ksa/myanmarlottery/repo/ScheduleRepositoryTest.java | // Path: src/main/java/com/ksa/myanmarlottery/model/ScheduleItem.java
// @Entity
// @NamedQueries({
// @NamedQuery(
// name = "scheduleItem.findAll",
// query = "from ScheduleItem s"
// )}
// )
// public class ScheduleItem implements Serializable {
//
// @Id
// private String recipientID;
//
// // 500 or 200
// private int lotteryType;
//
// // query by range or specific query
// private int queryType;
//
// @ElementCollection
// @CollectionTable(name="param_table", joinColumns=@JoinColumn(name="recipient_id"))
// @Column(name="params")
// @OrderColumn(name="param_index")
// private List<String> param = new ArrayList<>();
//
// private String originParam;
//
// @Temporal(TemporalType.TIMESTAMP)
// private Date creationDate = new Date();
//
// public ScheduleItem() {}
//
// public ScheduleItem(String recipientID, int lotteryType, int queryType, String originParam) {
// this.recipientID = recipientID;
// this.lotteryType = lotteryType;
// this.queryType = queryType;
// this.originParam = originParam;
// }
//
// public String getOriginParam() {
// return originParam;
// }
//
// public void setOriginParam(String originParam) {
// this.originParam = originParam;
// }
//
// public String getRecipientID() {
// return recipientID;
// }
//
// public void setRecipientID(String recipientID) {
// this.recipientID = recipientID;
// }
//
// public int getLotteryType() {
// return lotteryType;
// }
//
// public void setLotteryType(int lotteryType) {
// this.lotteryType = lotteryType;
// }
//
// public int getQueryType() {
// return queryType;
// }
//
// public void setQueryType(int queryType) {
// this.queryType = queryType;
// }
//
// public List<String> getParam() {
// return param;
// }
//
// public void setParam(List<String> param) {
// this.param = param;
// }
//
// public Date getCreationDate() {
// return creationDate;
// }
//
// public void setCreationDate(Date creationDate) {
// this.creationDate = creationDate;
// }
//
// }
//
// Path: src/main/java/com/ksa/myanmarlottery/repository/ResultRepository.java
// public interface ResultRepository {
// Result insert(Result result);
// void deleteByType(int type);
//
// /**
// *
// * @param minIndex
// * @param maxIndex
// * @param points
// * @param type
// * @return
// */
// public List<Prize> findPrizeByCode(int minIndex, int maxIndex, List<Integer> points, int type);
//
// /**
// *
// * @param codeIndex
// * @param startPoint
// * @param endPoint
// * @param startFivePt
// * @param endFivePt
// * @param startFourPt
// * @param endFourPt
// * @param startThreePt
// * @param endThreePt
// * @param startTwoPt
// * @param endTwoPt
// * @param type
// * @return
// */
// public List<Prize> findPrizeByPoints(int codeIndex, int startPoint, int endPoint,
// int startFivePt, int endFivePt, int startFourPt,
// int endFourPt, int startThreePt, int endThreePt,
// int startTwoPt, int endTwoPt, int type);
//
// public Result findResultByType(int type);
// /**
// * find prize on latest result by codeNo and type
// * @param codePoints
// * @param type
// * @return
// */
// public List<Prize> findPrizeByResultType(Map<String,List<Integer>> codePoints, int type);
//
// /**
// * find only latest result information WITHOUT prize list.
// * @param type
// * @return
// */
// public Result findLatestResultSummary(int type);
// }
//
// Path: src/main/java/com/ksa/myanmarlottery/repository/ScheduleRepository.java
// public interface ScheduleRepository {
// List<ScheduleItem> findAll();
// ScheduleItem insertOrUpdateItem(ScheduleItem item);
// ScheduleItem findItemByID(String senderID);
// void deleteItem(String id);
// }
| import com.ksa.myanmarlottery.model.ScheduleItem;
import com.ksa.myanmarlottery.repository.ResultRepository;
import com.ksa.myanmarlottery.repository.ScheduleRepository;
import java.util.List;
import org.junit.Assert;
import static org.junit.Assert.*;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase;
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.test.context.junit4.SpringRunner; | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.ksa.myanmarlottery.repo;
/**
*
* @author Kyawswa
*/
@Ignore
@RunWith(SpringRunner.class)
@DataJpaTest
@ComponentScan({"com.ksa.myanmarlottery"})
@AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE)
public class ScheduleRepositoryTest {
@Autowired | // Path: src/main/java/com/ksa/myanmarlottery/model/ScheduleItem.java
// @Entity
// @NamedQueries({
// @NamedQuery(
// name = "scheduleItem.findAll",
// query = "from ScheduleItem s"
// )}
// )
// public class ScheduleItem implements Serializable {
//
// @Id
// private String recipientID;
//
// // 500 or 200
// private int lotteryType;
//
// // query by range or specific query
// private int queryType;
//
// @ElementCollection
// @CollectionTable(name="param_table", joinColumns=@JoinColumn(name="recipient_id"))
// @Column(name="params")
// @OrderColumn(name="param_index")
// private List<String> param = new ArrayList<>();
//
// private String originParam;
//
// @Temporal(TemporalType.TIMESTAMP)
// private Date creationDate = new Date();
//
// public ScheduleItem() {}
//
// public ScheduleItem(String recipientID, int lotteryType, int queryType, String originParam) {
// this.recipientID = recipientID;
// this.lotteryType = lotteryType;
// this.queryType = queryType;
// this.originParam = originParam;
// }
//
// public String getOriginParam() {
// return originParam;
// }
//
// public void setOriginParam(String originParam) {
// this.originParam = originParam;
// }
//
// public String getRecipientID() {
// return recipientID;
// }
//
// public void setRecipientID(String recipientID) {
// this.recipientID = recipientID;
// }
//
// public int getLotteryType() {
// return lotteryType;
// }
//
// public void setLotteryType(int lotteryType) {
// this.lotteryType = lotteryType;
// }
//
// public int getQueryType() {
// return queryType;
// }
//
// public void setQueryType(int queryType) {
// this.queryType = queryType;
// }
//
// public List<String> getParam() {
// return param;
// }
//
// public void setParam(List<String> param) {
// this.param = param;
// }
//
// public Date getCreationDate() {
// return creationDate;
// }
//
// public void setCreationDate(Date creationDate) {
// this.creationDate = creationDate;
// }
//
// }
//
// Path: src/main/java/com/ksa/myanmarlottery/repository/ResultRepository.java
// public interface ResultRepository {
// Result insert(Result result);
// void deleteByType(int type);
//
// /**
// *
// * @param minIndex
// * @param maxIndex
// * @param points
// * @param type
// * @return
// */
// public List<Prize> findPrizeByCode(int minIndex, int maxIndex, List<Integer> points, int type);
//
// /**
// *
// * @param codeIndex
// * @param startPoint
// * @param endPoint
// * @param startFivePt
// * @param endFivePt
// * @param startFourPt
// * @param endFourPt
// * @param startThreePt
// * @param endThreePt
// * @param startTwoPt
// * @param endTwoPt
// * @param type
// * @return
// */
// public List<Prize> findPrizeByPoints(int codeIndex, int startPoint, int endPoint,
// int startFivePt, int endFivePt, int startFourPt,
// int endFourPt, int startThreePt, int endThreePt,
// int startTwoPt, int endTwoPt, int type);
//
// public Result findResultByType(int type);
// /**
// * find prize on latest result by codeNo and type
// * @param codePoints
// * @param type
// * @return
// */
// public List<Prize> findPrizeByResultType(Map<String,List<Integer>> codePoints, int type);
//
// /**
// * find only latest result information WITHOUT prize list.
// * @param type
// * @return
// */
// public Result findLatestResultSummary(int type);
// }
//
// Path: src/main/java/com/ksa/myanmarlottery/repository/ScheduleRepository.java
// public interface ScheduleRepository {
// List<ScheduleItem> findAll();
// ScheduleItem insertOrUpdateItem(ScheduleItem item);
// ScheduleItem findItemByID(String senderID);
// void deleteItem(String id);
// }
// Path: src/test/java/com/ksa/myanmarlottery/repo/ScheduleRepositoryTest.java
import com.ksa.myanmarlottery.model.ScheduleItem;
import com.ksa.myanmarlottery.repository.ResultRepository;
import com.ksa.myanmarlottery.repository.ScheduleRepository;
import java.util.List;
import org.junit.Assert;
import static org.junit.Assert.*;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase;
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.test.context.junit4.SpringRunner;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.ksa.myanmarlottery.repo;
/**
*
* @author Kyawswa
*/
@Ignore
@RunWith(SpringRunner.class)
@DataJpaTest
@ComponentScan({"com.ksa.myanmarlottery"})
@AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE)
public class ScheduleRepositoryTest {
@Autowired | private ScheduleRepository repository; |
kyawswa/myanmarlottery | src/test/java/com/ksa/myanmarlottery/repo/ScheduleRepositoryTest.java | // Path: src/main/java/com/ksa/myanmarlottery/model/ScheduleItem.java
// @Entity
// @NamedQueries({
// @NamedQuery(
// name = "scheduleItem.findAll",
// query = "from ScheduleItem s"
// )}
// )
// public class ScheduleItem implements Serializable {
//
// @Id
// private String recipientID;
//
// // 500 or 200
// private int lotteryType;
//
// // query by range or specific query
// private int queryType;
//
// @ElementCollection
// @CollectionTable(name="param_table", joinColumns=@JoinColumn(name="recipient_id"))
// @Column(name="params")
// @OrderColumn(name="param_index")
// private List<String> param = new ArrayList<>();
//
// private String originParam;
//
// @Temporal(TemporalType.TIMESTAMP)
// private Date creationDate = new Date();
//
// public ScheduleItem() {}
//
// public ScheduleItem(String recipientID, int lotteryType, int queryType, String originParam) {
// this.recipientID = recipientID;
// this.lotteryType = lotteryType;
// this.queryType = queryType;
// this.originParam = originParam;
// }
//
// public String getOriginParam() {
// return originParam;
// }
//
// public void setOriginParam(String originParam) {
// this.originParam = originParam;
// }
//
// public String getRecipientID() {
// return recipientID;
// }
//
// public void setRecipientID(String recipientID) {
// this.recipientID = recipientID;
// }
//
// public int getLotteryType() {
// return lotteryType;
// }
//
// public void setLotteryType(int lotteryType) {
// this.lotteryType = lotteryType;
// }
//
// public int getQueryType() {
// return queryType;
// }
//
// public void setQueryType(int queryType) {
// this.queryType = queryType;
// }
//
// public List<String> getParam() {
// return param;
// }
//
// public void setParam(List<String> param) {
// this.param = param;
// }
//
// public Date getCreationDate() {
// return creationDate;
// }
//
// public void setCreationDate(Date creationDate) {
// this.creationDate = creationDate;
// }
//
// }
//
// Path: src/main/java/com/ksa/myanmarlottery/repository/ResultRepository.java
// public interface ResultRepository {
// Result insert(Result result);
// void deleteByType(int type);
//
// /**
// *
// * @param minIndex
// * @param maxIndex
// * @param points
// * @param type
// * @return
// */
// public List<Prize> findPrizeByCode(int minIndex, int maxIndex, List<Integer> points, int type);
//
// /**
// *
// * @param codeIndex
// * @param startPoint
// * @param endPoint
// * @param startFivePt
// * @param endFivePt
// * @param startFourPt
// * @param endFourPt
// * @param startThreePt
// * @param endThreePt
// * @param startTwoPt
// * @param endTwoPt
// * @param type
// * @return
// */
// public List<Prize> findPrizeByPoints(int codeIndex, int startPoint, int endPoint,
// int startFivePt, int endFivePt, int startFourPt,
// int endFourPt, int startThreePt, int endThreePt,
// int startTwoPt, int endTwoPt, int type);
//
// public Result findResultByType(int type);
// /**
// * find prize on latest result by codeNo and type
// * @param codePoints
// * @param type
// * @return
// */
// public List<Prize> findPrizeByResultType(Map<String,List<Integer>> codePoints, int type);
//
// /**
// * find only latest result information WITHOUT prize list.
// * @param type
// * @return
// */
// public Result findLatestResultSummary(int type);
// }
//
// Path: src/main/java/com/ksa/myanmarlottery/repository/ScheduleRepository.java
// public interface ScheduleRepository {
// List<ScheduleItem> findAll();
// ScheduleItem insertOrUpdateItem(ScheduleItem item);
// ScheduleItem findItemByID(String senderID);
// void deleteItem(String id);
// }
| import com.ksa.myanmarlottery.model.ScheduleItem;
import com.ksa.myanmarlottery.repository.ResultRepository;
import com.ksa.myanmarlottery.repository.ScheduleRepository;
import java.util.List;
import org.junit.Assert;
import static org.junit.Assert.*;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase;
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.test.context.junit4.SpringRunner; | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.ksa.myanmarlottery.repo;
/**
*
* @author Kyawswa
*/
@Ignore
@RunWith(SpringRunner.class)
@DataJpaTest
@ComponentScan({"com.ksa.myanmarlottery"})
@AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE)
public class ScheduleRepositoryTest {
@Autowired
private ScheduleRepository repository;
@Test
public void testInsert() { | // Path: src/main/java/com/ksa/myanmarlottery/model/ScheduleItem.java
// @Entity
// @NamedQueries({
// @NamedQuery(
// name = "scheduleItem.findAll",
// query = "from ScheduleItem s"
// )}
// )
// public class ScheduleItem implements Serializable {
//
// @Id
// private String recipientID;
//
// // 500 or 200
// private int lotteryType;
//
// // query by range or specific query
// private int queryType;
//
// @ElementCollection
// @CollectionTable(name="param_table", joinColumns=@JoinColumn(name="recipient_id"))
// @Column(name="params")
// @OrderColumn(name="param_index")
// private List<String> param = new ArrayList<>();
//
// private String originParam;
//
// @Temporal(TemporalType.TIMESTAMP)
// private Date creationDate = new Date();
//
// public ScheduleItem() {}
//
// public ScheduleItem(String recipientID, int lotteryType, int queryType, String originParam) {
// this.recipientID = recipientID;
// this.lotteryType = lotteryType;
// this.queryType = queryType;
// this.originParam = originParam;
// }
//
// public String getOriginParam() {
// return originParam;
// }
//
// public void setOriginParam(String originParam) {
// this.originParam = originParam;
// }
//
// public String getRecipientID() {
// return recipientID;
// }
//
// public void setRecipientID(String recipientID) {
// this.recipientID = recipientID;
// }
//
// public int getLotteryType() {
// return lotteryType;
// }
//
// public void setLotteryType(int lotteryType) {
// this.lotteryType = lotteryType;
// }
//
// public int getQueryType() {
// return queryType;
// }
//
// public void setQueryType(int queryType) {
// this.queryType = queryType;
// }
//
// public List<String> getParam() {
// return param;
// }
//
// public void setParam(List<String> param) {
// this.param = param;
// }
//
// public Date getCreationDate() {
// return creationDate;
// }
//
// public void setCreationDate(Date creationDate) {
// this.creationDate = creationDate;
// }
//
// }
//
// Path: src/main/java/com/ksa/myanmarlottery/repository/ResultRepository.java
// public interface ResultRepository {
// Result insert(Result result);
// void deleteByType(int type);
//
// /**
// *
// * @param minIndex
// * @param maxIndex
// * @param points
// * @param type
// * @return
// */
// public List<Prize> findPrizeByCode(int minIndex, int maxIndex, List<Integer> points, int type);
//
// /**
// *
// * @param codeIndex
// * @param startPoint
// * @param endPoint
// * @param startFivePt
// * @param endFivePt
// * @param startFourPt
// * @param endFourPt
// * @param startThreePt
// * @param endThreePt
// * @param startTwoPt
// * @param endTwoPt
// * @param type
// * @return
// */
// public List<Prize> findPrizeByPoints(int codeIndex, int startPoint, int endPoint,
// int startFivePt, int endFivePt, int startFourPt,
// int endFourPt, int startThreePt, int endThreePt,
// int startTwoPt, int endTwoPt, int type);
//
// public Result findResultByType(int type);
// /**
// * find prize on latest result by codeNo and type
// * @param codePoints
// * @param type
// * @return
// */
// public List<Prize> findPrizeByResultType(Map<String,List<Integer>> codePoints, int type);
//
// /**
// * find only latest result information WITHOUT prize list.
// * @param type
// * @return
// */
// public Result findLatestResultSummary(int type);
// }
//
// Path: src/main/java/com/ksa/myanmarlottery/repository/ScheduleRepository.java
// public interface ScheduleRepository {
// List<ScheduleItem> findAll();
// ScheduleItem insertOrUpdateItem(ScheduleItem item);
// ScheduleItem findItemByID(String senderID);
// void deleteItem(String id);
// }
// Path: src/test/java/com/ksa/myanmarlottery/repo/ScheduleRepositoryTest.java
import com.ksa.myanmarlottery.model.ScheduleItem;
import com.ksa.myanmarlottery.repository.ResultRepository;
import com.ksa.myanmarlottery.repository.ScheduleRepository;
import java.util.List;
import org.junit.Assert;
import static org.junit.Assert.*;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase;
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.test.context.junit4.SpringRunner;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.ksa.myanmarlottery.repo;
/**
*
* @author Kyawswa
*/
@Ignore
@RunWith(SpringRunner.class)
@DataJpaTest
@ComponentScan({"com.ksa.myanmarlottery"})
@AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE)
public class ScheduleRepositoryTest {
@Autowired
private ScheduleRepository repository;
@Test
public void testInsert() { | ScheduleItem item = new ScheduleItem("01", 1, 1, "200 u 123456"); |
lukaspili/Mortar-architect | commons/src/main/java/architect/commons/transition/FadeModalTransition.java | // Path: architect/src/main/java/architect/ViewTransitionDirection.java
// public enum ViewTransitionDirection {
// FORWARD, BACKWARD, REPLACE
// }
| import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.view.View;
import architect.ViewTransitionDirection; | package architect.commons.transition;
/**
* @author Lukasz Piliszczuk - [email protected]
*/
public class FadeModalTransition extends ModalTransition {
protected boolean hideExitView;
public FadeModalTransition() {
}
public FadeModalTransition(Config config) {
super(config);
}
/**
* @param hideExitView should the transition hide the exit view?
*/
public FadeModalTransition(boolean hideExitView) {
this.hideExitView = hideExitView;
}
/**
* @param hideExitView should the transition hide the exit view?
*/
public FadeModalTransition(boolean hideExitView, Config config) {
super(config);
this.hideExitView = hideExitView;
}
@Override | // Path: architect/src/main/java/architect/ViewTransitionDirection.java
// public enum ViewTransitionDirection {
// FORWARD, BACKWARD, REPLACE
// }
// Path: commons/src/main/java/architect/commons/transition/FadeModalTransition.java
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.view.View;
import architect.ViewTransitionDirection;
package architect.commons.transition;
/**
* @author Lukasz Piliszczuk - [email protected]
*/
public class FadeModalTransition extends ModalTransition {
protected boolean hideExitView;
public FadeModalTransition() {
}
public FadeModalTransition(Config config) {
super(config);
}
/**
* @param hideExitView should the transition hide the exit view?
*/
public FadeModalTransition(boolean hideExitView) {
this.hideExitView = hideExitView;
}
/**
* @param hideExitView should the transition hide the exit view?
*/
public FadeModalTransition(boolean hideExitView, Config config) {
super(config);
this.hideExitView = hideExitView;
}
@Override | public void transition(View enterView, View exitView, ViewTransitionDirection direction, AnimatorSet set) { |
lukaspili/Mortar-architect | commons/src/main/java/architect/commons/view/StackedContainer.java | // Path: architect/src/main/java/architect/Stackable.java
// public interface Stackable {
//
// void configureScope(MortarScope.Builder builder, MortarScope parentScope);
// }
| import android.content.Context;
import architect.Stackable; | package architect.commons.view;
/**
* @author Lukasz Piliszczuk - [email protected]
*/
public interface StackedContainer {
String getStackableIdentifier();
| // Path: architect/src/main/java/architect/Stackable.java
// public interface Stackable {
//
// void configureScope(MortarScope.Builder builder, MortarScope parentScope);
// }
// Path: commons/src/main/java/architect/commons/view/StackedContainer.java
import android.content.Context;
import architect.Stackable;
package architect.commons.view;
/**
* @author Lukasz Piliszczuk - [email protected]
*/
public interface StackedContainer {
String getStackableIdentifier();
| Stackable getStackable(); |
lukaspili/Mortar-architect | app/src/main/java/com/mortarnav/presenter/HomeNestedPresenter.java | // Path: app/src/main/java/com/mortarnav/stackable/HomeStackable.java
// @Parcel(parcelsIndex = false)
// public class HomeStackable implements StackablePath {
//
// String name;
//
// @ParcelConstructor
// public HomeStackable(String name) {
// this.name = name;
// }
//
// @Override
// public View createView(Context context, ViewGroup parent) {
// return new HomeView(context);
// }
//
// @Override
// public void configureScope(MortarScope.Builder builder, MortarScope parentScope) {
// builder.withService(DaggerService.SERVICE_NAME, DaggerHomeStackable_Component.builder()
// .mainActivityComponent(parentScope.<MainActivityComponent>getService(DaggerService.SERVICE_NAME))
// .module(new Module())
// .build());
// }
//
// @dagger.Module
// public class Module {
//
// @Provides
// @DaggerScope(Component.class)
// public HomePresenter providesPresenter() {
// return new HomePresenter(name);
// }
// }
//
// @dagger.Component(dependencies = MainActivityComponent.class, modules = Module.class)
// @DaggerScope(Component.class)
// public interface Component extends WithActivityDependencies {
//
// void inject(HomeView view);
//
// void inject(HomeAdditionalCustomView view);
// }
// }
//
// Path: app/src/main/java/com/mortarnav/view/HomeNestedView.java
// @AutoInjector(HomeNestedPresenter.class)
// public class HomeNestedView extends StackedLinearLayout<HomeNestedPresenter> {
//
// @Bind(R.id.home_sub_random)
// public TextView randomTextView;
//
// public HomeNestedView(Context context, AttributeSet attrs) {
// super(context, attrs);
// }
//
// @Override
// public Stackable getStackable() {
// return new HomeNestedStackable();
// }
//
//
// @Override
// public void initWithContext(Context context) {
// DaggerService.<HomeNestedStackableComponent>get(context).inject(this);
//
// View view = View.inflate(context, R.layout.home_subcontent_view, this);
// ButterKnife.bind(view);
// }
//
// @OnClick
// void click() {
// presenter.click();
// }
// }
| import android.os.Bundle;
import com.mortarnav.DaggerScope;
import com.mortarnav.stackable.HomeStackable;
import com.mortarnav.view.HomeNestedView;
import java.util.Random;
import javax.inject.Inject;
import architect.robot.AutoStackable;
import autodagger.AutoComponent;
import mortar.ViewPresenter;
import timber.log.Timber; | package com.mortarnav.presenter;
/**
* @author Lukasz Piliszczuk - [email protected]
*/
@AutoStackable(
component = @AutoComponent(dependencies = HomeStackable.Component.class)
)
@DaggerScope(HomeNestedPresenter.class) | // Path: app/src/main/java/com/mortarnav/stackable/HomeStackable.java
// @Parcel(parcelsIndex = false)
// public class HomeStackable implements StackablePath {
//
// String name;
//
// @ParcelConstructor
// public HomeStackable(String name) {
// this.name = name;
// }
//
// @Override
// public View createView(Context context, ViewGroup parent) {
// return new HomeView(context);
// }
//
// @Override
// public void configureScope(MortarScope.Builder builder, MortarScope parentScope) {
// builder.withService(DaggerService.SERVICE_NAME, DaggerHomeStackable_Component.builder()
// .mainActivityComponent(parentScope.<MainActivityComponent>getService(DaggerService.SERVICE_NAME))
// .module(new Module())
// .build());
// }
//
// @dagger.Module
// public class Module {
//
// @Provides
// @DaggerScope(Component.class)
// public HomePresenter providesPresenter() {
// return new HomePresenter(name);
// }
// }
//
// @dagger.Component(dependencies = MainActivityComponent.class, modules = Module.class)
// @DaggerScope(Component.class)
// public interface Component extends WithActivityDependencies {
//
// void inject(HomeView view);
//
// void inject(HomeAdditionalCustomView view);
// }
// }
//
// Path: app/src/main/java/com/mortarnav/view/HomeNestedView.java
// @AutoInjector(HomeNestedPresenter.class)
// public class HomeNestedView extends StackedLinearLayout<HomeNestedPresenter> {
//
// @Bind(R.id.home_sub_random)
// public TextView randomTextView;
//
// public HomeNestedView(Context context, AttributeSet attrs) {
// super(context, attrs);
// }
//
// @Override
// public Stackable getStackable() {
// return new HomeNestedStackable();
// }
//
//
// @Override
// public void initWithContext(Context context) {
// DaggerService.<HomeNestedStackableComponent>get(context).inject(this);
//
// View view = View.inflate(context, R.layout.home_subcontent_view, this);
// ButterKnife.bind(view);
// }
//
// @OnClick
// void click() {
// presenter.click();
// }
// }
// Path: app/src/main/java/com/mortarnav/presenter/HomeNestedPresenter.java
import android.os.Bundle;
import com.mortarnav.DaggerScope;
import com.mortarnav.stackable.HomeStackable;
import com.mortarnav.view.HomeNestedView;
import java.util.Random;
import javax.inject.Inject;
import architect.robot.AutoStackable;
import autodagger.AutoComponent;
import mortar.ViewPresenter;
import timber.log.Timber;
package com.mortarnav.presenter;
/**
* @author Lukasz Piliszczuk - [email protected]
*/
@AutoStackable(
component = @AutoComponent(dependencies = HomeStackable.Component.class)
)
@DaggerScope(HomeNestedPresenter.class) | public class HomeNestedPresenter extends ViewPresenter<HomeNestedView> { |
lukaspili/Mortar-architect | app/src/main/java/com/mortarnav/view/HomeDoubleNestedView.java | // Path: app/src/main/java/com/mortarnav/presenter/HomeDoubleNestedPresenter.java
// @AutoStackable(
// component = @AutoComponent(dependencies = HomeNestedPresenter.class)
// )
// @DaggerScope(HomeDoubleNestedPresenter.class)
// public class HomeDoubleNestedPresenter extends ViewPresenter<HomeDoubleNestedView> {
//
//
// }
//
// Path: architect/src/main/java/architect/Stackable.java
// public interface Stackable {
//
// void configureScope(MortarScope.Builder builder, MortarScope parentScope);
// }
| import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import com.mortarnav.R;
import com.mortarnav.presenter.HomeDoubleNestedPresenter;
import com.mortarnav.presenter.stackable.HomeDoubleNestedStackable;
import com.mortarnav.presenter.stackable.HomeDoubleNestedStackableComponent;
import architect.Stackable;
import architect.commons.view.StackedLinearLayout;
import architect.robot.DaggerService;
import autodagger.AutoInjector;
import butterknife.ButterKnife; | package com.mortarnav.view;
/**
* @author Lukasz Piliszczuk - [email protected]
*/
@AutoInjector(HomeDoubleNestedPresenter.class)
public class HomeDoubleNestedView extends StackedLinearLayout<HomeDoubleNestedPresenter> {
public HomeDoubleNestedView(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override | // Path: app/src/main/java/com/mortarnav/presenter/HomeDoubleNestedPresenter.java
// @AutoStackable(
// component = @AutoComponent(dependencies = HomeNestedPresenter.class)
// )
// @DaggerScope(HomeDoubleNestedPresenter.class)
// public class HomeDoubleNestedPresenter extends ViewPresenter<HomeDoubleNestedView> {
//
//
// }
//
// Path: architect/src/main/java/architect/Stackable.java
// public interface Stackable {
//
// void configureScope(MortarScope.Builder builder, MortarScope parentScope);
// }
// Path: app/src/main/java/com/mortarnav/view/HomeDoubleNestedView.java
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import com.mortarnav.R;
import com.mortarnav.presenter.HomeDoubleNestedPresenter;
import com.mortarnav.presenter.stackable.HomeDoubleNestedStackable;
import com.mortarnav.presenter.stackable.HomeDoubleNestedStackableComponent;
import architect.Stackable;
import architect.commons.view.StackedLinearLayout;
import architect.robot.DaggerService;
import autodagger.AutoInjector;
import butterknife.ButterKnife;
package com.mortarnav.view;
/**
* @author Lukasz Piliszczuk - [email protected]
*/
@AutoInjector(HomeDoubleNestedPresenter.class)
public class HomeDoubleNestedView extends StackedLinearLayout<HomeDoubleNestedPresenter> {
public HomeDoubleNestedView(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override | public Stackable getStackable() { |
lukaspili/Mortar-architect | commons/src/main/java/architect/commons/adapter/StackablePagerAdapter.java | // Path: architect/src/main/java/architect/StackFactory.java
// public class StackFactory {
//
// public static Context createContext(Context parentContext, Stackable stackable) {
// return createContext(parentContext, stackable, null);
// }
//
// public static Context createContext(Context parentContext, Stackable stackable, String identifier) {
// Preconditions.checkNotNull(parentContext, "Parent context cannot be null");
// Preconditions.checkNotNull(stackable, "Stackable cannot be null");
//
// MortarScope parentScope = MortarScope.getScope(parentContext);
// Preconditions.checkNotNull(parentScope, "Parent scope cannot be null");
//
// String scopeName = identifier != null ? String.format("%s_%s", stackable.getClass().getName(), identifier) : stackable.getClass().getName();
// MortarScope mortarScope = parentScope.findChild(scopeName);
// if (mortarScope == null) {
// mortarScope = createScope(parentScope, stackable, scopeName);
// }
//
// return mortarScope.createContext(parentContext);
// }
//
// // /**
// // * Create Mortar scope from stack scope
// // */
// // static MortarScope createScope(MortarScope parentScope, Stackable stackable, String scopeName) {
// // MortarScope.Builder scopeBuilder = parentScope.buildChild();
// //
// // StackScope.Services services = stackable.withServices(parentScope);
// // if (services != null && !services.services.isEmpty()) {
// // for (Map.Entry<String, Object> service : services.services.entrySet()) {
// // scopeBuilder.withService(service.getKey(), service.getValue());
// // }
// // }
// //
// // return scopeBuilder.build(scopeName);
// // }
//
// /**
// * Create Mortar scope from stackable
// */
// static MortarScope createScope(MortarScope parentScope, Stackable stackable, String scopeName) {
// MortarScope.Builder scopeBuilder = parentScope.buildChild();
// stackable.configureScope(scopeBuilder, parentScope);
// return scopeBuilder.build(scopeName);
// }
// }
| import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;
import java.util.Arrays;
import java.util.List;
import architect.StackablePath;
import architect.StackFactory;
import mortar.MortarScope; | package architect.commons.adapter;
/**
* @author Lukasz Piliszczuk - [email protected]
*/
public class StackablePagerAdapter extends PagerAdapter {
private final Context context;
private final List<StackablePath> paths;
public StackablePagerAdapter(Context context, StackablePath... paths) {
this(context, Arrays.asList(paths));
}
public StackablePagerAdapter(Context context, List<StackablePath> paths) {
this.context = context;
this.paths = paths;
}
@Override
public int getCount() {
return paths.size();
}
@Override
public Object instantiateItem(ViewGroup container, int position) {
StackablePath path = paths.get(position);
| // Path: architect/src/main/java/architect/StackFactory.java
// public class StackFactory {
//
// public static Context createContext(Context parentContext, Stackable stackable) {
// return createContext(parentContext, stackable, null);
// }
//
// public static Context createContext(Context parentContext, Stackable stackable, String identifier) {
// Preconditions.checkNotNull(parentContext, "Parent context cannot be null");
// Preconditions.checkNotNull(stackable, "Stackable cannot be null");
//
// MortarScope parentScope = MortarScope.getScope(parentContext);
// Preconditions.checkNotNull(parentScope, "Parent scope cannot be null");
//
// String scopeName = identifier != null ? String.format("%s_%s", stackable.getClass().getName(), identifier) : stackable.getClass().getName();
// MortarScope mortarScope = parentScope.findChild(scopeName);
// if (mortarScope == null) {
// mortarScope = createScope(parentScope, stackable, scopeName);
// }
//
// return mortarScope.createContext(parentContext);
// }
//
// // /**
// // * Create Mortar scope from stack scope
// // */
// // static MortarScope createScope(MortarScope parentScope, Stackable stackable, String scopeName) {
// // MortarScope.Builder scopeBuilder = parentScope.buildChild();
// //
// // StackScope.Services services = stackable.withServices(parentScope);
// // if (services != null && !services.services.isEmpty()) {
// // for (Map.Entry<String, Object> service : services.services.entrySet()) {
// // scopeBuilder.withService(service.getKey(), service.getValue());
// // }
// // }
// //
// // return scopeBuilder.build(scopeName);
// // }
//
// /**
// * Create Mortar scope from stackable
// */
// static MortarScope createScope(MortarScope parentScope, Stackable stackable, String scopeName) {
// MortarScope.Builder scopeBuilder = parentScope.buildChild();
// stackable.configureScope(scopeBuilder, parentScope);
// return scopeBuilder.build(scopeName);
// }
// }
// Path: commons/src/main/java/architect/commons/adapter/StackablePagerAdapter.java
import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;
import java.util.Arrays;
import java.util.List;
import architect.StackablePath;
import architect.StackFactory;
import mortar.MortarScope;
package architect.commons.adapter;
/**
* @author Lukasz Piliszczuk - [email protected]
*/
public class StackablePagerAdapter extends PagerAdapter {
private final Context context;
private final List<StackablePath> paths;
public StackablePagerAdapter(Context context, StackablePath... paths) {
this(context, Arrays.asList(paths));
}
public StackablePagerAdapter(Context context, List<StackablePath> paths) {
this.context = context;
this.paths = paths;
}
@Override
public int getCount() {
return paths.size();
}
@Override
public Object instantiateItem(ViewGroup container, int position) {
StackablePath path = paths.get(position);
| Context pageContext = StackFactory.createContext(context, path, String.valueOf(position)); |
lukaspili/Mortar-architect | commons/src/main/java/architect/commons/transition/ModalTransition.java | // Path: architect/src/main/java/architect/ViewTransitionDirection.java
// public enum ViewTransitionDirection {
// FORWARD, BACKWARD, REPLACE
// }
| import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.view.View;
import android.view.animation.AccelerateDecelerateInterpolator;
import architect.ViewTransition;
import architect.ViewTransitionDirection; | package architect.commons.transition;
/**
* @author Lukasz Piliszczuk - [email protected]
*/
public abstract class ModalTransition<T extends View> implements ViewTransition<T, View> {
protected Config config;
public ModalTransition() {
this(new Config().duration(300).interpolator(new AccelerateDecelerateInterpolator()));
}
public ModalTransition(Config config) {
this.config = config;
}
@Override | // Path: architect/src/main/java/architect/ViewTransitionDirection.java
// public enum ViewTransitionDirection {
// FORWARD, BACKWARD, REPLACE
// }
// Path: commons/src/main/java/architect/commons/transition/ModalTransition.java
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.view.View;
import android.view.animation.AccelerateDecelerateInterpolator;
import architect.ViewTransition;
import architect.ViewTransitionDirection;
package architect.commons.transition;
/**
* @author Lukasz Piliszczuk - [email protected]
*/
public abstract class ModalTransition<T extends View> implements ViewTransition<T, View> {
protected Config config;
public ModalTransition() {
this(new Config().duration(300).interpolator(new AccelerateDecelerateInterpolator()));
}
public ModalTransition(Config config) {
this.config = config;
}
@Override | public void transition(final T enterView, final View exitView, ViewTransitionDirection direction, AnimatorSet set) { |
lukaspili/Mortar-architect | app/src/main/java/com/mortarnav/stackable/HomeStackable.java | // Path: app/src/main/java/com/mortarnav/deps/WithActivityDependencies.java
// public interface WithActivityDependencies extends WithAppDependencies {
//
// ToolbarOwner toolbarOwner();
// }
//
// Path: app/src/main/java/com/mortarnav/presenter/HomePresenter.java
// public class HomePresenter extends ViewPresenter<HomeView> implements ReceivesResult<String> {
//
// private static int count = 0;
//
// private final String name;
// private final int random;
//
// public HomePresenter(String name) {
// this.name = name;
// random = new Random().nextInt(100);
// }
//
// @Override
// protected void onLoad(Bundle savedInstanceState) {
// getView().titleTextView.setText(name);
//
// int r = savedInstanceState != null ? savedInstanceState.getInt("random") : random;
// getView().subtitleTextView.setText("Random number: " + r);
// }
//
// @Override
// protected void onSave(Bundle outState) {
// outState.putInt("random", random);
// }
//
// @Override
// public void onReceivedResult(String result) {
// Timber.d("Receive result: %s", result);
// // beware that this is called before onLoad() and getView() returns null here
// }
//
// public void nextHomeClick() {
// Navigator.get(getView()).push(new HomeStackable("Home " + ++count));
// }
//
//
// public void subnavClick() {
// // Navigator.get(getView()).chain(new NavigationChain().back().back());
// Navigator.get(getView()).push(new SubnavStackable());
// }
//
// public void customViewClick() {
// Timber.d("Click from custom view");
// }
//
// public void pagerClick() {
// Navigator.get(getView()).push(new SlidesStackable());
// }
//
// public void showPopupClick() {
// Navigator.get(getView()).show(new MyPopupStackable());
// }
//
// public void replaceNewHomeClick() {
// Navigator.get(getView()).replace(new HomeStackable("Replaced!"));
// }
//
// public void showReturnsResultClick() {
// Navigator.get(getView()).push(new ReturnsResultStackable());
// }
//
// public void backToRootClick() {
// Navigator.get(getView()).backToRoot("Result test back to root");
// // Navigator.get(getView()).chain(new NavigationChain()
// // .backToRoot()
// // .replace(new HomeStackable("REPLACED STACKABLE " + new Random().nextInt(10000))));
// }
//
// public void showTwoPopupsClick() {
// Navigator.get(getView()).show(new MyPopup2Stackable(), new MyPopupStackable());
// }
//
// public void showPopupTwoClick() {
// Navigator.get(getView()).show(new MyPopup2Stackable());
// }
//
// public void setNewStackClick() {
// Navigator.get(getView()).set(new NavigationStack()
// .put(new HomeStackable("NEW STACK 1"))
// .put(new HomeStackable("NEW STACK 2"))
// .put(new SlidesStackable()), ViewTransitionDirection.FORWARD);
// }
// }
//
// Path: app/src/main/java/com/mortarnav/view/HomeAdditionalCustomView.java
// public class HomeAdditionalCustomView extends FrameLayout {
//
// @Inject
// protected HomePresenter presenter;
//
// public HomeAdditionalCustomView(Context context, AttributeSet attrs) {
// super(context, attrs);
//
// DaggerService.<HomeStackable.Component>get(context).inject(this);
//
// View view = View.inflate(context, R.layout.home_additional_custom_view, this);
// ButterKnife.bind(view);
// }
//
// @OnClick
// void onClick() {
// presenter.customViewClick();
// }
//
//
// }
| import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import com.mortarnav.DaggerScope;
import com.mortarnav.MainActivityComponent;
import com.mortarnav.deps.WithActivityDependencies;
import com.mortarnav.presenter.HomePresenter;
import com.mortarnav.view.HomeAdditionalCustomView;
import com.mortarnav.view.HomeView;
import org.parceler.Parcel;
import org.parceler.ParcelConstructor;
import architect.StackablePath;
import architect.robot.DaggerService;
import dagger.Provides;
import mortar.MortarScope; | package com.mortarnav.stackable;
/**
* Manually created StackablePath
* You should rather use @AutoStackable if you can
*
* @author Lukasz Piliszczuk - [email protected]
*/
@Parcel(parcelsIndex = false)
public class HomeStackable implements StackablePath {
String name;
@ParcelConstructor
public HomeStackable(String name) {
this.name = name;
}
@Override
public View createView(Context context, ViewGroup parent) {
return new HomeView(context);
}
@Override
public void configureScope(MortarScope.Builder builder, MortarScope parentScope) {
builder.withService(DaggerService.SERVICE_NAME, DaggerHomeStackable_Component.builder()
.mainActivityComponent(parentScope.<MainActivityComponent>getService(DaggerService.SERVICE_NAME))
.module(new Module())
.build());
}
@dagger.Module
public class Module {
@Provides
@DaggerScope(Component.class) | // Path: app/src/main/java/com/mortarnav/deps/WithActivityDependencies.java
// public interface WithActivityDependencies extends WithAppDependencies {
//
// ToolbarOwner toolbarOwner();
// }
//
// Path: app/src/main/java/com/mortarnav/presenter/HomePresenter.java
// public class HomePresenter extends ViewPresenter<HomeView> implements ReceivesResult<String> {
//
// private static int count = 0;
//
// private final String name;
// private final int random;
//
// public HomePresenter(String name) {
// this.name = name;
// random = new Random().nextInt(100);
// }
//
// @Override
// protected void onLoad(Bundle savedInstanceState) {
// getView().titleTextView.setText(name);
//
// int r = savedInstanceState != null ? savedInstanceState.getInt("random") : random;
// getView().subtitleTextView.setText("Random number: " + r);
// }
//
// @Override
// protected void onSave(Bundle outState) {
// outState.putInt("random", random);
// }
//
// @Override
// public void onReceivedResult(String result) {
// Timber.d("Receive result: %s", result);
// // beware that this is called before onLoad() and getView() returns null here
// }
//
// public void nextHomeClick() {
// Navigator.get(getView()).push(new HomeStackable("Home " + ++count));
// }
//
//
// public void subnavClick() {
// // Navigator.get(getView()).chain(new NavigationChain().back().back());
// Navigator.get(getView()).push(new SubnavStackable());
// }
//
// public void customViewClick() {
// Timber.d("Click from custom view");
// }
//
// public void pagerClick() {
// Navigator.get(getView()).push(new SlidesStackable());
// }
//
// public void showPopupClick() {
// Navigator.get(getView()).show(new MyPopupStackable());
// }
//
// public void replaceNewHomeClick() {
// Navigator.get(getView()).replace(new HomeStackable("Replaced!"));
// }
//
// public void showReturnsResultClick() {
// Navigator.get(getView()).push(new ReturnsResultStackable());
// }
//
// public void backToRootClick() {
// Navigator.get(getView()).backToRoot("Result test back to root");
// // Navigator.get(getView()).chain(new NavigationChain()
// // .backToRoot()
// // .replace(new HomeStackable("REPLACED STACKABLE " + new Random().nextInt(10000))));
// }
//
// public void showTwoPopupsClick() {
// Navigator.get(getView()).show(new MyPopup2Stackable(), new MyPopupStackable());
// }
//
// public void showPopupTwoClick() {
// Navigator.get(getView()).show(new MyPopup2Stackable());
// }
//
// public void setNewStackClick() {
// Navigator.get(getView()).set(new NavigationStack()
// .put(new HomeStackable("NEW STACK 1"))
// .put(new HomeStackable("NEW STACK 2"))
// .put(new SlidesStackable()), ViewTransitionDirection.FORWARD);
// }
// }
//
// Path: app/src/main/java/com/mortarnav/view/HomeAdditionalCustomView.java
// public class HomeAdditionalCustomView extends FrameLayout {
//
// @Inject
// protected HomePresenter presenter;
//
// public HomeAdditionalCustomView(Context context, AttributeSet attrs) {
// super(context, attrs);
//
// DaggerService.<HomeStackable.Component>get(context).inject(this);
//
// View view = View.inflate(context, R.layout.home_additional_custom_view, this);
// ButterKnife.bind(view);
// }
//
// @OnClick
// void onClick() {
// presenter.customViewClick();
// }
//
//
// }
// Path: app/src/main/java/com/mortarnav/stackable/HomeStackable.java
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import com.mortarnav.DaggerScope;
import com.mortarnav.MainActivityComponent;
import com.mortarnav.deps.WithActivityDependencies;
import com.mortarnav.presenter.HomePresenter;
import com.mortarnav.view.HomeAdditionalCustomView;
import com.mortarnav.view.HomeView;
import org.parceler.Parcel;
import org.parceler.ParcelConstructor;
import architect.StackablePath;
import architect.robot.DaggerService;
import dagger.Provides;
import mortar.MortarScope;
package com.mortarnav.stackable;
/**
* Manually created StackablePath
* You should rather use @AutoStackable if you can
*
* @author Lukasz Piliszczuk - [email protected]
*/
@Parcel(parcelsIndex = false)
public class HomeStackable implements StackablePath {
String name;
@ParcelConstructor
public HomeStackable(String name) {
this.name = name;
}
@Override
public View createView(Context context, ViewGroup parent) {
return new HomeView(context);
}
@Override
public void configureScope(MortarScope.Builder builder, MortarScope parentScope) {
builder.withService(DaggerService.SERVICE_NAME, DaggerHomeStackable_Component.builder()
.mainActivityComponent(parentScope.<MainActivityComponent>getService(DaggerService.SERVICE_NAME))
.module(new Module())
.build());
}
@dagger.Module
public class Module {
@Provides
@DaggerScope(Component.class) | public HomePresenter providesPresenter() { |
lukaspili/Mortar-architect | app/src/main/java/com/mortarnav/stackable/HomeStackable.java | // Path: app/src/main/java/com/mortarnav/deps/WithActivityDependencies.java
// public interface WithActivityDependencies extends WithAppDependencies {
//
// ToolbarOwner toolbarOwner();
// }
//
// Path: app/src/main/java/com/mortarnav/presenter/HomePresenter.java
// public class HomePresenter extends ViewPresenter<HomeView> implements ReceivesResult<String> {
//
// private static int count = 0;
//
// private final String name;
// private final int random;
//
// public HomePresenter(String name) {
// this.name = name;
// random = new Random().nextInt(100);
// }
//
// @Override
// protected void onLoad(Bundle savedInstanceState) {
// getView().titleTextView.setText(name);
//
// int r = savedInstanceState != null ? savedInstanceState.getInt("random") : random;
// getView().subtitleTextView.setText("Random number: " + r);
// }
//
// @Override
// protected void onSave(Bundle outState) {
// outState.putInt("random", random);
// }
//
// @Override
// public void onReceivedResult(String result) {
// Timber.d("Receive result: %s", result);
// // beware that this is called before onLoad() and getView() returns null here
// }
//
// public void nextHomeClick() {
// Navigator.get(getView()).push(new HomeStackable("Home " + ++count));
// }
//
//
// public void subnavClick() {
// // Navigator.get(getView()).chain(new NavigationChain().back().back());
// Navigator.get(getView()).push(new SubnavStackable());
// }
//
// public void customViewClick() {
// Timber.d("Click from custom view");
// }
//
// public void pagerClick() {
// Navigator.get(getView()).push(new SlidesStackable());
// }
//
// public void showPopupClick() {
// Navigator.get(getView()).show(new MyPopupStackable());
// }
//
// public void replaceNewHomeClick() {
// Navigator.get(getView()).replace(new HomeStackable("Replaced!"));
// }
//
// public void showReturnsResultClick() {
// Navigator.get(getView()).push(new ReturnsResultStackable());
// }
//
// public void backToRootClick() {
// Navigator.get(getView()).backToRoot("Result test back to root");
// // Navigator.get(getView()).chain(new NavigationChain()
// // .backToRoot()
// // .replace(new HomeStackable("REPLACED STACKABLE " + new Random().nextInt(10000))));
// }
//
// public void showTwoPopupsClick() {
// Navigator.get(getView()).show(new MyPopup2Stackable(), new MyPopupStackable());
// }
//
// public void showPopupTwoClick() {
// Navigator.get(getView()).show(new MyPopup2Stackable());
// }
//
// public void setNewStackClick() {
// Navigator.get(getView()).set(new NavigationStack()
// .put(new HomeStackable("NEW STACK 1"))
// .put(new HomeStackable("NEW STACK 2"))
// .put(new SlidesStackable()), ViewTransitionDirection.FORWARD);
// }
// }
//
// Path: app/src/main/java/com/mortarnav/view/HomeAdditionalCustomView.java
// public class HomeAdditionalCustomView extends FrameLayout {
//
// @Inject
// protected HomePresenter presenter;
//
// public HomeAdditionalCustomView(Context context, AttributeSet attrs) {
// super(context, attrs);
//
// DaggerService.<HomeStackable.Component>get(context).inject(this);
//
// View view = View.inflate(context, R.layout.home_additional_custom_view, this);
// ButterKnife.bind(view);
// }
//
// @OnClick
// void onClick() {
// presenter.customViewClick();
// }
//
//
// }
| import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import com.mortarnav.DaggerScope;
import com.mortarnav.MainActivityComponent;
import com.mortarnav.deps.WithActivityDependencies;
import com.mortarnav.presenter.HomePresenter;
import com.mortarnav.view.HomeAdditionalCustomView;
import com.mortarnav.view.HomeView;
import org.parceler.Parcel;
import org.parceler.ParcelConstructor;
import architect.StackablePath;
import architect.robot.DaggerService;
import dagger.Provides;
import mortar.MortarScope; | package com.mortarnav.stackable;
/**
* Manually created StackablePath
* You should rather use @AutoStackable if you can
*
* @author Lukasz Piliszczuk - [email protected]
*/
@Parcel(parcelsIndex = false)
public class HomeStackable implements StackablePath {
String name;
@ParcelConstructor
public HomeStackable(String name) {
this.name = name;
}
@Override
public View createView(Context context, ViewGroup parent) {
return new HomeView(context);
}
@Override
public void configureScope(MortarScope.Builder builder, MortarScope parentScope) {
builder.withService(DaggerService.SERVICE_NAME, DaggerHomeStackable_Component.builder()
.mainActivityComponent(parentScope.<MainActivityComponent>getService(DaggerService.SERVICE_NAME))
.module(new Module())
.build());
}
@dagger.Module
public class Module {
@Provides
@DaggerScope(Component.class)
public HomePresenter providesPresenter() {
return new HomePresenter(name);
}
}
@dagger.Component(dependencies = MainActivityComponent.class, modules = Module.class)
@DaggerScope(Component.class) | // Path: app/src/main/java/com/mortarnav/deps/WithActivityDependencies.java
// public interface WithActivityDependencies extends WithAppDependencies {
//
// ToolbarOwner toolbarOwner();
// }
//
// Path: app/src/main/java/com/mortarnav/presenter/HomePresenter.java
// public class HomePresenter extends ViewPresenter<HomeView> implements ReceivesResult<String> {
//
// private static int count = 0;
//
// private final String name;
// private final int random;
//
// public HomePresenter(String name) {
// this.name = name;
// random = new Random().nextInt(100);
// }
//
// @Override
// protected void onLoad(Bundle savedInstanceState) {
// getView().titleTextView.setText(name);
//
// int r = savedInstanceState != null ? savedInstanceState.getInt("random") : random;
// getView().subtitleTextView.setText("Random number: " + r);
// }
//
// @Override
// protected void onSave(Bundle outState) {
// outState.putInt("random", random);
// }
//
// @Override
// public void onReceivedResult(String result) {
// Timber.d("Receive result: %s", result);
// // beware that this is called before onLoad() and getView() returns null here
// }
//
// public void nextHomeClick() {
// Navigator.get(getView()).push(new HomeStackable("Home " + ++count));
// }
//
//
// public void subnavClick() {
// // Navigator.get(getView()).chain(new NavigationChain().back().back());
// Navigator.get(getView()).push(new SubnavStackable());
// }
//
// public void customViewClick() {
// Timber.d("Click from custom view");
// }
//
// public void pagerClick() {
// Navigator.get(getView()).push(new SlidesStackable());
// }
//
// public void showPopupClick() {
// Navigator.get(getView()).show(new MyPopupStackable());
// }
//
// public void replaceNewHomeClick() {
// Navigator.get(getView()).replace(new HomeStackable("Replaced!"));
// }
//
// public void showReturnsResultClick() {
// Navigator.get(getView()).push(new ReturnsResultStackable());
// }
//
// public void backToRootClick() {
// Navigator.get(getView()).backToRoot("Result test back to root");
// // Navigator.get(getView()).chain(new NavigationChain()
// // .backToRoot()
// // .replace(new HomeStackable("REPLACED STACKABLE " + new Random().nextInt(10000))));
// }
//
// public void showTwoPopupsClick() {
// Navigator.get(getView()).show(new MyPopup2Stackable(), new MyPopupStackable());
// }
//
// public void showPopupTwoClick() {
// Navigator.get(getView()).show(new MyPopup2Stackable());
// }
//
// public void setNewStackClick() {
// Navigator.get(getView()).set(new NavigationStack()
// .put(new HomeStackable("NEW STACK 1"))
// .put(new HomeStackable("NEW STACK 2"))
// .put(new SlidesStackable()), ViewTransitionDirection.FORWARD);
// }
// }
//
// Path: app/src/main/java/com/mortarnav/view/HomeAdditionalCustomView.java
// public class HomeAdditionalCustomView extends FrameLayout {
//
// @Inject
// protected HomePresenter presenter;
//
// public HomeAdditionalCustomView(Context context, AttributeSet attrs) {
// super(context, attrs);
//
// DaggerService.<HomeStackable.Component>get(context).inject(this);
//
// View view = View.inflate(context, R.layout.home_additional_custom_view, this);
// ButterKnife.bind(view);
// }
//
// @OnClick
// void onClick() {
// presenter.customViewClick();
// }
//
//
// }
// Path: app/src/main/java/com/mortarnav/stackable/HomeStackable.java
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import com.mortarnav.DaggerScope;
import com.mortarnav.MainActivityComponent;
import com.mortarnav.deps.WithActivityDependencies;
import com.mortarnav.presenter.HomePresenter;
import com.mortarnav.view.HomeAdditionalCustomView;
import com.mortarnav.view.HomeView;
import org.parceler.Parcel;
import org.parceler.ParcelConstructor;
import architect.StackablePath;
import architect.robot.DaggerService;
import dagger.Provides;
import mortar.MortarScope;
package com.mortarnav.stackable;
/**
* Manually created StackablePath
* You should rather use @AutoStackable if you can
*
* @author Lukasz Piliszczuk - [email protected]
*/
@Parcel(parcelsIndex = false)
public class HomeStackable implements StackablePath {
String name;
@ParcelConstructor
public HomeStackable(String name) {
this.name = name;
}
@Override
public View createView(Context context, ViewGroup parent) {
return new HomeView(context);
}
@Override
public void configureScope(MortarScope.Builder builder, MortarScope parentScope) {
builder.withService(DaggerService.SERVICE_NAME, DaggerHomeStackable_Component.builder()
.mainActivityComponent(parentScope.<MainActivityComponent>getService(DaggerService.SERVICE_NAME))
.module(new Module())
.build());
}
@dagger.Module
public class Module {
@Provides
@DaggerScope(Component.class)
public HomePresenter providesPresenter() {
return new HomePresenter(name);
}
}
@dagger.Component(dependencies = MainActivityComponent.class, modules = Module.class)
@DaggerScope(Component.class) | public interface Component extends WithActivityDependencies { |
lukaspili/Mortar-architect | app/src/main/java/com/mortarnav/stackable/HomeStackable.java | // Path: app/src/main/java/com/mortarnav/deps/WithActivityDependencies.java
// public interface WithActivityDependencies extends WithAppDependencies {
//
// ToolbarOwner toolbarOwner();
// }
//
// Path: app/src/main/java/com/mortarnav/presenter/HomePresenter.java
// public class HomePresenter extends ViewPresenter<HomeView> implements ReceivesResult<String> {
//
// private static int count = 0;
//
// private final String name;
// private final int random;
//
// public HomePresenter(String name) {
// this.name = name;
// random = new Random().nextInt(100);
// }
//
// @Override
// protected void onLoad(Bundle savedInstanceState) {
// getView().titleTextView.setText(name);
//
// int r = savedInstanceState != null ? savedInstanceState.getInt("random") : random;
// getView().subtitleTextView.setText("Random number: " + r);
// }
//
// @Override
// protected void onSave(Bundle outState) {
// outState.putInt("random", random);
// }
//
// @Override
// public void onReceivedResult(String result) {
// Timber.d("Receive result: %s", result);
// // beware that this is called before onLoad() and getView() returns null here
// }
//
// public void nextHomeClick() {
// Navigator.get(getView()).push(new HomeStackable("Home " + ++count));
// }
//
//
// public void subnavClick() {
// // Navigator.get(getView()).chain(new NavigationChain().back().back());
// Navigator.get(getView()).push(new SubnavStackable());
// }
//
// public void customViewClick() {
// Timber.d("Click from custom view");
// }
//
// public void pagerClick() {
// Navigator.get(getView()).push(new SlidesStackable());
// }
//
// public void showPopupClick() {
// Navigator.get(getView()).show(new MyPopupStackable());
// }
//
// public void replaceNewHomeClick() {
// Navigator.get(getView()).replace(new HomeStackable("Replaced!"));
// }
//
// public void showReturnsResultClick() {
// Navigator.get(getView()).push(new ReturnsResultStackable());
// }
//
// public void backToRootClick() {
// Navigator.get(getView()).backToRoot("Result test back to root");
// // Navigator.get(getView()).chain(new NavigationChain()
// // .backToRoot()
// // .replace(new HomeStackable("REPLACED STACKABLE " + new Random().nextInt(10000))));
// }
//
// public void showTwoPopupsClick() {
// Navigator.get(getView()).show(new MyPopup2Stackable(), new MyPopupStackable());
// }
//
// public void showPopupTwoClick() {
// Navigator.get(getView()).show(new MyPopup2Stackable());
// }
//
// public void setNewStackClick() {
// Navigator.get(getView()).set(new NavigationStack()
// .put(new HomeStackable("NEW STACK 1"))
// .put(new HomeStackable("NEW STACK 2"))
// .put(new SlidesStackable()), ViewTransitionDirection.FORWARD);
// }
// }
//
// Path: app/src/main/java/com/mortarnav/view/HomeAdditionalCustomView.java
// public class HomeAdditionalCustomView extends FrameLayout {
//
// @Inject
// protected HomePresenter presenter;
//
// public HomeAdditionalCustomView(Context context, AttributeSet attrs) {
// super(context, attrs);
//
// DaggerService.<HomeStackable.Component>get(context).inject(this);
//
// View view = View.inflate(context, R.layout.home_additional_custom_view, this);
// ButterKnife.bind(view);
// }
//
// @OnClick
// void onClick() {
// presenter.customViewClick();
// }
//
//
// }
| import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import com.mortarnav.DaggerScope;
import com.mortarnav.MainActivityComponent;
import com.mortarnav.deps.WithActivityDependencies;
import com.mortarnav.presenter.HomePresenter;
import com.mortarnav.view.HomeAdditionalCustomView;
import com.mortarnav.view.HomeView;
import org.parceler.Parcel;
import org.parceler.ParcelConstructor;
import architect.StackablePath;
import architect.robot.DaggerService;
import dagger.Provides;
import mortar.MortarScope; |
@Override
public View createView(Context context, ViewGroup parent) {
return new HomeView(context);
}
@Override
public void configureScope(MortarScope.Builder builder, MortarScope parentScope) {
builder.withService(DaggerService.SERVICE_NAME, DaggerHomeStackable_Component.builder()
.mainActivityComponent(parentScope.<MainActivityComponent>getService(DaggerService.SERVICE_NAME))
.module(new Module())
.build());
}
@dagger.Module
public class Module {
@Provides
@DaggerScope(Component.class)
public HomePresenter providesPresenter() {
return new HomePresenter(name);
}
}
@dagger.Component(dependencies = MainActivityComponent.class, modules = Module.class)
@DaggerScope(Component.class)
public interface Component extends WithActivityDependencies {
void inject(HomeView view);
| // Path: app/src/main/java/com/mortarnav/deps/WithActivityDependencies.java
// public interface WithActivityDependencies extends WithAppDependencies {
//
// ToolbarOwner toolbarOwner();
// }
//
// Path: app/src/main/java/com/mortarnav/presenter/HomePresenter.java
// public class HomePresenter extends ViewPresenter<HomeView> implements ReceivesResult<String> {
//
// private static int count = 0;
//
// private final String name;
// private final int random;
//
// public HomePresenter(String name) {
// this.name = name;
// random = new Random().nextInt(100);
// }
//
// @Override
// protected void onLoad(Bundle savedInstanceState) {
// getView().titleTextView.setText(name);
//
// int r = savedInstanceState != null ? savedInstanceState.getInt("random") : random;
// getView().subtitleTextView.setText("Random number: " + r);
// }
//
// @Override
// protected void onSave(Bundle outState) {
// outState.putInt("random", random);
// }
//
// @Override
// public void onReceivedResult(String result) {
// Timber.d("Receive result: %s", result);
// // beware that this is called before onLoad() and getView() returns null here
// }
//
// public void nextHomeClick() {
// Navigator.get(getView()).push(new HomeStackable("Home " + ++count));
// }
//
//
// public void subnavClick() {
// // Navigator.get(getView()).chain(new NavigationChain().back().back());
// Navigator.get(getView()).push(new SubnavStackable());
// }
//
// public void customViewClick() {
// Timber.d("Click from custom view");
// }
//
// public void pagerClick() {
// Navigator.get(getView()).push(new SlidesStackable());
// }
//
// public void showPopupClick() {
// Navigator.get(getView()).show(new MyPopupStackable());
// }
//
// public void replaceNewHomeClick() {
// Navigator.get(getView()).replace(new HomeStackable("Replaced!"));
// }
//
// public void showReturnsResultClick() {
// Navigator.get(getView()).push(new ReturnsResultStackable());
// }
//
// public void backToRootClick() {
// Navigator.get(getView()).backToRoot("Result test back to root");
// // Navigator.get(getView()).chain(new NavigationChain()
// // .backToRoot()
// // .replace(new HomeStackable("REPLACED STACKABLE " + new Random().nextInt(10000))));
// }
//
// public void showTwoPopupsClick() {
// Navigator.get(getView()).show(new MyPopup2Stackable(), new MyPopupStackable());
// }
//
// public void showPopupTwoClick() {
// Navigator.get(getView()).show(new MyPopup2Stackable());
// }
//
// public void setNewStackClick() {
// Navigator.get(getView()).set(new NavigationStack()
// .put(new HomeStackable("NEW STACK 1"))
// .put(new HomeStackable("NEW STACK 2"))
// .put(new SlidesStackable()), ViewTransitionDirection.FORWARD);
// }
// }
//
// Path: app/src/main/java/com/mortarnav/view/HomeAdditionalCustomView.java
// public class HomeAdditionalCustomView extends FrameLayout {
//
// @Inject
// protected HomePresenter presenter;
//
// public HomeAdditionalCustomView(Context context, AttributeSet attrs) {
// super(context, attrs);
//
// DaggerService.<HomeStackable.Component>get(context).inject(this);
//
// View view = View.inflate(context, R.layout.home_additional_custom_view, this);
// ButterKnife.bind(view);
// }
//
// @OnClick
// void onClick() {
// presenter.customViewClick();
// }
//
//
// }
// Path: app/src/main/java/com/mortarnav/stackable/HomeStackable.java
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import com.mortarnav.DaggerScope;
import com.mortarnav.MainActivityComponent;
import com.mortarnav.deps.WithActivityDependencies;
import com.mortarnav.presenter.HomePresenter;
import com.mortarnav.view.HomeAdditionalCustomView;
import com.mortarnav.view.HomeView;
import org.parceler.Parcel;
import org.parceler.ParcelConstructor;
import architect.StackablePath;
import architect.robot.DaggerService;
import dagger.Provides;
import mortar.MortarScope;
@Override
public View createView(Context context, ViewGroup parent) {
return new HomeView(context);
}
@Override
public void configureScope(MortarScope.Builder builder, MortarScope parentScope) {
builder.withService(DaggerService.SERVICE_NAME, DaggerHomeStackable_Component.builder()
.mainActivityComponent(parentScope.<MainActivityComponent>getService(DaggerService.SERVICE_NAME))
.module(new Module())
.build());
}
@dagger.Module
public class Module {
@Provides
@DaggerScope(Component.class)
public HomePresenter providesPresenter() {
return new HomePresenter(name);
}
}
@dagger.Component(dependencies = MainActivityComponent.class, modules = Module.class)
@DaggerScope(Component.class)
public interface Component extends WithActivityDependencies {
void inject(HomeView view);
| void inject(HomeAdditionalCustomView view); |
lukaspili/Mortar-architect | commons/src/main/java/architect/commons/view/StackedRelativeLayout.java | // Path: architect/src/main/java/architect/StackFactory.java
// public class StackFactory {
//
// public static Context createContext(Context parentContext, Stackable stackable) {
// return createContext(parentContext, stackable, null);
// }
//
// public static Context createContext(Context parentContext, Stackable stackable, String identifier) {
// Preconditions.checkNotNull(parentContext, "Parent context cannot be null");
// Preconditions.checkNotNull(stackable, "Stackable cannot be null");
//
// MortarScope parentScope = MortarScope.getScope(parentContext);
// Preconditions.checkNotNull(parentScope, "Parent scope cannot be null");
//
// String scopeName = identifier != null ? String.format("%s_%s", stackable.getClass().getName(), identifier) : stackable.getClass().getName();
// MortarScope mortarScope = parentScope.findChild(scopeName);
// if (mortarScope == null) {
// mortarScope = createScope(parentScope, stackable, scopeName);
// }
//
// return mortarScope.createContext(parentContext);
// }
//
// // /**
// // * Create Mortar scope from stack scope
// // */
// // static MortarScope createScope(MortarScope parentScope, Stackable stackable, String scopeName) {
// // MortarScope.Builder scopeBuilder = parentScope.buildChild();
// //
// // StackScope.Services services = stackable.withServices(parentScope);
// // if (services != null && !services.services.isEmpty()) {
// // for (Map.Entry<String, Object> service : services.services.entrySet()) {
// // scopeBuilder.withService(service.getKey(), service.getValue());
// // }
// // }
// //
// // return scopeBuilder.build(scopeName);
// // }
//
// /**
// * Create Mortar scope from stackable
// */
// static MortarScope createScope(MortarScope parentScope, Stackable stackable, String scopeName) {
// MortarScope.Builder scopeBuilder = parentScope.buildChild();
// stackable.configureScope(scopeBuilder, parentScope);
// return scopeBuilder.build(scopeName);
// }
// }
| import android.content.Context;
import android.util.AttributeSet;
import architect.StackFactory;
import mortar.ViewPresenter; | package architect.commons.view;
/**
* @author Lukasz Piliszczuk - [email protected]
*/
public abstract class StackedRelativeLayout<T extends ViewPresenter> extends PresentedRelativeLayout<T>
implements StackedContainer {
public StackedRelativeLayout(Context context) {
super(context);
}
public StackedRelativeLayout(Context context, AttributeSet attrs) {
super(context, attrs);
}
public StackedRelativeLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
protected void init(Context context, AttributeSet attrs, int defStyleAttr) { | // Path: architect/src/main/java/architect/StackFactory.java
// public class StackFactory {
//
// public static Context createContext(Context parentContext, Stackable stackable) {
// return createContext(parentContext, stackable, null);
// }
//
// public static Context createContext(Context parentContext, Stackable stackable, String identifier) {
// Preconditions.checkNotNull(parentContext, "Parent context cannot be null");
// Preconditions.checkNotNull(stackable, "Stackable cannot be null");
//
// MortarScope parentScope = MortarScope.getScope(parentContext);
// Preconditions.checkNotNull(parentScope, "Parent scope cannot be null");
//
// String scopeName = identifier != null ? String.format("%s_%s", stackable.getClass().getName(), identifier) : stackable.getClass().getName();
// MortarScope mortarScope = parentScope.findChild(scopeName);
// if (mortarScope == null) {
// mortarScope = createScope(parentScope, stackable, scopeName);
// }
//
// return mortarScope.createContext(parentContext);
// }
//
// // /**
// // * Create Mortar scope from stack scope
// // */
// // static MortarScope createScope(MortarScope parentScope, Stackable stackable, String scopeName) {
// // MortarScope.Builder scopeBuilder = parentScope.buildChild();
// //
// // StackScope.Services services = stackable.withServices(parentScope);
// // if (services != null && !services.services.isEmpty()) {
// // for (Map.Entry<String, Object> service : services.services.entrySet()) {
// // scopeBuilder.withService(service.getKey(), service.getValue());
// // }
// // }
// //
// // return scopeBuilder.build(scopeName);
// // }
//
// /**
// * Create Mortar scope from stackable
// */
// static MortarScope createScope(MortarScope parentScope, Stackable stackable, String scopeName) {
// MortarScope.Builder scopeBuilder = parentScope.buildChild();
// stackable.configureScope(scopeBuilder, parentScope);
// return scopeBuilder.build(scopeName);
// }
// }
// Path: commons/src/main/java/architect/commons/view/StackedRelativeLayout.java
import android.content.Context;
import android.util.AttributeSet;
import architect.StackFactory;
import mortar.ViewPresenter;
package architect.commons.view;
/**
* @author Lukasz Piliszczuk - [email protected]
*/
public abstract class StackedRelativeLayout<T extends ViewPresenter> extends PresentedRelativeLayout<T>
implements StackedContainer {
public StackedRelativeLayout(Context context) {
super(context);
}
public StackedRelativeLayout(Context context, AttributeSet attrs) {
super(context, attrs);
}
public StackedRelativeLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
protected void init(Context context, AttributeSet attrs, int defStyleAttr) { | Context newContext = StackFactory.createContext(context, getStackable(), getStackableIdentifier()); |
lukaspili/Mortar-architect | app/src/main/java/com/mortarnav/view/HomeAdditionalCustomView.java | // Path: app/src/main/java/com/mortarnav/stackable/HomeStackable.java
// @Parcel(parcelsIndex = false)
// public class HomeStackable implements StackablePath {
//
// String name;
//
// @ParcelConstructor
// public HomeStackable(String name) {
// this.name = name;
// }
//
// @Override
// public View createView(Context context, ViewGroup parent) {
// return new HomeView(context);
// }
//
// @Override
// public void configureScope(MortarScope.Builder builder, MortarScope parentScope) {
// builder.withService(DaggerService.SERVICE_NAME, DaggerHomeStackable_Component.builder()
// .mainActivityComponent(parentScope.<MainActivityComponent>getService(DaggerService.SERVICE_NAME))
// .module(new Module())
// .build());
// }
//
// @dagger.Module
// public class Module {
//
// @Provides
// @DaggerScope(Component.class)
// public HomePresenter providesPresenter() {
// return new HomePresenter(name);
// }
// }
//
// @dagger.Component(dependencies = MainActivityComponent.class, modules = Module.class)
// @DaggerScope(Component.class)
// public interface Component extends WithActivityDependencies {
//
// void inject(HomeView view);
//
// void inject(HomeAdditionalCustomView view);
// }
// }
//
// Path: app/src/main/java/com/mortarnav/presenter/HomePresenter.java
// public class HomePresenter extends ViewPresenter<HomeView> implements ReceivesResult<String> {
//
// private static int count = 0;
//
// private final String name;
// private final int random;
//
// public HomePresenter(String name) {
// this.name = name;
// random = new Random().nextInt(100);
// }
//
// @Override
// protected void onLoad(Bundle savedInstanceState) {
// getView().titleTextView.setText(name);
//
// int r = savedInstanceState != null ? savedInstanceState.getInt("random") : random;
// getView().subtitleTextView.setText("Random number: " + r);
// }
//
// @Override
// protected void onSave(Bundle outState) {
// outState.putInt("random", random);
// }
//
// @Override
// public void onReceivedResult(String result) {
// Timber.d("Receive result: %s", result);
// // beware that this is called before onLoad() and getView() returns null here
// }
//
// public void nextHomeClick() {
// Navigator.get(getView()).push(new HomeStackable("Home " + ++count));
// }
//
//
// public void subnavClick() {
// // Navigator.get(getView()).chain(new NavigationChain().back().back());
// Navigator.get(getView()).push(new SubnavStackable());
// }
//
// public void customViewClick() {
// Timber.d("Click from custom view");
// }
//
// public void pagerClick() {
// Navigator.get(getView()).push(new SlidesStackable());
// }
//
// public void showPopupClick() {
// Navigator.get(getView()).show(new MyPopupStackable());
// }
//
// public void replaceNewHomeClick() {
// Navigator.get(getView()).replace(new HomeStackable("Replaced!"));
// }
//
// public void showReturnsResultClick() {
// Navigator.get(getView()).push(new ReturnsResultStackable());
// }
//
// public void backToRootClick() {
// Navigator.get(getView()).backToRoot("Result test back to root");
// // Navigator.get(getView()).chain(new NavigationChain()
// // .backToRoot()
// // .replace(new HomeStackable("REPLACED STACKABLE " + new Random().nextInt(10000))));
// }
//
// public void showTwoPopupsClick() {
// Navigator.get(getView()).show(new MyPopup2Stackable(), new MyPopupStackable());
// }
//
// public void showPopupTwoClick() {
// Navigator.get(getView()).show(new MyPopup2Stackable());
// }
//
// public void setNewStackClick() {
// Navigator.get(getView()).set(new NavigationStack()
// .put(new HomeStackable("NEW STACK 1"))
// .put(new HomeStackable("NEW STACK 2"))
// .put(new SlidesStackable()), ViewTransitionDirection.FORWARD);
// }
// }
| import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.FrameLayout;
import com.mortarnav.R;
import com.mortarnav.stackable.HomeStackable;
import com.mortarnav.presenter.HomePresenter;
import javax.inject.Inject;
import architect.robot.DaggerService;
import butterknife.ButterKnife;
import butterknife.OnClick; | package com.mortarnav.view;
/**
* @author Lukasz Piliszczuk - [email protected]
*/
public class HomeAdditionalCustomView extends FrameLayout {
@Inject | // Path: app/src/main/java/com/mortarnav/stackable/HomeStackable.java
// @Parcel(parcelsIndex = false)
// public class HomeStackable implements StackablePath {
//
// String name;
//
// @ParcelConstructor
// public HomeStackable(String name) {
// this.name = name;
// }
//
// @Override
// public View createView(Context context, ViewGroup parent) {
// return new HomeView(context);
// }
//
// @Override
// public void configureScope(MortarScope.Builder builder, MortarScope parentScope) {
// builder.withService(DaggerService.SERVICE_NAME, DaggerHomeStackable_Component.builder()
// .mainActivityComponent(parentScope.<MainActivityComponent>getService(DaggerService.SERVICE_NAME))
// .module(new Module())
// .build());
// }
//
// @dagger.Module
// public class Module {
//
// @Provides
// @DaggerScope(Component.class)
// public HomePresenter providesPresenter() {
// return new HomePresenter(name);
// }
// }
//
// @dagger.Component(dependencies = MainActivityComponent.class, modules = Module.class)
// @DaggerScope(Component.class)
// public interface Component extends WithActivityDependencies {
//
// void inject(HomeView view);
//
// void inject(HomeAdditionalCustomView view);
// }
// }
//
// Path: app/src/main/java/com/mortarnav/presenter/HomePresenter.java
// public class HomePresenter extends ViewPresenter<HomeView> implements ReceivesResult<String> {
//
// private static int count = 0;
//
// private final String name;
// private final int random;
//
// public HomePresenter(String name) {
// this.name = name;
// random = new Random().nextInt(100);
// }
//
// @Override
// protected void onLoad(Bundle savedInstanceState) {
// getView().titleTextView.setText(name);
//
// int r = savedInstanceState != null ? savedInstanceState.getInt("random") : random;
// getView().subtitleTextView.setText("Random number: " + r);
// }
//
// @Override
// protected void onSave(Bundle outState) {
// outState.putInt("random", random);
// }
//
// @Override
// public void onReceivedResult(String result) {
// Timber.d("Receive result: %s", result);
// // beware that this is called before onLoad() and getView() returns null here
// }
//
// public void nextHomeClick() {
// Navigator.get(getView()).push(new HomeStackable("Home " + ++count));
// }
//
//
// public void subnavClick() {
// // Navigator.get(getView()).chain(new NavigationChain().back().back());
// Navigator.get(getView()).push(new SubnavStackable());
// }
//
// public void customViewClick() {
// Timber.d("Click from custom view");
// }
//
// public void pagerClick() {
// Navigator.get(getView()).push(new SlidesStackable());
// }
//
// public void showPopupClick() {
// Navigator.get(getView()).show(new MyPopupStackable());
// }
//
// public void replaceNewHomeClick() {
// Navigator.get(getView()).replace(new HomeStackable("Replaced!"));
// }
//
// public void showReturnsResultClick() {
// Navigator.get(getView()).push(new ReturnsResultStackable());
// }
//
// public void backToRootClick() {
// Navigator.get(getView()).backToRoot("Result test back to root");
// // Navigator.get(getView()).chain(new NavigationChain()
// // .backToRoot()
// // .replace(new HomeStackable("REPLACED STACKABLE " + new Random().nextInt(10000))));
// }
//
// public void showTwoPopupsClick() {
// Navigator.get(getView()).show(new MyPopup2Stackable(), new MyPopupStackable());
// }
//
// public void showPopupTwoClick() {
// Navigator.get(getView()).show(new MyPopup2Stackable());
// }
//
// public void setNewStackClick() {
// Navigator.get(getView()).set(new NavigationStack()
// .put(new HomeStackable("NEW STACK 1"))
// .put(new HomeStackable("NEW STACK 2"))
// .put(new SlidesStackable()), ViewTransitionDirection.FORWARD);
// }
// }
// Path: app/src/main/java/com/mortarnav/view/HomeAdditionalCustomView.java
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.FrameLayout;
import com.mortarnav.R;
import com.mortarnav.stackable.HomeStackable;
import com.mortarnav.presenter.HomePresenter;
import javax.inject.Inject;
import architect.robot.DaggerService;
import butterknife.ButterKnife;
import butterknife.OnClick;
package com.mortarnav.view;
/**
* @author Lukasz Piliszczuk - [email protected]
*/
public class HomeAdditionalCustomView extends FrameLayout {
@Inject | protected HomePresenter presenter; |
lukaspili/Mortar-architect | app/src/main/java/com/mortarnav/view/HomeAdditionalCustomView.java | // Path: app/src/main/java/com/mortarnav/stackable/HomeStackable.java
// @Parcel(parcelsIndex = false)
// public class HomeStackable implements StackablePath {
//
// String name;
//
// @ParcelConstructor
// public HomeStackable(String name) {
// this.name = name;
// }
//
// @Override
// public View createView(Context context, ViewGroup parent) {
// return new HomeView(context);
// }
//
// @Override
// public void configureScope(MortarScope.Builder builder, MortarScope parentScope) {
// builder.withService(DaggerService.SERVICE_NAME, DaggerHomeStackable_Component.builder()
// .mainActivityComponent(parentScope.<MainActivityComponent>getService(DaggerService.SERVICE_NAME))
// .module(new Module())
// .build());
// }
//
// @dagger.Module
// public class Module {
//
// @Provides
// @DaggerScope(Component.class)
// public HomePresenter providesPresenter() {
// return new HomePresenter(name);
// }
// }
//
// @dagger.Component(dependencies = MainActivityComponent.class, modules = Module.class)
// @DaggerScope(Component.class)
// public interface Component extends WithActivityDependencies {
//
// void inject(HomeView view);
//
// void inject(HomeAdditionalCustomView view);
// }
// }
//
// Path: app/src/main/java/com/mortarnav/presenter/HomePresenter.java
// public class HomePresenter extends ViewPresenter<HomeView> implements ReceivesResult<String> {
//
// private static int count = 0;
//
// private final String name;
// private final int random;
//
// public HomePresenter(String name) {
// this.name = name;
// random = new Random().nextInt(100);
// }
//
// @Override
// protected void onLoad(Bundle savedInstanceState) {
// getView().titleTextView.setText(name);
//
// int r = savedInstanceState != null ? savedInstanceState.getInt("random") : random;
// getView().subtitleTextView.setText("Random number: " + r);
// }
//
// @Override
// protected void onSave(Bundle outState) {
// outState.putInt("random", random);
// }
//
// @Override
// public void onReceivedResult(String result) {
// Timber.d("Receive result: %s", result);
// // beware that this is called before onLoad() and getView() returns null here
// }
//
// public void nextHomeClick() {
// Navigator.get(getView()).push(new HomeStackable("Home " + ++count));
// }
//
//
// public void subnavClick() {
// // Navigator.get(getView()).chain(new NavigationChain().back().back());
// Navigator.get(getView()).push(new SubnavStackable());
// }
//
// public void customViewClick() {
// Timber.d("Click from custom view");
// }
//
// public void pagerClick() {
// Navigator.get(getView()).push(new SlidesStackable());
// }
//
// public void showPopupClick() {
// Navigator.get(getView()).show(new MyPopupStackable());
// }
//
// public void replaceNewHomeClick() {
// Navigator.get(getView()).replace(new HomeStackable("Replaced!"));
// }
//
// public void showReturnsResultClick() {
// Navigator.get(getView()).push(new ReturnsResultStackable());
// }
//
// public void backToRootClick() {
// Navigator.get(getView()).backToRoot("Result test back to root");
// // Navigator.get(getView()).chain(new NavigationChain()
// // .backToRoot()
// // .replace(new HomeStackable("REPLACED STACKABLE " + new Random().nextInt(10000))));
// }
//
// public void showTwoPopupsClick() {
// Navigator.get(getView()).show(new MyPopup2Stackable(), new MyPopupStackable());
// }
//
// public void showPopupTwoClick() {
// Navigator.get(getView()).show(new MyPopup2Stackable());
// }
//
// public void setNewStackClick() {
// Navigator.get(getView()).set(new NavigationStack()
// .put(new HomeStackable("NEW STACK 1"))
// .put(new HomeStackable("NEW STACK 2"))
// .put(new SlidesStackable()), ViewTransitionDirection.FORWARD);
// }
// }
| import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.FrameLayout;
import com.mortarnav.R;
import com.mortarnav.stackable.HomeStackable;
import com.mortarnav.presenter.HomePresenter;
import javax.inject.Inject;
import architect.robot.DaggerService;
import butterknife.ButterKnife;
import butterknife.OnClick; | package com.mortarnav.view;
/**
* @author Lukasz Piliszczuk - [email protected]
*/
public class HomeAdditionalCustomView extends FrameLayout {
@Inject
protected HomePresenter presenter;
public HomeAdditionalCustomView(Context context, AttributeSet attrs) {
super(context, attrs);
| // Path: app/src/main/java/com/mortarnav/stackable/HomeStackable.java
// @Parcel(parcelsIndex = false)
// public class HomeStackable implements StackablePath {
//
// String name;
//
// @ParcelConstructor
// public HomeStackable(String name) {
// this.name = name;
// }
//
// @Override
// public View createView(Context context, ViewGroup parent) {
// return new HomeView(context);
// }
//
// @Override
// public void configureScope(MortarScope.Builder builder, MortarScope parentScope) {
// builder.withService(DaggerService.SERVICE_NAME, DaggerHomeStackable_Component.builder()
// .mainActivityComponent(parentScope.<MainActivityComponent>getService(DaggerService.SERVICE_NAME))
// .module(new Module())
// .build());
// }
//
// @dagger.Module
// public class Module {
//
// @Provides
// @DaggerScope(Component.class)
// public HomePresenter providesPresenter() {
// return new HomePresenter(name);
// }
// }
//
// @dagger.Component(dependencies = MainActivityComponent.class, modules = Module.class)
// @DaggerScope(Component.class)
// public interface Component extends WithActivityDependencies {
//
// void inject(HomeView view);
//
// void inject(HomeAdditionalCustomView view);
// }
// }
//
// Path: app/src/main/java/com/mortarnav/presenter/HomePresenter.java
// public class HomePresenter extends ViewPresenter<HomeView> implements ReceivesResult<String> {
//
// private static int count = 0;
//
// private final String name;
// private final int random;
//
// public HomePresenter(String name) {
// this.name = name;
// random = new Random().nextInt(100);
// }
//
// @Override
// protected void onLoad(Bundle savedInstanceState) {
// getView().titleTextView.setText(name);
//
// int r = savedInstanceState != null ? savedInstanceState.getInt("random") : random;
// getView().subtitleTextView.setText("Random number: " + r);
// }
//
// @Override
// protected void onSave(Bundle outState) {
// outState.putInt("random", random);
// }
//
// @Override
// public void onReceivedResult(String result) {
// Timber.d("Receive result: %s", result);
// // beware that this is called before onLoad() and getView() returns null here
// }
//
// public void nextHomeClick() {
// Navigator.get(getView()).push(new HomeStackable("Home " + ++count));
// }
//
//
// public void subnavClick() {
// // Navigator.get(getView()).chain(new NavigationChain().back().back());
// Navigator.get(getView()).push(new SubnavStackable());
// }
//
// public void customViewClick() {
// Timber.d("Click from custom view");
// }
//
// public void pagerClick() {
// Navigator.get(getView()).push(new SlidesStackable());
// }
//
// public void showPopupClick() {
// Navigator.get(getView()).show(new MyPopupStackable());
// }
//
// public void replaceNewHomeClick() {
// Navigator.get(getView()).replace(new HomeStackable("Replaced!"));
// }
//
// public void showReturnsResultClick() {
// Navigator.get(getView()).push(new ReturnsResultStackable());
// }
//
// public void backToRootClick() {
// Navigator.get(getView()).backToRoot("Result test back to root");
// // Navigator.get(getView()).chain(new NavigationChain()
// // .backToRoot()
// // .replace(new HomeStackable("REPLACED STACKABLE " + new Random().nextInt(10000))));
// }
//
// public void showTwoPopupsClick() {
// Navigator.get(getView()).show(new MyPopup2Stackable(), new MyPopupStackable());
// }
//
// public void showPopupTwoClick() {
// Navigator.get(getView()).show(new MyPopup2Stackable());
// }
//
// public void setNewStackClick() {
// Navigator.get(getView()).set(new NavigationStack()
// .put(new HomeStackable("NEW STACK 1"))
// .put(new HomeStackable("NEW STACK 2"))
// .put(new SlidesStackable()), ViewTransitionDirection.FORWARD);
// }
// }
// Path: app/src/main/java/com/mortarnav/view/HomeAdditionalCustomView.java
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.FrameLayout;
import com.mortarnav.R;
import com.mortarnav.stackable.HomeStackable;
import com.mortarnav.presenter.HomePresenter;
import javax.inject.Inject;
import architect.robot.DaggerService;
import butterknife.ButterKnife;
import butterknife.OnClick;
package com.mortarnav.view;
/**
* @author Lukasz Piliszczuk - [email protected]
*/
public class HomeAdditionalCustomView extends FrameLayout {
@Inject
protected HomePresenter presenter;
public HomeAdditionalCustomView(Context context, AttributeSet attrs) {
super(context, attrs);
| DaggerService.<HomeStackable.Component>get(context).inject(this); |
lukaspili/Mortar-architect | commons/src/main/java/architect/commons/transition/LateralViewTransition.java | // Path: architect/src/main/java/architect/ViewTransitionDirection.java
// public enum ViewTransitionDirection {
// FORWARD, BACKWARD, REPLACE
// }
| import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.view.View;
import android.view.animation.AccelerateDecelerateInterpolator;
import architect.ViewTransition;
import architect.ViewTransitionDirection; | package architect.commons.transition;
/**
* Left / right transition
*
* @author Lukasz Piliszczuk - [email protected]
*/
public class LateralViewTransition implements ViewTransition {
protected Config config;
public LateralViewTransition() {
this(new Config().duration(300).interpolator(new AccelerateDecelerateInterpolator()));
}
public LateralViewTransition(Config config) {
this.config = config;
}
@Override | // Path: architect/src/main/java/architect/ViewTransitionDirection.java
// public enum ViewTransitionDirection {
// FORWARD, BACKWARD, REPLACE
// }
// Path: commons/src/main/java/architect/commons/transition/LateralViewTransition.java
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.view.View;
import android.view.animation.AccelerateDecelerateInterpolator;
import architect.ViewTransition;
import architect.ViewTransitionDirection;
package architect.commons.transition;
/**
* Left / right transition
*
* @author Lukasz Piliszczuk - [email protected]
*/
public class LateralViewTransition implements ViewTransition {
protected Config config;
public LateralViewTransition() {
this(new Config().duration(300).interpolator(new AccelerateDecelerateInterpolator()));
}
public LateralViewTransition(Config config) {
this.config = config;
}
@Override | public void transition(View enterView, View exitView, ViewTransitionDirection direction, AnimatorSet set) { |
lukaspili/Mortar-architect | autopath-compiler/src/main/java/architect/autopath/compiler/composer/PathComposer.java | // Path: autopath-compiler/src/main/java/architect/autopath/compiler/spec/ConstructorSpec.java
// public class ConstructorSpec {
//
// private final List<ParamSpec> fields;
//
// public ConstructorSpec() {
// fields = new LinkedList<>();
// }
//
// public List<ParamSpec> getFields() {
// return fields;
// }
//
// public boolean isDefault() {
// return fields.isEmpty();
// }
// }
| import com.hannesdorfmann.parcelableplease.annotation.ParcelablePlease;
import com.squareup.javapoet.AnnotationSpec;
import com.squareup.javapoet.ArrayTypeName;
import com.squareup.javapoet.ClassName;
import com.squareup.javapoet.FieldSpec;
import com.squareup.javapoet.JavaFile;
import com.squareup.javapoet.MethodSpec;
import com.squareup.javapoet.ParameterizedTypeName;
import com.squareup.javapoet.TypeName;
import com.squareup.javapoet.TypeSpec;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Generated;
import javax.lang.model.element.Modifier;
import architect.autopath.compiler.spec.ConstructorSpec;
import architect.autopath.compiler.spec.ParamSpec;
import architect.autopath.compiler.spec.PathSpec;
import processorworkflow.AbstractComposer; | package architect.autopath.compiler.composer;
/**
* @author Lukasz Piliszczuk - [email protected]
*/
public class PathComposer extends AbstractComposer<PathSpec> {
private static final ClassName NAVIGATIONPATH_CLS = ClassName.get("architect", "StackPath");
private static final ClassName PARCEL_CLS = ClassName.get("android.os", "Parcel");
private static final ClassName PARCEL_CREATOR_CLS = ClassName.get("android.os.Parcelable", "Creator");
private static final ClassName CONTEXT_CLS = ClassName.get("android.content", "Context");
public PathComposer(List<architect.autopath.compiler.spec.PathSpec> specs) {
super(specs);
}
@Override
protected JavaFile compose(PathSpec spec) {
TypeSpec typeSpec = build(spec);
return JavaFile.builder(spec.getClassName().packageName(), typeSpec).build();
}
private TypeSpec build(PathSpec spec) {
StringBuilder constructorParamsStringBuilder = new StringBuilder();
List<FieldSpec> fieldSpecs = new ArrayList<>();
for (ParamSpec paramSpec : spec.getFields()) {
fieldSpecs.add(FieldSpec.builder(paramSpec.getTypeName(), paramSpec.getName()).build());
constructorParamsStringBuilder.append(paramSpec.getName()).append(", ");
}
if (constructorParamsStringBuilder.length() > 0) {
constructorParamsStringBuilder.delete(constructorParamsStringBuilder.length() - 2, constructorParamsStringBuilder.length());
}
String constructorParamsString = constructorParamsStringBuilder.toString();
List<MethodSpec> methodSpecs = new ArrayList<>(); | // Path: autopath-compiler/src/main/java/architect/autopath/compiler/spec/ConstructorSpec.java
// public class ConstructorSpec {
//
// private final List<ParamSpec> fields;
//
// public ConstructorSpec() {
// fields = new LinkedList<>();
// }
//
// public List<ParamSpec> getFields() {
// return fields;
// }
//
// public boolean isDefault() {
// return fields.isEmpty();
// }
// }
// Path: autopath-compiler/src/main/java/architect/autopath/compiler/composer/PathComposer.java
import com.hannesdorfmann.parcelableplease.annotation.ParcelablePlease;
import com.squareup.javapoet.AnnotationSpec;
import com.squareup.javapoet.ArrayTypeName;
import com.squareup.javapoet.ClassName;
import com.squareup.javapoet.FieldSpec;
import com.squareup.javapoet.JavaFile;
import com.squareup.javapoet.MethodSpec;
import com.squareup.javapoet.ParameterizedTypeName;
import com.squareup.javapoet.TypeName;
import com.squareup.javapoet.TypeSpec;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Generated;
import javax.lang.model.element.Modifier;
import architect.autopath.compiler.spec.ConstructorSpec;
import architect.autopath.compiler.spec.ParamSpec;
import architect.autopath.compiler.spec.PathSpec;
import processorworkflow.AbstractComposer;
package architect.autopath.compiler.composer;
/**
* @author Lukasz Piliszczuk - [email protected]
*/
public class PathComposer extends AbstractComposer<PathSpec> {
private static final ClassName NAVIGATIONPATH_CLS = ClassName.get("architect", "StackPath");
private static final ClassName PARCEL_CLS = ClassName.get("android.os", "Parcel");
private static final ClassName PARCEL_CREATOR_CLS = ClassName.get("android.os.Parcelable", "Creator");
private static final ClassName CONTEXT_CLS = ClassName.get("android.content", "Context");
public PathComposer(List<architect.autopath.compiler.spec.PathSpec> specs) {
super(specs);
}
@Override
protected JavaFile compose(PathSpec spec) {
TypeSpec typeSpec = build(spec);
return JavaFile.builder(spec.getClassName().packageName(), typeSpec).build();
}
private TypeSpec build(PathSpec spec) {
StringBuilder constructorParamsStringBuilder = new StringBuilder();
List<FieldSpec> fieldSpecs = new ArrayList<>();
for (ParamSpec paramSpec : spec.getFields()) {
fieldSpecs.add(FieldSpec.builder(paramSpec.getTypeName(), paramSpec.getName()).build());
constructorParamsStringBuilder.append(paramSpec.getName()).append(", ");
}
if (constructorParamsStringBuilder.length() > 0) {
constructorParamsStringBuilder.delete(constructorParamsStringBuilder.length() - 2, constructorParamsStringBuilder.length());
}
String constructorParamsString = constructorParamsStringBuilder.toString();
List<MethodSpec> methodSpecs = new ArrayList<>(); | for (ConstructorSpec constructorSpec : spec.getConstructors()) { |
lukaspili/Mortar-architect | app/src/main/java/com/mortarnav/view/HomeNestedView.java | // Path: app/src/main/java/com/mortarnav/presenter/HomeNestedPresenter.java
// @AutoStackable(
// component = @AutoComponent(dependencies = HomeStackable.Component.class)
// )
// @DaggerScope(HomeNestedPresenter.class)
// public class HomeNestedPresenter extends ViewPresenter<HomeNestedView> {
//
// private final int random;
//
// @Inject
// public HomeNestedPresenter() {
// random = new Random().nextInt(100);
// }
//
// @Override
// protected void onLoad(Bundle savedInstanceState) {
// int r = savedInstanceState != null ? savedInstanceState.getInt("random") : random;
// getView().randomTextView.setText("Random " + r);
// }
//
// @Override
// protected void onSave(Bundle outState) {
// outState.putInt("random", random);
// }
//
// public void click() {
// Timber.d("Clicked on home subcontent");
// }
// }
//
// Path: architect/src/main/java/architect/Stackable.java
// public interface Stackable {
//
// void configureScope(MortarScope.Builder builder, MortarScope parentScope);
// }
| import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.TextView;
import com.mortarnav.R;
import com.mortarnav.presenter.HomeNestedPresenter;
import com.mortarnav.presenter.stackable.HomeNestedStackable;
import com.mortarnav.presenter.stackable.HomeNestedStackableComponent;
import architect.Stackable;
import architect.commons.view.StackedLinearLayout;
import architect.robot.DaggerService;
import autodagger.AutoInjector;
import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick; | package com.mortarnav.view;
/**
* @author Lukasz Piliszczuk - [email protected]
*/
@AutoInjector(HomeNestedPresenter.class)
public class HomeNestedView extends StackedLinearLayout<HomeNestedPresenter> {
@Bind(R.id.home_sub_random)
public TextView randomTextView;
public HomeNestedView(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override | // Path: app/src/main/java/com/mortarnav/presenter/HomeNestedPresenter.java
// @AutoStackable(
// component = @AutoComponent(dependencies = HomeStackable.Component.class)
// )
// @DaggerScope(HomeNestedPresenter.class)
// public class HomeNestedPresenter extends ViewPresenter<HomeNestedView> {
//
// private final int random;
//
// @Inject
// public HomeNestedPresenter() {
// random = new Random().nextInt(100);
// }
//
// @Override
// protected void onLoad(Bundle savedInstanceState) {
// int r = savedInstanceState != null ? savedInstanceState.getInt("random") : random;
// getView().randomTextView.setText("Random " + r);
// }
//
// @Override
// protected void onSave(Bundle outState) {
// outState.putInt("random", random);
// }
//
// public void click() {
// Timber.d("Clicked on home subcontent");
// }
// }
//
// Path: architect/src/main/java/architect/Stackable.java
// public interface Stackable {
//
// void configureScope(MortarScope.Builder builder, MortarScope parentScope);
// }
// Path: app/src/main/java/com/mortarnav/view/HomeNestedView.java
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.TextView;
import com.mortarnav.R;
import com.mortarnav.presenter.HomeNestedPresenter;
import com.mortarnav.presenter.stackable.HomeNestedStackable;
import com.mortarnav.presenter.stackable.HomeNestedStackableComponent;
import architect.Stackable;
import architect.commons.view.StackedLinearLayout;
import architect.robot.DaggerService;
import autodagger.AutoInjector;
import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;
package com.mortarnav.view;
/**
* @author Lukasz Piliszczuk - [email protected]
*/
@AutoInjector(HomeNestedPresenter.class)
public class HomeNestedView extends StackedLinearLayout<HomeNestedPresenter> {
@Bind(R.id.home_sub_random)
public TextView randomTextView;
public HomeNestedView(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override | public Stackable getStackable() { |
lukaspili/Mortar-architect | app/src/main/java/com/mortarnav/presenter/SlidesPresenter.java | // Path: app/src/main/java/com/mortarnav/view/SlidesView.java
// @AutoInjector(SlidesPresenter.class)
// public class SlidesView extends PresentedLinearLayout<SlidesPresenter> implements HandlesViewTransition {
//
// @Inject
// protected ToolbarOwner toolbarOwner;
//
// @Bind(R.id.pager)
// public ViewPager viewPager;
//
// public StackablePagerAdapter adapter;
//
// public SlidesView(Context context) {
// super(context);
//
// DaggerService.<SlidesStackableComponent>get(context).inject(this);
//
// View view = View.inflate(context, R.layout.slides_view, this);
// ButterKnife.bind(view);
// }
//
// public void show(SlidePageStackable[] pages) {
// adapter = new StackablePagerAdapter(getContext(), pages);
// viewPager.setAdapter(adapter);
// }
//
// @Override
// public void onViewTransition(AnimatorSet set) {
// if (set != null) {
// set.addListener(new AnimatorListenerAdapter() {
// @Override
// public void onAnimationEnd(Animator animation) {
// toolbarOwner.hide();
// }
// });
// Animator animator = toolbarOwner.animateHide();
// if (animator != null) {
// set.play(animator);
// }
// } else {
// toolbarOwner.hide();
// }
// }
// }
| import android.os.Bundle;
import com.mortarnav.DaggerScope;
import com.mortarnav.StandardAutoComponent;
import com.mortarnav.presenter.stackable.SlidePageStackable;
import com.mortarnav.view.SlidesView;
import architect.robot.AutoStackable;
import autodagger.AutoComponent;
import mortar.ViewPresenter; | package com.mortarnav.presenter;
/**
* @author Lukasz Piliszczuk - [email protected]
*/
@AutoStackable(
component = @AutoComponent(includes = StandardAutoComponent.class), | // Path: app/src/main/java/com/mortarnav/view/SlidesView.java
// @AutoInjector(SlidesPresenter.class)
// public class SlidesView extends PresentedLinearLayout<SlidesPresenter> implements HandlesViewTransition {
//
// @Inject
// protected ToolbarOwner toolbarOwner;
//
// @Bind(R.id.pager)
// public ViewPager viewPager;
//
// public StackablePagerAdapter adapter;
//
// public SlidesView(Context context) {
// super(context);
//
// DaggerService.<SlidesStackableComponent>get(context).inject(this);
//
// View view = View.inflate(context, R.layout.slides_view, this);
// ButterKnife.bind(view);
// }
//
// public void show(SlidePageStackable[] pages) {
// adapter = new StackablePagerAdapter(getContext(), pages);
// viewPager.setAdapter(adapter);
// }
//
// @Override
// public void onViewTransition(AnimatorSet set) {
// if (set != null) {
// set.addListener(new AnimatorListenerAdapter() {
// @Override
// public void onAnimationEnd(Animator animation) {
// toolbarOwner.hide();
// }
// });
// Animator animator = toolbarOwner.animateHide();
// if (animator != null) {
// set.play(animator);
// }
// } else {
// toolbarOwner.hide();
// }
// }
// }
// Path: app/src/main/java/com/mortarnav/presenter/SlidesPresenter.java
import android.os.Bundle;
import com.mortarnav.DaggerScope;
import com.mortarnav.StandardAutoComponent;
import com.mortarnav.presenter.stackable.SlidePageStackable;
import com.mortarnav.view.SlidesView;
import architect.robot.AutoStackable;
import autodagger.AutoComponent;
import mortar.ViewPresenter;
package com.mortarnav.presenter;
/**
* @author Lukasz Piliszczuk - [email protected]
*/
@AutoStackable(
component = @AutoComponent(includes = StandardAutoComponent.class), | pathWithView = SlidesView.class |
lukaspili/Mortar-architect | app/src/main/java/com/mortarnav/view/MyPopup2View.java | // Path: app/src/main/java/com/mortarnav/ToolbarOwner.java
// @AutoInjector(MainActivity.class)
// @DaggerScope(MainActivity.class)
// public class ToolbarOwner extends Presenter<Toolbar> {
//
// @Inject
// public ToolbarOwner() {
// }
//
// public Animator animateHide() {
// if (!hasView()) return null;
// if (getView().getVisibility() == View.GONE) {
// return null;
// }
// return ObjectAnimator.ofFloat(getView(), View.Y, 0, -getView().getHeight());
// }
//
// public Animator animateShow() {
// if (!hasView()) return null;
// if (getView().getVisibility() == View.VISIBLE) {
// return null;
// }
// return ObjectAnimator.ofFloat(getView(), View.Y, -getView().getHeight(), 0);
// }
//
// public void hide() {
// if (!hasView()) return;
// getView().setVisibility(View.GONE);
// }
//
// public void show() {
// if (!hasView()) return;
// getView().setVisibility(View.VISIBLE);
// }
//
// public void setTitle(String title) {
// if (!hasView()) return;
// getView().setTitle(title);
// }
//
// @Override
// protected BundleService extractBundleService(Toolbar view) {
// return BundleService.getBundleService(view.getContext());
// }
//
//
// }
//
// Path: commons/src/main/java/architect/commons/view/PresentedLinearLayout.java
// public abstract class PresentedLinearLayout<T extends ViewPresenter> extends LinearLayout
// implements HasPresenter<T> {
//
// @Inject
// protected T presenter;
//
// public PresentedLinearLayout(Context context) {
// super(context);
// init(context, null, -1);
// }
//
// public PresentedLinearLayout(Context context, AttributeSet attrs) {
// super(context, attrs);
// init(context, attrs, -1);
// }
//
// public PresentedLinearLayout(Context context, AttributeSet attrs, int defStyleAttr) {
// super(context, attrs, defStyleAttr);
// init(context, attrs, defStyleAttr);
// }
//
// protected void init(Context context, AttributeSet attrs, int defStyleAttr) {
//
// }
//
// @Override
// protected void onAttachedToWindow() {
// super.onAttachedToWindow();
// presenter.takeView(this);
// }
//
// @Override
// protected void onDetachedFromWindow() {
// presenter.dropView(this);
// super.onDetachedFromWindow();
// }
//
// @Override
// public T getPresenter() {
// return presenter;
// }
// }
//
// Path: architect/src/main/java/architect/view/HandlesViewTransition.java
// public interface HandlesViewTransition {
//
// /**
// * Will receive the following view transition
// *
// * Hook that allows to add additional animations to the view transition animator set
// * Do not start the animator set yourself
// *
// * The animator set can be null, if the view is presented without animation
// * It happens at least during config changes (rotation)
// */
// void onViewTransition(AnimatorSet set);
// }
| import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.content.Context;
import android.view.View;
import com.mortarnav.R;
import com.mortarnav.ToolbarOwner;
import com.mortarnav.presenter.MyPopup2Presenter;
import com.mortarnav.presenter.stackable.MyPopup2StackableComponent;
import javax.inject.Inject;
import architect.commons.view.PresentedLinearLayout;
import architect.robot.DaggerService;
import architect.view.HandlesViewTransition;
import autodagger.AutoInjector;
import butterknife.ButterKnife;
import butterknife.OnClick; | package com.mortarnav.view;
/**
* @author Lukasz Piliszczuk - [email protected]
*/
@AutoInjector(MyPopup2Presenter.class)
public class MyPopup2View extends PresentedLinearLayout<MyPopup2Presenter> implements HandlesViewTransition {
@Inject | // Path: app/src/main/java/com/mortarnav/ToolbarOwner.java
// @AutoInjector(MainActivity.class)
// @DaggerScope(MainActivity.class)
// public class ToolbarOwner extends Presenter<Toolbar> {
//
// @Inject
// public ToolbarOwner() {
// }
//
// public Animator animateHide() {
// if (!hasView()) return null;
// if (getView().getVisibility() == View.GONE) {
// return null;
// }
// return ObjectAnimator.ofFloat(getView(), View.Y, 0, -getView().getHeight());
// }
//
// public Animator animateShow() {
// if (!hasView()) return null;
// if (getView().getVisibility() == View.VISIBLE) {
// return null;
// }
// return ObjectAnimator.ofFloat(getView(), View.Y, -getView().getHeight(), 0);
// }
//
// public void hide() {
// if (!hasView()) return;
// getView().setVisibility(View.GONE);
// }
//
// public void show() {
// if (!hasView()) return;
// getView().setVisibility(View.VISIBLE);
// }
//
// public void setTitle(String title) {
// if (!hasView()) return;
// getView().setTitle(title);
// }
//
// @Override
// protected BundleService extractBundleService(Toolbar view) {
// return BundleService.getBundleService(view.getContext());
// }
//
//
// }
//
// Path: commons/src/main/java/architect/commons/view/PresentedLinearLayout.java
// public abstract class PresentedLinearLayout<T extends ViewPresenter> extends LinearLayout
// implements HasPresenter<T> {
//
// @Inject
// protected T presenter;
//
// public PresentedLinearLayout(Context context) {
// super(context);
// init(context, null, -1);
// }
//
// public PresentedLinearLayout(Context context, AttributeSet attrs) {
// super(context, attrs);
// init(context, attrs, -1);
// }
//
// public PresentedLinearLayout(Context context, AttributeSet attrs, int defStyleAttr) {
// super(context, attrs, defStyleAttr);
// init(context, attrs, defStyleAttr);
// }
//
// protected void init(Context context, AttributeSet attrs, int defStyleAttr) {
//
// }
//
// @Override
// protected void onAttachedToWindow() {
// super.onAttachedToWindow();
// presenter.takeView(this);
// }
//
// @Override
// protected void onDetachedFromWindow() {
// presenter.dropView(this);
// super.onDetachedFromWindow();
// }
//
// @Override
// public T getPresenter() {
// return presenter;
// }
// }
//
// Path: architect/src/main/java/architect/view/HandlesViewTransition.java
// public interface HandlesViewTransition {
//
// /**
// * Will receive the following view transition
// *
// * Hook that allows to add additional animations to the view transition animator set
// * Do not start the animator set yourself
// *
// * The animator set can be null, if the view is presented without animation
// * It happens at least during config changes (rotation)
// */
// void onViewTransition(AnimatorSet set);
// }
// Path: app/src/main/java/com/mortarnav/view/MyPopup2View.java
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.content.Context;
import android.view.View;
import com.mortarnav.R;
import com.mortarnav.ToolbarOwner;
import com.mortarnav.presenter.MyPopup2Presenter;
import com.mortarnav.presenter.stackable.MyPopup2StackableComponent;
import javax.inject.Inject;
import architect.commons.view.PresentedLinearLayout;
import architect.robot.DaggerService;
import architect.view.HandlesViewTransition;
import autodagger.AutoInjector;
import butterknife.ButterKnife;
import butterknife.OnClick;
package com.mortarnav.view;
/**
* @author Lukasz Piliszczuk - [email protected]
*/
@AutoInjector(MyPopup2Presenter.class)
public class MyPopup2View extends PresentedLinearLayout<MyPopup2Presenter> implements HandlesViewTransition {
@Inject | protected ToolbarOwner toolbarOwner; |
lukaspili/Mortar-architect | app/src/main/java/com/mortarnav/stackable/BannerStackable.java | // Path: app/src/main/java/com/mortarnav/MainActivity.java
// @AutoComponent(
// dependencies = App.class,
// superinterfaces = WithActivityDependencies.class
// )
// @AutoInjector
// @DaggerScope(MainActivity.class)
// public class MainActivity extends AppCompatActivity {
//
// private MortarScope scope;
// private Navigator navigator;
//
// @Inject
// protected ToolbarOwner toolbarOwner;
//
// @Bind(R.id.navigator_container)
// protected NavigatorView containerView;
//
// @Bind(R.id.toolbar)
// protected Toolbar toolbar;
//
// @Override
// public Object getSystemService(String name) {
// if (scope != null && scope.hasService(name)) {
// return scope.getService(name);
// }
//
// return super.getSystemService(name);
// }
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setContentView(R.layout.activity_main);
// ButterKnife.bind(this);
//
// toolbar.setTitle("Mortar architect");
// setSupportActionBar(toolbar);
//
// scope = ActivityArchitector.onCreateScope(this, savedInstanceState, new Architected() {
// @Override
// public Navigator createNavigator(MortarScope scope) {
// Navigator navigator = Navigator.create(scope, new Parceler());
// navigator.transitions().register(new TransitionsMapping()
// .byDefault(new LateralViewTransition(new Config().duration(300)))
// .show(MyPopupView.class).withTransition(new FadeModalTransition(new Config().duration(250)))
// .show(MyPopup2View.class).withTransition(new BottomAppearTransition(true, new Config().duration(1000)))
// // .show(SlidesView.class).withTransition(new CustomFullScreenLateralTransition())
// );
// return navigator;
// }
//
// @Override
// public void configureScope(MortarScope.Builder builder, MortarScope parentScope) {
// MainActivityComponent component = DaggerMainActivityComponent.builder()
// .appComponent(parentScope.<AppComponent>getService(DaggerService.SERVICE_NAME))
// .build();
// builder.withService(DaggerService.SERVICE_NAME, component);
// }
// });
//
// DaggerService.<MainActivityComponent>get(this).inject(this);
// toolbarOwner.takeView(toolbar);
//
// // it is usually the best to create the navigator after everything else
// navigator = ActivityArchitector.onCreateNavigator(this, savedInstanceState, containerView, new HomeStackable("Default home path"));
// }
//
// @Override
// protected void onNewIntent(Intent intent) {
// super.onNewIntent(intent);
// navigator.delegate().onNewIntent(intent);
// }
//
// @Override
// protected void onSaveInstanceState(Bundle outState) {
// super.onSaveInstanceState(outState);
// BundleServiceRunner.getBundleServiceRunner(scope).onSaveInstanceState(outState);
// navigator.delegate().onSaveInstanceState(outState);
// }
//
// @Override
// protected void onStart() {
// super.onStart();
// navigator.delegate().onStart();
// }
//
// @Override
// protected void onStop() {
// navigator.delegate().onStop();
// super.onStop();
// }
//
// @Override
// protected void onDestroy() {
// toolbarOwner.dropView(toolbar);
//
// navigator.delegate().onDestroy();
// navigator = null;
//
// if (isFinishing() && scope != null) {
// scope.destroy();
// scope = null;
// }
//
// super.onDestroy();
// }
//
// @Override
// public void onBackPressed() {
// if (navigator.delegate().onBackPressed()) {
// return;
// }
//
// super.onBackPressed();
// }
// }
//
// Path: app/src/main/java/com/mortarnav/presenter/BannerPresenter.java
// @DaggerScope(BannerPresenter.class)
// public class BannerPresenter extends ViewPresenter<BannerView> {
//
// @Inject
// public BannerPresenter() {
//
// }
//
// @Override
// protected void onLoad(Bundle savedInstanceState) {
// super.onLoad(savedInstanceState);
// }
//
// public void click() {
// Timber.d("Clicked on banner!");
// }
// }
//
// Path: architect/src/main/java/architect/NavigatorServices.java
// public class NavigatorServices {
//
// /**
// * Get service from navigator's mortar scope or its parent
// */
// public static <T> T getService(MortarScope scope, String name) {
// Navigator navigator = scope.getService(Navigator.SERVICE_NAME);
// Preconditions.checkNotNull(navigator, "Cannot find navigator in the scope");
//
// return navigator.getScope().getService(name);
// }
// }
//
// Path: architect/src/main/java/architect/Stackable.java
// public interface Stackable {
//
// void configureScope(MortarScope.Builder builder, MortarScope parentScope);
// }
| import com.mortarnav.DaggerScope;
import com.mortarnav.MainActivity;
import com.mortarnav.MainActivityComponent;
import com.mortarnav.presenter.BannerPresenter;
import architect.NavigatorServices;
import architect.Stackable;
import architect.robot.DaggerService;
import autodagger.AutoComponent;
import mortar.MortarScope; | package com.mortarnav.stackable;
/**
* @author Lukasz Piliszczuk - [email protected]
*/
@AutoComponent(
dependencies = MainActivity.class, | // Path: app/src/main/java/com/mortarnav/MainActivity.java
// @AutoComponent(
// dependencies = App.class,
// superinterfaces = WithActivityDependencies.class
// )
// @AutoInjector
// @DaggerScope(MainActivity.class)
// public class MainActivity extends AppCompatActivity {
//
// private MortarScope scope;
// private Navigator navigator;
//
// @Inject
// protected ToolbarOwner toolbarOwner;
//
// @Bind(R.id.navigator_container)
// protected NavigatorView containerView;
//
// @Bind(R.id.toolbar)
// protected Toolbar toolbar;
//
// @Override
// public Object getSystemService(String name) {
// if (scope != null && scope.hasService(name)) {
// return scope.getService(name);
// }
//
// return super.getSystemService(name);
// }
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setContentView(R.layout.activity_main);
// ButterKnife.bind(this);
//
// toolbar.setTitle("Mortar architect");
// setSupportActionBar(toolbar);
//
// scope = ActivityArchitector.onCreateScope(this, savedInstanceState, new Architected() {
// @Override
// public Navigator createNavigator(MortarScope scope) {
// Navigator navigator = Navigator.create(scope, new Parceler());
// navigator.transitions().register(new TransitionsMapping()
// .byDefault(new LateralViewTransition(new Config().duration(300)))
// .show(MyPopupView.class).withTransition(new FadeModalTransition(new Config().duration(250)))
// .show(MyPopup2View.class).withTransition(new BottomAppearTransition(true, new Config().duration(1000)))
// // .show(SlidesView.class).withTransition(new CustomFullScreenLateralTransition())
// );
// return navigator;
// }
//
// @Override
// public void configureScope(MortarScope.Builder builder, MortarScope parentScope) {
// MainActivityComponent component = DaggerMainActivityComponent.builder()
// .appComponent(parentScope.<AppComponent>getService(DaggerService.SERVICE_NAME))
// .build();
// builder.withService(DaggerService.SERVICE_NAME, component);
// }
// });
//
// DaggerService.<MainActivityComponent>get(this).inject(this);
// toolbarOwner.takeView(toolbar);
//
// // it is usually the best to create the navigator after everything else
// navigator = ActivityArchitector.onCreateNavigator(this, savedInstanceState, containerView, new HomeStackable("Default home path"));
// }
//
// @Override
// protected void onNewIntent(Intent intent) {
// super.onNewIntent(intent);
// navigator.delegate().onNewIntent(intent);
// }
//
// @Override
// protected void onSaveInstanceState(Bundle outState) {
// super.onSaveInstanceState(outState);
// BundleServiceRunner.getBundleServiceRunner(scope).onSaveInstanceState(outState);
// navigator.delegate().onSaveInstanceState(outState);
// }
//
// @Override
// protected void onStart() {
// super.onStart();
// navigator.delegate().onStart();
// }
//
// @Override
// protected void onStop() {
// navigator.delegate().onStop();
// super.onStop();
// }
//
// @Override
// protected void onDestroy() {
// toolbarOwner.dropView(toolbar);
//
// navigator.delegate().onDestroy();
// navigator = null;
//
// if (isFinishing() && scope != null) {
// scope.destroy();
// scope = null;
// }
//
// super.onDestroy();
// }
//
// @Override
// public void onBackPressed() {
// if (navigator.delegate().onBackPressed()) {
// return;
// }
//
// super.onBackPressed();
// }
// }
//
// Path: app/src/main/java/com/mortarnav/presenter/BannerPresenter.java
// @DaggerScope(BannerPresenter.class)
// public class BannerPresenter extends ViewPresenter<BannerView> {
//
// @Inject
// public BannerPresenter() {
//
// }
//
// @Override
// protected void onLoad(Bundle savedInstanceState) {
// super.onLoad(savedInstanceState);
// }
//
// public void click() {
// Timber.d("Clicked on banner!");
// }
// }
//
// Path: architect/src/main/java/architect/NavigatorServices.java
// public class NavigatorServices {
//
// /**
// * Get service from navigator's mortar scope or its parent
// */
// public static <T> T getService(MortarScope scope, String name) {
// Navigator navigator = scope.getService(Navigator.SERVICE_NAME);
// Preconditions.checkNotNull(navigator, "Cannot find navigator in the scope");
//
// return navigator.getScope().getService(name);
// }
// }
//
// Path: architect/src/main/java/architect/Stackable.java
// public interface Stackable {
//
// void configureScope(MortarScope.Builder builder, MortarScope parentScope);
// }
// Path: app/src/main/java/com/mortarnav/stackable/BannerStackable.java
import com.mortarnav.DaggerScope;
import com.mortarnav.MainActivity;
import com.mortarnav.MainActivityComponent;
import com.mortarnav.presenter.BannerPresenter;
import architect.NavigatorServices;
import architect.Stackable;
import architect.robot.DaggerService;
import autodagger.AutoComponent;
import mortar.MortarScope;
package com.mortarnav.stackable;
/**
* @author Lukasz Piliszczuk - [email protected]
*/
@AutoComponent(
dependencies = MainActivity.class, | target = BannerPresenter.class) |
lukaspili/Mortar-architect | app/src/main/java/com/mortarnav/stackable/BannerStackable.java | // Path: app/src/main/java/com/mortarnav/MainActivity.java
// @AutoComponent(
// dependencies = App.class,
// superinterfaces = WithActivityDependencies.class
// )
// @AutoInjector
// @DaggerScope(MainActivity.class)
// public class MainActivity extends AppCompatActivity {
//
// private MortarScope scope;
// private Navigator navigator;
//
// @Inject
// protected ToolbarOwner toolbarOwner;
//
// @Bind(R.id.navigator_container)
// protected NavigatorView containerView;
//
// @Bind(R.id.toolbar)
// protected Toolbar toolbar;
//
// @Override
// public Object getSystemService(String name) {
// if (scope != null && scope.hasService(name)) {
// return scope.getService(name);
// }
//
// return super.getSystemService(name);
// }
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setContentView(R.layout.activity_main);
// ButterKnife.bind(this);
//
// toolbar.setTitle("Mortar architect");
// setSupportActionBar(toolbar);
//
// scope = ActivityArchitector.onCreateScope(this, savedInstanceState, new Architected() {
// @Override
// public Navigator createNavigator(MortarScope scope) {
// Navigator navigator = Navigator.create(scope, new Parceler());
// navigator.transitions().register(new TransitionsMapping()
// .byDefault(new LateralViewTransition(new Config().duration(300)))
// .show(MyPopupView.class).withTransition(new FadeModalTransition(new Config().duration(250)))
// .show(MyPopup2View.class).withTransition(new BottomAppearTransition(true, new Config().duration(1000)))
// // .show(SlidesView.class).withTransition(new CustomFullScreenLateralTransition())
// );
// return navigator;
// }
//
// @Override
// public void configureScope(MortarScope.Builder builder, MortarScope parentScope) {
// MainActivityComponent component = DaggerMainActivityComponent.builder()
// .appComponent(parentScope.<AppComponent>getService(DaggerService.SERVICE_NAME))
// .build();
// builder.withService(DaggerService.SERVICE_NAME, component);
// }
// });
//
// DaggerService.<MainActivityComponent>get(this).inject(this);
// toolbarOwner.takeView(toolbar);
//
// // it is usually the best to create the navigator after everything else
// navigator = ActivityArchitector.onCreateNavigator(this, savedInstanceState, containerView, new HomeStackable("Default home path"));
// }
//
// @Override
// protected void onNewIntent(Intent intent) {
// super.onNewIntent(intent);
// navigator.delegate().onNewIntent(intent);
// }
//
// @Override
// protected void onSaveInstanceState(Bundle outState) {
// super.onSaveInstanceState(outState);
// BundleServiceRunner.getBundleServiceRunner(scope).onSaveInstanceState(outState);
// navigator.delegate().onSaveInstanceState(outState);
// }
//
// @Override
// protected void onStart() {
// super.onStart();
// navigator.delegate().onStart();
// }
//
// @Override
// protected void onStop() {
// navigator.delegate().onStop();
// super.onStop();
// }
//
// @Override
// protected void onDestroy() {
// toolbarOwner.dropView(toolbar);
//
// navigator.delegate().onDestroy();
// navigator = null;
//
// if (isFinishing() && scope != null) {
// scope.destroy();
// scope = null;
// }
//
// super.onDestroy();
// }
//
// @Override
// public void onBackPressed() {
// if (navigator.delegate().onBackPressed()) {
// return;
// }
//
// super.onBackPressed();
// }
// }
//
// Path: app/src/main/java/com/mortarnav/presenter/BannerPresenter.java
// @DaggerScope(BannerPresenter.class)
// public class BannerPresenter extends ViewPresenter<BannerView> {
//
// @Inject
// public BannerPresenter() {
//
// }
//
// @Override
// protected void onLoad(Bundle savedInstanceState) {
// super.onLoad(savedInstanceState);
// }
//
// public void click() {
// Timber.d("Clicked on banner!");
// }
// }
//
// Path: architect/src/main/java/architect/NavigatorServices.java
// public class NavigatorServices {
//
// /**
// * Get service from navigator's mortar scope or its parent
// */
// public static <T> T getService(MortarScope scope, String name) {
// Navigator navigator = scope.getService(Navigator.SERVICE_NAME);
// Preconditions.checkNotNull(navigator, "Cannot find navigator in the scope");
//
// return navigator.getScope().getService(name);
// }
// }
//
// Path: architect/src/main/java/architect/Stackable.java
// public interface Stackable {
//
// void configureScope(MortarScope.Builder builder, MortarScope parentScope);
// }
| import com.mortarnav.DaggerScope;
import com.mortarnav.MainActivity;
import com.mortarnav.MainActivityComponent;
import com.mortarnav.presenter.BannerPresenter;
import architect.NavigatorServices;
import architect.Stackable;
import architect.robot.DaggerService;
import autodagger.AutoComponent;
import mortar.MortarScope; | package com.mortarnav.stackable;
/**
* @author Lukasz Piliszczuk - [email protected]
*/
@AutoComponent(
dependencies = MainActivity.class,
target = BannerPresenter.class)
@DaggerScope(BannerPresenter.class) | // Path: app/src/main/java/com/mortarnav/MainActivity.java
// @AutoComponent(
// dependencies = App.class,
// superinterfaces = WithActivityDependencies.class
// )
// @AutoInjector
// @DaggerScope(MainActivity.class)
// public class MainActivity extends AppCompatActivity {
//
// private MortarScope scope;
// private Navigator navigator;
//
// @Inject
// protected ToolbarOwner toolbarOwner;
//
// @Bind(R.id.navigator_container)
// protected NavigatorView containerView;
//
// @Bind(R.id.toolbar)
// protected Toolbar toolbar;
//
// @Override
// public Object getSystemService(String name) {
// if (scope != null && scope.hasService(name)) {
// return scope.getService(name);
// }
//
// return super.getSystemService(name);
// }
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setContentView(R.layout.activity_main);
// ButterKnife.bind(this);
//
// toolbar.setTitle("Mortar architect");
// setSupportActionBar(toolbar);
//
// scope = ActivityArchitector.onCreateScope(this, savedInstanceState, new Architected() {
// @Override
// public Navigator createNavigator(MortarScope scope) {
// Navigator navigator = Navigator.create(scope, new Parceler());
// navigator.transitions().register(new TransitionsMapping()
// .byDefault(new LateralViewTransition(new Config().duration(300)))
// .show(MyPopupView.class).withTransition(new FadeModalTransition(new Config().duration(250)))
// .show(MyPopup2View.class).withTransition(new BottomAppearTransition(true, new Config().duration(1000)))
// // .show(SlidesView.class).withTransition(new CustomFullScreenLateralTransition())
// );
// return navigator;
// }
//
// @Override
// public void configureScope(MortarScope.Builder builder, MortarScope parentScope) {
// MainActivityComponent component = DaggerMainActivityComponent.builder()
// .appComponent(parentScope.<AppComponent>getService(DaggerService.SERVICE_NAME))
// .build();
// builder.withService(DaggerService.SERVICE_NAME, component);
// }
// });
//
// DaggerService.<MainActivityComponent>get(this).inject(this);
// toolbarOwner.takeView(toolbar);
//
// // it is usually the best to create the navigator after everything else
// navigator = ActivityArchitector.onCreateNavigator(this, savedInstanceState, containerView, new HomeStackable("Default home path"));
// }
//
// @Override
// protected void onNewIntent(Intent intent) {
// super.onNewIntent(intent);
// navigator.delegate().onNewIntent(intent);
// }
//
// @Override
// protected void onSaveInstanceState(Bundle outState) {
// super.onSaveInstanceState(outState);
// BundleServiceRunner.getBundleServiceRunner(scope).onSaveInstanceState(outState);
// navigator.delegate().onSaveInstanceState(outState);
// }
//
// @Override
// protected void onStart() {
// super.onStart();
// navigator.delegate().onStart();
// }
//
// @Override
// protected void onStop() {
// navigator.delegate().onStop();
// super.onStop();
// }
//
// @Override
// protected void onDestroy() {
// toolbarOwner.dropView(toolbar);
//
// navigator.delegate().onDestroy();
// navigator = null;
//
// if (isFinishing() && scope != null) {
// scope.destroy();
// scope = null;
// }
//
// super.onDestroy();
// }
//
// @Override
// public void onBackPressed() {
// if (navigator.delegate().onBackPressed()) {
// return;
// }
//
// super.onBackPressed();
// }
// }
//
// Path: app/src/main/java/com/mortarnav/presenter/BannerPresenter.java
// @DaggerScope(BannerPresenter.class)
// public class BannerPresenter extends ViewPresenter<BannerView> {
//
// @Inject
// public BannerPresenter() {
//
// }
//
// @Override
// protected void onLoad(Bundle savedInstanceState) {
// super.onLoad(savedInstanceState);
// }
//
// public void click() {
// Timber.d("Clicked on banner!");
// }
// }
//
// Path: architect/src/main/java/architect/NavigatorServices.java
// public class NavigatorServices {
//
// /**
// * Get service from navigator's mortar scope or its parent
// */
// public static <T> T getService(MortarScope scope, String name) {
// Navigator navigator = scope.getService(Navigator.SERVICE_NAME);
// Preconditions.checkNotNull(navigator, "Cannot find navigator in the scope");
//
// return navigator.getScope().getService(name);
// }
// }
//
// Path: architect/src/main/java/architect/Stackable.java
// public interface Stackable {
//
// void configureScope(MortarScope.Builder builder, MortarScope parentScope);
// }
// Path: app/src/main/java/com/mortarnav/stackable/BannerStackable.java
import com.mortarnav.DaggerScope;
import com.mortarnav.MainActivity;
import com.mortarnav.MainActivityComponent;
import com.mortarnav.presenter.BannerPresenter;
import architect.NavigatorServices;
import architect.Stackable;
import architect.robot.DaggerService;
import autodagger.AutoComponent;
import mortar.MortarScope;
package com.mortarnav.stackable;
/**
* @author Lukasz Piliszczuk - [email protected]
*/
@AutoComponent(
dependencies = MainActivity.class,
target = BannerPresenter.class)
@DaggerScope(BannerPresenter.class) | public class BannerStackable implements Stackable { |
lukaspili/Mortar-architect | app/src/main/java/com/mortarnav/stackable/BannerStackable.java | // Path: app/src/main/java/com/mortarnav/MainActivity.java
// @AutoComponent(
// dependencies = App.class,
// superinterfaces = WithActivityDependencies.class
// )
// @AutoInjector
// @DaggerScope(MainActivity.class)
// public class MainActivity extends AppCompatActivity {
//
// private MortarScope scope;
// private Navigator navigator;
//
// @Inject
// protected ToolbarOwner toolbarOwner;
//
// @Bind(R.id.navigator_container)
// protected NavigatorView containerView;
//
// @Bind(R.id.toolbar)
// protected Toolbar toolbar;
//
// @Override
// public Object getSystemService(String name) {
// if (scope != null && scope.hasService(name)) {
// return scope.getService(name);
// }
//
// return super.getSystemService(name);
// }
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setContentView(R.layout.activity_main);
// ButterKnife.bind(this);
//
// toolbar.setTitle("Mortar architect");
// setSupportActionBar(toolbar);
//
// scope = ActivityArchitector.onCreateScope(this, savedInstanceState, new Architected() {
// @Override
// public Navigator createNavigator(MortarScope scope) {
// Navigator navigator = Navigator.create(scope, new Parceler());
// navigator.transitions().register(new TransitionsMapping()
// .byDefault(new LateralViewTransition(new Config().duration(300)))
// .show(MyPopupView.class).withTransition(new FadeModalTransition(new Config().duration(250)))
// .show(MyPopup2View.class).withTransition(new BottomAppearTransition(true, new Config().duration(1000)))
// // .show(SlidesView.class).withTransition(new CustomFullScreenLateralTransition())
// );
// return navigator;
// }
//
// @Override
// public void configureScope(MortarScope.Builder builder, MortarScope parentScope) {
// MainActivityComponent component = DaggerMainActivityComponent.builder()
// .appComponent(parentScope.<AppComponent>getService(DaggerService.SERVICE_NAME))
// .build();
// builder.withService(DaggerService.SERVICE_NAME, component);
// }
// });
//
// DaggerService.<MainActivityComponent>get(this).inject(this);
// toolbarOwner.takeView(toolbar);
//
// // it is usually the best to create the navigator after everything else
// navigator = ActivityArchitector.onCreateNavigator(this, savedInstanceState, containerView, new HomeStackable("Default home path"));
// }
//
// @Override
// protected void onNewIntent(Intent intent) {
// super.onNewIntent(intent);
// navigator.delegate().onNewIntent(intent);
// }
//
// @Override
// protected void onSaveInstanceState(Bundle outState) {
// super.onSaveInstanceState(outState);
// BundleServiceRunner.getBundleServiceRunner(scope).onSaveInstanceState(outState);
// navigator.delegate().onSaveInstanceState(outState);
// }
//
// @Override
// protected void onStart() {
// super.onStart();
// navigator.delegate().onStart();
// }
//
// @Override
// protected void onStop() {
// navigator.delegate().onStop();
// super.onStop();
// }
//
// @Override
// protected void onDestroy() {
// toolbarOwner.dropView(toolbar);
//
// navigator.delegate().onDestroy();
// navigator = null;
//
// if (isFinishing() && scope != null) {
// scope.destroy();
// scope = null;
// }
//
// super.onDestroy();
// }
//
// @Override
// public void onBackPressed() {
// if (navigator.delegate().onBackPressed()) {
// return;
// }
//
// super.onBackPressed();
// }
// }
//
// Path: app/src/main/java/com/mortarnav/presenter/BannerPresenter.java
// @DaggerScope(BannerPresenter.class)
// public class BannerPresenter extends ViewPresenter<BannerView> {
//
// @Inject
// public BannerPresenter() {
//
// }
//
// @Override
// protected void onLoad(Bundle savedInstanceState) {
// super.onLoad(savedInstanceState);
// }
//
// public void click() {
// Timber.d("Clicked on banner!");
// }
// }
//
// Path: architect/src/main/java/architect/NavigatorServices.java
// public class NavigatorServices {
//
// /**
// * Get service from navigator's mortar scope or its parent
// */
// public static <T> T getService(MortarScope scope, String name) {
// Navigator navigator = scope.getService(Navigator.SERVICE_NAME);
// Preconditions.checkNotNull(navigator, "Cannot find navigator in the scope");
//
// return navigator.getScope().getService(name);
// }
// }
//
// Path: architect/src/main/java/architect/Stackable.java
// public interface Stackable {
//
// void configureScope(MortarScope.Builder builder, MortarScope parentScope);
// }
| import com.mortarnav.DaggerScope;
import com.mortarnav.MainActivity;
import com.mortarnav.MainActivityComponent;
import com.mortarnav.presenter.BannerPresenter;
import architect.NavigatorServices;
import architect.Stackable;
import architect.robot.DaggerService;
import autodagger.AutoComponent;
import mortar.MortarScope; | package com.mortarnav.stackable;
/**
* @author Lukasz Piliszczuk - [email protected]
*/
@AutoComponent(
dependencies = MainActivity.class,
target = BannerPresenter.class)
@DaggerScope(BannerPresenter.class)
public class BannerStackable implements Stackable {
@Override
public void configureScope(MortarScope.Builder builder, MortarScope parentScope) {
// parentScope is not the main activity scope, but the scope of its container (like home scope)
// retreive the main activity component from the navigator scope | // Path: app/src/main/java/com/mortarnav/MainActivity.java
// @AutoComponent(
// dependencies = App.class,
// superinterfaces = WithActivityDependencies.class
// )
// @AutoInjector
// @DaggerScope(MainActivity.class)
// public class MainActivity extends AppCompatActivity {
//
// private MortarScope scope;
// private Navigator navigator;
//
// @Inject
// protected ToolbarOwner toolbarOwner;
//
// @Bind(R.id.navigator_container)
// protected NavigatorView containerView;
//
// @Bind(R.id.toolbar)
// protected Toolbar toolbar;
//
// @Override
// public Object getSystemService(String name) {
// if (scope != null && scope.hasService(name)) {
// return scope.getService(name);
// }
//
// return super.getSystemService(name);
// }
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
//
// setContentView(R.layout.activity_main);
// ButterKnife.bind(this);
//
// toolbar.setTitle("Mortar architect");
// setSupportActionBar(toolbar);
//
// scope = ActivityArchitector.onCreateScope(this, savedInstanceState, new Architected() {
// @Override
// public Navigator createNavigator(MortarScope scope) {
// Navigator navigator = Navigator.create(scope, new Parceler());
// navigator.transitions().register(new TransitionsMapping()
// .byDefault(new LateralViewTransition(new Config().duration(300)))
// .show(MyPopupView.class).withTransition(new FadeModalTransition(new Config().duration(250)))
// .show(MyPopup2View.class).withTransition(new BottomAppearTransition(true, new Config().duration(1000)))
// // .show(SlidesView.class).withTransition(new CustomFullScreenLateralTransition())
// );
// return navigator;
// }
//
// @Override
// public void configureScope(MortarScope.Builder builder, MortarScope parentScope) {
// MainActivityComponent component = DaggerMainActivityComponent.builder()
// .appComponent(parentScope.<AppComponent>getService(DaggerService.SERVICE_NAME))
// .build();
// builder.withService(DaggerService.SERVICE_NAME, component);
// }
// });
//
// DaggerService.<MainActivityComponent>get(this).inject(this);
// toolbarOwner.takeView(toolbar);
//
// // it is usually the best to create the navigator after everything else
// navigator = ActivityArchitector.onCreateNavigator(this, savedInstanceState, containerView, new HomeStackable("Default home path"));
// }
//
// @Override
// protected void onNewIntent(Intent intent) {
// super.onNewIntent(intent);
// navigator.delegate().onNewIntent(intent);
// }
//
// @Override
// protected void onSaveInstanceState(Bundle outState) {
// super.onSaveInstanceState(outState);
// BundleServiceRunner.getBundleServiceRunner(scope).onSaveInstanceState(outState);
// navigator.delegate().onSaveInstanceState(outState);
// }
//
// @Override
// protected void onStart() {
// super.onStart();
// navigator.delegate().onStart();
// }
//
// @Override
// protected void onStop() {
// navigator.delegate().onStop();
// super.onStop();
// }
//
// @Override
// protected void onDestroy() {
// toolbarOwner.dropView(toolbar);
//
// navigator.delegate().onDestroy();
// navigator = null;
//
// if (isFinishing() && scope != null) {
// scope.destroy();
// scope = null;
// }
//
// super.onDestroy();
// }
//
// @Override
// public void onBackPressed() {
// if (navigator.delegate().onBackPressed()) {
// return;
// }
//
// super.onBackPressed();
// }
// }
//
// Path: app/src/main/java/com/mortarnav/presenter/BannerPresenter.java
// @DaggerScope(BannerPresenter.class)
// public class BannerPresenter extends ViewPresenter<BannerView> {
//
// @Inject
// public BannerPresenter() {
//
// }
//
// @Override
// protected void onLoad(Bundle savedInstanceState) {
// super.onLoad(savedInstanceState);
// }
//
// public void click() {
// Timber.d("Clicked on banner!");
// }
// }
//
// Path: architect/src/main/java/architect/NavigatorServices.java
// public class NavigatorServices {
//
// /**
// * Get service from navigator's mortar scope or its parent
// */
// public static <T> T getService(MortarScope scope, String name) {
// Navigator navigator = scope.getService(Navigator.SERVICE_NAME);
// Preconditions.checkNotNull(navigator, "Cannot find navigator in the scope");
//
// return navigator.getScope().getService(name);
// }
// }
//
// Path: architect/src/main/java/architect/Stackable.java
// public interface Stackable {
//
// void configureScope(MortarScope.Builder builder, MortarScope parentScope);
// }
// Path: app/src/main/java/com/mortarnav/stackable/BannerStackable.java
import com.mortarnav.DaggerScope;
import com.mortarnav.MainActivity;
import com.mortarnav.MainActivityComponent;
import com.mortarnav.presenter.BannerPresenter;
import architect.NavigatorServices;
import architect.Stackable;
import architect.robot.DaggerService;
import autodagger.AutoComponent;
import mortar.MortarScope;
package com.mortarnav.stackable;
/**
* @author Lukasz Piliszczuk - [email protected]
*/
@AutoComponent(
dependencies = MainActivity.class,
target = BannerPresenter.class)
@DaggerScope(BannerPresenter.class)
public class BannerStackable implements Stackable {
@Override
public void configureScope(MortarScope.Builder builder, MortarScope parentScope) {
// parentScope is not the main activity scope, but the scope of its container (like home scope)
// retreive the main activity component from the navigator scope | MainActivityComponent component = NavigatorServices.getService(parentScope, DaggerService.SERVICE_NAME); |
lukaspili/Mortar-architect | app/src/main/java/com/mortarnav/presenter/HomeDoubleNestedPresenter.java | // Path: app/src/main/java/com/mortarnav/view/HomeDoubleNestedView.java
// @AutoInjector(HomeDoubleNestedPresenter.class)
// public class HomeDoubleNestedView extends StackedLinearLayout<HomeDoubleNestedPresenter> {
//
//
// public HomeDoubleNestedView(Context context, AttributeSet attrs) {
// super(context, attrs);
// }
//
// @Override
// public Stackable getStackable() {
// return new HomeDoubleNestedStackable();
// }
//
// @Override
// public void initWithContext(Context context) {
// DaggerService.<HomeDoubleNestedStackableComponent>get(context).inject(this);
//
// View view = View.inflate(context, R.layout.home_double_subcontent_view, this);
// ButterKnife.bind(view);
// }
// }
| import com.mortarnav.DaggerScope;
import com.mortarnav.view.HomeDoubleNestedView;
import architect.robot.AutoStackable;
import autodagger.AutoComponent;
import mortar.ViewPresenter; | package com.mortarnav.presenter;
/**
* @author Lukasz Piliszczuk - [email protected]
*/
@AutoStackable(
component = @AutoComponent(dependencies = HomeNestedPresenter.class)
)
@DaggerScope(HomeDoubleNestedPresenter.class) | // Path: app/src/main/java/com/mortarnav/view/HomeDoubleNestedView.java
// @AutoInjector(HomeDoubleNestedPresenter.class)
// public class HomeDoubleNestedView extends StackedLinearLayout<HomeDoubleNestedPresenter> {
//
//
// public HomeDoubleNestedView(Context context, AttributeSet attrs) {
// super(context, attrs);
// }
//
// @Override
// public Stackable getStackable() {
// return new HomeDoubleNestedStackable();
// }
//
// @Override
// public void initWithContext(Context context) {
// DaggerService.<HomeDoubleNestedStackableComponent>get(context).inject(this);
//
// View view = View.inflate(context, R.layout.home_double_subcontent_view, this);
// ButterKnife.bind(view);
// }
// }
// Path: app/src/main/java/com/mortarnav/presenter/HomeDoubleNestedPresenter.java
import com.mortarnav.DaggerScope;
import com.mortarnav.view.HomeDoubleNestedView;
import architect.robot.AutoStackable;
import autodagger.AutoComponent;
import mortar.ViewPresenter;
package com.mortarnav.presenter;
/**
* @author Lukasz Piliszczuk - [email protected]
*/
@AutoStackable(
component = @AutoComponent(dependencies = HomeNestedPresenter.class)
)
@DaggerScope(HomeDoubleNestedPresenter.class) | public class HomeDoubleNestedPresenter extends ViewPresenter<HomeDoubleNestedView> { |
lukaspili/Mortar-architect | app/src/main/java/com/mortarnav/StandardAutoComponent.java | // Path: app/src/main/java/com/mortarnav/deps/WithActivityDependencies.java
// public interface WithActivityDependencies extends WithAppDependencies {
//
// ToolbarOwner toolbarOwner();
// }
//
// Path: app/src/main/java/com/mortarnav/deps/WithAppDependencies.java
// public interface WithAppDependencies {
//
// RestClient restClient();
//
// UserManager userManager();
// }
| import com.mortarnav.deps.WithActivityDependencies;
import com.mortarnav.deps.WithAppDependencies;
import autodagger.AutoComponent; | package com.mortarnav;
/**
* @author Lukasz Piliszczuk - [email protected]
*/
@AutoComponent(
dependencies = MainActivity.class, | // Path: app/src/main/java/com/mortarnav/deps/WithActivityDependencies.java
// public interface WithActivityDependencies extends WithAppDependencies {
//
// ToolbarOwner toolbarOwner();
// }
//
// Path: app/src/main/java/com/mortarnav/deps/WithAppDependencies.java
// public interface WithAppDependencies {
//
// RestClient restClient();
//
// UserManager userManager();
// }
// Path: app/src/main/java/com/mortarnav/StandardAutoComponent.java
import com.mortarnav.deps.WithActivityDependencies;
import com.mortarnav.deps.WithAppDependencies;
import autodagger.AutoComponent;
package com.mortarnav;
/**
* @author Lukasz Piliszczuk - [email protected]
*/
@AutoComponent(
dependencies = MainActivity.class, | superinterfaces = WithActivityDependencies.class) |
lukaspili/Mortar-architect | app/src/main/java/com/mortarnav/presenter/SlidePagePresenter.java | // Path: app/src/main/java/com/mortarnav/deps/RestClient.java
// @DaggerScope(App.class)
// public class RestClient {
//
// @Inject
// public RestClient() {
// }
// }
//
// Path: app/src/main/java/com/mortarnav/deps/UserManager.java
// @DaggerScope(App.class)
// public class UserManager {
//
// @Inject
// public UserManager() {
// }
// }
//
// Path: app/src/main/java/com/mortarnav/deps/WithAppDependencies.java
// public interface WithAppDependencies {
//
// RestClient restClient();
//
// UserManager userManager();
// }
| import android.os.Bundle;
import com.mortarnav.DaggerScope;
import com.mortarnav.deps.RestClient;
import com.mortarnav.deps.UserManager;
import com.mortarnav.deps.WithAppDependencies;
import com.mortarnav.view.SlidePageView;
import architect.robot.AutoStackable;
import architect.robot.FromPath;
import autodagger.AutoComponent;
import mortar.ViewPresenter; | package com.mortarnav.presenter;
/**
* @author Lukasz Piliszczuk - [email protected]
*/
@AutoStackable(
component = @AutoComponent(
dependencies = SlidesPresenter.class, | // Path: app/src/main/java/com/mortarnav/deps/RestClient.java
// @DaggerScope(App.class)
// public class RestClient {
//
// @Inject
// public RestClient() {
// }
// }
//
// Path: app/src/main/java/com/mortarnav/deps/UserManager.java
// @DaggerScope(App.class)
// public class UserManager {
//
// @Inject
// public UserManager() {
// }
// }
//
// Path: app/src/main/java/com/mortarnav/deps/WithAppDependencies.java
// public interface WithAppDependencies {
//
// RestClient restClient();
//
// UserManager userManager();
// }
// Path: app/src/main/java/com/mortarnav/presenter/SlidePagePresenter.java
import android.os.Bundle;
import com.mortarnav.DaggerScope;
import com.mortarnav.deps.RestClient;
import com.mortarnav.deps.UserManager;
import com.mortarnav.deps.WithAppDependencies;
import com.mortarnav.view.SlidePageView;
import architect.robot.AutoStackable;
import architect.robot.FromPath;
import autodagger.AutoComponent;
import mortar.ViewPresenter;
package com.mortarnav.presenter;
/**
* @author Lukasz Piliszczuk - [email protected]
*/
@AutoStackable(
component = @AutoComponent(
dependencies = SlidesPresenter.class, | superinterfaces = WithAppDependencies.class), |
lukaspili/Mortar-architect | app/src/main/java/com/mortarnav/presenter/SlidePagePresenter.java | // Path: app/src/main/java/com/mortarnav/deps/RestClient.java
// @DaggerScope(App.class)
// public class RestClient {
//
// @Inject
// public RestClient() {
// }
// }
//
// Path: app/src/main/java/com/mortarnav/deps/UserManager.java
// @DaggerScope(App.class)
// public class UserManager {
//
// @Inject
// public UserManager() {
// }
// }
//
// Path: app/src/main/java/com/mortarnav/deps/WithAppDependencies.java
// public interface WithAppDependencies {
//
// RestClient restClient();
//
// UserManager userManager();
// }
| import android.os.Bundle;
import com.mortarnav.DaggerScope;
import com.mortarnav.deps.RestClient;
import com.mortarnav.deps.UserManager;
import com.mortarnav.deps.WithAppDependencies;
import com.mortarnav.view.SlidePageView;
import architect.robot.AutoStackable;
import architect.robot.FromPath;
import autodagger.AutoComponent;
import mortar.ViewPresenter; | package com.mortarnav.presenter;
/**
* @author Lukasz Piliszczuk - [email protected]
*/
@AutoStackable(
component = @AutoComponent(
dependencies = SlidesPresenter.class,
superinterfaces = WithAppDependencies.class),
pathWithView = SlidePageView.class
)
@DaggerScope(SlidePagePresenter.class)
public class SlidePagePresenter extends ViewPresenter<SlidePageView> {
private final int id;
// some dependencies provided by dagger | // Path: app/src/main/java/com/mortarnav/deps/RestClient.java
// @DaggerScope(App.class)
// public class RestClient {
//
// @Inject
// public RestClient() {
// }
// }
//
// Path: app/src/main/java/com/mortarnav/deps/UserManager.java
// @DaggerScope(App.class)
// public class UserManager {
//
// @Inject
// public UserManager() {
// }
// }
//
// Path: app/src/main/java/com/mortarnav/deps/WithAppDependencies.java
// public interface WithAppDependencies {
//
// RestClient restClient();
//
// UserManager userManager();
// }
// Path: app/src/main/java/com/mortarnav/presenter/SlidePagePresenter.java
import android.os.Bundle;
import com.mortarnav.DaggerScope;
import com.mortarnav.deps.RestClient;
import com.mortarnav.deps.UserManager;
import com.mortarnav.deps.WithAppDependencies;
import com.mortarnav.view.SlidePageView;
import architect.robot.AutoStackable;
import architect.robot.FromPath;
import autodagger.AutoComponent;
import mortar.ViewPresenter;
package com.mortarnav.presenter;
/**
* @author Lukasz Piliszczuk - [email protected]
*/
@AutoStackable(
component = @AutoComponent(
dependencies = SlidesPresenter.class,
superinterfaces = WithAppDependencies.class),
pathWithView = SlidePageView.class
)
@DaggerScope(SlidePagePresenter.class)
public class SlidePagePresenter extends ViewPresenter<SlidePageView> {
private final int id;
// some dependencies provided by dagger | private final RestClient restClient; |
lukaspili/Mortar-architect | app/src/main/java/com/mortarnav/presenter/SlidePagePresenter.java | // Path: app/src/main/java/com/mortarnav/deps/RestClient.java
// @DaggerScope(App.class)
// public class RestClient {
//
// @Inject
// public RestClient() {
// }
// }
//
// Path: app/src/main/java/com/mortarnav/deps/UserManager.java
// @DaggerScope(App.class)
// public class UserManager {
//
// @Inject
// public UserManager() {
// }
// }
//
// Path: app/src/main/java/com/mortarnav/deps/WithAppDependencies.java
// public interface WithAppDependencies {
//
// RestClient restClient();
//
// UserManager userManager();
// }
| import android.os.Bundle;
import com.mortarnav.DaggerScope;
import com.mortarnav.deps.RestClient;
import com.mortarnav.deps.UserManager;
import com.mortarnav.deps.WithAppDependencies;
import com.mortarnav.view.SlidePageView;
import architect.robot.AutoStackable;
import architect.robot.FromPath;
import autodagger.AutoComponent;
import mortar.ViewPresenter; | package com.mortarnav.presenter;
/**
* @author Lukasz Piliszczuk - [email protected]
*/
@AutoStackable(
component = @AutoComponent(
dependencies = SlidesPresenter.class,
superinterfaces = WithAppDependencies.class),
pathWithView = SlidePageView.class
)
@DaggerScope(SlidePagePresenter.class)
public class SlidePagePresenter extends ViewPresenter<SlidePageView> {
private final int id;
// some dependencies provided by dagger
private final RestClient restClient; | // Path: app/src/main/java/com/mortarnav/deps/RestClient.java
// @DaggerScope(App.class)
// public class RestClient {
//
// @Inject
// public RestClient() {
// }
// }
//
// Path: app/src/main/java/com/mortarnav/deps/UserManager.java
// @DaggerScope(App.class)
// public class UserManager {
//
// @Inject
// public UserManager() {
// }
// }
//
// Path: app/src/main/java/com/mortarnav/deps/WithAppDependencies.java
// public interface WithAppDependencies {
//
// RestClient restClient();
//
// UserManager userManager();
// }
// Path: app/src/main/java/com/mortarnav/presenter/SlidePagePresenter.java
import android.os.Bundle;
import com.mortarnav.DaggerScope;
import com.mortarnav.deps.RestClient;
import com.mortarnav.deps.UserManager;
import com.mortarnav.deps.WithAppDependencies;
import com.mortarnav.view.SlidePageView;
import architect.robot.AutoStackable;
import architect.robot.FromPath;
import autodagger.AutoComponent;
import mortar.ViewPresenter;
package com.mortarnav.presenter;
/**
* @author Lukasz Piliszczuk - [email protected]
*/
@AutoStackable(
component = @AutoComponent(
dependencies = SlidesPresenter.class,
superinterfaces = WithAppDependencies.class),
pathWithView = SlidePageView.class
)
@DaggerScope(SlidePagePresenter.class)
public class SlidePagePresenter extends ViewPresenter<SlidePageView> {
private final int id;
// some dependencies provided by dagger
private final RestClient restClient; | private final UserManager userManager; |
DorianScholz/OpenLibre | app/src/main/java/de/dorianscholz/openlibre/UserDataRealmMigration.java | // Path: app/src/main/java/de/dorianscholz/openlibre/RawDataRealmMigration.java
// static final RealmObjectSchema.Function timezoneTransformFunction = new RealmObjectSchema.Function() {
// @Override
// public void apply(DynamicRealmObject obj) {
// // set timezone offset value
// long date = obj.getLong("date");
// Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("Europe/Berlin"));
// cal.set(2017, Calendar.JANUARY, 30, 0, 0, 0);
// TimeZone timeZone; // the timezone during data aquisition was not saved before schema version 2, so we have to guess the correct value for old data
// if (date < cal.getTime().getTime()) { // before 30.01.2017 the only existing app installation was exclusively used in germany...
// timeZone = TimeZone.getTimeZone("Europe/Berlin");
// } else {
// timeZone = TimeZone.getDefault(); // after that, use the device's current timezone
// }
// int timezoneOffsetInMinutes = timeZone.getOffset(date) / 1000 / 60;
// obj.set("timezoneOffsetInMinutes", timezoneOffsetInMinutes);
// }
// };
| import io.realm.DynamicRealm;
import io.realm.RealmMigration;
import io.realm.RealmObjectSchema;
import io.realm.RealmSchema;
import static de.dorianscholz.openlibre.RawDataRealmMigration.timezoneTransformFunction; | package de.dorianscholz.openlibre;
class UserDataRealmMigration implements RealmMigration {
@Override
public void migrate(DynamicRealm realm, long oldVersion, long newVersion) {
// During a migration, a DynamicRealm is exposed. A DynamicRealm is an untyped variant of a normal Realm, but
// with the same object creation and query capabilities.
// A DynamicRealm uses Strings instead of Class references because the Classes might not even exist or have been
// renamed.
// Access the Realm schema in order to create, modify or delete classes and their fields.
RealmSchema schema = realm.getSchema();
// Migrate from version 0 to version 1
if (oldVersion == 0) {
oldVersion++;
}
// Migrate from version 1 to version 2
if (oldVersion == 1) {
RealmObjectSchema bloodGlucoseDataSchema = schema.get("BloodGlucoseData");
bloodGlucoseDataSchema
.addField("timezoneOffsetInMinutes", int.class) | // Path: app/src/main/java/de/dorianscholz/openlibre/RawDataRealmMigration.java
// static final RealmObjectSchema.Function timezoneTransformFunction = new RealmObjectSchema.Function() {
// @Override
// public void apply(DynamicRealmObject obj) {
// // set timezone offset value
// long date = obj.getLong("date");
// Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("Europe/Berlin"));
// cal.set(2017, Calendar.JANUARY, 30, 0, 0, 0);
// TimeZone timeZone; // the timezone during data aquisition was not saved before schema version 2, so we have to guess the correct value for old data
// if (date < cal.getTime().getTime()) { // before 30.01.2017 the only existing app installation was exclusively used in germany...
// timeZone = TimeZone.getTimeZone("Europe/Berlin");
// } else {
// timeZone = TimeZone.getDefault(); // after that, use the device's current timezone
// }
// int timezoneOffsetInMinutes = timeZone.getOffset(date) / 1000 / 60;
// obj.set("timezoneOffsetInMinutes", timezoneOffsetInMinutes);
// }
// };
// Path: app/src/main/java/de/dorianscholz/openlibre/UserDataRealmMigration.java
import io.realm.DynamicRealm;
import io.realm.RealmMigration;
import io.realm.RealmObjectSchema;
import io.realm.RealmSchema;
import static de.dorianscholz.openlibre.RawDataRealmMigration.timezoneTransformFunction;
package de.dorianscholz.openlibre;
class UserDataRealmMigration implements RealmMigration {
@Override
public void migrate(DynamicRealm realm, long oldVersion, long newVersion) {
// During a migration, a DynamicRealm is exposed. A DynamicRealm is an untyped variant of a normal Realm, but
// with the same object creation and query capabilities.
// A DynamicRealm uses Strings instead of Class references because the Classes might not even exist or have been
// renamed.
// Access the Realm schema in order to create, modify or delete classes and their fields.
RealmSchema schema = realm.getSchema();
// Migrate from version 0 to version 1
if (oldVersion == 0) {
oldVersion++;
}
// Migrate from version 1 to version 2
if (oldVersion == 1) {
RealmObjectSchema bloodGlucoseDataSchema = schema.get("BloodGlucoseData");
bloodGlucoseDataSchema
.addField("timezoneOffsetInMinutes", int.class) | .transform(timezoneTransformFunction); |
DorianScholz/OpenLibre | app/src/main/java/de/dorianscholz/openlibre/model/ReadingData.java | // Path: app/src/main/java/de/dorianscholz/openlibre/OpenLibre.java
// public static RealmConfiguration realmConfigProcessedData;
//
// Path: app/src/main/java/de/dorianscholz/openlibre/model/SensorData.java
// public static final long maxSensorAgeInMinutes = TimeUnit.DAYS.toMinutes(14); // data generated by the sensor after 14 days also has faults
//
// Path: app/src/main/java/de/dorianscholz/openlibre/model/SensorData.java
// public static final long minSensorAgeInMinutes = 60; // data generated by the sensor in the first 60 minutes is not correct
| import android.util.Log;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import io.realm.Realm;
import io.realm.RealmList;
import io.realm.RealmObject;
import io.realm.RealmResults;
import io.realm.Sort;
import io.realm.annotations.PrimaryKey;
import static de.dorianscholz.openlibre.OpenLibre.realmConfigProcessedData;
import static de.dorianscholz.openlibre.model.SensorData.maxSensorAgeInMinutes;
import static de.dorianscholz.openlibre.model.SensorData.minSensorAgeInMinutes;
import static java.lang.Math.min; | package de.dorianscholz.openlibre.model;
public class ReadingData extends RealmObject {
public static final String ID = "id";
public static final String SENSOR = "sensor";
public static final String SENSOR_AGE_IN_MINUTES = "sensorAgeInMinutes";
public static final String DATE = "date";
public static final String TIMEZONE_OFFSET_IN_MINUTES = "timezoneOffsetInMinutes";
public static final String TREND = "trend";
public static final String HISTORY = "history";
public static final int numHistoryValues = 32;
public static final int historyIntervalInMinutes = 15;
public static final int numTrendValues = 16;
@PrimaryKey
private String id;
private SensorData sensor;
private int sensorAgeInMinutes = -1;
private long date = -1;
private int timezoneOffsetInMinutes;
private RealmList<GlucoseData> trend = new RealmList<>();
private RealmList<GlucoseData> history = new RealmList<>();
public ReadingData() {}
public ReadingData(RawTagData rawTagData) {
id = rawTagData.getId();
date = rawTagData.getDate();
timezoneOffsetInMinutes = rawTagData.getTimezoneOffsetInMinutes();
sensorAgeInMinutes = rawTagData.getSensorAgeInMinutes();
| // Path: app/src/main/java/de/dorianscholz/openlibre/OpenLibre.java
// public static RealmConfiguration realmConfigProcessedData;
//
// Path: app/src/main/java/de/dorianscholz/openlibre/model/SensorData.java
// public static final long maxSensorAgeInMinutes = TimeUnit.DAYS.toMinutes(14); // data generated by the sensor after 14 days also has faults
//
// Path: app/src/main/java/de/dorianscholz/openlibre/model/SensorData.java
// public static final long minSensorAgeInMinutes = 60; // data generated by the sensor in the first 60 minutes is not correct
// Path: app/src/main/java/de/dorianscholz/openlibre/model/ReadingData.java
import android.util.Log;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import io.realm.Realm;
import io.realm.RealmList;
import io.realm.RealmObject;
import io.realm.RealmResults;
import io.realm.Sort;
import io.realm.annotations.PrimaryKey;
import static de.dorianscholz.openlibre.OpenLibre.realmConfigProcessedData;
import static de.dorianscholz.openlibre.model.SensorData.maxSensorAgeInMinutes;
import static de.dorianscholz.openlibre.model.SensorData.minSensorAgeInMinutes;
import static java.lang.Math.min;
package de.dorianscholz.openlibre.model;
public class ReadingData extends RealmObject {
public static final String ID = "id";
public static final String SENSOR = "sensor";
public static final String SENSOR_AGE_IN_MINUTES = "sensorAgeInMinutes";
public static final String DATE = "date";
public static final String TIMEZONE_OFFSET_IN_MINUTES = "timezoneOffsetInMinutes";
public static final String TREND = "trend";
public static final String HISTORY = "history";
public static final int numHistoryValues = 32;
public static final int historyIntervalInMinutes = 15;
public static final int numTrendValues = 16;
@PrimaryKey
private String id;
private SensorData sensor;
private int sensorAgeInMinutes = -1;
private long date = -1;
private int timezoneOffsetInMinutes;
private RealmList<GlucoseData> trend = new RealmList<>();
private RealmList<GlucoseData> history = new RealmList<>();
public ReadingData() {}
public ReadingData(RawTagData rawTagData) {
id = rawTagData.getId();
date = rawTagData.getDate();
timezoneOffsetInMinutes = rawTagData.getTimezoneOffsetInMinutes();
sensorAgeInMinutes = rawTagData.getSensorAgeInMinutes();
| Realm realmProcessedData = Realm.getInstance(realmConfigProcessedData); |
DorianScholz/OpenLibre | app/src/main/java/de/dorianscholz/openlibre/model/ReadingData.java | // Path: app/src/main/java/de/dorianscholz/openlibre/OpenLibre.java
// public static RealmConfiguration realmConfigProcessedData;
//
// Path: app/src/main/java/de/dorianscholz/openlibre/model/SensorData.java
// public static final long maxSensorAgeInMinutes = TimeUnit.DAYS.toMinutes(14); // data generated by the sensor after 14 days also has faults
//
// Path: app/src/main/java/de/dorianscholz/openlibre/model/SensorData.java
// public static final long minSensorAgeInMinutes = 60; // data generated by the sensor in the first 60 minutes is not correct
| import android.util.Log;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import io.realm.Realm;
import io.realm.RealmList;
import io.realm.RealmObject;
import io.realm.RealmResults;
import io.realm.Sort;
import io.realm.annotations.PrimaryKey;
import static de.dorianscholz.openlibre.OpenLibre.realmConfigProcessedData;
import static de.dorianscholz.openlibre.model.SensorData.maxSensorAgeInMinutes;
import static de.dorianscholz.openlibre.model.SensorData.minSensorAgeInMinutes;
import static java.lang.Math.min; | public static final int historyIntervalInMinutes = 15;
public static final int numTrendValues = 16;
@PrimaryKey
private String id;
private SensorData sensor;
private int sensorAgeInMinutes = -1;
private long date = -1;
private int timezoneOffsetInMinutes;
private RealmList<GlucoseData> trend = new RealmList<>();
private RealmList<GlucoseData> history = new RealmList<>();
public ReadingData() {}
public ReadingData(RawTagData rawTagData) {
id = rawTagData.getId();
date = rawTagData.getDate();
timezoneOffsetInMinutes = rawTagData.getTimezoneOffsetInMinutes();
sensorAgeInMinutes = rawTagData.getSensorAgeInMinutes();
Realm realmProcessedData = Realm.getInstance(realmConfigProcessedData);
// find or create entry for this sensor
RealmResults<SensorData> sensors = realmProcessedData.where(SensorData.class).contains(SensorData.ID, rawTagData.getTagId()).findAll();
if (sensors.size() > 0) {
sensor = sensors.first();
} else {
sensor = new SensorData(rawTagData);
}
// check if sensor is of valid age | // Path: app/src/main/java/de/dorianscholz/openlibre/OpenLibre.java
// public static RealmConfiguration realmConfigProcessedData;
//
// Path: app/src/main/java/de/dorianscholz/openlibre/model/SensorData.java
// public static final long maxSensorAgeInMinutes = TimeUnit.DAYS.toMinutes(14); // data generated by the sensor after 14 days also has faults
//
// Path: app/src/main/java/de/dorianscholz/openlibre/model/SensorData.java
// public static final long minSensorAgeInMinutes = 60; // data generated by the sensor in the first 60 minutes is not correct
// Path: app/src/main/java/de/dorianscholz/openlibre/model/ReadingData.java
import android.util.Log;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import io.realm.Realm;
import io.realm.RealmList;
import io.realm.RealmObject;
import io.realm.RealmResults;
import io.realm.Sort;
import io.realm.annotations.PrimaryKey;
import static de.dorianscholz.openlibre.OpenLibre.realmConfigProcessedData;
import static de.dorianscholz.openlibre.model.SensorData.maxSensorAgeInMinutes;
import static de.dorianscholz.openlibre.model.SensorData.minSensorAgeInMinutes;
import static java.lang.Math.min;
public static final int historyIntervalInMinutes = 15;
public static final int numTrendValues = 16;
@PrimaryKey
private String id;
private SensorData sensor;
private int sensorAgeInMinutes = -1;
private long date = -1;
private int timezoneOffsetInMinutes;
private RealmList<GlucoseData> trend = new RealmList<>();
private RealmList<GlucoseData> history = new RealmList<>();
public ReadingData() {}
public ReadingData(RawTagData rawTagData) {
id = rawTagData.getId();
date = rawTagData.getDate();
timezoneOffsetInMinutes = rawTagData.getTimezoneOffsetInMinutes();
sensorAgeInMinutes = rawTagData.getSensorAgeInMinutes();
Realm realmProcessedData = Realm.getInstance(realmConfigProcessedData);
// find or create entry for this sensor
RealmResults<SensorData> sensors = realmProcessedData.where(SensorData.class).contains(SensorData.ID, rawTagData.getTagId()).findAll();
if (sensors.size() > 0) {
sensor = sensors.first();
} else {
sensor = new SensorData(rawTagData);
}
// check if sensor is of valid age | if (sensorAgeInMinutes <= minSensorAgeInMinutes || sensorAgeInMinutes > maxSensorAgeInMinutes) { |
DorianScholz/OpenLibre | app/src/main/java/de/dorianscholz/openlibre/model/ReadingData.java | // Path: app/src/main/java/de/dorianscholz/openlibre/OpenLibre.java
// public static RealmConfiguration realmConfigProcessedData;
//
// Path: app/src/main/java/de/dorianscholz/openlibre/model/SensorData.java
// public static final long maxSensorAgeInMinutes = TimeUnit.DAYS.toMinutes(14); // data generated by the sensor after 14 days also has faults
//
// Path: app/src/main/java/de/dorianscholz/openlibre/model/SensorData.java
// public static final long minSensorAgeInMinutes = 60; // data generated by the sensor in the first 60 minutes is not correct
| import android.util.Log;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import io.realm.Realm;
import io.realm.RealmList;
import io.realm.RealmObject;
import io.realm.RealmResults;
import io.realm.Sort;
import io.realm.annotations.PrimaryKey;
import static de.dorianscholz.openlibre.OpenLibre.realmConfigProcessedData;
import static de.dorianscholz.openlibre.model.SensorData.maxSensorAgeInMinutes;
import static de.dorianscholz.openlibre.model.SensorData.minSensorAgeInMinutes;
import static java.lang.Math.min; | public static final int historyIntervalInMinutes = 15;
public static final int numTrendValues = 16;
@PrimaryKey
private String id;
private SensorData sensor;
private int sensorAgeInMinutes = -1;
private long date = -1;
private int timezoneOffsetInMinutes;
private RealmList<GlucoseData> trend = new RealmList<>();
private RealmList<GlucoseData> history = new RealmList<>();
public ReadingData() {}
public ReadingData(RawTagData rawTagData) {
id = rawTagData.getId();
date = rawTagData.getDate();
timezoneOffsetInMinutes = rawTagData.getTimezoneOffsetInMinutes();
sensorAgeInMinutes = rawTagData.getSensorAgeInMinutes();
Realm realmProcessedData = Realm.getInstance(realmConfigProcessedData);
// find or create entry for this sensor
RealmResults<SensorData> sensors = realmProcessedData.where(SensorData.class).contains(SensorData.ID, rawTagData.getTagId()).findAll();
if (sensors.size() > 0) {
sensor = sensors.first();
} else {
sensor = new SensorData(rawTagData);
}
// check if sensor is of valid age | // Path: app/src/main/java/de/dorianscholz/openlibre/OpenLibre.java
// public static RealmConfiguration realmConfigProcessedData;
//
// Path: app/src/main/java/de/dorianscholz/openlibre/model/SensorData.java
// public static final long maxSensorAgeInMinutes = TimeUnit.DAYS.toMinutes(14); // data generated by the sensor after 14 days also has faults
//
// Path: app/src/main/java/de/dorianscholz/openlibre/model/SensorData.java
// public static final long minSensorAgeInMinutes = 60; // data generated by the sensor in the first 60 minutes is not correct
// Path: app/src/main/java/de/dorianscholz/openlibre/model/ReadingData.java
import android.util.Log;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import io.realm.Realm;
import io.realm.RealmList;
import io.realm.RealmObject;
import io.realm.RealmResults;
import io.realm.Sort;
import io.realm.annotations.PrimaryKey;
import static de.dorianscholz.openlibre.OpenLibre.realmConfigProcessedData;
import static de.dorianscholz.openlibre.model.SensorData.maxSensorAgeInMinutes;
import static de.dorianscholz.openlibre.model.SensorData.minSensorAgeInMinutes;
import static java.lang.Math.min;
public static final int historyIntervalInMinutes = 15;
public static final int numTrendValues = 16;
@PrimaryKey
private String id;
private SensorData sensor;
private int sensorAgeInMinutes = -1;
private long date = -1;
private int timezoneOffsetInMinutes;
private RealmList<GlucoseData> trend = new RealmList<>();
private RealmList<GlucoseData> history = new RealmList<>();
public ReadingData() {}
public ReadingData(RawTagData rawTagData) {
id = rawTagData.getId();
date = rawTagData.getDate();
timezoneOffsetInMinutes = rawTagData.getTimezoneOffsetInMinutes();
sensorAgeInMinutes = rawTagData.getSensorAgeInMinutes();
Realm realmProcessedData = Realm.getInstance(realmConfigProcessedData);
// find or create entry for this sensor
RealmResults<SensorData> sensors = realmProcessedData.where(SensorData.class).contains(SensorData.ID, rawTagData.getTagId()).findAll();
if (sensors.size() > 0) {
sensor = sensors.first();
} else {
sensor = new SensorData(rawTagData);
}
// check if sensor is of valid age | if (sensorAgeInMinutes <= minSensorAgeInMinutes || sensorAgeInMinutes > maxSensorAgeInMinutes) { |
DorianScholz/OpenLibre | app/src/main/java/de/dorianscholz/openlibre/ui/BloodGlucoseInputFragment.java | // Path: app/src/main/java/de/dorianscholz/openlibre/model/BloodGlucoseData.java
// public class BloodGlucoseData extends RealmObject implements Comparable<BloodGlucoseData> {
// public static final String ID = "id";
// static final String GLUCOSE_LEVEL = "glucoseLevel";
// public static final String DATE = "date";
// public static final String TIMEZONE_OFFSET_IN_MINUTES = "timezoneOffsetInMinutes";
//
// @PrimaryKey
// private String id;
// private float glucoseLevel = -1; // in mg/dl
// private long date;
// private int timezoneOffsetInMinutes;
//
// public BloodGlucoseData() {}
// public BloodGlucoseData(long date, float glucoseLevel) {
// this.date = date;
// timezoneOffsetInMinutes = TimeZone.getDefault().getOffset(System.currentTimeMillis()) / 1000 / 60;
// this.glucoseLevel = glucoseLevel;
// id = String.format(Locale.US, "blood_%s", mFormatDateTime.format(new Date(date)));
// }
//
// public float glucose() {
// return glucoseLevel;
// }
//
// public String glucoseString() {
// return formatValue(glucose());
// }
//
// @Override
// public int compareTo(@NonNull BloodGlucoseData another) {
// return (int) (date - another.date);
// }
//
// public long getDate() {
// return date;
// }
//
// public int getTimezoneOffsetInMinutes() {
// return timezoneOffsetInMinutes;
// }
// }
//
// Path: app/src/main/java/de/dorianscholz/openlibre/OpenLibre.java
// public static RealmConfiguration realmConfigUserData;
| import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.DialogFragment;
import android.support.v7.app.AlertDialog;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import java.util.Date;
import de.dorianscholz.openlibre.R;
import de.dorianscholz.openlibre.model.BloodGlucoseData;
import io.realm.Realm;
import static de.dorianscholz.openlibre.OpenLibre.realmConfigUserData; | package de.dorianscholz.openlibre.ui;
public class BloodGlucoseInputFragment extends DialogFragment {
public BloodGlucoseInputFragment() {
// Required empty public constructor
}
public static BloodGlucoseInputFragment newInstance() {
BloodGlucoseInputFragment fragment = new BloodGlucoseInputFragment();
Bundle args = new Bundle();
fragment.setArguments(args);
return fragment;
}
public void saveBloodGlucoseLevel(long date, float bloodGlucoseLevel) { | // Path: app/src/main/java/de/dorianscholz/openlibre/model/BloodGlucoseData.java
// public class BloodGlucoseData extends RealmObject implements Comparable<BloodGlucoseData> {
// public static final String ID = "id";
// static final String GLUCOSE_LEVEL = "glucoseLevel";
// public static final String DATE = "date";
// public static final String TIMEZONE_OFFSET_IN_MINUTES = "timezoneOffsetInMinutes";
//
// @PrimaryKey
// private String id;
// private float glucoseLevel = -1; // in mg/dl
// private long date;
// private int timezoneOffsetInMinutes;
//
// public BloodGlucoseData() {}
// public BloodGlucoseData(long date, float glucoseLevel) {
// this.date = date;
// timezoneOffsetInMinutes = TimeZone.getDefault().getOffset(System.currentTimeMillis()) / 1000 / 60;
// this.glucoseLevel = glucoseLevel;
// id = String.format(Locale.US, "blood_%s", mFormatDateTime.format(new Date(date)));
// }
//
// public float glucose() {
// return glucoseLevel;
// }
//
// public String glucoseString() {
// return formatValue(glucose());
// }
//
// @Override
// public int compareTo(@NonNull BloodGlucoseData another) {
// return (int) (date - another.date);
// }
//
// public long getDate() {
// return date;
// }
//
// public int getTimezoneOffsetInMinutes() {
// return timezoneOffsetInMinutes;
// }
// }
//
// Path: app/src/main/java/de/dorianscholz/openlibre/OpenLibre.java
// public static RealmConfiguration realmConfigUserData;
// Path: app/src/main/java/de/dorianscholz/openlibre/ui/BloodGlucoseInputFragment.java
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.DialogFragment;
import android.support.v7.app.AlertDialog;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import java.util.Date;
import de.dorianscholz.openlibre.R;
import de.dorianscholz.openlibre.model.BloodGlucoseData;
import io.realm.Realm;
import static de.dorianscholz.openlibre.OpenLibre.realmConfigUserData;
package de.dorianscholz.openlibre.ui;
public class BloodGlucoseInputFragment extends DialogFragment {
public BloodGlucoseInputFragment() {
// Required empty public constructor
}
public static BloodGlucoseInputFragment newInstance() {
BloodGlucoseInputFragment fragment = new BloodGlucoseInputFragment();
Bundle args = new Bundle();
fragment.setArguments(args);
return fragment;
}
public void saveBloodGlucoseLevel(long date, float bloodGlucoseLevel) { | Realm realmUserData = Realm.getInstance(realmConfigUserData); |
DorianScholz/OpenLibre | app/src/main/java/de/dorianscholz/openlibre/ui/BloodGlucoseInputFragment.java | // Path: app/src/main/java/de/dorianscholz/openlibre/model/BloodGlucoseData.java
// public class BloodGlucoseData extends RealmObject implements Comparable<BloodGlucoseData> {
// public static final String ID = "id";
// static final String GLUCOSE_LEVEL = "glucoseLevel";
// public static final String DATE = "date";
// public static final String TIMEZONE_OFFSET_IN_MINUTES = "timezoneOffsetInMinutes";
//
// @PrimaryKey
// private String id;
// private float glucoseLevel = -1; // in mg/dl
// private long date;
// private int timezoneOffsetInMinutes;
//
// public BloodGlucoseData() {}
// public BloodGlucoseData(long date, float glucoseLevel) {
// this.date = date;
// timezoneOffsetInMinutes = TimeZone.getDefault().getOffset(System.currentTimeMillis()) / 1000 / 60;
// this.glucoseLevel = glucoseLevel;
// id = String.format(Locale.US, "blood_%s", mFormatDateTime.format(new Date(date)));
// }
//
// public float glucose() {
// return glucoseLevel;
// }
//
// public String glucoseString() {
// return formatValue(glucose());
// }
//
// @Override
// public int compareTo(@NonNull BloodGlucoseData another) {
// return (int) (date - another.date);
// }
//
// public long getDate() {
// return date;
// }
//
// public int getTimezoneOffsetInMinutes() {
// return timezoneOffsetInMinutes;
// }
// }
//
// Path: app/src/main/java/de/dorianscholz/openlibre/OpenLibre.java
// public static RealmConfiguration realmConfigUserData;
| import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.DialogFragment;
import android.support.v7.app.AlertDialog;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import java.util.Date;
import de.dorianscholz.openlibre.R;
import de.dorianscholz.openlibre.model.BloodGlucoseData;
import io.realm.Realm;
import static de.dorianscholz.openlibre.OpenLibre.realmConfigUserData; | package de.dorianscholz.openlibre.ui;
public class BloodGlucoseInputFragment extends DialogFragment {
public BloodGlucoseInputFragment() {
// Required empty public constructor
}
public static BloodGlucoseInputFragment newInstance() {
BloodGlucoseInputFragment fragment = new BloodGlucoseInputFragment();
Bundle args = new Bundle();
fragment.setArguments(args);
return fragment;
}
public void saveBloodGlucoseLevel(long date, float bloodGlucoseLevel) {
Realm realmUserData = Realm.getInstance(realmConfigUserData);
realmUserData.beginTransaction(); | // Path: app/src/main/java/de/dorianscholz/openlibre/model/BloodGlucoseData.java
// public class BloodGlucoseData extends RealmObject implements Comparable<BloodGlucoseData> {
// public static final String ID = "id";
// static final String GLUCOSE_LEVEL = "glucoseLevel";
// public static final String DATE = "date";
// public static final String TIMEZONE_OFFSET_IN_MINUTES = "timezoneOffsetInMinutes";
//
// @PrimaryKey
// private String id;
// private float glucoseLevel = -1; // in mg/dl
// private long date;
// private int timezoneOffsetInMinutes;
//
// public BloodGlucoseData() {}
// public BloodGlucoseData(long date, float glucoseLevel) {
// this.date = date;
// timezoneOffsetInMinutes = TimeZone.getDefault().getOffset(System.currentTimeMillis()) / 1000 / 60;
// this.glucoseLevel = glucoseLevel;
// id = String.format(Locale.US, "blood_%s", mFormatDateTime.format(new Date(date)));
// }
//
// public float glucose() {
// return glucoseLevel;
// }
//
// public String glucoseString() {
// return formatValue(glucose());
// }
//
// @Override
// public int compareTo(@NonNull BloodGlucoseData another) {
// return (int) (date - another.date);
// }
//
// public long getDate() {
// return date;
// }
//
// public int getTimezoneOffsetInMinutes() {
// return timezoneOffsetInMinutes;
// }
// }
//
// Path: app/src/main/java/de/dorianscholz/openlibre/OpenLibre.java
// public static RealmConfiguration realmConfigUserData;
// Path: app/src/main/java/de/dorianscholz/openlibre/ui/BloodGlucoseInputFragment.java
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.DialogFragment;
import android.support.v7.app.AlertDialog;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import java.util.Date;
import de.dorianscholz.openlibre.R;
import de.dorianscholz.openlibre.model.BloodGlucoseData;
import io.realm.Realm;
import static de.dorianscholz.openlibre.OpenLibre.realmConfigUserData;
package de.dorianscholz.openlibre.ui;
public class BloodGlucoseInputFragment extends DialogFragment {
public BloodGlucoseInputFragment() {
// Required empty public constructor
}
public static BloodGlucoseInputFragment newInstance() {
BloodGlucoseInputFragment fragment = new BloodGlucoseInputFragment();
Bundle args = new Bundle();
fragment.setArguments(args);
return fragment;
}
public void saveBloodGlucoseLevel(long date, float bloodGlucoseLevel) {
Realm realmUserData = Realm.getInstance(realmConfigUserData);
realmUserData.beginTransaction(); | realmUserData.copyToRealmOrUpdate(new BloodGlucoseData(date, bloodGlucoseLevel)); |
DorianScholz/OpenLibre | app/src/main/java/de/dorianscholz/openlibre/ui/DateTimeMarkerView.java | // Path: app/src/main/java/de/dorianscholz/openlibre/model/AlgorithmUtil.java
// public static final DateFormat mFormatDateTime = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
//
// Path: app/src/main/java/de/dorianscholz/openlibre/model/GlucoseData.java
// public static String formatValue(float value) {
// return GLUCOSE_UNIT_IS_MMOL ?
// new DecimalFormat("##.0").format(value) :
// new DecimalFormat("###").format(value);
// }
//
// Path: app/src/main/java/de/dorianscholz/openlibre/model/GlucoseData.java
// public static String getDisplayUnit() {
// return GLUCOSE_UNIT_IS_MMOL ? "mmol/l" : "mg/dl";
// }
| import android.content.Context;
import android.util.Log;
import android.widget.TextView;
import com.github.mikephil.charting.charts.Chart;
import com.github.mikephil.charting.components.MarkerView;
import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.highlight.Highlight;
import com.github.mikephil.charting.utils.MPPointF;
import java.util.Date;
import java.util.concurrent.TimeUnit;
import de.dorianscholz.openlibre.R;
import static de.dorianscholz.openlibre.model.AlgorithmUtil.mFormatDateTime;
import static de.dorianscholz.openlibre.model.GlucoseData.formatValue;
import static de.dorianscholz.openlibre.model.GlucoseData.getDisplayUnit;
import static java.lang.Math.max;
import static java.lang.Math.min; | package de.dorianscholz.openlibre.ui;
public class DateTimeMarkerView extends MarkerView {
private TextView tvContent;
private long mFirstDate;
public DateTimeMarkerView(Context context, int layoutResource) {
super(context, layoutResource);
tvContent = (TextView) findViewById(R.id.tvContent);
}
public void setFirstDate(long firstDate) {
mFirstDate = firstDate;
}
private long convertXAxisValueToDate(float value) {
return mFirstDate + (long) (value * TimeUnit.MINUTES.toMillis(1L));
}
@Override
public void refreshContent(Entry e, Highlight highlight) { | // Path: app/src/main/java/de/dorianscholz/openlibre/model/AlgorithmUtil.java
// public static final DateFormat mFormatDateTime = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
//
// Path: app/src/main/java/de/dorianscholz/openlibre/model/GlucoseData.java
// public static String formatValue(float value) {
// return GLUCOSE_UNIT_IS_MMOL ?
// new DecimalFormat("##.0").format(value) :
// new DecimalFormat("###").format(value);
// }
//
// Path: app/src/main/java/de/dorianscholz/openlibre/model/GlucoseData.java
// public static String getDisplayUnit() {
// return GLUCOSE_UNIT_IS_MMOL ? "mmol/l" : "mg/dl";
// }
// Path: app/src/main/java/de/dorianscholz/openlibre/ui/DateTimeMarkerView.java
import android.content.Context;
import android.util.Log;
import android.widget.TextView;
import com.github.mikephil.charting.charts.Chart;
import com.github.mikephil.charting.components.MarkerView;
import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.highlight.Highlight;
import com.github.mikephil.charting.utils.MPPointF;
import java.util.Date;
import java.util.concurrent.TimeUnit;
import de.dorianscholz.openlibre.R;
import static de.dorianscholz.openlibre.model.AlgorithmUtil.mFormatDateTime;
import static de.dorianscholz.openlibre.model.GlucoseData.formatValue;
import static de.dorianscholz.openlibre.model.GlucoseData.getDisplayUnit;
import static java.lang.Math.max;
import static java.lang.Math.min;
package de.dorianscholz.openlibre.ui;
public class DateTimeMarkerView extends MarkerView {
private TextView tvContent;
private long mFirstDate;
public DateTimeMarkerView(Context context, int layoutResource) {
super(context, layoutResource);
tvContent = (TextView) findViewById(R.id.tvContent);
}
public void setFirstDate(long firstDate) {
mFirstDate = firstDate;
}
private long convertXAxisValueToDate(float value) {
return mFirstDate + (long) (value * TimeUnit.MINUTES.toMillis(1L));
}
@Override
public void refreshContent(Entry e, Highlight highlight) { | tvContent.setText(formatValue(e.getY()) + " " + getDisplayUnit() + " at " + mFormatDateTime.format(new Date(convertXAxisValueToDate(e.getX())))); |
DorianScholz/OpenLibre | app/src/main/java/de/dorianscholz/openlibre/ui/DateTimeMarkerView.java | // Path: app/src/main/java/de/dorianscholz/openlibre/model/AlgorithmUtil.java
// public static final DateFormat mFormatDateTime = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
//
// Path: app/src/main/java/de/dorianscholz/openlibre/model/GlucoseData.java
// public static String formatValue(float value) {
// return GLUCOSE_UNIT_IS_MMOL ?
// new DecimalFormat("##.0").format(value) :
// new DecimalFormat("###").format(value);
// }
//
// Path: app/src/main/java/de/dorianscholz/openlibre/model/GlucoseData.java
// public static String getDisplayUnit() {
// return GLUCOSE_UNIT_IS_MMOL ? "mmol/l" : "mg/dl";
// }
| import android.content.Context;
import android.util.Log;
import android.widget.TextView;
import com.github.mikephil.charting.charts.Chart;
import com.github.mikephil.charting.components.MarkerView;
import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.highlight.Highlight;
import com.github.mikephil.charting.utils.MPPointF;
import java.util.Date;
import java.util.concurrent.TimeUnit;
import de.dorianscholz.openlibre.R;
import static de.dorianscholz.openlibre.model.AlgorithmUtil.mFormatDateTime;
import static de.dorianscholz.openlibre.model.GlucoseData.formatValue;
import static de.dorianscholz.openlibre.model.GlucoseData.getDisplayUnit;
import static java.lang.Math.max;
import static java.lang.Math.min; | package de.dorianscholz.openlibre.ui;
public class DateTimeMarkerView extends MarkerView {
private TextView tvContent;
private long mFirstDate;
public DateTimeMarkerView(Context context, int layoutResource) {
super(context, layoutResource);
tvContent = (TextView) findViewById(R.id.tvContent);
}
public void setFirstDate(long firstDate) {
mFirstDate = firstDate;
}
private long convertXAxisValueToDate(float value) {
return mFirstDate + (long) (value * TimeUnit.MINUTES.toMillis(1L));
}
@Override
public void refreshContent(Entry e, Highlight highlight) { | // Path: app/src/main/java/de/dorianscholz/openlibre/model/AlgorithmUtil.java
// public static final DateFormat mFormatDateTime = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
//
// Path: app/src/main/java/de/dorianscholz/openlibre/model/GlucoseData.java
// public static String formatValue(float value) {
// return GLUCOSE_UNIT_IS_MMOL ?
// new DecimalFormat("##.0").format(value) :
// new DecimalFormat("###").format(value);
// }
//
// Path: app/src/main/java/de/dorianscholz/openlibre/model/GlucoseData.java
// public static String getDisplayUnit() {
// return GLUCOSE_UNIT_IS_MMOL ? "mmol/l" : "mg/dl";
// }
// Path: app/src/main/java/de/dorianscholz/openlibre/ui/DateTimeMarkerView.java
import android.content.Context;
import android.util.Log;
import android.widget.TextView;
import com.github.mikephil.charting.charts.Chart;
import com.github.mikephil.charting.components.MarkerView;
import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.highlight.Highlight;
import com.github.mikephil.charting.utils.MPPointF;
import java.util.Date;
import java.util.concurrent.TimeUnit;
import de.dorianscholz.openlibre.R;
import static de.dorianscholz.openlibre.model.AlgorithmUtil.mFormatDateTime;
import static de.dorianscholz.openlibre.model.GlucoseData.formatValue;
import static de.dorianscholz.openlibre.model.GlucoseData.getDisplayUnit;
import static java.lang.Math.max;
import static java.lang.Math.min;
package de.dorianscholz.openlibre.ui;
public class DateTimeMarkerView extends MarkerView {
private TextView tvContent;
private long mFirstDate;
public DateTimeMarkerView(Context context, int layoutResource) {
super(context, layoutResource);
tvContent = (TextView) findViewById(R.id.tvContent);
}
public void setFirstDate(long firstDate) {
mFirstDate = firstDate;
}
private long convertXAxisValueToDate(float value) {
return mFirstDate + (long) (value * TimeUnit.MINUTES.toMillis(1L));
}
@Override
public void refreshContent(Entry e, Highlight highlight) { | tvContent.setText(formatValue(e.getY()) + " " + getDisplayUnit() + " at " + mFormatDateTime.format(new Date(convertXAxisValueToDate(e.getX())))); |
DorianScholz/OpenLibre | app/src/main/java/de/dorianscholz/openlibre/ui/DateTimeMarkerView.java | // Path: app/src/main/java/de/dorianscholz/openlibre/model/AlgorithmUtil.java
// public static final DateFormat mFormatDateTime = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
//
// Path: app/src/main/java/de/dorianscholz/openlibre/model/GlucoseData.java
// public static String formatValue(float value) {
// return GLUCOSE_UNIT_IS_MMOL ?
// new DecimalFormat("##.0").format(value) :
// new DecimalFormat("###").format(value);
// }
//
// Path: app/src/main/java/de/dorianscholz/openlibre/model/GlucoseData.java
// public static String getDisplayUnit() {
// return GLUCOSE_UNIT_IS_MMOL ? "mmol/l" : "mg/dl";
// }
| import android.content.Context;
import android.util.Log;
import android.widget.TextView;
import com.github.mikephil.charting.charts.Chart;
import com.github.mikephil.charting.components.MarkerView;
import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.highlight.Highlight;
import com.github.mikephil.charting.utils.MPPointF;
import java.util.Date;
import java.util.concurrent.TimeUnit;
import de.dorianscholz.openlibre.R;
import static de.dorianscholz.openlibre.model.AlgorithmUtil.mFormatDateTime;
import static de.dorianscholz.openlibre.model.GlucoseData.formatValue;
import static de.dorianscholz.openlibre.model.GlucoseData.getDisplayUnit;
import static java.lang.Math.max;
import static java.lang.Math.min; | package de.dorianscholz.openlibre.ui;
public class DateTimeMarkerView extends MarkerView {
private TextView tvContent;
private long mFirstDate;
public DateTimeMarkerView(Context context, int layoutResource) {
super(context, layoutResource);
tvContent = (TextView) findViewById(R.id.tvContent);
}
public void setFirstDate(long firstDate) {
mFirstDate = firstDate;
}
private long convertXAxisValueToDate(float value) {
return mFirstDate + (long) (value * TimeUnit.MINUTES.toMillis(1L));
}
@Override
public void refreshContent(Entry e, Highlight highlight) { | // Path: app/src/main/java/de/dorianscholz/openlibre/model/AlgorithmUtil.java
// public static final DateFormat mFormatDateTime = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
//
// Path: app/src/main/java/de/dorianscholz/openlibre/model/GlucoseData.java
// public static String formatValue(float value) {
// return GLUCOSE_UNIT_IS_MMOL ?
// new DecimalFormat("##.0").format(value) :
// new DecimalFormat("###").format(value);
// }
//
// Path: app/src/main/java/de/dorianscholz/openlibre/model/GlucoseData.java
// public static String getDisplayUnit() {
// return GLUCOSE_UNIT_IS_MMOL ? "mmol/l" : "mg/dl";
// }
// Path: app/src/main/java/de/dorianscholz/openlibre/ui/DateTimeMarkerView.java
import android.content.Context;
import android.util.Log;
import android.widget.TextView;
import com.github.mikephil.charting.charts.Chart;
import com.github.mikephil.charting.components.MarkerView;
import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.highlight.Highlight;
import com.github.mikephil.charting.utils.MPPointF;
import java.util.Date;
import java.util.concurrent.TimeUnit;
import de.dorianscholz.openlibre.R;
import static de.dorianscholz.openlibre.model.AlgorithmUtil.mFormatDateTime;
import static de.dorianscholz.openlibre.model.GlucoseData.formatValue;
import static de.dorianscholz.openlibre.model.GlucoseData.getDisplayUnit;
import static java.lang.Math.max;
import static java.lang.Math.min;
package de.dorianscholz.openlibre.ui;
public class DateTimeMarkerView extends MarkerView {
private TextView tvContent;
private long mFirstDate;
public DateTimeMarkerView(Context context, int layoutResource) {
super(context, layoutResource);
tvContent = (TextView) findViewById(R.id.tvContent);
}
public void setFirstDate(long firstDate) {
mFirstDate = firstDate;
}
private long convertXAxisValueToDate(float value) {
return mFirstDate + (long) (value * TimeUnit.MINUTES.toMillis(1L));
}
@Override
public void refreshContent(Entry e, Highlight highlight) { | tvContent.setText(formatValue(e.getY()) + " " + getDisplayUnit() + " at " + mFormatDateTime.format(new Date(convertXAxisValueToDate(e.getX())))); |
DorianScholz/OpenLibre | app/src/main/java/de/dorianscholz/openlibre/ui/SensorStatusFragment.java | // Path: app/src/main/java/de/dorianscholz/openlibre/model/SensorData.java
// public class SensorData extends RealmObject {
// public static final String ID = "id";
// public static final String START_DATE = "startDate";
//
// public static final long minSensorAgeInMinutes = 60; // data generated by the sensor in the first 60 minutes is not correct
// public static final long maxSensorAgeInMinutes = TimeUnit.DAYS.toMinutes(14); // data generated by the sensor after 14 days also has faults
//
// @PrimaryKey
// private String id;
// private long startDate = -1;
//
// public SensorData() {}
//
// public SensorData(RawTagData rawTagData) {
// id = String.format(Locale.US, "sensor_%s", rawTagData.getTagId());
// startDate = rawTagData.getDate() - (rawTagData.getDate() % TimeUnit.MINUTES.toMillis(1))
// - TimeUnit.MINUTES.toMillis(rawTagData.getSensorAgeInMinutes());
// }
//
// public SensorData(SensorData sensor) {
// this.id = sensor.id;
// this.startDate = sensor.getStartDate();
// }
//
// public String getTagId() {
// return id.substring(7);
// }
//
// public long getTimeLeft() {
// return max(0, startDate + TimeUnit.MINUTES.toMillis(maxSensorAgeInMinutes) - System.currentTimeMillis());
// }
//
// public long getStartDate() {
// return startDate;
// }
//
// public String getId() {
// return id;
// }
// }
//
// Path: app/src/main/java/de/dorianscholz/openlibre/OpenLibre.java
// public static RealmConfiguration realmConfigProcessedData;
//
// Path: app/src/main/java/de/dorianscholz/openlibre/model/AlgorithmUtil.java
// public static String getDurationBreakdown(Resources resources, long duration)
// {
// duration = max(0, duration);
//
// long days = TimeUnit.MILLISECONDS.toDays(duration);
// duration -= TimeUnit.DAYS.toMillis(days);
// long hours = TimeUnit.MILLISECONDS.toHours(duration);
// duration -= TimeUnit.HOURS.toMillis(hours);
// long minutes = TimeUnit.MILLISECONDS.toMinutes(duration);
//
// if (days > 1) {
// return days + " " + resources.getString(R.string.days);
// }
// if (days == 1) {
// return "1 " + resources.getString(R.string.day);
// }
// if (hours > 1) {
// return hours + " " + resources.getString(R.string.hours);
// }
// if (hours == 1) {
// return "1 " + resources.getString(R.string.hour);
// }
// if (minutes > 1) {
// return minutes + " " + resources.getString(R.string.minutes);
// }
// if (minutes == 1) {
// return "1 " + resources.getString(R.string.minute);
// }
//
// return "0 " + resources.getString(R.string.minutes);
// }
//
// Path: app/src/main/java/de/dorianscholz/openlibre/model/SensorData.java
// public static final String START_DATE = "startDate";
| import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.DialogFragment;
import android.support.v7.app.AlertDialog;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import java.text.DateFormat;
import java.util.Date;
import java.util.concurrent.TimeUnit;
import de.dorianscholz.openlibre.R;
import de.dorianscholz.openlibre.model.SensorData;
import io.realm.Realm;
import io.realm.RealmResults;
import io.realm.Sort;
import static de.dorianscholz.openlibre.OpenLibre.realmConfigProcessedData;
import static de.dorianscholz.openlibre.model.AlgorithmUtil.getDurationBreakdown;
import static de.dorianscholz.openlibre.model.SensorData.START_DATE; | package de.dorianscholz.openlibre.ui;
public class SensorStatusFragment extends DialogFragment {
public SensorStatusFragment() {
// Required empty public constructor
}
public static SensorStatusFragment newInstance() {
SensorStatusFragment fragment = new SensorStatusFragment();
Bundle args = new Bundle();
fragment.setArguments(args);
return fragment;
}
public void setupUi(View view) { | // Path: app/src/main/java/de/dorianscholz/openlibre/model/SensorData.java
// public class SensorData extends RealmObject {
// public static final String ID = "id";
// public static final String START_DATE = "startDate";
//
// public static final long minSensorAgeInMinutes = 60; // data generated by the sensor in the first 60 minutes is not correct
// public static final long maxSensorAgeInMinutes = TimeUnit.DAYS.toMinutes(14); // data generated by the sensor after 14 days also has faults
//
// @PrimaryKey
// private String id;
// private long startDate = -1;
//
// public SensorData() {}
//
// public SensorData(RawTagData rawTagData) {
// id = String.format(Locale.US, "sensor_%s", rawTagData.getTagId());
// startDate = rawTagData.getDate() - (rawTagData.getDate() % TimeUnit.MINUTES.toMillis(1))
// - TimeUnit.MINUTES.toMillis(rawTagData.getSensorAgeInMinutes());
// }
//
// public SensorData(SensorData sensor) {
// this.id = sensor.id;
// this.startDate = sensor.getStartDate();
// }
//
// public String getTagId() {
// return id.substring(7);
// }
//
// public long getTimeLeft() {
// return max(0, startDate + TimeUnit.MINUTES.toMillis(maxSensorAgeInMinutes) - System.currentTimeMillis());
// }
//
// public long getStartDate() {
// return startDate;
// }
//
// public String getId() {
// return id;
// }
// }
//
// Path: app/src/main/java/de/dorianscholz/openlibre/OpenLibre.java
// public static RealmConfiguration realmConfigProcessedData;
//
// Path: app/src/main/java/de/dorianscholz/openlibre/model/AlgorithmUtil.java
// public static String getDurationBreakdown(Resources resources, long duration)
// {
// duration = max(0, duration);
//
// long days = TimeUnit.MILLISECONDS.toDays(duration);
// duration -= TimeUnit.DAYS.toMillis(days);
// long hours = TimeUnit.MILLISECONDS.toHours(duration);
// duration -= TimeUnit.HOURS.toMillis(hours);
// long minutes = TimeUnit.MILLISECONDS.toMinutes(duration);
//
// if (days > 1) {
// return days + " " + resources.getString(R.string.days);
// }
// if (days == 1) {
// return "1 " + resources.getString(R.string.day);
// }
// if (hours > 1) {
// return hours + " " + resources.getString(R.string.hours);
// }
// if (hours == 1) {
// return "1 " + resources.getString(R.string.hour);
// }
// if (minutes > 1) {
// return minutes + " " + resources.getString(R.string.minutes);
// }
// if (minutes == 1) {
// return "1 " + resources.getString(R.string.minute);
// }
//
// return "0 " + resources.getString(R.string.minutes);
// }
//
// Path: app/src/main/java/de/dorianscholz/openlibre/model/SensorData.java
// public static final String START_DATE = "startDate";
// Path: app/src/main/java/de/dorianscholz/openlibre/ui/SensorStatusFragment.java
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.DialogFragment;
import android.support.v7.app.AlertDialog;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import java.text.DateFormat;
import java.util.Date;
import java.util.concurrent.TimeUnit;
import de.dorianscholz.openlibre.R;
import de.dorianscholz.openlibre.model.SensorData;
import io.realm.Realm;
import io.realm.RealmResults;
import io.realm.Sort;
import static de.dorianscholz.openlibre.OpenLibre.realmConfigProcessedData;
import static de.dorianscholz.openlibre.model.AlgorithmUtil.getDurationBreakdown;
import static de.dorianscholz.openlibre.model.SensorData.START_DATE;
package de.dorianscholz.openlibre.ui;
public class SensorStatusFragment extends DialogFragment {
public SensorStatusFragment() {
// Required empty public constructor
}
public static SensorStatusFragment newInstance() {
SensorStatusFragment fragment = new SensorStatusFragment();
Bundle args = new Bundle();
fragment.setArguments(args);
return fragment;
}
public void setupUi(View view) { | Realm realmProcessedData = Realm.getInstance(realmConfigProcessedData); |
DorianScholz/OpenLibre | app/src/main/java/de/dorianscholz/openlibre/ui/SensorStatusFragment.java | // Path: app/src/main/java/de/dorianscholz/openlibre/model/SensorData.java
// public class SensorData extends RealmObject {
// public static final String ID = "id";
// public static final String START_DATE = "startDate";
//
// public static final long minSensorAgeInMinutes = 60; // data generated by the sensor in the first 60 minutes is not correct
// public static final long maxSensorAgeInMinutes = TimeUnit.DAYS.toMinutes(14); // data generated by the sensor after 14 days also has faults
//
// @PrimaryKey
// private String id;
// private long startDate = -1;
//
// public SensorData() {}
//
// public SensorData(RawTagData rawTagData) {
// id = String.format(Locale.US, "sensor_%s", rawTagData.getTagId());
// startDate = rawTagData.getDate() - (rawTagData.getDate() % TimeUnit.MINUTES.toMillis(1))
// - TimeUnit.MINUTES.toMillis(rawTagData.getSensorAgeInMinutes());
// }
//
// public SensorData(SensorData sensor) {
// this.id = sensor.id;
// this.startDate = sensor.getStartDate();
// }
//
// public String getTagId() {
// return id.substring(7);
// }
//
// public long getTimeLeft() {
// return max(0, startDate + TimeUnit.MINUTES.toMillis(maxSensorAgeInMinutes) - System.currentTimeMillis());
// }
//
// public long getStartDate() {
// return startDate;
// }
//
// public String getId() {
// return id;
// }
// }
//
// Path: app/src/main/java/de/dorianscholz/openlibre/OpenLibre.java
// public static RealmConfiguration realmConfigProcessedData;
//
// Path: app/src/main/java/de/dorianscholz/openlibre/model/AlgorithmUtil.java
// public static String getDurationBreakdown(Resources resources, long duration)
// {
// duration = max(0, duration);
//
// long days = TimeUnit.MILLISECONDS.toDays(duration);
// duration -= TimeUnit.DAYS.toMillis(days);
// long hours = TimeUnit.MILLISECONDS.toHours(duration);
// duration -= TimeUnit.HOURS.toMillis(hours);
// long minutes = TimeUnit.MILLISECONDS.toMinutes(duration);
//
// if (days > 1) {
// return days + " " + resources.getString(R.string.days);
// }
// if (days == 1) {
// return "1 " + resources.getString(R.string.day);
// }
// if (hours > 1) {
// return hours + " " + resources.getString(R.string.hours);
// }
// if (hours == 1) {
// return "1 " + resources.getString(R.string.hour);
// }
// if (minutes > 1) {
// return minutes + " " + resources.getString(R.string.minutes);
// }
// if (minutes == 1) {
// return "1 " + resources.getString(R.string.minute);
// }
//
// return "0 " + resources.getString(R.string.minutes);
// }
//
// Path: app/src/main/java/de/dorianscholz/openlibre/model/SensorData.java
// public static final String START_DATE = "startDate";
| import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.DialogFragment;
import android.support.v7.app.AlertDialog;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import java.text.DateFormat;
import java.util.Date;
import java.util.concurrent.TimeUnit;
import de.dorianscholz.openlibre.R;
import de.dorianscholz.openlibre.model.SensorData;
import io.realm.Realm;
import io.realm.RealmResults;
import io.realm.Sort;
import static de.dorianscholz.openlibre.OpenLibre.realmConfigProcessedData;
import static de.dorianscholz.openlibre.model.AlgorithmUtil.getDurationBreakdown;
import static de.dorianscholz.openlibre.model.SensorData.START_DATE; | package de.dorianscholz.openlibre.ui;
public class SensorStatusFragment extends DialogFragment {
public SensorStatusFragment() {
// Required empty public constructor
}
public static SensorStatusFragment newInstance() {
SensorStatusFragment fragment = new SensorStatusFragment();
Bundle args = new Bundle();
fragment.setArguments(args);
return fragment;
}
public void setupUi(View view) {
Realm realmProcessedData = Realm.getInstance(realmConfigProcessedData); | // Path: app/src/main/java/de/dorianscholz/openlibre/model/SensorData.java
// public class SensorData extends RealmObject {
// public static final String ID = "id";
// public static final String START_DATE = "startDate";
//
// public static final long minSensorAgeInMinutes = 60; // data generated by the sensor in the first 60 minutes is not correct
// public static final long maxSensorAgeInMinutes = TimeUnit.DAYS.toMinutes(14); // data generated by the sensor after 14 days also has faults
//
// @PrimaryKey
// private String id;
// private long startDate = -1;
//
// public SensorData() {}
//
// public SensorData(RawTagData rawTagData) {
// id = String.format(Locale.US, "sensor_%s", rawTagData.getTagId());
// startDate = rawTagData.getDate() - (rawTagData.getDate() % TimeUnit.MINUTES.toMillis(1))
// - TimeUnit.MINUTES.toMillis(rawTagData.getSensorAgeInMinutes());
// }
//
// public SensorData(SensorData sensor) {
// this.id = sensor.id;
// this.startDate = sensor.getStartDate();
// }
//
// public String getTagId() {
// return id.substring(7);
// }
//
// public long getTimeLeft() {
// return max(0, startDate + TimeUnit.MINUTES.toMillis(maxSensorAgeInMinutes) - System.currentTimeMillis());
// }
//
// public long getStartDate() {
// return startDate;
// }
//
// public String getId() {
// return id;
// }
// }
//
// Path: app/src/main/java/de/dorianscholz/openlibre/OpenLibre.java
// public static RealmConfiguration realmConfigProcessedData;
//
// Path: app/src/main/java/de/dorianscholz/openlibre/model/AlgorithmUtil.java
// public static String getDurationBreakdown(Resources resources, long duration)
// {
// duration = max(0, duration);
//
// long days = TimeUnit.MILLISECONDS.toDays(duration);
// duration -= TimeUnit.DAYS.toMillis(days);
// long hours = TimeUnit.MILLISECONDS.toHours(duration);
// duration -= TimeUnit.HOURS.toMillis(hours);
// long minutes = TimeUnit.MILLISECONDS.toMinutes(duration);
//
// if (days > 1) {
// return days + " " + resources.getString(R.string.days);
// }
// if (days == 1) {
// return "1 " + resources.getString(R.string.day);
// }
// if (hours > 1) {
// return hours + " " + resources.getString(R.string.hours);
// }
// if (hours == 1) {
// return "1 " + resources.getString(R.string.hour);
// }
// if (minutes > 1) {
// return minutes + " " + resources.getString(R.string.minutes);
// }
// if (minutes == 1) {
// return "1 " + resources.getString(R.string.minute);
// }
//
// return "0 " + resources.getString(R.string.minutes);
// }
//
// Path: app/src/main/java/de/dorianscholz/openlibre/model/SensorData.java
// public static final String START_DATE = "startDate";
// Path: app/src/main/java/de/dorianscholz/openlibre/ui/SensorStatusFragment.java
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.DialogFragment;
import android.support.v7.app.AlertDialog;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import java.text.DateFormat;
import java.util.Date;
import java.util.concurrent.TimeUnit;
import de.dorianscholz.openlibre.R;
import de.dorianscholz.openlibre.model.SensorData;
import io.realm.Realm;
import io.realm.RealmResults;
import io.realm.Sort;
import static de.dorianscholz.openlibre.OpenLibre.realmConfigProcessedData;
import static de.dorianscholz.openlibre.model.AlgorithmUtil.getDurationBreakdown;
import static de.dorianscholz.openlibre.model.SensorData.START_DATE;
package de.dorianscholz.openlibre.ui;
public class SensorStatusFragment extends DialogFragment {
public SensorStatusFragment() {
// Required empty public constructor
}
public static SensorStatusFragment newInstance() {
SensorStatusFragment fragment = new SensorStatusFragment();
Bundle args = new Bundle();
fragment.setArguments(args);
return fragment;
}
public void setupUi(View view) {
Realm realmProcessedData = Realm.getInstance(realmConfigProcessedData); | RealmResults<SensorData> sensorDataResults = realmProcessedData.where(SensorData.class). |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.