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
regis-leray/factory_duke
src/test/java/custom/EmptyFactory.java
// Path: src/main/java/factoryduke/FactoryDuke.java // public class FactoryDuke { // private FactoryDuke() { // } // // public static <T> void define(Class<T> clazz, Supplier<T> builder) { // define(clazz, clazz.getCanonicalName(), builder); // } // // public static <T> void define(Class<T> clazz, String identifier, Supplier<T> builder) { // FactoryRuntimeHolder.getRuntime().register(new SupplyTemplate<>(clazz, identifier, builder)); // } // // public static <T> void define(Class<T> clazz, Consumer<T> builder) { // define(clazz, clazz.getCanonicalName(), builder); // } // // public static <T> void define(Class<T> clazz, String identifier, Consumer<T> builder) { // FactoryRuntimeHolder.getRuntime().register(new ConsumerTemplate(clazz, identifier, builder)); // } // // public static <T> HookBuilder<T> build(Class<T> clazz) { // return build(clazz, clazz.getCanonicalName()); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, String identifier) { // return build(clazz, identifier, o -> { // }); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, Consumer<T> override) { // return build(clazz, clazz.getCanonicalName(), override); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, String identifier, Consumer<T> override) { // return FactoryRuntimeHolder.getRuntime().build(identifier, override); // } // // public static FactoryContext load() { // return load(new String[0]); // } // // public static FactoryContext load(String... packages) { // return FactoryRuntimeHolder.getRuntime().load(packages); // } // // public static void reset() { // FactoryRuntimeHolder.getRuntime().reset(); // } // } // // Path: src/main/java/factoryduke/TFactory.java // public interface TFactory { // void define(); // } // // Path: src/test/java/model/Role.java // public enum Role { // ADMIN, USER // } // // Path: src/test/java/model/User.java // public class User { // private long id; // private String name; // private String lastName; // private Role role; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // private Address addr; // // public Role getRole() { // return role; // } // // public void setRole(Role role) { // this.role = role; // } // // public void setAddr(Address addr) { // this.addr = addr; // } // // public void setLastName(String lastName) { // this.lastName = lastName; // } // // public void setName(String name) { // this.name = name; // } // // public Address getAddr() { // return addr; // } // // public String getLastName() { // return lastName; // } // // public String getName() { // return name; // } // }
import factoryduke.FactoryDuke; import factoryduke.TFactory; import model.Role; import model.User;
/** * The MIT License * Copyright (c) 2016 Regis Leray * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package custom; public class EmptyFactory implements TFactory { @Override public void define() {
// Path: src/main/java/factoryduke/FactoryDuke.java // public class FactoryDuke { // private FactoryDuke() { // } // // public static <T> void define(Class<T> clazz, Supplier<T> builder) { // define(clazz, clazz.getCanonicalName(), builder); // } // // public static <T> void define(Class<T> clazz, String identifier, Supplier<T> builder) { // FactoryRuntimeHolder.getRuntime().register(new SupplyTemplate<>(clazz, identifier, builder)); // } // // public static <T> void define(Class<T> clazz, Consumer<T> builder) { // define(clazz, clazz.getCanonicalName(), builder); // } // // public static <T> void define(Class<T> clazz, String identifier, Consumer<T> builder) { // FactoryRuntimeHolder.getRuntime().register(new ConsumerTemplate(clazz, identifier, builder)); // } // // public static <T> HookBuilder<T> build(Class<T> clazz) { // return build(clazz, clazz.getCanonicalName()); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, String identifier) { // return build(clazz, identifier, o -> { // }); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, Consumer<T> override) { // return build(clazz, clazz.getCanonicalName(), override); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, String identifier, Consumer<T> override) { // return FactoryRuntimeHolder.getRuntime().build(identifier, override); // } // // public static FactoryContext load() { // return load(new String[0]); // } // // public static FactoryContext load(String... packages) { // return FactoryRuntimeHolder.getRuntime().load(packages); // } // // public static void reset() { // FactoryRuntimeHolder.getRuntime().reset(); // } // } // // Path: src/main/java/factoryduke/TFactory.java // public interface TFactory { // void define(); // } // // Path: src/test/java/model/Role.java // public enum Role { // ADMIN, USER // } // // Path: src/test/java/model/User.java // public class User { // private long id; // private String name; // private String lastName; // private Role role; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // private Address addr; // // public Role getRole() { // return role; // } // // public void setRole(Role role) { // this.role = role; // } // // public void setAddr(Address addr) { // this.addr = addr; // } // // public void setLastName(String lastName) { // this.lastName = lastName; // } // // public void setName(String name) { // this.name = name; // } // // public Address getAddr() { // return addr; // } // // public String getLastName() { // return lastName; // } // // public String getName() { // return name; // } // } // Path: src/test/java/custom/EmptyFactory.java import factoryduke.FactoryDuke; import factoryduke.TFactory; import model.Role; import model.User; /** * The MIT License * Copyright (c) 2016 Regis Leray * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package custom; public class EmptyFactory implements TFactory { @Override public void define() {
FactoryDuke.define(User.class, u -> {
regis-leray/factory_duke
src/test/java/custom/EmptyFactory.java
// Path: src/main/java/factoryduke/FactoryDuke.java // public class FactoryDuke { // private FactoryDuke() { // } // // public static <T> void define(Class<T> clazz, Supplier<T> builder) { // define(clazz, clazz.getCanonicalName(), builder); // } // // public static <T> void define(Class<T> clazz, String identifier, Supplier<T> builder) { // FactoryRuntimeHolder.getRuntime().register(new SupplyTemplate<>(clazz, identifier, builder)); // } // // public static <T> void define(Class<T> clazz, Consumer<T> builder) { // define(clazz, clazz.getCanonicalName(), builder); // } // // public static <T> void define(Class<T> clazz, String identifier, Consumer<T> builder) { // FactoryRuntimeHolder.getRuntime().register(new ConsumerTemplate(clazz, identifier, builder)); // } // // public static <T> HookBuilder<T> build(Class<T> clazz) { // return build(clazz, clazz.getCanonicalName()); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, String identifier) { // return build(clazz, identifier, o -> { // }); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, Consumer<T> override) { // return build(clazz, clazz.getCanonicalName(), override); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, String identifier, Consumer<T> override) { // return FactoryRuntimeHolder.getRuntime().build(identifier, override); // } // // public static FactoryContext load() { // return load(new String[0]); // } // // public static FactoryContext load(String... packages) { // return FactoryRuntimeHolder.getRuntime().load(packages); // } // // public static void reset() { // FactoryRuntimeHolder.getRuntime().reset(); // } // } // // Path: src/main/java/factoryduke/TFactory.java // public interface TFactory { // void define(); // } // // Path: src/test/java/model/Role.java // public enum Role { // ADMIN, USER // } // // Path: src/test/java/model/User.java // public class User { // private long id; // private String name; // private String lastName; // private Role role; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // private Address addr; // // public Role getRole() { // return role; // } // // public void setRole(Role role) { // this.role = role; // } // // public void setAddr(Address addr) { // this.addr = addr; // } // // public void setLastName(String lastName) { // this.lastName = lastName; // } // // public void setName(String name) { // this.name = name; // } // // public Address getAddr() { // return addr; // } // // public String getLastName() { // return lastName; // } // // public String getName() { // return name; // } // }
import factoryduke.FactoryDuke; import factoryduke.TFactory; import model.Role; import model.User;
/** * The MIT License * Copyright (c) 2016 Regis Leray * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package custom; public class EmptyFactory implements TFactory { @Override public void define() {
// Path: src/main/java/factoryduke/FactoryDuke.java // public class FactoryDuke { // private FactoryDuke() { // } // // public static <T> void define(Class<T> clazz, Supplier<T> builder) { // define(clazz, clazz.getCanonicalName(), builder); // } // // public static <T> void define(Class<T> clazz, String identifier, Supplier<T> builder) { // FactoryRuntimeHolder.getRuntime().register(new SupplyTemplate<>(clazz, identifier, builder)); // } // // public static <T> void define(Class<T> clazz, Consumer<T> builder) { // define(clazz, clazz.getCanonicalName(), builder); // } // // public static <T> void define(Class<T> clazz, String identifier, Consumer<T> builder) { // FactoryRuntimeHolder.getRuntime().register(new ConsumerTemplate(clazz, identifier, builder)); // } // // public static <T> HookBuilder<T> build(Class<T> clazz) { // return build(clazz, clazz.getCanonicalName()); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, String identifier) { // return build(clazz, identifier, o -> { // }); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, Consumer<T> override) { // return build(clazz, clazz.getCanonicalName(), override); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, String identifier, Consumer<T> override) { // return FactoryRuntimeHolder.getRuntime().build(identifier, override); // } // // public static FactoryContext load() { // return load(new String[0]); // } // // public static FactoryContext load(String... packages) { // return FactoryRuntimeHolder.getRuntime().load(packages); // } // // public static void reset() { // FactoryRuntimeHolder.getRuntime().reset(); // } // } // // Path: src/main/java/factoryduke/TFactory.java // public interface TFactory { // void define(); // } // // Path: src/test/java/model/Role.java // public enum Role { // ADMIN, USER // } // // Path: src/test/java/model/User.java // public class User { // private long id; // private String name; // private String lastName; // private Role role; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // private Address addr; // // public Role getRole() { // return role; // } // // public void setRole(Role role) { // this.role = role; // } // // public void setAddr(Address addr) { // this.addr = addr; // } // // public void setLastName(String lastName) { // this.lastName = lastName; // } // // public void setName(String name) { // this.name = name; // } // // public Address getAddr() { // return addr; // } // // public String getLastName() { // return lastName; // } // // public String getName() { // return name; // } // } // Path: src/test/java/custom/EmptyFactory.java import factoryduke.FactoryDuke; import factoryduke.TFactory; import model.Role; import model.User; /** * The MIT License * Copyright (c) 2016 Regis Leray * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package custom; public class EmptyFactory implements TFactory { @Override public void define() {
FactoryDuke.define(User.class, u -> {
regis-leray/factory_duke
src/test/java/custom/EmptyFactory.java
// Path: src/main/java/factoryduke/FactoryDuke.java // public class FactoryDuke { // private FactoryDuke() { // } // // public static <T> void define(Class<T> clazz, Supplier<T> builder) { // define(clazz, clazz.getCanonicalName(), builder); // } // // public static <T> void define(Class<T> clazz, String identifier, Supplier<T> builder) { // FactoryRuntimeHolder.getRuntime().register(new SupplyTemplate<>(clazz, identifier, builder)); // } // // public static <T> void define(Class<T> clazz, Consumer<T> builder) { // define(clazz, clazz.getCanonicalName(), builder); // } // // public static <T> void define(Class<T> clazz, String identifier, Consumer<T> builder) { // FactoryRuntimeHolder.getRuntime().register(new ConsumerTemplate(clazz, identifier, builder)); // } // // public static <T> HookBuilder<T> build(Class<T> clazz) { // return build(clazz, clazz.getCanonicalName()); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, String identifier) { // return build(clazz, identifier, o -> { // }); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, Consumer<T> override) { // return build(clazz, clazz.getCanonicalName(), override); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, String identifier, Consumer<T> override) { // return FactoryRuntimeHolder.getRuntime().build(identifier, override); // } // // public static FactoryContext load() { // return load(new String[0]); // } // // public static FactoryContext load(String... packages) { // return FactoryRuntimeHolder.getRuntime().load(packages); // } // // public static void reset() { // FactoryRuntimeHolder.getRuntime().reset(); // } // } // // Path: src/main/java/factoryduke/TFactory.java // public interface TFactory { // void define(); // } // // Path: src/test/java/model/Role.java // public enum Role { // ADMIN, USER // } // // Path: src/test/java/model/User.java // public class User { // private long id; // private String name; // private String lastName; // private Role role; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // private Address addr; // // public Role getRole() { // return role; // } // // public void setRole(Role role) { // this.role = role; // } // // public void setAddr(Address addr) { // this.addr = addr; // } // // public void setLastName(String lastName) { // this.lastName = lastName; // } // // public void setName(String name) { // this.name = name; // } // // public Address getAddr() { // return addr; // } // // public String getLastName() { // return lastName; // } // // public String getName() { // return name; // } // }
import factoryduke.FactoryDuke; import factoryduke.TFactory; import model.Role; import model.User;
/** * The MIT License * Copyright (c) 2016 Regis Leray * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package custom; public class EmptyFactory implements TFactory { @Override public void define() { FactoryDuke.define(User.class, u -> { u.setName("Empty");
// Path: src/main/java/factoryduke/FactoryDuke.java // public class FactoryDuke { // private FactoryDuke() { // } // // public static <T> void define(Class<T> clazz, Supplier<T> builder) { // define(clazz, clazz.getCanonicalName(), builder); // } // // public static <T> void define(Class<T> clazz, String identifier, Supplier<T> builder) { // FactoryRuntimeHolder.getRuntime().register(new SupplyTemplate<>(clazz, identifier, builder)); // } // // public static <T> void define(Class<T> clazz, Consumer<T> builder) { // define(clazz, clazz.getCanonicalName(), builder); // } // // public static <T> void define(Class<T> clazz, String identifier, Consumer<T> builder) { // FactoryRuntimeHolder.getRuntime().register(new ConsumerTemplate(clazz, identifier, builder)); // } // // public static <T> HookBuilder<T> build(Class<T> clazz) { // return build(clazz, clazz.getCanonicalName()); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, String identifier) { // return build(clazz, identifier, o -> { // }); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, Consumer<T> override) { // return build(clazz, clazz.getCanonicalName(), override); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, String identifier, Consumer<T> override) { // return FactoryRuntimeHolder.getRuntime().build(identifier, override); // } // // public static FactoryContext load() { // return load(new String[0]); // } // // public static FactoryContext load(String... packages) { // return FactoryRuntimeHolder.getRuntime().load(packages); // } // // public static void reset() { // FactoryRuntimeHolder.getRuntime().reset(); // } // } // // Path: src/main/java/factoryduke/TFactory.java // public interface TFactory { // void define(); // } // // Path: src/test/java/model/Role.java // public enum Role { // ADMIN, USER // } // // Path: src/test/java/model/User.java // public class User { // private long id; // private String name; // private String lastName; // private Role role; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // private Address addr; // // public Role getRole() { // return role; // } // // public void setRole(Role role) { // this.role = role; // } // // public void setAddr(Address addr) { // this.addr = addr; // } // // public void setLastName(String lastName) { // this.lastName = lastName; // } // // public void setName(String name) { // this.name = name; // } // // public Address getAddr() { // return addr; // } // // public String getLastName() { // return lastName; // } // // public String getName() { // return name; // } // } // Path: src/test/java/custom/EmptyFactory.java import factoryduke.FactoryDuke; import factoryduke.TFactory; import model.Role; import model.User; /** * The MIT License * Copyright (c) 2016 Regis Leray * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package custom; public class EmptyFactory implements TFactory { @Override public void define() { FactoryDuke.define(User.class, u -> { u.setName("Empty");
u.setRole(Role.ADMIN);
regis-leray/factory_duke
src/test/java/factories/UserFactory.java
// Path: src/main/java/factoryduke/TFactory.java // public interface TFactory { // void define(); // } // // Path: src/main/java/factoryduke/FactoryDuke.java // public class FactoryDuke { // private FactoryDuke() { // } // // public static <T> void define(Class<T> clazz, Supplier<T> builder) { // define(clazz, clazz.getCanonicalName(), builder); // } // // public static <T> void define(Class<T> clazz, String identifier, Supplier<T> builder) { // FactoryRuntimeHolder.getRuntime().register(new SupplyTemplate<>(clazz, identifier, builder)); // } // // public static <T> void define(Class<T> clazz, Consumer<T> builder) { // define(clazz, clazz.getCanonicalName(), builder); // } // // public static <T> void define(Class<T> clazz, String identifier, Consumer<T> builder) { // FactoryRuntimeHolder.getRuntime().register(new ConsumerTemplate(clazz, identifier, builder)); // } // // public static <T> HookBuilder<T> build(Class<T> clazz) { // return build(clazz, clazz.getCanonicalName()); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, String identifier) { // return build(clazz, identifier, o -> { // }); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, Consumer<T> override) { // return build(clazz, clazz.getCanonicalName(), override); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, String identifier, Consumer<T> override) { // return FactoryRuntimeHolder.getRuntime().build(identifier, override); // } // // public static FactoryContext load() { // return load(new String[0]); // } // // public static FactoryContext load(String... packages) { // return FactoryRuntimeHolder.getRuntime().load(packages); // } // // public static void reset() { // FactoryRuntimeHolder.getRuntime().reset(); // } // } // // Path: src/test/java/model/Address.java // public class Address { // private String country; // private String street; // private String city; // // public String getCountry() { // return country; // } // // public void setCountry(String country) { // this.country = country; // } // // public String getCity() { // return city; // } // // public void setCity(String city) { // this.city = city; // } // // public String getStreet() { // return street; // } // // public void setStreet(String street) { // this.street = street; // } // } // // Path: src/test/java/model/Role.java // public enum Role { // ADMIN, USER // } // // Path: src/test/java/model/User.java // public class User { // private long id; // private String name; // private String lastName; // private Role role; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // private Address addr; // // public Role getRole() { // return role; // } // // public void setRole(Role role) { // this.role = role; // } // // public void setAddr(Address addr) { // this.addr = addr; // } // // public void setLastName(String lastName) { // this.lastName = lastName; // } // // public void setName(String name) { // this.name = name; // } // // public Address getAddr() { // return addr; // } // // public String getLastName() { // return lastName; // } // // public String getName() { // return name; // } // }
import factoryduke.TFactory; import factoryduke.FactoryDuke; import model.Address; import model.Role; import model.User;
/** * The MIT License * Copyright (c) 2016 Regis Leray * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package factories; public class UserFactory implements TFactory { @Override public void define() {
// Path: src/main/java/factoryduke/TFactory.java // public interface TFactory { // void define(); // } // // Path: src/main/java/factoryduke/FactoryDuke.java // public class FactoryDuke { // private FactoryDuke() { // } // // public static <T> void define(Class<T> clazz, Supplier<T> builder) { // define(clazz, clazz.getCanonicalName(), builder); // } // // public static <T> void define(Class<T> clazz, String identifier, Supplier<T> builder) { // FactoryRuntimeHolder.getRuntime().register(new SupplyTemplate<>(clazz, identifier, builder)); // } // // public static <T> void define(Class<T> clazz, Consumer<T> builder) { // define(clazz, clazz.getCanonicalName(), builder); // } // // public static <T> void define(Class<T> clazz, String identifier, Consumer<T> builder) { // FactoryRuntimeHolder.getRuntime().register(new ConsumerTemplate(clazz, identifier, builder)); // } // // public static <T> HookBuilder<T> build(Class<T> clazz) { // return build(clazz, clazz.getCanonicalName()); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, String identifier) { // return build(clazz, identifier, o -> { // }); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, Consumer<T> override) { // return build(clazz, clazz.getCanonicalName(), override); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, String identifier, Consumer<T> override) { // return FactoryRuntimeHolder.getRuntime().build(identifier, override); // } // // public static FactoryContext load() { // return load(new String[0]); // } // // public static FactoryContext load(String... packages) { // return FactoryRuntimeHolder.getRuntime().load(packages); // } // // public static void reset() { // FactoryRuntimeHolder.getRuntime().reset(); // } // } // // Path: src/test/java/model/Address.java // public class Address { // private String country; // private String street; // private String city; // // public String getCountry() { // return country; // } // // public void setCountry(String country) { // this.country = country; // } // // public String getCity() { // return city; // } // // public void setCity(String city) { // this.city = city; // } // // public String getStreet() { // return street; // } // // public void setStreet(String street) { // this.street = street; // } // } // // Path: src/test/java/model/Role.java // public enum Role { // ADMIN, USER // } // // Path: src/test/java/model/User.java // public class User { // private long id; // private String name; // private String lastName; // private Role role; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // private Address addr; // // public Role getRole() { // return role; // } // // public void setRole(Role role) { // this.role = role; // } // // public void setAddr(Address addr) { // this.addr = addr; // } // // public void setLastName(String lastName) { // this.lastName = lastName; // } // // public void setName(String name) { // this.name = name; // } // // public Address getAddr() { // return addr; // } // // public String getLastName() { // return lastName; // } // // public String getName() { // return name; // } // } // Path: src/test/java/factories/UserFactory.java import factoryduke.TFactory; import factoryduke.FactoryDuke; import model.Address; import model.Role; import model.User; /** * The MIT License * Copyright (c) 2016 Regis Leray * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package factories; public class UserFactory implements TFactory { @Override public void define() {
FactoryDuke.define(User.class, "admin_user", u -> {
regis-leray/factory_duke
src/test/java/factories/UserFactory.java
// Path: src/main/java/factoryduke/TFactory.java // public interface TFactory { // void define(); // } // // Path: src/main/java/factoryduke/FactoryDuke.java // public class FactoryDuke { // private FactoryDuke() { // } // // public static <T> void define(Class<T> clazz, Supplier<T> builder) { // define(clazz, clazz.getCanonicalName(), builder); // } // // public static <T> void define(Class<T> clazz, String identifier, Supplier<T> builder) { // FactoryRuntimeHolder.getRuntime().register(new SupplyTemplate<>(clazz, identifier, builder)); // } // // public static <T> void define(Class<T> clazz, Consumer<T> builder) { // define(clazz, clazz.getCanonicalName(), builder); // } // // public static <T> void define(Class<T> clazz, String identifier, Consumer<T> builder) { // FactoryRuntimeHolder.getRuntime().register(new ConsumerTemplate(clazz, identifier, builder)); // } // // public static <T> HookBuilder<T> build(Class<T> clazz) { // return build(clazz, clazz.getCanonicalName()); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, String identifier) { // return build(clazz, identifier, o -> { // }); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, Consumer<T> override) { // return build(clazz, clazz.getCanonicalName(), override); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, String identifier, Consumer<T> override) { // return FactoryRuntimeHolder.getRuntime().build(identifier, override); // } // // public static FactoryContext load() { // return load(new String[0]); // } // // public static FactoryContext load(String... packages) { // return FactoryRuntimeHolder.getRuntime().load(packages); // } // // public static void reset() { // FactoryRuntimeHolder.getRuntime().reset(); // } // } // // Path: src/test/java/model/Address.java // public class Address { // private String country; // private String street; // private String city; // // public String getCountry() { // return country; // } // // public void setCountry(String country) { // this.country = country; // } // // public String getCity() { // return city; // } // // public void setCity(String city) { // this.city = city; // } // // public String getStreet() { // return street; // } // // public void setStreet(String street) { // this.street = street; // } // } // // Path: src/test/java/model/Role.java // public enum Role { // ADMIN, USER // } // // Path: src/test/java/model/User.java // public class User { // private long id; // private String name; // private String lastName; // private Role role; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // private Address addr; // // public Role getRole() { // return role; // } // // public void setRole(Role role) { // this.role = role; // } // // public void setAddr(Address addr) { // this.addr = addr; // } // // public void setLastName(String lastName) { // this.lastName = lastName; // } // // public void setName(String name) { // this.name = name; // } // // public Address getAddr() { // return addr; // } // // public String getLastName() { // return lastName; // } // // public String getName() { // return name; // } // }
import factoryduke.TFactory; import factoryduke.FactoryDuke; import model.Address; import model.Role; import model.User;
/** * The MIT License * Copyright (c) 2016 Regis Leray * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package factories; public class UserFactory implements TFactory { @Override public void define() {
// Path: src/main/java/factoryduke/TFactory.java // public interface TFactory { // void define(); // } // // Path: src/main/java/factoryduke/FactoryDuke.java // public class FactoryDuke { // private FactoryDuke() { // } // // public static <T> void define(Class<T> clazz, Supplier<T> builder) { // define(clazz, clazz.getCanonicalName(), builder); // } // // public static <T> void define(Class<T> clazz, String identifier, Supplier<T> builder) { // FactoryRuntimeHolder.getRuntime().register(new SupplyTemplate<>(clazz, identifier, builder)); // } // // public static <T> void define(Class<T> clazz, Consumer<T> builder) { // define(clazz, clazz.getCanonicalName(), builder); // } // // public static <T> void define(Class<T> clazz, String identifier, Consumer<T> builder) { // FactoryRuntimeHolder.getRuntime().register(new ConsumerTemplate(clazz, identifier, builder)); // } // // public static <T> HookBuilder<T> build(Class<T> clazz) { // return build(clazz, clazz.getCanonicalName()); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, String identifier) { // return build(clazz, identifier, o -> { // }); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, Consumer<T> override) { // return build(clazz, clazz.getCanonicalName(), override); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, String identifier, Consumer<T> override) { // return FactoryRuntimeHolder.getRuntime().build(identifier, override); // } // // public static FactoryContext load() { // return load(new String[0]); // } // // public static FactoryContext load(String... packages) { // return FactoryRuntimeHolder.getRuntime().load(packages); // } // // public static void reset() { // FactoryRuntimeHolder.getRuntime().reset(); // } // } // // Path: src/test/java/model/Address.java // public class Address { // private String country; // private String street; // private String city; // // public String getCountry() { // return country; // } // // public void setCountry(String country) { // this.country = country; // } // // public String getCity() { // return city; // } // // public void setCity(String city) { // this.city = city; // } // // public String getStreet() { // return street; // } // // public void setStreet(String street) { // this.street = street; // } // } // // Path: src/test/java/model/Role.java // public enum Role { // ADMIN, USER // } // // Path: src/test/java/model/User.java // public class User { // private long id; // private String name; // private String lastName; // private Role role; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // private Address addr; // // public Role getRole() { // return role; // } // // public void setRole(Role role) { // this.role = role; // } // // public void setAddr(Address addr) { // this.addr = addr; // } // // public void setLastName(String lastName) { // this.lastName = lastName; // } // // public void setName(String name) { // this.name = name; // } // // public Address getAddr() { // return addr; // } // // public String getLastName() { // return lastName; // } // // public String getName() { // return name; // } // } // Path: src/test/java/factories/UserFactory.java import factoryduke.TFactory; import factoryduke.FactoryDuke; import model.Address; import model.Role; import model.User; /** * The MIT License * Copyright (c) 2016 Regis Leray * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package factories; public class UserFactory implements TFactory { @Override public void define() {
FactoryDuke.define(User.class, "admin_user", u -> {
regis-leray/factory_duke
src/test/java/factories/UserFactory.java
// Path: src/main/java/factoryduke/TFactory.java // public interface TFactory { // void define(); // } // // Path: src/main/java/factoryduke/FactoryDuke.java // public class FactoryDuke { // private FactoryDuke() { // } // // public static <T> void define(Class<T> clazz, Supplier<T> builder) { // define(clazz, clazz.getCanonicalName(), builder); // } // // public static <T> void define(Class<T> clazz, String identifier, Supplier<T> builder) { // FactoryRuntimeHolder.getRuntime().register(new SupplyTemplate<>(clazz, identifier, builder)); // } // // public static <T> void define(Class<T> clazz, Consumer<T> builder) { // define(clazz, clazz.getCanonicalName(), builder); // } // // public static <T> void define(Class<T> clazz, String identifier, Consumer<T> builder) { // FactoryRuntimeHolder.getRuntime().register(new ConsumerTemplate(clazz, identifier, builder)); // } // // public static <T> HookBuilder<T> build(Class<T> clazz) { // return build(clazz, clazz.getCanonicalName()); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, String identifier) { // return build(clazz, identifier, o -> { // }); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, Consumer<T> override) { // return build(clazz, clazz.getCanonicalName(), override); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, String identifier, Consumer<T> override) { // return FactoryRuntimeHolder.getRuntime().build(identifier, override); // } // // public static FactoryContext load() { // return load(new String[0]); // } // // public static FactoryContext load(String... packages) { // return FactoryRuntimeHolder.getRuntime().load(packages); // } // // public static void reset() { // FactoryRuntimeHolder.getRuntime().reset(); // } // } // // Path: src/test/java/model/Address.java // public class Address { // private String country; // private String street; // private String city; // // public String getCountry() { // return country; // } // // public void setCountry(String country) { // this.country = country; // } // // public String getCity() { // return city; // } // // public void setCity(String city) { // this.city = city; // } // // public String getStreet() { // return street; // } // // public void setStreet(String street) { // this.street = street; // } // } // // Path: src/test/java/model/Role.java // public enum Role { // ADMIN, USER // } // // Path: src/test/java/model/User.java // public class User { // private long id; // private String name; // private String lastName; // private Role role; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // private Address addr; // // public Role getRole() { // return role; // } // // public void setRole(Role role) { // this.role = role; // } // // public void setAddr(Address addr) { // this.addr = addr; // } // // public void setLastName(String lastName) { // this.lastName = lastName; // } // // public void setName(String name) { // this.name = name; // } // // public Address getAddr() { // return addr; // } // // public String getLastName() { // return lastName; // } // // public String getName() { // return name; // } // }
import factoryduke.TFactory; import factoryduke.FactoryDuke; import model.Address; import model.Role; import model.User;
/** * The MIT License * Copyright (c) 2016 Regis Leray * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package factories; public class UserFactory implements TFactory { @Override public void define() { FactoryDuke.define(User.class, "admin_user", u -> { u.setLastName("John"); u.setName("Malcom");
// Path: src/main/java/factoryduke/TFactory.java // public interface TFactory { // void define(); // } // // Path: src/main/java/factoryduke/FactoryDuke.java // public class FactoryDuke { // private FactoryDuke() { // } // // public static <T> void define(Class<T> clazz, Supplier<T> builder) { // define(clazz, clazz.getCanonicalName(), builder); // } // // public static <T> void define(Class<T> clazz, String identifier, Supplier<T> builder) { // FactoryRuntimeHolder.getRuntime().register(new SupplyTemplate<>(clazz, identifier, builder)); // } // // public static <T> void define(Class<T> clazz, Consumer<T> builder) { // define(clazz, clazz.getCanonicalName(), builder); // } // // public static <T> void define(Class<T> clazz, String identifier, Consumer<T> builder) { // FactoryRuntimeHolder.getRuntime().register(new ConsumerTemplate(clazz, identifier, builder)); // } // // public static <T> HookBuilder<T> build(Class<T> clazz) { // return build(clazz, clazz.getCanonicalName()); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, String identifier) { // return build(clazz, identifier, o -> { // }); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, Consumer<T> override) { // return build(clazz, clazz.getCanonicalName(), override); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, String identifier, Consumer<T> override) { // return FactoryRuntimeHolder.getRuntime().build(identifier, override); // } // // public static FactoryContext load() { // return load(new String[0]); // } // // public static FactoryContext load(String... packages) { // return FactoryRuntimeHolder.getRuntime().load(packages); // } // // public static void reset() { // FactoryRuntimeHolder.getRuntime().reset(); // } // } // // Path: src/test/java/model/Address.java // public class Address { // private String country; // private String street; // private String city; // // public String getCountry() { // return country; // } // // public void setCountry(String country) { // this.country = country; // } // // public String getCity() { // return city; // } // // public void setCity(String city) { // this.city = city; // } // // public String getStreet() { // return street; // } // // public void setStreet(String street) { // this.street = street; // } // } // // Path: src/test/java/model/Role.java // public enum Role { // ADMIN, USER // } // // Path: src/test/java/model/User.java // public class User { // private long id; // private String name; // private String lastName; // private Role role; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // private Address addr; // // public Role getRole() { // return role; // } // // public void setRole(Role role) { // this.role = role; // } // // public void setAddr(Address addr) { // this.addr = addr; // } // // public void setLastName(String lastName) { // this.lastName = lastName; // } // // public void setName(String name) { // this.name = name; // } // // public Address getAddr() { // return addr; // } // // public String getLastName() { // return lastName; // } // // public String getName() { // return name; // } // } // Path: src/test/java/factories/UserFactory.java import factoryduke.TFactory; import factoryduke.FactoryDuke; import model.Address; import model.Role; import model.User; /** * The MIT License * Copyright (c) 2016 Regis Leray * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package factories; public class UserFactory implements TFactory { @Override public void define() { FactoryDuke.define(User.class, "admin_user", u -> { u.setLastName("John"); u.setName("Malcom");
u.setRole(Role.ADMIN);
regis-leray/factory_duke
src/test/java/factories/UserFactory.java
// Path: src/main/java/factoryduke/TFactory.java // public interface TFactory { // void define(); // } // // Path: src/main/java/factoryduke/FactoryDuke.java // public class FactoryDuke { // private FactoryDuke() { // } // // public static <T> void define(Class<T> clazz, Supplier<T> builder) { // define(clazz, clazz.getCanonicalName(), builder); // } // // public static <T> void define(Class<T> clazz, String identifier, Supplier<T> builder) { // FactoryRuntimeHolder.getRuntime().register(new SupplyTemplate<>(clazz, identifier, builder)); // } // // public static <T> void define(Class<T> clazz, Consumer<T> builder) { // define(clazz, clazz.getCanonicalName(), builder); // } // // public static <T> void define(Class<T> clazz, String identifier, Consumer<T> builder) { // FactoryRuntimeHolder.getRuntime().register(new ConsumerTemplate(clazz, identifier, builder)); // } // // public static <T> HookBuilder<T> build(Class<T> clazz) { // return build(clazz, clazz.getCanonicalName()); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, String identifier) { // return build(clazz, identifier, o -> { // }); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, Consumer<T> override) { // return build(clazz, clazz.getCanonicalName(), override); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, String identifier, Consumer<T> override) { // return FactoryRuntimeHolder.getRuntime().build(identifier, override); // } // // public static FactoryContext load() { // return load(new String[0]); // } // // public static FactoryContext load(String... packages) { // return FactoryRuntimeHolder.getRuntime().load(packages); // } // // public static void reset() { // FactoryRuntimeHolder.getRuntime().reset(); // } // } // // Path: src/test/java/model/Address.java // public class Address { // private String country; // private String street; // private String city; // // public String getCountry() { // return country; // } // // public void setCountry(String country) { // this.country = country; // } // // public String getCity() { // return city; // } // // public void setCity(String city) { // this.city = city; // } // // public String getStreet() { // return street; // } // // public void setStreet(String street) { // this.street = street; // } // } // // Path: src/test/java/model/Role.java // public enum Role { // ADMIN, USER // } // // Path: src/test/java/model/User.java // public class User { // private long id; // private String name; // private String lastName; // private Role role; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // private Address addr; // // public Role getRole() { // return role; // } // // public void setRole(Role role) { // this.role = role; // } // // public void setAddr(Address addr) { // this.addr = addr; // } // // public void setLastName(String lastName) { // this.lastName = lastName; // } // // public void setName(String name) { // this.name = name; // } // // public Address getAddr() { // return addr; // } // // public String getLastName() { // return lastName; // } // // public String getName() { // return name; // } // }
import factoryduke.TFactory; import factoryduke.FactoryDuke; import model.Address; import model.Role; import model.User;
/** * The MIT License * Copyright (c) 2016 Regis Leray * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package factories; public class UserFactory implements TFactory { @Override public void define() { FactoryDuke.define(User.class, "admin_user", u -> { u.setLastName("John"); u.setName("Malcom"); u.setRole(Role.ADMIN); }); FactoryDuke.define(User.class, "user_with_fr_address", () -> { User u = FactoryDuke.build(User.class).toOne();
// Path: src/main/java/factoryduke/TFactory.java // public interface TFactory { // void define(); // } // // Path: src/main/java/factoryduke/FactoryDuke.java // public class FactoryDuke { // private FactoryDuke() { // } // // public static <T> void define(Class<T> clazz, Supplier<T> builder) { // define(clazz, clazz.getCanonicalName(), builder); // } // // public static <T> void define(Class<T> clazz, String identifier, Supplier<T> builder) { // FactoryRuntimeHolder.getRuntime().register(new SupplyTemplate<>(clazz, identifier, builder)); // } // // public static <T> void define(Class<T> clazz, Consumer<T> builder) { // define(clazz, clazz.getCanonicalName(), builder); // } // // public static <T> void define(Class<T> clazz, String identifier, Consumer<T> builder) { // FactoryRuntimeHolder.getRuntime().register(new ConsumerTemplate(clazz, identifier, builder)); // } // // public static <T> HookBuilder<T> build(Class<T> clazz) { // return build(clazz, clazz.getCanonicalName()); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, String identifier) { // return build(clazz, identifier, o -> { // }); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, Consumer<T> override) { // return build(clazz, clazz.getCanonicalName(), override); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, String identifier, Consumer<T> override) { // return FactoryRuntimeHolder.getRuntime().build(identifier, override); // } // // public static FactoryContext load() { // return load(new String[0]); // } // // public static FactoryContext load(String... packages) { // return FactoryRuntimeHolder.getRuntime().load(packages); // } // // public static void reset() { // FactoryRuntimeHolder.getRuntime().reset(); // } // } // // Path: src/test/java/model/Address.java // public class Address { // private String country; // private String street; // private String city; // // public String getCountry() { // return country; // } // // public void setCountry(String country) { // this.country = country; // } // // public String getCity() { // return city; // } // // public void setCity(String city) { // this.city = city; // } // // public String getStreet() { // return street; // } // // public void setStreet(String street) { // this.street = street; // } // } // // Path: src/test/java/model/Role.java // public enum Role { // ADMIN, USER // } // // Path: src/test/java/model/User.java // public class User { // private long id; // private String name; // private String lastName; // private Role role; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // private Address addr; // // public Role getRole() { // return role; // } // // public void setRole(Role role) { // this.role = role; // } // // public void setAddr(Address addr) { // this.addr = addr; // } // // public void setLastName(String lastName) { // this.lastName = lastName; // } // // public void setName(String name) { // this.name = name; // } // // public Address getAddr() { // return addr; // } // // public String getLastName() { // return lastName; // } // // public String getName() { // return name; // } // } // Path: src/test/java/factories/UserFactory.java import factoryduke.TFactory; import factoryduke.FactoryDuke; import model.Address; import model.Role; import model.User; /** * The MIT License * Copyright (c) 2016 Regis Leray * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package factories; public class UserFactory implements TFactory { @Override public void define() { FactoryDuke.define(User.class, "admin_user", u -> { u.setLastName("John"); u.setName("Malcom"); u.setRole(Role.ADMIN); }); FactoryDuke.define(User.class, "user_with_fr_address", () -> { User u = FactoryDuke.build(User.class).toOne();
u.setAddr(FactoryDuke.build(Address.class, "address_in_fr").toOne());
regis-leray/factory_duke
src/test/java/factories/ContactFactory.java
// Path: src/main/java/factoryduke/FactoryDuke.java // public class FactoryDuke { // private FactoryDuke() { // } // // public static <T> void define(Class<T> clazz, Supplier<T> builder) { // define(clazz, clazz.getCanonicalName(), builder); // } // // public static <T> void define(Class<T> clazz, String identifier, Supplier<T> builder) { // FactoryRuntimeHolder.getRuntime().register(new SupplyTemplate<>(clazz, identifier, builder)); // } // // public static <T> void define(Class<T> clazz, Consumer<T> builder) { // define(clazz, clazz.getCanonicalName(), builder); // } // // public static <T> void define(Class<T> clazz, String identifier, Consumer<T> builder) { // FactoryRuntimeHolder.getRuntime().register(new ConsumerTemplate(clazz, identifier, builder)); // } // // public static <T> HookBuilder<T> build(Class<T> clazz) { // return build(clazz, clazz.getCanonicalName()); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, String identifier) { // return build(clazz, identifier, o -> { // }); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, Consumer<T> override) { // return build(clazz, clazz.getCanonicalName(), override); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, String identifier, Consumer<T> override) { // return FactoryRuntimeHolder.getRuntime().build(identifier, override); // } // // public static FactoryContext load() { // return load(new String[0]); // } // // public static FactoryContext load(String... packages) { // return FactoryRuntimeHolder.getRuntime().load(packages); // } // // public static void reset() { // FactoryRuntimeHolder.getRuntime().reset(); // } // } // // Path: src/main/java/factoryduke/TFactory.java // public interface TFactory { // void define(); // } // // Path: src/test/java/model/Contact.java // public class Contact { // // private String email; // private String phone; // // public String getEmail() { // return email; // } // // public void setEmail(String email) { // this.email = email; // } // // public String getPhone() { // return phone; // } // // public void setPhone(String phone) { // this.phone = phone; // } // }
import factoryduke.FactoryDuke; import factoryduke.TFactory; import model.Contact;
/** * The MIT License * Copyright (c) 2016 Regis Leray * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package factories; public class ContactFactory implements TFactory { @Override public void define(){
// Path: src/main/java/factoryduke/FactoryDuke.java // public class FactoryDuke { // private FactoryDuke() { // } // // public static <T> void define(Class<T> clazz, Supplier<T> builder) { // define(clazz, clazz.getCanonicalName(), builder); // } // // public static <T> void define(Class<T> clazz, String identifier, Supplier<T> builder) { // FactoryRuntimeHolder.getRuntime().register(new SupplyTemplate<>(clazz, identifier, builder)); // } // // public static <T> void define(Class<T> clazz, Consumer<T> builder) { // define(clazz, clazz.getCanonicalName(), builder); // } // // public static <T> void define(Class<T> clazz, String identifier, Consumer<T> builder) { // FactoryRuntimeHolder.getRuntime().register(new ConsumerTemplate(clazz, identifier, builder)); // } // // public static <T> HookBuilder<T> build(Class<T> clazz) { // return build(clazz, clazz.getCanonicalName()); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, String identifier) { // return build(clazz, identifier, o -> { // }); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, Consumer<T> override) { // return build(clazz, clazz.getCanonicalName(), override); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, String identifier, Consumer<T> override) { // return FactoryRuntimeHolder.getRuntime().build(identifier, override); // } // // public static FactoryContext load() { // return load(new String[0]); // } // // public static FactoryContext load(String... packages) { // return FactoryRuntimeHolder.getRuntime().load(packages); // } // // public static void reset() { // FactoryRuntimeHolder.getRuntime().reset(); // } // } // // Path: src/main/java/factoryduke/TFactory.java // public interface TFactory { // void define(); // } // // Path: src/test/java/model/Contact.java // public class Contact { // // private String email; // private String phone; // // public String getEmail() { // return email; // } // // public void setEmail(String email) { // this.email = email; // } // // public String getPhone() { // return phone; // } // // public void setPhone(String phone) { // this.phone = phone; // } // } // Path: src/test/java/factories/ContactFactory.java import factoryduke.FactoryDuke; import factoryduke.TFactory; import model.Contact; /** * The MIT License * Copyright (c) 2016 Regis Leray * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package factories; public class ContactFactory implements TFactory { @Override public void define(){
FactoryDuke.define(Contact.class , c -> {
regis-leray/factory_duke
src/test/java/factories/ContactFactory.java
// Path: src/main/java/factoryduke/FactoryDuke.java // public class FactoryDuke { // private FactoryDuke() { // } // // public static <T> void define(Class<T> clazz, Supplier<T> builder) { // define(clazz, clazz.getCanonicalName(), builder); // } // // public static <T> void define(Class<T> clazz, String identifier, Supplier<T> builder) { // FactoryRuntimeHolder.getRuntime().register(new SupplyTemplate<>(clazz, identifier, builder)); // } // // public static <T> void define(Class<T> clazz, Consumer<T> builder) { // define(clazz, clazz.getCanonicalName(), builder); // } // // public static <T> void define(Class<T> clazz, String identifier, Consumer<T> builder) { // FactoryRuntimeHolder.getRuntime().register(new ConsumerTemplate(clazz, identifier, builder)); // } // // public static <T> HookBuilder<T> build(Class<T> clazz) { // return build(clazz, clazz.getCanonicalName()); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, String identifier) { // return build(clazz, identifier, o -> { // }); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, Consumer<T> override) { // return build(clazz, clazz.getCanonicalName(), override); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, String identifier, Consumer<T> override) { // return FactoryRuntimeHolder.getRuntime().build(identifier, override); // } // // public static FactoryContext load() { // return load(new String[0]); // } // // public static FactoryContext load(String... packages) { // return FactoryRuntimeHolder.getRuntime().load(packages); // } // // public static void reset() { // FactoryRuntimeHolder.getRuntime().reset(); // } // } // // Path: src/main/java/factoryduke/TFactory.java // public interface TFactory { // void define(); // } // // Path: src/test/java/model/Contact.java // public class Contact { // // private String email; // private String phone; // // public String getEmail() { // return email; // } // // public void setEmail(String email) { // this.email = email; // } // // public String getPhone() { // return phone; // } // // public void setPhone(String phone) { // this.phone = phone; // } // }
import factoryduke.FactoryDuke; import factoryduke.TFactory; import model.Contact;
/** * The MIT License * Copyright (c) 2016 Regis Leray * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package factories; public class ContactFactory implements TFactory { @Override public void define(){
// Path: src/main/java/factoryduke/FactoryDuke.java // public class FactoryDuke { // private FactoryDuke() { // } // // public static <T> void define(Class<T> clazz, Supplier<T> builder) { // define(clazz, clazz.getCanonicalName(), builder); // } // // public static <T> void define(Class<T> clazz, String identifier, Supplier<T> builder) { // FactoryRuntimeHolder.getRuntime().register(new SupplyTemplate<>(clazz, identifier, builder)); // } // // public static <T> void define(Class<T> clazz, Consumer<T> builder) { // define(clazz, clazz.getCanonicalName(), builder); // } // // public static <T> void define(Class<T> clazz, String identifier, Consumer<T> builder) { // FactoryRuntimeHolder.getRuntime().register(new ConsumerTemplate(clazz, identifier, builder)); // } // // public static <T> HookBuilder<T> build(Class<T> clazz) { // return build(clazz, clazz.getCanonicalName()); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, String identifier) { // return build(clazz, identifier, o -> { // }); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, Consumer<T> override) { // return build(clazz, clazz.getCanonicalName(), override); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, String identifier, Consumer<T> override) { // return FactoryRuntimeHolder.getRuntime().build(identifier, override); // } // // public static FactoryContext load() { // return load(new String[0]); // } // // public static FactoryContext load(String... packages) { // return FactoryRuntimeHolder.getRuntime().load(packages); // } // // public static void reset() { // FactoryRuntimeHolder.getRuntime().reset(); // } // } // // Path: src/main/java/factoryduke/TFactory.java // public interface TFactory { // void define(); // } // // Path: src/test/java/model/Contact.java // public class Contact { // // private String email; // private String phone; // // public String getEmail() { // return email; // } // // public void setEmail(String email) { // this.email = email; // } // // public String getPhone() { // return phone; // } // // public void setPhone(String phone) { // this.phone = phone; // } // } // Path: src/test/java/factories/ContactFactory.java import factoryduke.FactoryDuke; import factoryduke.TFactory; import model.Contact; /** * The MIT License * Copyright (c) 2016 Regis Leray * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package factories; public class ContactFactory implements TFactory { @Override public void define(){
FactoryDuke.define(Contact.class , c -> {
regis-leray/factory_duke
src/main/java/factoryduke/ConsumerTemplate.java
// Path: src/main/java/factoryduke/exceptions/TemplateInstanciationException.java // public class TemplateInstanciationException extends RuntimeException { // public TemplateInstanciationException(Throwable cause) { // super(cause); // } // }
import java.util.function.Consumer; import factoryduke.exceptions.TemplateInstanciationException;
/** * The MIT License * Copyright (c) 2016 Regis Leray * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package factoryduke; public class ConsumerTemplate extends Template { private Consumer consumer; public <T> ConsumerTemplate(Class<T> clazz, String identifier, Consumer<T> consumer) { super(clazz, identifier); this.consumer = consumer; } @Override public <T> T create() { try { T instance = (T) getClazz().newInstance(); consumer.accept(instance); return instance; } catch (ClassCastException | InstantiationException | IllegalAccessException e) {
// Path: src/main/java/factoryduke/exceptions/TemplateInstanciationException.java // public class TemplateInstanciationException extends RuntimeException { // public TemplateInstanciationException(Throwable cause) { // super(cause); // } // } // Path: src/main/java/factoryduke/ConsumerTemplate.java import java.util.function.Consumer; import factoryduke.exceptions.TemplateInstanciationException; /** * The MIT License * Copyright (c) 2016 Regis Leray * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package factoryduke; public class ConsumerTemplate extends Template { private Consumer consumer; public <T> ConsumerTemplate(Class<T> clazz, String identifier, Consumer<T> consumer) { super(clazz, identifier); this.consumer = consumer; } @Override public <T> T create() { try { T instance = (T) getClazz().newInstance(); consumer.accept(instance); return instance; } catch (ClassCastException | InstantiationException | IllegalAccessException e) {
throw new TemplateInstanciationException(e);
regis-leray/factory_duke
src/test/java/Factories.java
// Path: src/main/java/factoryduke/TFactory.java // public interface TFactory { // void define(); // } // // Path: src/main/java/factoryduke/FactoryDuke.java // public class FactoryDuke { // private FactoryDuke() { // } // // public static <T> void define(Class<T> clazz, Supplier<T> builder) { // define(clazz, clazz.getCanonicalName(), builder); // } // // public static <T> void define(Class<T> clazz, String identifier, Supplier<T> builder) { // FactoryRuntimeHolder.getRuntime().register(new SupplyTemplate<>(clazz, identifier, builder)); // } // // public static <T> void define(Class<T> clazz, Consumer<T> builder) { // define(clazz, clazz.getCanonicalName(), builder); // } // // public static <T> void define(Class<T> clazz, String identifier, Consumer<T> builder) { // FactoryRuntimeHolder.getRuntime().register(new ConsumerTemplate(clazz, identifier, builder)); // } // // public static <T> HookBuilder<T> build(Class<T> clazz) { // return build(clazz, clazz.getCanonicalName()); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, String identifier) { // return build(clazz, identifier, o -> { // }); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, Consumer<T> override) { // return build(clazz, clazz.getCanonicalName(), override); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, String identifier, Consumer<T> override) { // return FactoryRuntimeHolder.getRuntime().build(identifier, override); // } // // public static FactoryContext load() { // return load(new String[0]); // } // // public static FactoryContext load(String... packages) { // return FactoryRuntimeHolder.getRuntime().load(packages); // } // // public static void reset() { // FactoryRuntimeHolder.getRuntime().reset(); // } // } // // Path: src/test/java/model/Address.java // public class Address { // private String country; // private String street; // private String city; // // public String getCountry() { // return country; // } // // public void setCountry(String country) { // this.country = country; // } // // public String getCity() { // return city; // } // // public void setCity(String city) { // this.city = city; // } // // public String getStreet() { // return street; // } // // public void setStreet(String street) { // this.street = street; // } // } // // Path: src/test/java/model/Role.java // public enum Role { // ADMIN, USER // } // // Path: src/test/java/model/User.java // public class User { // private long id; // private String name; // private String lastName; // private Role role; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // private Address addr; // // public Role getRole() { // return role; // } // // public void setRole(Role role) { // this.role = role; // } // // public void setAddr(Address addr) { // this.addr = addr; // } // // public void setLastName(String lastName) { // this.lastName = lastName; // } // // public void setName(String name) { // this.name = name; // } // // public Address getAddr() { // return addr; // } // // public String getLastName() { // return lastName; // } // // public String getName() { // return name; // } // }
import factoryduke.TFactory; import factoryduke.FactoryDuke; import model.Address; import model.Role; import model.User;
/** * The MIT License * Copyright (c) 2016 Regis Leray * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ public class Factories implements TFactory { @Override public void define() {
// Path: src/main/java/factoryduke/TFactory.java // public interface TFactory { // void define(); // } // // Path: src/main/java/factoryduke/FactoryDuke.java // public class FactoryDuke { // private FactoryDuke() { // } // // public static <T> void define(Class<T> clazz, Supplier<T> builder) { // define(clazz, clazz.getCanonicalName(), builder); // } // // public static <T> void define(Class<T> clazz, String identifier, Supplier<T> builder) { // FactoryRuntimeHolder.getRuntime().register(new SupplyTemplate<>(clazz, identifier, builder)); // } // // public static <T> void define(Class<T> clazz, Consumer<T> builder) { // define(clazz, clazz.getCanonicalName(), builder); // } // // public static <T> void define(Class<T> clazz, String identifier, Consumer<T> builder) { // FactoryRuntimeHolder.getRuntime().register(new ConsumerTemplate(clazz, identifier, builder)); // } // // public static <T> HookBuilder<T> build(Class<T> clazz) { // return build(clazz, clazz.getCanonicalName()); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, String identifier) { // return build(clazz, identifier, o -> { // }); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, Consumer<T> override) { // return build(clazz, clazz.getCanonicalName(), override); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, String identifier, Consumer<T> override) { // return FactoryRuntimeHolder.getRuntime().build(identifier, override); // } // // public static FactoryContext load() { // return load(new String[0]); // } // // public static FactoryContext load(String... packages) { // return FactoryRuntimeHolder.getRuntime().load(packages); // } // // public static void reset() { // FactoryRuntimeHolder.getRuntime().reset(); // } // } // // Path: src/test/java/model/Address.java // public class Address { // private String country; // private String street; // private String city; // // public String getCountry() { // return country; // } // // public void setCountry(String country) { // this.country = country; // } // // public String getCity() { // return city; // } // // public void setCity(String city) { // this.city = city; // } // // public String getStreet() { // return street; // } // // public void setStreet(String street) { // this.street = street; // } // } // // Path: src/test/java/model/Role.java // public enum Role { // ADMIN, USER // } // // Path: src/test/java/model/User.java // public class User { // private long id; // private String name; // private String lastName; // private Role role; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // private Address addr; // // public Role getRole() { // return role; // } // // public void setRole(Role role) { // this.role = role; // } // // public void setAddr(Address addr) { // this.addr = addr; // } // // public void setLastName(String lastName) { // this.lastName = lastName; // } // // public void setName(String name) { // this.name = name; // } // // public Address getAddr() { // return addr; // } // // public String getLastName() { // return lastName; // } // // public String getName() { // return name; // } // } // Path: src/test/java/Factories.java import factoryduke.TFactory; import factoryduke.FactoryDuke; import model.Address; import model.Role; import model.User; /** * The MIT License * Copyright (c) 2016 Regis Leray * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ public class Factories implements TFactory { @Override public void define() {
FactoryDuke.define(User.class, u -> {
regis-leray/factory_duke
src/test/java/Factories.java
// Path: src/main/java/factoryduke/TFactory.java // public interface TFactory { // void define(); // } // // Path: src/main/java/factoryduke/FactoryDuke.java // public class FactoryDuke { // private FactoryDuke() { // } // // public static <T> void define(Class<T> clazz, Supplier<T> builder) { // define(clazz, clazz.getCanonicalName(), builder); // } // // public static <T> void define(Class<T> clazz, String identifier, Supplier<T> builder) { // FactoryRuntimeHolder.getRuntime().register(new SupplyTemplate<>(clazz, identifier, builder)); // } // // public static <T> void define(Class<T> clazz, Consumer<T> builder) { // define(clazz, clazz.getCanonicalName(), builder); // } // // public static <T> void define(Class<T> clazz, String identifier, Consumer<T> builder) { // FactoryRuntimeHolder.getRuntime().register(new ConsumerTemplate(clazz, identifier, builder)); // } // // public static <T> HookBuilder<T> build(Class<T> clazz) { // return build(clazz, clazz.getCanonicalName()); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, String identifier) { // return build(clazz, identifier, o -> { // }); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, Consumer<T> override) { // return build(clazz, clazz.getCanonicalName(), override); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, String identifier, Consumer<T> override) { // return FactoryRuntimeHolder.getRuntime().build(identifier, override); // } // // public static FactoryContext load() { // return load(new String[0]); // } // // public static FactoryContext load(String... packages) { // return FactoryRuntimeHolder.getRuntime().load(packages); // } // // public static void reset() { // FactoryRuntimeHolder.getRuntime().reset(); // } // } // // Path: src/test/java/model/Address.java // public class Address { // private String country; // private String street; // private String city; // // public String getCountry() { // return country; // } // // public void setCountry(String country) { // this.country = country; // } // // public String getCity() { // return city; // } // // public void setCity(String city) { // this.city = city; // } // // public String getStreet() { // return street; // } // // public void setStreet(String street) { // this.street = street; // } // } // // Path: src/test/java/model/Role.java // public enum Role { // ADMIN, USER // } // // Path: src/test/java/model/User.java // public class User { // private long id; // private String name; // private String lastName; // private Role role; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // private Address addr; // // public Role getRole() { // return role; // } // // public void setRole(Role role) { // this.role = role; // } // // public void setAddr(Address addr) { // this.addr = addr; // } // // public void setLastName(String lastName) { // this.lastName = lastName; // } // // public void setName(String name) { // this.name = name; // } // // public Address getAddr() { // return addr; // } // // public String getLastName() { // return lastName; // } // // public String getName() { // return name; // } // }
import factoryduke.TFactory; import factoryduke.FactoryDuke; import model.Address; import model.Role; import model.User;
/** * The MIT License * Copyright (c) 2016 Regis Leray * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ public class Factories implements TFactory { @Override public void define() {
// Path: src/main/java/factoryduke/TFactory.java // public interface TFactory { // void define(); // } // // Path: src/main/java/factoryduke/FactoryDuke.java // public class FactoryDuke { // private FactoryDuke() { // } // // public static <T> void define(Class<T> clazz, Supplier<T> builder) { // define(clazz, clazz.getCanonicalName(), builder); // } // // public static <T> void define(Class<T> clazz, String identifier, Supplier<T> builder) { // FactoryRuntimeHolder.getRuntime().register(new SupplyTemplate<>(clazz, identifier, builder)); // } // // public static <T> void define(Class<T> clazz, Consumer<T> builder) { // define(clazz, clazz.getCanonicalName(), builder); // } // // public static <T> void define(Class<T> clazz, String identifier, Consumer<T> builder) { // FactoryRuntimeHolder.getRuntime().register(new ConsumerTemplate(clazz, identifier, builder)); // } // // public static <T> HookBuilder<T> build(Class<T> clazz) { // return build(clazz, clazz.getCanonicalName()); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, String identifier) { // return build(clazz, identifier, o -> { // }); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, Consumer<T> override) { // return build(clazz, clazz.getCanonicalName(), override); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, String identifier, Consumer<T> override) { // return FactoryRuntimeHolder.getRuntime().build(identifier, override); // } // // public static FactoryContext load() { // return load(new String[0]); // } // // public static FactoryContext load(String... packages) { // return FactoryRuntimeHolder.getRuntime().load(packages); // } // // public static void reset() { // FactoryRuntimeHolder.getRuntime().reset(); // } // } // // Path: src/test/java/model/Address.java // public class Address { // private String country; // private String street; // private String city; // // public String getCountry() { // return country; // } // // public void setCountry(String country) { // this.country = country; // } // // public String getCity() { // return city; // } // // public void setCity(String city) { // this.city = city; // } // // public String getStreet() { // return street; // } // // public void setStreet(String street) { // this.street = street; // } // } // // Path: src/test/java/model/Role.java // public enum Role { // ADMIN, USER // } // // Path: src/test/java/model/User.java // public class User { // private long id; // private String name; // private String lastName; // private Role role; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // private Address addr; // // public Role getRole() { // return role; // } // // public void setRole(Role role) { // this.role = role; // } // // public void setAddr(Address addr) { // this.addr = addr; // } // // public void setLastName(String lastName) { // this.lastName = lastName; // } // // public void setName(String name) { // this.name = name; // } // // public Address getAddr() { // return addr; // } // // public String getLastName() { // return lastName; // } // // public String getName() { // return name; // } // } // Path: src/test/java/Factories.java import factoryduke.TFactory; import factoryduke.FactoryDuke; import model.Address; import model.Role; import model.User; /** * The MIT License * Copyright (c) 2016 Regis Leray * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ public class Factories implements TFactory { @Override public void define() {
FactoryDuke.define(User.class, u -> {
regis-leray/factory_duke
src/test/java/Factories.java
// Path: src/main/java/factoryduke/TFactory.java // public interface TFactory { // void define(); // } // // Path: src/main/java/factoryduke/FactoryDuke.java // public class FactoryDuke { // private FactoryDuke() { // } // // public static <T> void define(Class<T> clazz, Supplier<T> builder) { // define(clazz, clazz.getCanonicalName(), builder); // } // // public static <T> void define(Class<T> clazz, String identifier, Supplier<T> builder) { // FactoryRuntimeHolder.getRuntime().register(new SupplyTemplate<>(clazz, identifier, builder)); // } // // public static <T> void define(Class<T> clazz, Consumer<T> builder) { // define(clazz, clazz.getCanonicalName(), builder); // } // // public static <T> void define(Class<T> clazz, String identifier, Consumer<T> builder) { // FactoryRuntimeHolder.getRuntime().register(new ConsumerTemplate(clazz, identifier, builder)); // } // // public static <T> HookBuilder<T> build(Class<T> clazz) { // return build(clazz, clazz.getCanonicalName()); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, String identifier) { // return build(clazz, identifier, o -> { // }); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, Consumer<T> override) { // return build(clazz, clazz.getCanonicalName(), override); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, String identifier, Consumer<T> override) { // return FactoryRuntimeHolder.getRuntime().build(identifier, override); // } // // public static FactoryContext load() { // return load(new String[0]); // } // // public static FactoryContext load(String... packages) { // return FactoryRuntimeHolder.getRuntime().load(packages); // } // // public static void reset() { // FactoryRuntimeHolder.getRuntime().reset(); // } // } // // Path: src/test/java/model/Address.java // public class Address { // private String country; // private String street; // private String city; // // public String getCountry() { // return country; // } // // public void setCountry(String country) { // this.country = country; // } // // public String getCity() { // return city; // } // // public void setCity(String city) { // this.city = city; // } // // public String getStreet() { // return street; // } // // public void setStreet(String street) { // this.street = street; // } // } // // Path: src/test/java/model/Role.java // public enum Role { // ADMIN, USER // } // // Path: src/test/java/model/User.java // public class User { // private long id; // private String name; // private String lastName; // private Role role; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // private Address addr; // // public Role getRole() { // return role; // } // // public void setRole(Role role) { // this.role = role; // } // // public void setAddr(Address addr) { // this.addr = addr; // } // // public void setLastName(String lastName) { // this.lastName = lastName; // } // // public void setName(String name) { // this.name = name; // } // // public Address getAddr() { // return addr; // } // // public String getLastName() { // return lastName; // } // // public String getName() { // return name; // } // }
import factoryduke.TFactory; import factoryduke.FactoryDuke; import model.Address; import model.Role; import model.User;
/** * The MIT License * Copyright (c) 2016 Regis Leray * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ public class Factories implements TFactory { @Override public void define() { FactoryDuke.define(User.class, u -> { u.setLastName("Scott"); u.setName("Malcom");
// Path: src/main/java/factoryduke/TFactory.java // public interface TFactory { // void define(); // } // // Path: src/main/java/factoryduke/FactoryDuke.java // public class FactoryDuke { // private FactoryDuke() { // } // // public static <T> void define(Class<T> clazz, Supplier<T> builder) { // define(clazz, clazz.getCanonicalName(), builder); // } // // public static <T> void define(Class<T> clazz, String identifier, Supplier<T> builder) { // FactoryRuntimeHolder.getRuntime().register(new SupplyTemplate<>(clazz, identifier, builder)); // } // // public static <T> void define(Class<T> clazz, Consumer<T> builder) { // define(clazz, clazz.getCanonicalName(), builder); // } // // public static <T> void define(Class<T> clazz, String identifier, Consumer<T> builder) { // FactoryRuntimeHolder.getRuntime().register(new ConsumerTemplate(clazz, identifier, builder)); // } // // public static <T> HookBuilder<T> build(Class<T> clazz) { // return build(clazz, clazz.getCanonicalName()); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, String identifier) { // return build(clazz, identifier, o -> { // }); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, Consumer<T> override) { // return build(clazz, clazz.getCanonicalName(), override); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, String identifier, Consumer<T> override) { // return FactoryRuntimeHolder.getRuntime().build(identifier, override); // } // // public static FactoryContext load() { // return load(new String[0]); // } // // public static FactoryContext load(String... packages) { // return FactoryRuntimeHolder.getRuntime().load(packages); // } // // public static void reset() { // FactoryRuntimeHolder.getRuntime().reset(); // } // } // // Path: src/test/java/model/Address.java // public class Address { // private String country; // private String street; // private String city; // // public String getCountry() { // return country; // } // // public void setCountry(String country) { // this.country = country; // } // // public String getCity() { // return city; // } // // public void setCity(String city) { // this.city = city; // } // // public String getStreet() { // return street; // } // // public void setStreet(String street) { // this.street = street; // } // } // // Path: src/test/java/model/Role.java // public enum Role { // ADMIN, USER // } // // Path: src/test/java/model/User.java // public class User { // private long id; // private String name; // private String lastName; // private Role role; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // private Address addr; // // public Role getRole() { // return role; // } // // public void setRole(Role role) { // this.role = role; // } // // public void setAddr(Address addr) { // this.addr = addr; // } // // public void setLastName(String lastName) { // this.lastName = lastName; // } // // public void setName(String name) { // this.name = name; // } // // public Address getAddr() { // return addr; // } // // public String getLastName() { // return lastName; // } // // public String getName() { // return name; // } // } // Path: src/test/java/Factories.java import factoryduke.TFactory; import factoryduke.FactoryDuke; import model.Address; import model.Role; import model.User; /** * The MIT License * Copyright (c) 2016 Regis Leray * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ public class Factories implements TFactory { @Override public void define() { FactoryDuke.define(User.class, u -> { u.setLastName("Scott"); u.setName("Malcom");
u.setRole(Role.USER);
regis-leray/factory_duke
src/test/java/Factories.java
// Path: src/main/java/factoryduke/TFactory.java // public interface TFactory { // void define(); // } // // Path: src/main/java/factoryduke/FactoryDuke.java // public class FactoryDuke { // private FactoryDuke() { // } // // public static <T> void define(Class<T> clazz, Supplier<T> builder) { // define(clazz, clazz.getCanonicalName(), builder); // } // // public static <T> void define(Class<T> clazz, String identifier, Supplier<T> builder) { // FactoryRuntimeHolder.getRuntime().register(new SupplyTemplate<>(clazz, identifier, builder)); // } // // public static <T> void define(Class<T> clazz, Consumer<T> builder) { // define(clazz, clazz.getCanonicalName(), builder); // } // // public static <T> void define(Class<T> clazz, String identifier, Consumer<T> builder) { // FactoryRuntimeHolder.getRuntime().register(new ConsumerTemplate(clazz, identifier, builder)); // } // // public static <T> HookBuilder<T> build(Class<T> clazz) { // return build(clazz, clazz.getCanonicalName()); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, String identifier) { // return build(clazz, identifier, o -> { // }); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, Consumer<T> override) { // return build(clazz, clazz.getCanonicalName(), override); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, String identifier, Consumer<T> override) { // return FactoryRuntimeHolder.getRuntime().build(identifier, override); // } // // public static FactoryContext load() { // return load(new String[0]); // } // // public static FactoryContext load(String... packages) { // return FactoryRuntimeHolder.getRuntime().load(packages); // } // // public static void reset() { // FactoryRuntimeHolder.getRuntime().reset(); // } // } // // Path: src/test/java/model/Address.java // public class Address { // private String country; // private String street; // private String city; // // public String getCountry() { // return country; // } // // public void setCountry(String country) { // this.country = country; // } // // public String getCity() { // return city; // } // // public void setCity(String city) { // this.city = city; // } // // public String getStreet() { // return street; // } // // public void setStreet(String street) { // this.street = street; // } // } // // Path: src/test/java/model/Role.java // public enum Role { // ADMIN, USER // } // // Path: src/test/java/model/User.java // public class User { // private long id; // private String name; // private String lastName; // private Role role; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // private Address addr; // // public Role getRole() { // return role; // } // // public void setRole(Role role) { // this.role = role; // } // // public void setAddr(Address addr) { // this.addr = addr; // } // // public void setLastName(String lastName) { // this.lastName = lastName; // } // // public void setName(String name) { // this.name = name; // } // // public Address getAddr() { // return addr; // } // // public String getLastName() { // return lastName; // } // // public String getName() { // return name; // } // }
import factoryduke.TFactory; import factoryduke.FactoryDuke; import model.Address; import model.Role; import model.User;
/** * The MIT License * Copyright (c) 2016 Regis Leray * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ public class Factories implements TFactory { @Override public void define() { FactoryDuke.define(User.class, u -> { u.setLastName("Scott"); u.setName("Malcom"); u.setRole(Role.USER); });
// Path: src/main/java/factoryduke/TFactory.java // public interface TFactory { // void define(); // } // // Path: src/main/java/factoryduke/FactoryDuke.java // public class FactoryDuke { // private FactoryDuke() { // } // // public static <T> void define(Class<T> clazz, Supplier<T> builder) { // define(clazz, clazz.getCanonicalName(), builder); // } // // public static <T> void define(Class<T> clazz, String identifier, Supplier<T> builder) { // FactoryRuntimeHolder.getRuntime().register(new SupplyTemplate<>(clazz, identifier, builder)); // } // // public static <T> void define(Class<T> clazz, Consumer<T> builder) { // define(clazz, clazz.getCanonicalName(), builder); // } // // public static <T> void define(Class<T> clazz, String identifier, Consumer<T> builder) { // FactoryRuntimeHolder.getRuntime().register(new ConsumerTemplate(clazz, identifier, builder)); // } // // public static <T> HookBuilder<T> build(Class<T> clazz) { // return build(clazz, clazz.getCanonicalName()); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, String identifier) { // return build(clazz, identifier, o -> { // }); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, Consumer<T> override) { // return build(clazz, clazz.getCanonicalName(), override); // } // // public static <T> HookBuilder<T> build(Class<T> clazz, String identifier, Consumer<T> override) { // return FactoryRuntimeHolder.getRuntime().build(identifier, override); // } // // public static FactoryContext load() { // return load(new String[0]); // } // // public static FactoryContext load(String... packages) { // return FactoryRuntimeHolder.getRuntime().load(packages); // } // // public static void reset() { // FactoryRuntimeHolder.getRuntime().reset(); // } // } // // Path: src/test/java/model/Address.java // public class Address { // private String country; // private String street; // private String city; // // public String getCountry() { // return country; // } // // public void setCountry(String country) { // this.country = country; // } // // public String getCity() { // return city; // } // // public void setCity(String city) { // this.city = city; // } // // public String getStreet() { // return street; // } // // public void setStreet(String street) { // this.street = street; // } // } // // Path: src/test/java/model/Role.java // public enum Role { // ADMIN, USER // } // // Path: src/test/java/model/User.java // public class User { // private long id; // private String name; // private String lastName; // private Role role; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // private Address addr; // // public Role getRole() { // return role; // } // // public void setRole(Role role) { // this.role = role; // } // // public void setAddr(Address addr) { // this.addr = addr; // } // // public void setLastName(String lastName) { // this.lastName = lastName; // } // // public void setName(String name) { // this.name = name; // } // // public Address getAddr() { // return addr; // } // // public String getLastName() { // return lastName; // } // // public String getName() { // return name; // } // } // Path: src/test/java/Factories.java import factoryduke.TFactory; import factoryduke.FactoryDuke; import model.Address; import model.Role; import model.User; /** * The MIT License * Copyright (c) 2016 Regis Leray * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ public class Factories implements TFactory { @Override public void define() { FactoryDuke.define(User.class, u -> { u.setLastName("Scott"); u.setName("Malcom"); u.setRole(Role.USER); });
FactoryDuke.define(Address.class, a -> {
regis-leray/factory_duke
src/main/java/factoryduke/builder/HookInstanceBuilder.java
// Path: src/main/java/factoryduke/function/Callback.java // @FunctionalInterface // public interface Callback { // void call(); // }
import java.util.List; import java.util.function.Consumer; import factoryduke.function.Callback;
/** * The MIT License * Copyright (c) 2016 Regis Leray * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package factoryduke.builder; public class HookInstanceBuilder<T> implements HookBuilder<T> { private InstanceBuilder<T> builder; private final List<Consumer> afterHooks;
// Path: src/main/java/factoryduke/function/Callback.java // @FunctionalInterface // public interface Callback { // void call(); // } // Path: src/main/java/factoryduke/builder/HookInstanceBuilder.java import java.util.List; import java.util.function.Consumer; import factoryduke.function.Callback; /** * The MIT License * Copyright (c) 2016 Regis Leray * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package factoryduke.builder; public class HookInstanceBuilder<T> implements HookBuilder<T> { private InstanceBuilder<T> builder; private final List<Consumer> afterHooks;
private final List<Callback> beforeHooks;
regis-leray/factory_duke
src/test/java/factoryduke/FactoryRuntimeTest.java
// Path: src/main/java/factoryduke/exceptions/TemplateDuplicateException.java // public class TemplateDuplicateException extends RuntimeException{ // public TemplateDuplicateException(String message) { // super(message); // } // } // // Path: src/main/java/factoryduke/exceptions/TemplateInstanciationException.java // public class TemplateInstanciationException extends RuntimeException { // public TemplateInstanciationException(Throwable cause) { // super(cause); // } // } // // Path: src/main/java/factoryduke/exceptions/TemplateNotFoundException.java // public class TemplateNotFoundException extends RuntimeException { // public TemplateNotFoundException(String message) { // super(message); // } // } // // Path: src/test/java/model/Address.java // public class Address { // private String country; // private String street; // private String city; // // public String getCountry() { // return country; // } // // public void setCountry(String country) { // this.country = country; // } // // public String getCity() { // return city; // } // // public void setCity(String city) { // this.city = city; // } // // public String getStreet() { // return street; // } // // public void setStreet(String street) { // this.street = street; // } // } // // Path: src/test/java/model/User.java // public class User { // private long id; // private String name; // private String lastName; // private Role role; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // private Address addr; // // public Role getRole() { // return role; // } // // public void setRole(Role role) { // this.role = role; // } // // public void setAddr(Address addr) { // this.addr = addr; // } // // public void setLastName(String lastName) { // this.lastName = lastName; // } // // public void setName(String name) { // this.name = name; // } // // public Address getAddr() { // return addr; // } // // public String getLastName() { // return lastName; // } // // public String getName() { // return name; // } // }
import factoryduke.exceptions.TemplateNotFoundException; import model.Address; import model.User; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import org.junit.Before; import org.junit.Test; import factoryduke.exceptions.TemplateDuplicateException; import factoryduke.exceptions.TemplateInstanciationException;
/** * The MIT License * Copyright (c) 2016 Regis Leray * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package factoryduke; public class FactoryRuntimeTest { @Before public void removeTemplate() { FactoryRuntimeHolder.getRuntime().reset(); } @Test public void found_factories() { FactoryRuntimeHolder.getRuntime().load(); assertThat(FactoryRuntimeHolder.getRuntime().getTemplates()).hasSize(7); } @Test public void reset() { assertThat(FactoryRuntimeHolder.getRuntime().getTemplates()).isEmpty(); } @Test public void duplicate_definition() {
// Path: src/main/java/factoryduke/exceptions/TemplateDuplicateException.java // public class TemplateDuplicateException extends RuntimeException{ // public TemplateDuplicateException(String message) { // super(message); // } // } // // Path: src/main/java/factoryduke/exceptions/TemplateInstanciationException.java // public class TemplateInstanciationException extends RuntimeException { // public TemplateInstanciationException(Throwable cause) { // super(cause); // } // } // // Path: src/main/java/factoryduke/exceptions/TemplateNotFoundException.java // public class TemplateNotFoundException extends RuntimeException { // public TemplateNotFoundException(String message) { // super(message); // } // } // // Path: src/test/java/model/Address.java // public class Address { // private String country; // private String street; // private String city; // // public String getCountry() { // return country; // } // // public void setCountry(String country) { // this.country = country; // } // // public String getCity() { // return city; // } // // public void setCity(String city) { // this.city = city; // } // // public String getStreet() { // return street; // } // // public void setStreet(String street) { // this.street = street; // } // } // // Path: src/test/java/model/User.java // public class User { // private long id; // private String name; // private String lastName; // private Role role; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // private Address addr; // // public Role getRole() { // return role; // } // // public void setRole(Role role) { // this.role = role; // } // // public void setAddr(Address addr) { // this.addr = addr; // } // // public void setLastName(String lastName) { // this.lastName = lastName; // } // // public void setName(String name) { // this.name = name; // } // // public Address getAddr() { // return addr; // } // // public String getLastName() { // return lastName; // } // // public String getName() { // return name; // } // } // Path: src/test/java/factoryduke/FactoryRuntimeTest.java import factoryduke.exceptions.TemplateNotFoundException; import model.Address; import model.User; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import org.junit.Before; import org.junit.Test; import factoryduke.exceptions.TemplateDuplicateException; import factoryduke.exceptions.TemplateInstanciationException; /** * The MIT License * Copyright (c) 2016 Regis Leray * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package factoryduke; public class FactoryRuntimeTest { @Before public void removeTemplate() { FactoryRuntimeHolder.getRuntime().reset(); } @Test public void found_factories() { FactoryRuntimeHolder.getRuntime().load(); assertThat(FactoryRuntimeHolder.getRuntime().getTemplates()).hasSize(7); } @Test public void reset() { assertThat(FactoryRuntimeHolder.getRuntime().getTemplates()).isEmpty(); } @Test public void duplicate_definition() {
Template tp = new ConsumerTemplate(User.class, User.class.getCanonicalName(), u -> u.setName("test"));
regis-leray/factory_duke
src/test/java/factoryduke/FactoryRuntimeTest.java
// Path: src/main/java/factoryduke/exceptions/TemplateDuplicateException.java // public class TemplateDuplicateException extends RuntimeException{ // public TemplateDuplicateException(String message) { // super(message); // } // } // // Path: src/main/java/factoryduke/exceptions/TemplateInstanciationException.java // public class TemplateInstanciationException extends RuntimeException { // public TemplateInstanciationException(Throwable cause) { // super(cause); // } // } // // Path: src/main/java/factoryduke/exceptions/TemplateNotFoundException.java // public class TemplateNotFoundException extends RuntimeException { // public TemplateNotFoundException(String message) { // super(message); // } // } // // Path: src/test/java/model/Address.java // public class Address { // private String country; // private String street; // private String city; // // public String getCountry() { // return country; // } // // public void setCountry(String country) { // this.country = country; // } // // public String getCity() { // return city; // } // // public void setCity(String city) { // this.city = city; // } // // public String getStreet() { // return street; // } // // public void setStreet(String street) { // this.street = street; // } // } // // Path: src/test/java/model/User.java // public class User { // private long id; // private String name; // private String lastName; // private Role role; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // private Address addr; // // public Role getRole() { // return role; // } // // public void setRole(Role role) { // this.role = role; // } // // public void setAddr(Address addr) { // this.addr = addr; // } // // public void setLastName(String lastName) { // this.lastName = lastName; // } // // public void setName(String name) { // this.name = name; // } // // public Address getAddr() { // return addr; // } // // public String getLastName() { // return lastName; // } // // public String getName() { // return name; // } // }
import factoryduke.exceptions.TemplateNotFoundException; import model.Address; import model.User; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import org.junit.Before; import org.junit.Test; import factoryduke.exceptions.TemplateDuplicateException; import factoryduke.exceptions.TemplateInstanciationException;
/** * The MIT License * Copyright (c) 2016 Regis Leray * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package factoryduke; public class FactoryRuntimeTest { @Before public void removeTemplate() { FactoryRuntimeHolder.getRuntime().reset(); } @Test public void found_factories() { FactoryRuntimeHolder.getRuntime().load(); assertThat(FactoryRuntimeHolder.getRuntime().getTemplates()).hasSize(7); } @Test public void reset() { assertThat(FactoryRuntimeHolder.getRuntime().getTemplates()).isEmpty(); } @Test public void duplicate_definition() { Template tp = new ConsumerTemplate(User.class, User.class.getCanonicalName(), u -> u.setName("test")); FactoryRuntimeHolder.getRuntime().register(tp); assertThatThrownBy(() -> FactoryRuntimeHolder.getRuntime().register(tp))
// Path: src/main/java/factoryduke/exceptions/TemplateDuplicateException.java // public class TemplateDuplicateException extends RuntimeException{ // public TemplateDuplicateException(String message) { // super(message); // } // } // // Path: src/main/java/factoryduke/exceptions/TemplateInstanciationException.java // public class TemplateInstanciationException extends RuntimeException { // public TemplateInstanciationException(Throwable cause) { // super(cause); // } // } // // Path: src/main/java/factoryduke/exceptions/TemplateNotFoundException.java // public class TemplateNotFoundException extends RuntimeException { // public TemplateNotFoundException(String message) { // super(message); // } // } // // Path: src/test/java/model/Address.java // public class Address { // private String country; // private String street; // private String city; // // public String getCountry() { // return country; // } // // public void setCountry(String country) { // this.country = country; // } // // public String getCity() { // return city; // } // // public void setCity(String city) { // this.city = city; // } // // public String getStreet() { // return street; // } // // public void setStreet(String street) { // this.street = street; // } // } // // Path: src/test/java/model/User.java // public class User { // private long id; // private String name; // private String lastName; // private Role role; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // private Address addr; // // public Role getRole() { // return role; // } // // public void setRole(Role role) { // this.role = role; // } // // public void setAddr(Address addr) { // this.addr = addr; // } // // public void setLastName(String lastName) { // this.lastName = lastName; // } // // public void setName(String name) { // this.name = name; // } // // public Address getAddr() { // return addr; // } // // public String getLastName() { // return lastName; // } // // public String getName() { // return name; // } // } // Path: src/test/java/factoryduke/FactoryRuntimeTest.java import factoryduke.exceptions.TemplateNotFoundException; import model.Address; import model.User; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import org.junit.Before; import org.junit.Test; import factoryduke.exceptions.TemplateDuplicateException; import factoryduke.exceptions.TemplateInstanciationException; /** * The MIT License * Copyright (c) 2016 Regis Leray * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package factoryduke; public class FactoryRuntimeTest { @Before public void removeTemplate() { FactoryRuntimeHolder.getRuntime().reset(); } @Test public void found_factories() { FactoryRuntimeHolder.getRuntime().load(); assertThat(FactoryRuntimeHolder.getRuntime().getTemplates()).hasSize(7); } @Test public void reset() { assertThat(FactoryRuntimeHolder.getRuntime().getTemplates()).isEmpty(); } @Test public void duplicate_definition() { Template tp = new ConsumerTemplate(User.class, User.class.getCanonicalName(), u -> u.setName("test")); FactoryRuntimeHolder.getRuntime().register(tp); assertThatThrownBy(() -> FactoryRuntimeHolder.getRuntime().register(tp))
.isInstanceOf(TemplateDuplicateException.class)
regis-leray/factory_duke
src/test/java/factoryduke/FactoryRuntimeTest.java
// Path: src/main/java/factoryduke/exceptions/TemplateDuplicateException.java // public class TemplateDuplicateException extends RuntimeException{ // public TemplateDuplicateException(String message) { // super(message); // } // } // // Path: src/main/java/factoryduke/exceptions/TemplateInstanciationException.java // public class TemplateInstanciationException extends RuntimeException { // public TemplateInstanciationException(Throwable cause) { // super(cause); // } // } // // Path: src/main/java/factoryduke/exceptions/TemplateNotFoundException.java // public class TemplateNotFoundException extends RuntimeException { // public TemplateNotFoundException(String message) { // super(message); // } // } // // Path: src/test/java/model/Address.java // public class Address { // private String country; // private String street; // private String city; // // public String getCountry() { // return country; // } // // public void setCountry(String country) { // this.country = country; // } // // public String getCity() { // return city; // } // // public void setCity(String city) { // this.city = city; // } // // public String getStreet() { // return street; // } // // public void setStreet(String street) { // this.street = street; // } // } // // Path: src/test/java/model/User.java // public class User { // private long id; // private String name; // private String lastName; // private Role role; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // private Address addr; // // public Role getRole() { // return role; // } // // public void setRole(Role role) { // this.role = role; // } // // public void setAddr(Address addr) { // this.addr = addr; // } // // public void setLastName(String lastName) { // this.lastName = lastName; // } // // public void setName(String name) { // this.name = name; // } // // public Address getAddr() { // return addr; // } // // public String getLastName() { // return lastName; // } // // public String getName() { // return name; // } // }
import factoryduke.exceptions.TemplateNotFoundException; import model.Address; import model.User; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import org.junit.Before; import org.junit.Test; import factoryduke.exceptions.TemplateDuplicateException; import factoryduke.exceptions.TemplateInstanciationException;
/** * The MIT License * Copyright (c) 2016 Regis Leray * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package factoryduke; public class FactoryRuntimeTest { @Before public void removeTemplate() { FactoryRuntimeHolder.getRuntime().reset(); } @Test public void found_factories() { FactoryRuntimeHolder.getRuntime().load(); assertThat(FactoryRuntimeHolder.getRuntime().getTemplates()).hasSize(7); } @Test public void reset() { assertThat(FactoryRuntimeHolder.getRuntime().getTemplates()).isEmpty(); } @Test public void duplicate_definition() { Template tp = new ConsumerTemplate(User.class, User.class.getCanonicalName(), u -> u.setName("test")); FactoryRuntimeHolder.getRuntime().register(tp); assertThatThrownBy(() -> FactoryRuntimeHolder.getRuntime().register(tp)) .isInstanceOf(TemplateDuplicateException.class) .hasMessageContaining("Cannot define duplicate template with the same identifier") .hasNoCause(); } @Test public void build_instance_with_supplier_wrong_cast() { FactoryRuntimeHolder.getRuntime().load(); assertThatThrownBy(() -> {
// Path: src/main/java/factoryduke/exceptions/TemplateDuplicateException.java // public class TemplateDuplicateException extends RuntimeException{ // public TemplateDuplicateException(String message) { // super(message); // } // } // // Path: src/main/java/factoryduke/exceptions/TemplateInstanciationException.java // public class TemplateInstanciationException extends RuntimeException { // public TemplateInstanciationException(Throwable cause) { // super(cause); // } // } // // Path: src/main/java/factoryduke/exceptions/TemplateNotFoundException.java // public class TemplateNotFoundException extends RuntimeException { // public TemplateNotFoundException(String message) { // super(message); // } // } // // Path: src/test/java/model/Address.java // public class Address { // private String country; // private String street; // private String city; // // public String getCountry() { // return country; // } // // public void setCountry(String country) { // this.country = country; // } // // public String getCity() { // return city; // } // // public void setCity(String city) { // this.city = city; // } // // public String getStreet() { // return street; // } // // public void setStreet(String street) { // this.street = street; // } // } // // Path: src/test/java/model/User.java // public class User { // private long id; // private String name; // private String lastName; // private Role role; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // private Address addr; // // public Role getRole() { // return role; // } // // public void setRole(Role role) { // this.role = role; // } // // public void setAddr(Address addr) { // this.addr = addr; // } // // public void setLastName(String lastName) { // this.lastName = lastName; // } // // public void setName(String name) { // this.name = name; // } // // public Address getAddr() { // return addr; // } // // public String getLastName() { // return lastName; // } // // public String getName() { // return name; // } // } // Path: src/test/java/factoryduke/FactoryRuntimeTest.java import factoryduke.exceptions.TemplateNotFoundException; import model.Address; import model.User; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import org.junit.Before; import org.junit.Test; import factoryduke.exceptions.TemplateDuplicateException; import factoryduke.exceptions.TemplateInstanciationException; /** * The MIT License * Copyright (c) 2016 Regis Leray * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package factoryduke; public class FactoryRuntimeTest { @Before public void removeTemplate() { FactoryRuntimeHolder.getRuntime().reset(); } @Test public void found_factories() { FactoryRuntimeHolder.getRuntime().load(); assertThat(FactoryRuntimeHolder.getRuntime().getTemplates()).hasSize(7); } @Test public void reset() { assertThat(FactoryRuntimeHolder.getRuntime().getTemplates()).isEmpty(); } @Test public void duplicate_definition() { Template tp = new ConsumerTemplate(User.class, User.class.getCanonicalName(), u -> u.setName("test")); FactoryRuntimeHolder.getRuntime().register(tp); assertThatThrownBy(() -> FactoryRuntimeHolder.getRuntime().register(tp)) .isInstanceOf(TemplateDuplicateException.class) .hasMessageContaining("Cannot define duplicate template with the same identifier") .hasNoCause(); } @Test public void build_instance_with_supplier_wrong_cast() { FactoryRuntimeHolder.getRuntime().load(); assertThatThrownBy(() -> {
FactoryRuntimeHolder.getRuntime().<Address>build("admin_user", o -> {
regis-leray/factory_duke
src/test/java/factoryduke/FactoryRuntimeTest.java
// Path: src/main/java/factoryduke/exceptions/TemplateDuplicateException.java // public class TemplateDuplicateException extends RuntimeException{ // public TemplateDuplicateException(String message) { // super(message); // } // } // // Path: src/main/java/factoryduke/exceptions/TemplateInstanciationException.java // public class TemplateInstanciationException extends RuntimeException { // public TemplateInstanciationException(Throwable cause) { // super(cause); // } // } // // Path: src/main/java/factoryduke/exceptions/TemplateNotFoundException.java // public class TemplateNotFoundException extends RuntimeException { // public TemplateNotFoundException(String message) { // super(message); // } // } // // Path: src/test/java/model/Address.java // public class Address { // private String country; // private String street; // private String city; // // public String getCountry() { // return country; // } // // public void setCountry(String country) { // this.country = country; // } // // public String getCity() { // return city; // } // // public void setCity(String city) { // this.city = city; // } // // public String getStreet() { // return street; // } // // public void setStreet(String street) { // this.street = street; // } // } // // Path: src/test/java/model/User.java // public class User { // private long id; // private String name; // private String lastName; // private Role role; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // private Address addr; // // public Role getRole() { // return role; // } // // public void setRole(Role role) { // this.role = role; // } // // public void setAddr(Address addr) { // this.addr = addr; // } // // public void setLastName(String lastName) { // this.lastName = lastName; // } // // public void setName(String name) { // this.name = name; // } // // public Address getAddr() { // return addr; // } // // public String getLastName() { // return lastName; // } // // public String getName() { // return name; // } // }
import factoryduke.exceptions.TemplateNotFoundException; import model.Address; import model.User; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import org.junit.Before; import org.junit.Test; import factoryduke.exceptions.TemplateDuplicateException; import factoryduke.exceptions.TemplateInstanciationException;
.isInstanceOf(TemplateDuplicateException.class) .hasMessageContaining("Cannot define duplicate template with the same identifier") .hasNoCause(); } @Test public void build_instance_with_supplier_wrong_cast() { FactoryRuntimeHolder.getRuntime().load(); assertThatThrownBy(() -> { FactoryRuntimeHolder.getRuntime().<Address>build("admin_user", o -> { }).toOne(); }).isInstanceOf(ClassCastException.class); } @Test public void build_instance_with_consumer_wrong_cast() { FactoryRuntimeHolder.getRuntime().load(); assertThatThrownBy(() -> { FactoryRuntimeHolder.getRuntime().<Address>build("user_with_fr_address", o -> { }).toOne(); }).isInstanceOf(ClassCastException.class); } @Test public void no_template_found() { assertThatThrownBy(() -> FactoryRuntimeHolder.getRuntime().<User>build("not_found", u -> { })
// Path: src/main/java/factoryduke/exceptions/TemplateDuplicateException.java // public class TemplateDuplicateException extends RuntimeException{ // public TemplateDuplicateException(String message) { // super(message); // } // } // // Path: src/main/java/factoryduke/exceptions/TemplateInstanciationException.java // public class TemplateInstanciationException extends RuntimeException { // public TemplateInstanciationException(Throwable cause) { // super(cause); // } // } // // Path: src/main/java/factoryduke/exceptions/TemplateNotFoundException.java // public class TemplateNotFoundException extends RuntimeException { // public TemplateNotFoundException(String message) { // super(message); // } // } // // Path: src/test/java/model/Address.java // public class Address { // private String country; // private String street; // private String city; // // public String getCountry() { // return country; // } // // public void setCountry(String country) { // this.country = country; // } // // public String getCity() { // return city; // } // // public void setCity(String city) { // this.city = city; // } // // public String getStreet() { // return street; // } // // public void setStreet(String street) { // this.street = street; // } // } // // Path: src/test/java/model/User.java // public class User { // private long id; // private String name; // private String lastName; // private Role role; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // private Address addr; // // public Role getRole() { // return role; // } // // public void setRole(Role role) { // this.role = role; // } // // public void setAddr(Address addr) { // this.addr = addr; // } // // public void setLastName(String lastName) { // this.lastName = lastName; // } // // public void setName(String name) { // this.name = name; // } // // public Address getAddr() { // return addr; // } // // public String getLastName() { // return lastName; // } // // public String getName() { // return name; // } // } // Path: src/test/java/factoryduke/FactoryRuntimeTest.java import factoryduke.exceptions.TemplateNotFoundException; import model.Address; import model.User; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import org.junit.Before; import org.junit.Test; import factoryduke.exceptions.TemplateDuplicateException; import factoryduke.exceptions.TemplateInstanciationException; .isInstanceOf(TemplateDuplicateException.class) .hasMessageContaining("Cannot define duplicate template with the same identifier") .hasNoCause(); } @Test public void build_instance_with_supplier_wrong_cast() { FactoryRuntimeHolder.getRuntime().load(); assertThatThrownBy(() -> { FactoryRuntimeHolder.getRuntime().<Address>build("admin_user", o -> { }).toOne(); }).isInstanceOf(ClassCastException.class); } @Test public void build_instance_with_consumer_wrong_cast() { FactoryRuntimeHolder.getRuntime().load(); assertThatThrownBy(() -> { FactoryRuntimeHolder.getRuntime().<Address>build("user_with_fr_address", o -> { }).toOne(); }).isInstanceOf(ClassCastException.class); } @Test public void no_template_found() { assertThatThrownBy(() -> FactoryRuntimeHolder.getRuntime().<User>build("not_found", u -> { })
).isInstanceOf(TemplateNotFoundException.class)
regis-leray/factory_duke
src/test/java/factoryduke/FactoryRuntimeTest.java
// Path: src/main/java/factoryduke/exceptions/TemplateDuplicateException.java // public class TemplateDuplicateException extends RuntimeException{ // public TemplateDuplicateException(String message) { // super(message); // } // } // // Path: src/main/java/factoryduke/exceptions/TemplateInstanciationException.java // public class TemplateInstanciationException extends RuntimeException { // public TemplateInstanciationException(Throwable cause) { // super(cause); // } // } // // Path: src/main/java/factoryduke/exceptions/TemplateNotFoundException.java // public class TemplateNotFoundException extends RuntimeException { // public TemplateNotFoundException(String message) { // super(message); // } // } // // Path: src/test/java/model/Address.java // public class Address { // private String country; // private String street; // private String city; // // public String getCountry() { // return country; // } // // public void setCountry(String country) { // this.country = country; // } // // public String getCity() { // return city; // } // // public void setCity(String city) { // this.city = city; // } // // public String getStreet() { // return street; // } // // public void setStreet(String street) { // this.street = street; // } // } // // Path: src/test/java/model/User.java // public class User { // private long id; // private String name; // private String lastName; // private Role role; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // private Address addr; // // public Role getRole() { // return role; // } // // public void setRole(Role role) { // this.role = role; // } // // public void setAddr(Address addr) { // this.addr = addr; // } // // public void setLastName(String lastName) { // this.lastName = lastName; // } // // public void setName(String name) { // this.name = name; // } // // public Address getAddr() { // return addr; // } // // public String getLastName() { // return lastName; // } // // public String getName() { // return name; // } // }
import factoryduke.exceptions.TemplateNotFoundException; import model.Address; import model.User; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import org.junit.Before; import org.junit.Test; import factoryduke.exceptions.TemplateDuplicateException; import factoryduke.exceptions.TemplateInstanciationException;
@Test public void build_instance_with_consumer_wrong_cast() { FactoryRuntimeHolder.getRuntime().load(); assertThatThrownBy(() -> { FactoryRuntimeHolder.getRuntime().<Address>build("user_with_fr_address", o -> { }).toOne(); }).isInstanceOf(ClassCastException.class); } @Test public void no_template_found() { assertThatThrownBy(() -> FactoryRuntimeHolder.getRuntime().<User>build("not_found", u -> { }) ).isInstanceOf(TemplateNotFoundException.class) .hasMessageContaining("No builder register with identifier : not_found") .hasNoCause(); } @Test public void no_constructor_with_template() { Template tp = new ConsumerTemplate(NoConstructor.class, "no_default_constructor", c -> { }); FactoryRuntimeHolder.getRuntime().register(tp); assertThatThrownBy(() -> FactoryRuntimeHolder.getRuntime().build("no_default_constructor", c -> { }).toOne()
// Path: src/main/java/factoryduke/exceptions/TemplateDuplicateException.java // public class TemplateDuplicateException extends RuntimeException{ // public TemplateDuplicateException(String message) { // super(message); // } // } // // Path: src/main/java/factoryduke/exceptions/TemplateInstanciationException.java // public class TemplateInstanciationException extends RuntimeException { // public TemplateInstanciationException(Throwable cause) { // super(cause); // } // } // // Path: src/main/java/factoryduke/exceptions/TemplateNotFoundException.java // public class TemplateNotFoundException extends RuntimeException { // public TemplateNotFoundException(String message) { // super(message); // } // } // // Path: src/test/java/model/Address.java // public class Address { // private String country; // private String street; // private String city; // // public String getCountry() { // return country; // } // // public void setCountry(String country) { // this.country = country; // } // // public String getCity() { // return city; // } // // public void setCity(String city) { // this.city = city; // } // // public String getStreet() { // return street; // } // // public void setStreet(String street) { // this.street = street; // } // } // // Path: src/test/java/model/User.java // public class User { // private long id; // private String name; // private String lastName; // private Role role; // // public long getId() { // return id; // } // // public void setId(long id) { // this.id = id; // } // // private Address addr; // // public Role getRole() { // return role; // } // // public void setRole(Role role) { // this.role = role; // } // // public void setAddr(Address addr) { // this.addr = addr; // } // // public void setLastName(String lastName) { // this.lastName = lastName; // } // // public void setName(String name) { // this.name = name; // } // // public Address getAddr() { // return addr; // } // // public String getLastName() { // return lastName; // } // // public String getName() { // return name; // } // } // Path: src/test/java/factoryduke/FactoryRuntimeTest.java import factoryduke.exceptions.TemplateNotFoundException; import model.Address; import model.User; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import org.junit.Before; import org.junit.Test; import factoryduke.exceptions.TemplateDuplicateException; import factoryduke.exceptions.TemplateInstanciationException; @Test public void build_instance_with_consumer_wrong_cast() { FactoryRuntimeHolder.getRuntime().load(); assertThatThrownBy(() -> { FactoryRuntimeHolder.getRuntime().<Address>build("user_with_fr_address", o -> { }).toOne(); }).isInstanceOf(ClassCastException.class); } @Test public void no_template_found() { assertThatThrownBy(() -> FactoryRuntimeHolder.getRuntime().<User>build("not_found", u -> { }) ).isInstanceOf(TemplateNotFoundException.class) .hasMessageContaining("No builder register with identifier : not_found") .hasNoCause(); } @Test public void no_constructor_with_template() { Template tp = new ConsumerTemplate(NoConstructor.class, "no_default_constructor", c -> { }); FactoryRuntimeHolder.getRuntime().register(tp); assertThatThrownBy(() -> FactoryRuntimeHolder.getRuntime().build("no_default_constructor", c -> { }).toOne()
).isInstanceOf(TemplateInstanciationException.class);
cybro/PalmCalc
PalmCalc/src/com/cybrosys/scientific/Logic.java
// Path: PalmCalc/src/com/cybrosys/scientific/CalculatorDisplay.java // enum Scroll { // UP, DOWN, NONE // }
import org.javia.arity.Symbols; import org.javia.arity.SyntaxException; import com.cybrosys.scientific.CalculatorDisplay.Scroll; import com.cybrosys.palmcalc.R; import android.text.TextUtils; import android.view.KeyEvent; import android.widget.EditText; import android.content.Context; import java.text.DecimalFormat; import java.text.NumberFormat; import java.util.Locale;
EditText etxtEditText = mDisplay.getEditText(); ScientificActivity.imm.hideSoftInputFromWindow( etxtEditText.getWindowToken(), 0); int cursorPos = etxtEditText.getSelectionStart(); return isToLeft ? cursorPos == 0 : cursorPos >= etxtEditText.length(); } private String getText() { return mDisplay.getText().toString(); } void insert(String strDelta) { mDisplay.insert(strDelta); setDeleteMode(inDelModeBa); } public void resumeWithHistory() { clearWithHistory(false); } private void clearWithHistory(boolean isScroll) { String strText = mHistory.getText(); if (strMarker.equals(strText)) { if (!mHistory.moveToPrevious()) { strText = ""; } strText = mHistory.getText();
// Path: PalmCalc/src/com/cybrosys/scientific/CalculatorDisplay.java // enum Scroll { // UP, DOWN, NONE // } // Path: PalmCalc/src/com/cybrosys/scientific/Logic.java import org.javia.arity.Symbols; import org.javia.arity.SyntaxException; import com.cybrosys.scientific.CalculatorDisplay.Scroll; import com.cybrosys.palmcalc.R; import android.text.TextUtils; import android.view.KeyEvent; import android.widget.EditText; import android.content.Context; import java.text.DecimalFormat; import java.text.NumberFormat; import java.util.Locale; EditText etxtEditText = mDisplay.getEditText(); ScientificActivity.imm.hideSoftInputFromWindow( etxtEditText.getWindowToken(), 0); int cursorPos = etxtEditText.getSelectionStart(); return isToLeft ? cursorPos == 0 : cursorPos >= etxtEditText.length(); } private String getText() { return mDisplay.getText().toString(); } void insert(String strDelta) { mDisplay.insert(strDelta); setDeleteMode(inDelModeBa); } public void resumeWithHistory() { clearWithHistory(false); } private void clearWithHistory(boolean isScroll) { String strText = mHistory.getText(); if (strMarker.equals(strText)) { if (!mHistory.moveToPrevious()) { strText = ""; } strText = mHistory.getText();
evaluateAndShowResult(strText, CalculatorDisplay.Scroll.NONE);
cybro/PalmCalc
PalmCalc/src/com/cybrosys/basic/Logic.java
// Path: PalmCalc/src/com/cybrosys/basic/CalculatorDisplay.java // enum Scroll { // UP, DOWN, NONE // }
import com.cybrosys.basic.CalculatorDisplay.Scroll; import android.text.TextUtils; import android.util.Log; import android.view.KeyEvent; import android.widget.EditText; import android.content.Context; import java.util.Locale; import org.javia.arity.Symbols; import org.javia.arity.SyntaxException;
mLineLength = nDigits; } boolean eatHorizontalMove(boolean toLeft) { EditText editText = mDisplay.getEditText(); int cursorPos = editText.getSelectionStart(); return toLeft ? cursorPos == 0 : cursorPos >= editText.length(); } private String getText() { return mDisplay.getText().toString(); } void insert(String delta) { Log.d("Display", delta); mDisplay.insert(delta); setDeleteMode(DELETE_MODE_BACKSPACE); } public void resumeWithHistory() { clearWithHistory(false); } private void clearWithHistory(boolean scroll) { String text = mHistory.getText(); if (MARKER_EVALUATE_ON_RESUME.equals(text)) { if (!mHistory.moveToPrevious()) { text = ""; } text = mHistory.getText();
// Path: PalmCalc/src/com/cybrosys/basic/CalculatorDisplay.java // enum Scroll { // UP, DOWN, NONE // } // Path: PalmCalc/src/com/cybrosys/basic/Logic.java import com.cybrosys.basic.CalculatorDisplay.Scroll; import android.text.TextUtils; import android.util.Log; import android.view.KeyEvent; import android.widget.EditText; import android.content.Context; import java.util.Locale; import org.javia.arity.Symbols; import org.javia.arity.SyntaxException; mLineLength = nDigits; } boolean eatHorizontalMove(boolean toLeft) { EditText editText = mDisplay.getEditText(); int cursorPos = editText.getSelectionStart(); return toLeft ? cursorPos == 0 : cursorPos >= editText.length(); } private String getText() { return mDisplay.getText().toString(); } void insert(String delta) { Log.d("Display", delta); mDisplay.insert(delta); setDeleteMode(DELETE_MODE_BACKSPACE); } public void resumeWithHistory() { clearWithHistory(false); } private void clearWithHistory(boolean scroll) { String text = mHistory.getText(); if (MARKER_EVALUATE_ON_RESUME.equals(text)) { if (!mHistory.moveToPrevious()) { text = ""; } text = mHistory.getText();
evaluateAndShowResult(text, CalculatorDisplay.Scroll.NONE);
epam/Gepard
gepard-examples/src/main/java/com/epam/gepard/examples/gherkin/cucumber/multifeature/MultiFeaturesTest.java
// Path: gepard-gherkin-cucumber/src/main/java/com/epam/gepard/gherkin/cucumber/CucumberTestCase.java // @CucumberOptions(strict = true, monochrome = true) // public abstract class CucumberTestCase implements GepardTestClass { // // /** // * The entry point to the Cucumber test. Sets up the test case and runs it. // */ // @Test // public void testRunCucumber() { // try { // Cucumber cucumber = new Cucumber(this.getClass()); // RunNotifier notifier = new RunNotifier(); // notifier.addFirstListener(new CucumberEventListener()); // GenericListTestSuite.getGlobalDataStorage().put(this.getClass().toString(), this); // cucumber.run(notifier); // } catch (InitializationError | IOException e) { // naTestCase("Cucumber Run Initialization Error: " + e.getMessage()); // } // } // // }
import com.epam.gepard.annotations.TestClass; import com.epam.gepard.gherkin.cucumber.CucumberTestCase; import cucumber.api.CucumberOptions;
package com.epam.gepard.examples.gherkin.cucumber.multifeature; /*========================================================================== Copyright 2004-2015 EPAM Systems This file is part of Gepard. Gepard is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Gepard 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 Gepard. If not, see <http://www.gnu.org/licenses/>. ===========================================================================*/ /** * Wrapper Junit test for Cucumber glue code placed next to this class. * Many such glue code presents next to this class. */ @TestClass(id = "Cucumber Test", name = "MultiFeaturesTest - Multi") @CucumberOptions(tags = "@specific")
// Path: gepard-gherkin-cucumber/src/main/java/com/epam/gepard/gherkin/cucumber/CucumberTestCase.java // @CucumberOptions(strict = true, monochrome = true) // public abstract class CucumberTestCase implements GepardTestClass { // // /** // * The entry point to the Cucumber test. Sets up the test case and runs it. // */ // @Test // public void testRunCucumber() { // try { // Cucumber cucumber = new Cucumber(this.getClass()); // RunNotifier notifier = new RunNotifier(); // notifier.addFirstListener(new CucumberEventListener()); // GenericListTestSuite.getGlobalDataStorage().put(this.getClass().toString(), this); // cucumber.run(notifier); // } catch (InitializationError | IOException e) { // naTestCase("Cucumber Run Initialization Error: " + e.getMessage()); // } // } // // } // Path: gepard-examples/src/main/java/com/epam/gepard/examples/gherkin/cucumber/multifeature/MultiFeaturesTest.java import com.epam.gepard.annotations.TestClass; import com.epam.gepard.gherkin.cucumber.CucumberTestCase; import cucumber.api.CucumberOptions; package com.epam.gepard.examples.gherkin.cucumber.multifeature; /*========================================================================== Copyright 2004-2015 EPAM Systems This file is part of Gepard. Gepard is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Gepard 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 Gepard. If not, see <http://www.gnu.org/licenses/>. ===========================================================================*/ /** * Wrapper Junit test for Cucumber glue code placed next to this class. * Many such glue code presents next to this class. */ @TestClass(id = "Cucumber Test", name = "MultiFeaturesTest - Multi") @CucumberOptions(tags = "@specific")
public class MultiFeaturesTest extends CucumberTestCase {
epam/Gepard
gepard-gherkin-jbehave/src/main/java/com/epam/gepard/gherkin/jbehave/GepardEmbedder.java
// Path: gepard-gherkin-jbehave/src/main/java/com/epam/gepard/gherkin/jbehave/helper/InstanceStepsFactoryCreator.java // public class InstanceStepsFactoryCreator { // // /** // * Creates an {@link InstanceStepsFactory} with the given {@link Configuration} for the given {@link com.epam.gepard.gherkin.jbehave.JBehaveTestCase}. // * @param configuration the configuration to use // * @param testCase the test case which will be used in the step creation process // * @return a new instance of {@link InstanceStepsFactory} // */ // public InstanceStepsFactory createForTestCase(final Configuration configuration, final JBehaveTestCase testCase) { // return new InstanceStepsFactory(configuration, testCase); // } // // }
import static java.util.Arrays.asList; import org.jbehave.core.configuration.Configuration; import org.jbehave.core.embedder.Embedder; import org.jbehave.core.embedder.NullEmbedderMonitor; import org.jbehave.core.steps.InstanceStepsFactory; import com.epam.gepard.gherkin.jbehave.helper.InstanceStepsFactoryCreator;
package com.epam.gepard.gherkin.jbehave; /*========================================================================== Copyright 2004-2015 EPAM Systems This file is part of Gepard. Gepard is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Gepard 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 Gepard. If not, see <http://www.gnu.org/licenses/>. ===========================================================================*/ /** * Wrapper for the {@link Embedder} class. * @author Adam_Csaba_Kiraly */ public class GepardEmbedder { private final Embedder embedder; private final ConfigurationFactory configurationFactory;
// Path: gepard-gherkin-jbehave/src/main/java/com/epam/gepard/gherkin/jbehave/helper/InstanceStepsFactoryCreator.java // public class InstanceStepsFactoryCreator { // // /** // * Creates an {@link InstanceStepsFactory} with the given {@link Configuration} for the given {@link com.epam.gepard.gherkin.jbehave.JBehaveTestCase}. // * @param configuration the configuration to use // * @param testCase the test case which will be used in the step creation process // * @return a new instance of {@link InstanceStepsFactory} // */ // public InstanceStepsFactory createForTestCase(final Configuration configuration, final JBehaveTestCase testCase) { // return new InstanceStepsFactory(configuration, testCase); // } // // } // Path: gepard-gherkin-jbehave/src/main/java/com/epam/gepard/gherkin/jbehave/GepardEmbedder.java import static java.util.Arrays.asList; import org.jbehave.core.configuration.Configuration; import org.jbehave.core.embedder.Embedder; import org.jbehave.core.embedder.NullEmbedderMonitor; import org.jbehave.core.steps.InstanceStepsFactory; import com.epam.gepard.gherkin.jbehave.helper.InstanceStepsFactoryCreator; package com.epam.gepard.gherkin.jbehave; /*========================================================================== Copyright 2004-2015 EPAM Systems This file is part of Gepard. Gepard is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Gepard 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 Gepard. If not, see <http://www.gnu.org/licenses/>. ===========================================================================*/ /** * Wrapper for the {@link Embedder} class. * @author Adam_Csaba_Kiraly */ public class GepardEmbedder { private final Embedder embedder; private final ConfigurationFactory configurationFactory;
private final InstanceStepsFactoryCreator instanceStepsFactoryCreator;
epam/Gepard
gepard-gherkin-jbehave/src/main/java/com/epam/gepard/gherkin/jbehave/JBehaveTestCase.java
// Path: gepard-gherkin-jbehave/src/main/java/com/epam/gepard/gherkin/jbehave/helper/InstanceStepsFactoryCreator.java // public class InstanceStepsFactoryCreator { // // /** // * Creates an {@link InstanceStepsFactory} with the given {@link Configuration} for the given {@link com.epam.gepard.gherkin.jbehave.JBehaveTestCase}. // * @param configuration the configuration to use // * @param testCase the test case which will be used in the step creation process // * @return a new instance of {@link InstanceStepsFactory} // */ // public InstanceStepsFactory createForTestCase(final Configuration configuration, final JBehaveTestCase testCase) { // return new InstanceStepsFactory(configuration, testCase); // } // // }
import com.epam.gepard.generic.GepardTestClass; import com.epam.gepard.gherkin.jbehave.helper.InstanceStepsFactoryCreator; import com.epam.gepard.logger.HtmlRunReporter; import com.epam.gepard.logger.LogFileWriter; import org.jbehave.core.embedder.Embedder;
package com.epam.gepard.gherkin.jbehave; /*========================================================================== Copyright 2004-2015 EPAM Systems This file is part of Gepard. Gepard is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Gepard 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 Gepard. If not, see <http://www.gnu.org/licenses/>. ===========================================================================*/ /** * Serves as a parent class for Jbehave based tests. * * @author Adam_Csaba_Kiraly */ public abstract class JBehaveTestCase implements GepardTestClass { private final GepardEmbedder gepardEmbedder; /** * Constructs a new instance of {@link JBehaveTestCase}. */ public JBehaveTestCase() {
// Path: gepard-gherkin-jbehave/src/main/java/com/epam/gepard/gherkin/jbehave/helper/InstanceStepsFactoryCreator.java // public class InstanceStepsFactoryCreator { // // /** // * Creates an {@link InstanceStepsFactory} with the given {@link Configuration} for the given {@link com.epam.gepard.gherkin.jbehave.JBehaveTestCase}. // * @param configuration the configuration to use // * @param testCase the test case which will be used in the step creation process // * @return a new instance of {@link InstanceStepsFactory} // */ // public InstanceStepsFactory createForTestCase(final Configuration configuration, final JBehaveTestCase testCase) { // return new InstanceStepsFactory(configuration, testCase); // } // // } // Path: gepard-gherkin-jbehave/src/main/java/com/epam/gepard/gherkin/jbehave/JBehaveTestCase.java import com.epam.gepard.generic.GepardTestClass; import com.epam.gepard.gherkin.jbehave.helper.InstanceStepsFactoryCreator; import com.epam.gepard.logger.HtmlRunReporter; import com.epam.gepard.logger.LogFileWriter; import org.jbehave.core.embedder.Embedder; package com.epam.gepard.gherkin.jbehave; /*========================================================================== Copyright 2004-2015 EPAM Systems This file is part of Gepard. Gepard is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Gepard 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 Gepard. If not, see <http://www.gnu.org/licenses/>. ===========================================================================*/ /** * Serves as a parent class for Jbehave based tests. * * @author Adam_Csaba_Kiraly */ public abstract class JBehaveTestCase implements GepardTestClass { private final GepardEmbedder gepardEmbedder; /** * Constructs a new instance of {@link JBehaveTestCase}. */ public JBehaveTestCase() {
gepardEmbedder = new GepardEmbedder(new Embedder(), new ConfigurationFactory(), new InstanceStepsFactoryCreator());
epam/Gepard
gepard-gherkin-jbehave/src/main/java/com/epam/gepard/gherkin/jbehave/ConfigurationFactory.java
// Path: gepard-gherkin-jbehave/src/main/java/com/epam/gepard/gherkin/jbehave/helper/PendingStepStrategyFactory.java // public class PendingStepStrategyFactory { // // /** // * Creates a new instance of {@link FailingUponPendingStep}. // * @return a new instance of {@link FailingUponPendingStep} // */ // public FailingUponPendingStep createFailingUponPendingStep() { // return new FailingUponPendingStep(); // } // // } // // Path: gepard-gherkin-jbehave/src/main/java/com/epam/gepard/gherkin/jbehave/helper/StoryParserFactory.java // public class StoryParserFactory { // // /** // * Creates a new instance of {@link GherkinStoryParser}. // * @return a new instance of {@link GherkinStoryParser} // */ // public GherkinStoryParser createGherkinStoryParser() { // return new GherkinStoryParser(); // } // } // // Path: gepard-gherkin-jbehave/src/main/java/com/epam/gepard/gherkin/jbehave/helper/StoryReporterBuilderFactory.java // public class StoryReporterBuilderFactory { // // /** // * Creates a new {@link StoryReporterBuilder} using {@link com.epam.gepard.gherkin.jbehave.JBehaveStoryReporter}. // * @param testCase the test case to use for reporting // * @return the new instance // */ // public StoryReporterBuilder createForTestCase(final JBehaveTestCase testCase) { // URL codeLocation = CodeLocations.codeLocationFromPath(""); // return new StoryReporterBuilder().withCodeLocation(codeLocation).withRelativeDirectory("").withReporters(new JBehaveStoryReporter(testCase)); // } // }
import org.jbehave.core.configuration.Configuration; import org.jbehave.core.configuration.MostUsefulConfiguration; import org.jbehave.core.failures.FailingUponPendingStep; import org.jbehave.core.parsers.gherkin.GherkinStoryParser; import org.jbehave.core.reporters.StoryReporterBuilder; import com.epam.gepard.gherkin.jbehave.helper.PendingStepStrategyFactory; import com.epam.gepard.gherkin.jbehave.helper.StoryParserFactory; import com.epam.gepard.gherkin.jbehave.helper.StoryReporterBuilderFactory;
package com.epam.gepard.gherkin.jbehave; /*========================================================================== Copyright 2004-2015 EPAM Systems This file is part of Gepard. Gepard is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Gepard 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 Gepard. If not, see <http://www.gnu.org/licenses/>. ===========================================================================*/ /** * Creates the {@link Configuration} for the Embedder. * @author Adam_Csaba_Kiraly */ public class ConfigurationFactory { private final StoryParserFactory storyParserFactory = new StoryParserFactory();
// Path: gepard-gherkin-jbehave/src/main/java/com/epam/gepard/gherkin/jbehave/helper/PendingStepStrategyFactory.java // public class PendingStepStrategyFactory { // // /** // * Creates a new instance of {@link FailingUponPendingStep}. // * @return a new instance of {@link FailingUponPendingStep} // */ // public FailingUponPendingStep createFailingUponPendingStep() { // return new FailingUponPendingStep(); // } // // } // // Path: gepard-gherkin-jbehave/src/main/java/com/epam/gepard/gherkin/jbehave/helper/StoryParserFactory.java // public class StoryParserFactory { // // /** // * Creates a new instance of {@link GherkinStoryParser}. // * @return a new instance of {@link GherkinStoryParser} // */ // public GherkinStoryParser createGherkinStoryParser() { // return new GherkinStoryParser(); // } // } // // Path: gepard-gherkin-jbehave/src/main/java/com/epam/gepard/gherkin/jbehave/helper/StoryReporterBuilderFactory.java // public class StoryReporterBuilderFactory { // // /** // * Creates a new {@link StoryReporterBuilder} using {@link com.epam.gepard.gherkin.jbehave.JBehaveStoryReporter}. // * @param testCase the test case to use for reporting // * @return the new instance // */ // public StoryReporterBuilder createForTestCase(final JBehaveTestCase testCase) { // URL codeLocation = CodeLocations.codeLocationFromPath(""); // return new StoryReporterBuilder().withCodeLocation(codeLocation).withRelativeDirectory("").withReporters(new JBehaveStoryReporter(testCase)); // } // } // Path: gepard-gherkin-jbehave/src/main/java/com/epam/gepard/gherkin/jbehave/ConfigurationFactory.java import org.jbehave.core.configuration.Configuration; import org.jbehave.core.configuration.MostUsefulConfiguration; import org.jbehave.core.failures.FailingUponPendingStep; import org.jbehave.core.parsers.gherkin.GherkinStoryParser; import org.jbehave.core.reporters.StoryReporterBuilder; import com.epam.gepard.gherkin.jbehave.helper.PendingStepStrategyFactory; import com.epam.gepard.gherkin.jbehave.helper.StoryParserFactory; import com.epam.gepard.gherkin.jbehave.helper.StoryReporterBuilderFactory; package com.epam.gepard.gherkin.jbehave; /*========================================================================== Copyright 2004-2015 EPAM Systems This file is part of Gepard. Gepard is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Gepard 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 Gepard. If not, see <http://www.gnu.org/licenses/>. ===========================================================================*/ /** * Creates the {@link Configuration} for the Embedder. * @author Adam_Csaba_Kiraly */ public class ConfigurationFactory { private final StoryParserFactory storyParserFactory = new StoryParserFactory();
private final StoryReporterBuilderFactory storyReporterBuilderFactory = new StoryReporterBuilderFactory();
epam/Gepard
gepard-gherkin-jbehave/src/main/java/com/epam/gepard/gherkin/jbehave/ConfigurationFactory.java
// Path: gepard-gherkin-jbehave/src/main/java/com/epam/gepard/gherkin/jbehave/helper/PendingStepStrategyFactory.java // public class PendingStepStrategyFactory { // // /** // * Creates a new instance of {@link FailingUponPendingStep}. // * @return a new instance of {@link FailingUponPendingStep} // */ // public FailingUponPendingStep createFailingUponPendingStep() { // return new FailingUponPendingStep(); // } // // } // // Path: gepard-gherkin-jbehave/src/main/java/com/epam/gepard/gherkin/jbehave/helper/StoryParserFactory.java // public class StoryParserFactory { // // /** // * Creates a new instance of {@link GherkinStoryParser}. // * @return a new instance of {@link GherkinStoryParser} // */ // public GherkinStoryParser createGherkinStoryParser() { // return new GherkinStoryParser(); // } // } // // Path: gepard-gherkin-jbehave/src/main/java/com/epam/gepard/gherkin/jbehave/helper/StoryReporterBuilderFactory.java // public class StoryReporterBuilderFactory { // // /** // * Creates a new {@link StoryReporterBuilder} using {@link com.epam.gepard.gherkin.jbehave.JBehaveStoryReporter}. // * @param testCase the test case to use for reporting // * @return the new instance // */ // public StoryReporterBuilder createForTestCase(final JBehaveTestCase testCase) { // URL codeLocation = CodeLocations.codeLocationFromPath(""); // return new StoryReporterBuilder().withCodeLocation(codeLocation).withRelativeDirectory("").withReporters(new JBehaveStoryReporter(testCase)); // } // }
import org.jbehave.core.configuration.Configuration; import org.jbehave.core.configuration.MostUsefulConfiguration; import org.jbehave.core.failures.FailingUponPendingStep; import org.jbehave.core.parsers.gherkin.GherkinStoryParser; import org.jbehave.core.reporters.StoryReporterBuilder; import com.epam.gepard.gherkin.jbehave.helper.PendingStepStrategyFactory; import com.epam.gepard.gherkin.jbehave.helper.StoryParserFactory; import com.epam.gepard.gherkin.jbehave.helper.StoryReporterBuilderFactory;
package com.epam.gepard.gherkin.jbehave; /*========================================================================== Copyright 2004-2015 EPAM Systems This file is part of Gepard. Gepard is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Gepard 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 Gepard. If not, see <http://www.gnu.org/licenses/>. ===========================================================================*/ /** * Creates the {@link Configuration} for the Embedder. * @author Adam_Csaba_Kiraly */ public class ConfigurationFactory { private final StoryParserFactory storyParserFactory = new StoryParserFactory(); private final StoryReporterBuilderFactory storyReporterBuilderFactory = new StoryReporterBuilderFactory();
// Path: gepard-gherkin-jbehave/src/main/java/com/epam/gepard/gherkin/jbehave/helper/PendingStepStrategyFactory.java // public class PendingStepStrategyFactory { // // /** // * Creates a new instance of {@link FailingUponPendingStep}. // * @return a new instance of {@link FailingUponPendingStep} // */ // public FailingUponPendingStep createFailingUponPendingStep() { // return new FailingUponPendingStep(); // } // // } // // Path: gepard-gherkin-jbehave/src/main/java/com/epam/gepard/gherkin/jbehave/helper/StoryParserFactory.java // public class StoryParserFactory { // // /** // * Creates a new instance of {@link GherkinStoryParser}. // * @return a new instance of {@link GherkinStoryParser} // */ // public GherkinStoryParser createGherkinStoryParser() { // return new GherkinStoryParser(); // } // } // // Path: gepard-gherkin-jbehave/src/main/java/com/epam/gepard/gherkin/jbehave/helper/StoryReporterBuilderFactory.java // public class StoryReporterBuilderFactory { // // /** // * Creates a new {@link StoryReporterBuilder} using {@link com.epam.gepard.gherkin.jbehave.JBehaveStoryReporter}. // * @param testCase the test case to use for reporting // * @return the new instance // */ // public StoryReporterBuilder createForTestCase(final JBehaveTestCase testCase) { // URL codeLocation = CodeLocations.codeLocationFromPath(""); // return new StoryReporterBuilder().withCodeLocation(codeLocation).withRelativeDirectory("").withReporters(new JBehaveStoryReporter(testCase)); // } // } // Path: gepard-gherkin-jbehave/src/main/java/com/epam/gepard/gherkin/jbehave/ConfigurationFactory.java import org.jbehave.core.configuration.Configuration; import org.jbehave.core.configuration.MostUsefulConfiguration; import org.jbehave.core.failures.FailingUponPendingStep; import org.jbehave.core.parsers.gherkin.GherkinStoryParser; import org.jbehave.core.reporters.StoryReporterBuilder; import com.epam.gepard.gherkin.jbehave.helper.PendingStepStrategyFactory; import com.epam.gepard.gherkin.jbehave.helper.StoryParserFactory; import com.epam.gepard.gherkin.jbehave.helper.StoryReporterBuilderFactory; package com.epam.gepard.gherkin.jbehave; /*========================================================================== Copyright 2004-2015 EPAM Systems This file is part of Gepard. Gepard is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Gepard 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 Gepard. If not, see <http://www.gnu.org/licenses/>. ===========================================================================*/ /** * Creates the {@link Configuration} for the Embedder. * @author Adam_Csaba_Kiraly */ public class ConfigurationFactory { private final StoryParserFactory storyParserFactory = new StoryParserFactory(); private final StoryReporterBuilderFactory storyReporterBuilderFactory = new StoryReporterBuilderFactory();
private final PendingStepStrategyFactory pendingStepStrategyFactory = new PendingStepStrategyFactory();
epam/Gepard
gepard-selenium/src/main/java/com/epam/gepard/selenium/browsers/WebDriverUtil.java
// Path: gepard-selenium/src/main/java/com/epam/gepard/selenium/helper/EnvironmentHelper.java // public class EnvironmentHelper { // private Environment environment; // // /** // * Default constructor. // * @param environment is the parent environment class of Gepard. // */ // public EnvironmentHelper(Environment environment) { // this.environment = environment; // } // // public String getTestEnvironmentURL() { // return environment.getProperty("env." + environment.getTestEnvironmentID() + ".url"); // } // // public String getTestEnvironmentURLSecure() { // return environment.getProperty("env." + environment.getTestEnvironmentID() + ".url.secure"); // } // // /** // * Gets the browser that is specified to thi specific TSID. // * @return with the TSID specific browser string. // */ // public String getTestEnvironmentBrowser() { // return environment.getProperty("env." + environment.getTestEnvironmentID() + ".browser"); // } // // /** // * Simple wrapper ofor getting environment properties. // * @param propertyKey is the key of the property. // * @return with property value. // */ // public String getProperty(final String propertyKey) { // return environment.getProperty(propertyKey); // } // // /** // * // * Simple wrapper ofor getting environment properties. // * @param propertyKey is the key of the property. // * @param defaultValue is the default value, if parameter was not found. // * @return with property value. // */ // public String getProperty(final String propertyKey, final String defaultValue) { // return environment.getProperty(propertyKey, defaultValue); // } // }
import com.epam.gepard.exception.SimpleGepardException; import com.epam.gepard.generic.GepardTestClass; import com.epam.gepard.selenium.helper.EnvironmentHelper; import com.epam.gepard.util.FileUtil; import com.epam.gepard.util.Util; import com.thoughtworks.selenium.Selenium; import com.thoughtworks.selenium.SeleniumException; import com.thoughtworks.selenium.webdriven.WebDriverBackedSelenium; import org.apache.http.client.utils.URIBuilder; import org.openqa.selenium.By; import org.openqa.selenium.OutputType; import org.openqa.selenium.TakesScreenshot; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebDriverException; import org.openqa.selenium.WebElement; import org.openqa.selenium.remote.Augmenter; import org.openqa.selenium.remote.DesiredCapabilities; import org.openqa.selenium.remote.RemoteWebDriver; import java.awt.event.KeyEvent; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.PrintWriter; import java.net.MalformedURLException; import java.net.URISyntaxException; import java.net.URL; import java.text.SimpleDateFormat; import java.util.Date;
package com.epam.gepard.selenium.browsers; /*========================================================================== Copyright 2004-2015 EPAM Systems This file is part of Gepard. Gepard is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Gepard 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 Gepard. If not, see <http://www.gnu.org/licenses/>. ===========================================================================*/ /** * Utility functions for Selenium. * * @author Tamas_Kohegyi */ public class WebDriverUtil { public static final String SELENIUM_PORT = "gepard.selenium.port"; public static final String SELENIUM_HOST = "gepard.selenium.host"; public static final String DEFAULT_TIMEOUT = "30000"; public static final String SELENIUM_BROWSER_FIREFOX = "gepard.selenium.browserString.FF"; public static final String SELENIUM_BROWSER_INTERNET_EXPLORER = "gepard.selenium.browserString.IE"; public static final String SELENIUM_BROWSER_GOOGLE_CHROME = "gepard.selenium.browserString.GoogleChrome"; public static final String SELENIUM_BROWSER_SAFARI = "gepard.selenium.browserString.Safari"; private static final long WEB_DRIVER_SHUTDOWN_DELAY = 5000; private static int dumpFileCount; private GepardTestClass tc; /** * WebDriver main object. */ private WebDriver webDriver; /** * Selenium main object. */ private Selenium selenium; /** * Environment extender. */
// Path: gepard-selenium/src/main/java/com/epam/gepard/selenium/helper/EnvironmentHelper.java // public class EnvironmentHelper { // private Environment environment; // // /** // * Default constructor. // * @param environment is the parent environment class of Gepard. // */ // public EnvironmentHelper(Environment environment) { // this.environment = environment; // } // // public String getTestEnvironmentURL() { // return environment.getProperty("env." + environment.getTestEnvironmentID() + ".url"); // } // // public String getTestEnvironmentURLSecure() { // return environment.getProperty("env." + environment.getTestEnvironmentID() + ".url.secure"); // } // // /** // * Gets the browser that is specified to thi specific TSID. // * @return with the TSID specific browser string. // */ // public String getTestEnvironmentBrowser() { // return environment.getProperty("env." + environment.getTestEnvironmentID() + ".browser"); // } // // /** // * Simple wrapper ofor getting environment properties. // * @param propertyKey is the key of the property. // * @return with property value. // */ // public String getProperty(final String propertyKey) { // return environment.getProperty(propertyKey); // } // // /** // * // * Simple wrapper ofor getting environment properties. // * @param propertyKey is the key of the property. // * @param defaultValue is the default value, if parameter was not found. // * @return with property value. // */ // public String getProperty(final String propertyKey, final String defaultValue) { // return environment.getProperty(propertyKey, defaultValue); // } // } // Path: gepard-selenium/src/main/java/com/epam/gepard/selenium/browsers/WebDriverUtil.java import com.epam.gepard.exception.SimpleGepardException; import com.epam.gepard.generic.GepardTestClass; import com.epam.gepard.selenium.helper.EnvironmentHelper; import com.epam.gepard.util.FileUtil; import com.epam.gepard.util.Util; import com.thoughtworks.selenium.Selenium; import com.thoughtworks.selenium.SeleniumException; import com.thoughtworks.selenium.webdriven.WebDriverBackedSelenium; import org.apache.http.client.utils.URIBuilder; import org.openqa.selenium.By; import org.openqa.selenium.OutputType; import org.openqa.selenium.TakesScreenshot; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebDriverException; import org.openqa.selenium.WebElement; import org.openqa.selenium.remote.Augmenter; import org.openqa.selenium.remote.DesiredCapabilities; import org.openqa.selenium.remote.RemoteWebDriver; import java.awt.event.KeyEvent; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.PrintWriter; import java.net.MalformedURLException; import java.net.URISyntaxException; import java.net.URL; import java.text.SimpleDateFormat; import java.util.Date; package com.epam.gepard.selenium.browsers; /*========================================================================== Copyright 2004-2015 EPAM Systems This file is part of Gepard. Gepard is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Gepard 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 Gepard. If not, see <http://www.gnu.org/licenses/>. ===========================================================================*/ /** * Utility functions for Selenium. * * @author Tamas_Kohegyi */ public class WebDriverUtil { public static final String SELENIUM_PORT = "gepard.selenium.port"; public static final String SELENIUM_HOST = "gepard.selenium.host"; public static final String DEFAULT_TIMEOUT = "30000"; public static final String SELENIUM_BROWSER_FIREFOX = "gepard.selenium.browserString.FF"; public static final String SELENIUM_BROWSER_INTERNET_EXPLORER = "gepard.selenium.browserString.IE"; public static final String SELENIUM_BROWSER_GOOGLE_CHROME = "gepard.selenium.browserString.GoogleChrome"; public static final String SELENIUM_BROWSER_SAFARI = "gepard.selenium.browserString.Safari"; private static final long WEB_DRIVER_SHUTDOWN_DELAY = 5000; private static int dumpFileCount; private GepardTestClass tc; /** * WebDriver main object. */ private WebDriver webDriver; /** * Selenium main object. */ private Selenium selenium; /** * Environment extender. */
private EnvironmentHelper environmentHelper;
epam/Gepard
gepard-selenium/src/main/java/com/epam/gepard/selenium/conditionwatcher/AbstractWebDriverWatchable.java
// Path: gepard-selenium/src/main/java/com/epam/gepard/selenium/conditionwatcher/selectors/Selector.java // public interface Selector { // /** // * Gets the selector part of the object. // * @return with the selector string, // */ // String getSelector(); // // /** // * Define method of how the selector should work. // * @return with the selected object (implementation will decide how). // */ // By getBy(); // }
import com.epam.gepard.inspector.conditionwatcher.Watchable; import com.epam.gepard.selenium.conditionwatcher.selectors.Selector; import org.openqa.selenium.NoSuchElementException; import org.openqa.selenium.WebDriver;
package com.epam.gepard.selenium.conditionwatcher; /** * This class provides a Template Method pattern implementation for {@link Watchable} objects. * You must override at least the evaluate() method. * If that returns true, the detailed message logged and the conditionAction is executed. * * @author Robert_Ambrus */ public abstract class AbstractWebDriverWatchable implements Watchable<WebDriver> { private final String message; /** * Constructor for this simple implementation. * * @param message The message you want to see in the log. */ public AbstractWebDriverWatchable(String message) { this.message = message; } @Override public final boolean checkCondition(WebDriver webDriver) { boolean retval = false; if (evaluate(webDriver)) { retval = true; handleCondition(webDriver); } return retval; } @Override public String getMessage() { return message; } /** * This method should evaluate whether the watched condition is actually true. * * @param webDriver is the webDriver object. * @return Returns true if the watched condition is true. */ protected abstract boolean evaluate(WebDriver webDriver); /** * Return detailed message to include in the log when this event is happening. * * @param webDriver is the webDriver object. * @return empty string by default, override if you want a detailed message logged. */ protected String getDetailedMessage(WebDriver webDriver) { return ""; } /** * This method is called when the condition is true. * * @param webDriver is the webDriver object. */ protected void handleCondition(WebDriver webDriver) { } /** * Checks Visibility of an element based on selector. * * @param webDriver is the web driver object * @param selector of the element * @return true if visible */
// Path: gepard-selenium/src/main/java/com/epam/gepard/selenium/conditionwatcher/selectors/Selector.java // public interface Selector { // /** // * Gets the selector part of the object. // * @return with the selector string, // */ // String getSelector(); // // /** // * Define method of how the selector should work. // * @return with the selected object (implementation will decide how). // */ // By getBy(); // } // Path: gepard-selenium/src/main/java/com/epam/gepard/selenium/conditionwatcher/AbstractWebDriverWatchable.java import com.epam.gepard.inspector.conditionwatcher.Watchable; import com.epam.gepard.selenium.conditionwatcher.selectors.Selector; import org.openqa.selenium.NoSuchElementException; import org.openqa.selenium.WebDriver; package com.epam.gepard.selenium.conditionwatcher; /** * This class provides a Template Method pattern implementation for {@link Watchable} objects. * You must override at least the evaluate() method. * If that returns true, the detailed message logged and the conditionAction is executed. * * @author Robert_Ambrus */ public abstract class AbstractWebDriverWatchable implements Watchable<WebDriver> { private final String message; /** * Constructor for this simple implementation. * * @param message The message you want to see in the log. */ public AbstractWebDriverWatchable(String message) { this.message = message; } @Override public final boolean checkCondition(WebDriver webDriver) { boolean retval = false; if (evaluate(webDriver)) { retval = true; handleCondition(webDriver); } return retval; } @Override public String getMessage() { return message; } /** * This method should evaluate whether the watched condition is actually true. * * @param webDriver is the webDriver object. * @return Returns true if the watched condition is true. */ protected abstract boolean evaluate(WebDriver webDriver); /** * Return detailed message to include in the log when this event is happening. * * @param webDriver is the webDriver object. * @return empty string by default, override if you want a detailed message logged. */ protected String getDetailedMessage(WebDriver webDriver) { return ""; } /** * This method is called when the condition is true. * * @param webDriver is the webDriver object. */ protected void handleCondition(WebDriver webDriver) { } /** * Checks Visibility of an element based on selector. * * @param webDriver is the web driver object * @param selector of the element * @return true if visible */
protected boolean isVisible(WebDriver webDriver, Selector selector) {
epam/Gepard
gepard-gherkin-jbehave/src/test/java/com/epam/gepard/gherkin/jbehave/ConfigurationFactoryTest.java
// Path: gepard-gherkin-jbehave/src/main/java/com/epam/gepard/gherkin/jbehave/helper/PendingStepStrategyFactory.java // public class PendingStepStrategyFactory { // // /** // * Creates a new instance of {@link FailingUponPendingStep}. // * @return a new instance of {@link FailingUponPendingStep} // */ // public FailingUponPendingStep createFailingUponPendingStep() { // return new FailingUponPendingStep(); // } // // } // // Path: gepard-gherkin-jbehave/src/main/java/com/epam/gepard/gherkin/jbehave/helper/StoryParserFactory.java // public class StoryParserFactory { // // /** // * Creates a new instance of {@link GherkinStoryParser}. // * @return a new instance of {@link GherkinStoryParser} // */ // public GherkinStoryParser createGherkinStoryParser() { // return new GherkinStoryParser(); // } // } // // Path: gepard-gherkin-jbehave/src/main/java/com/epam/gepard/gherkin/jbehave/helper/StoryReporterBuilderFactory.java // public class StoryReporterBuilderFactory { // // /** // * Creates a new {@link StoryReporterBuilder} using {@link com.epam.gepard.gherkin.jbehave.JBehaveStoryReporter}. // * @param testCase the test case to use for reporting // * @return the new instance // */ // public StoryReporterBuilder createForTestCase(final JBehaveTestCase testCase) { // URL codeLocation = CodeLocations.codeLocationFromPath(""); // return new StoryReporterBuilder().withCodeLocation(codeLocation).withRelativeDirectory("").withReporters(new JBehaveStoryReporter(testCase)); // } // }
import org.mockito.internal.util.reflection.Whitebox; import com.epam.gepard.gherkin.jbehave.helper.PendingStepStrategyFactory; import com.epam.gepard.gherkin.jbehave.helper.StoryParserFactory; import com.epam.gepard.gherkin.jbehave.helper.StoryReporterBuilderFactory; import static org.junit.Assert.assertEquals; import static org.mockito.BDDMockito.given; import org.jbehave.core.configuration.Configuration; import org.jbehave.core.failures.FailingUponPendingStep; import org.jbehave.core.parsers.gherkin.GherkinStoryParser; import org.jbehave.core.reporters.StoryReporterBuilder; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations;
package com.epam.gepard.gherkin.jbehave; /*========================================================================== Copyright 2004-2015 EPAM Systems This file is part of Gepard. Gepard is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Gepard 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 Gepard. If not, see <http://www.gnu.org/licenses/>. ===========================================================================*/ /** * Unit test for {@link ConfigurationFactory}. * @author Adam_Csaba_Kiraly */ public class ConfigurationFactoryTest { @Mock
// Path: gepard-gherkin-jbehave/src/main/java/com/epam/gepard/gherkin/jbehave/helper/PendingStepStrategyFactory.java // public class PendingStepStrategyFactory { // // /** // * Creates a new instance of {@link FailingUponPendingStep}. // * @return a new instance of {@link FailingUponPendingStep} // */ // public FailingUponPendingStep createFailingUponPendingStep() { // return new FailingUponPendingStep(); // } // // } // // Path: gepard-gherkin-jbehave/src/main/java/com/epam/gepard/gherkin/jbehave/helper/StoryParserFactory.java // public class StoryParserFactory { // // /** // * Creates a new instance of {@link GherkinStoryParser}. // * @return a new instance of {@link GherkinStoryParser} // */ // public GherkinStoryParser createGherkinStoryParser() { // return new GherkinStoryParser(); // } // } // // Path: gepard-gherkin-jbehave/src/main/java/com/epam/gepard/gherkin/jbehave/helper/StoryReporterBuilderFactory.java // public class StoryReporterBuilderFactory { // // /** // * Creates a new {@link StoryReporterBuilder} using {@link com.epam.gepard.gherkin.jbehave.JBehaveStoryReporter}. // * @param testCase the test case to use for reporting // * @return the new instance // */ // public StoryReporterBuilder createForTestCase(final JBehaveTestCase testCase) { // URL codeLocation = CodeLocations.codeLocationFromPath(""); // return new StoryReporterBuilder().withCodeLocation(codeLocation).withRelativeDirectory("").withReporters(new JBehaveStoryReporter(testCase)); // } // } // Path: gepard-gherkin-jbehave/src/test/java/com/epam/gepard/gherkin/jbehave/ConfigurationFactoryTest.java import org.mockito.internal.util.reflection.Whitebox; import com.epam.gepard.gherkin.jbehave.helper.PendingStepStrategyFactory; import com.epam.gepard.gherkin.jbehave.helper.StoryParserFactory; import com.epam.gepard.gherkin.jbehave.helper.StoryReporterBuilderFactory; import static org.junit.Assert.assertEquals; import static org.mockito.BDDMockito.given; import org.jbehave.core.configuration.Configuration; import org.jbehave.core.failures.FailingUponPendingStep; import org.jbehave.core.parsers.gherkin.GherkinStoryParser; import org.jbehave.core.reporters.StoryReporterBuilder; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; package com.epam.gepard.gherkin.jbehave; /*========================================================================== Copyright 2004-2015 EPAM Systems This file is part of Gepard. Gepard is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Gepard 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 Gepard. If not, see <http://www.gnu.org/licenses/>. ===========================================================================*/ /** * Unit test for {@link ConfigurationFactory}. * @author Adam_Csaba_Kiraly */ public class ConfigurationFactoryTest { @Mock
private StoryParserFactory storyParserFactory;
epam/Gepard
gepard-gherkin-jbehave/src/test/java/com/epam/gepard/gherkin/jbehave/ConfigurationFactoryTest.java
// Path: gepard-gherkin-jbehave/src/main/java/com/epam/gepard/gherkin/jbehave/helper/PendingStepStrategyFactory.java // public class PendingStepStrategyFactory { // // /** // * Creates a new instance of {@link FailingUponPendingStep}. // * @return a new instance of {@link FailingUponPendingStep} // */ // public FailingUponPendingStep createFailingUponPendingStep() { // return new FailingUponPendingStep(); // } // // } // // Path: gepard-gherkin-jbehave/src/main/java/com/epam/gepard/gherkin/jbehave/helper/StoryParserFactory.java // public class StoryParserFactory { // // /** // * Creates a new instance of {@link GherkinStoryParser}. // * @return a new instance of {@link GherkinStoryParser} // */ // public GherkinStoryParser createGherkinStoryParser() { // return new GherkinStoryParser(); // } // } // // Path: gepard-gherkin-jbehave/src/main/java/com/epam/gepard/gherkin/jbehave/helper/StoryReporterBuilderFactory.java // public class StoryReporterBuilderFactory { // // /** // * Creates a new {@link StoryReporterBuilder} using {@link com.epam.gepard.gherkin.jbehave.JBehaveStoryReporter}. // * @param testCase the test case to use for reporting // * @return the new instance // */ // public StoryReporterBuilder createForTestCase(final JBehaveTestCase testCase) { // URL codeLocation = CodeLocations.codeLocationFromPath(""); // return new StoryReporterBuilder().withCodeLocation(codeLocation).withRelativeDirectory("").withReporters(new JBehaveStoryReporter(testCase)); // } // }
import org.mockito.internal.util.reflection.Whitebox; import com.epam.gepard.gherkin.jbehave.helper.PendingStepStrategyFactory; import com.epam.gepard.gherkin.jbehave.helper.StoryParserFactory; import com.epam.gepard.gherkin.jbehave.helper.StoryReporterBuilderFactory; import static org.junit.Assert.assertEquals; import static org.mockito.BDDMockito.given; import org.jbehave.core.configuration.Configuration; import org.jbehave.core.failures.FailingUponPendingStep; import org.jbehave.core.parsers.gherkin.GherkinStoryParser; import org.jbehave.core.reporters.StoryReporterBuilder; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations;
package com.epam.gepard.gherkin.jbehave; /*========================================================================== Copyright 2004-2015 EPAM Systems This file is part of Gepard. Gepard is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Gepard 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 Gepard. If not, see <http://www.gnu.org/licenses/>. ===========================================================================*/ /** * Unit test for {@link ConfigurationFactory}. * @author Adam_Csaba_Kiraly */ public class ConfigurationFactoryTest { @Mock private StoryParserFactory storyParserFactory; @Mock
// Path: gepard-gherkin-jbehave/src/main/java/com/epam/gepard/gherkin/jbehave/helper/PendingStepStrategyFactory.java // public class PendingStepStrategyFactory { // // /** // * Creates a new instance of {@link FailingUponPendingStep}. // * @return a new instance of {@link FailingUponPendingStep} // */ // public FailingUponPendingStep createFailingUponPendingStep() { // return new FailingUponPendingStep(); // } // // } // // Path: gepard-gherkin-jbehave/src/main/java/com/epam/gepard/gherkin/jbehave/helper/StoryParserFactory.java // public class StoryParserFactory { // // /** // * Creates a new instance of {@link GherkinStoryParser}. // * @return a new instance of {@link GherkinStoryParser} // */ // public GherkinStoryParser createGherkinStoryParser() { // return new GherkinStoryParser(); // } // } // // Path: gepard-gherkin-jbehave/src/main/java/com/epam/gepard/gherkin/jbehave/helper/StoryReporterBuilderFactory.java // public class StoryReporterBuilderFactory { // // /** // * Creates a new {@link StoryReporterBuilder} using {@link com.epam.gepard.gherkin.jbehave.JBehaveStoryReporter}. // * @param testCase the test case to use for reporting // * @return the new instance // */ // public StoryReporterBuilder createForTestCase(final JBehaveTestCase testCase) { // URL codeLocation = CodeLocations.codeLocationFromPath(""); // return new StoryReporterBuilder().withCodeLocation(codeLocation).withRelativeDirectory("").withReporters(new JBehaveStoryReporter(testCase)); // } // } // Path: gepard-gherkin-jbehave/src/test/java/com/epam/gepard/gherkin/jbehave/ConfigurationFactoryTest.java import org.mockito.internal.util.reflection.Whitebox; import com.epam.gepard.gherkin.jbehave.helper.PendingStepStrategyFactory; import com.epam.gepard.gherkin.jbehave.helper.StoryParserFactory; import com.epam.gepard.gherkin.jbehave.helper.StoryReporterBuilderFactory; import static org.junit.Assert.assertEquals; import static org.mockito.BDDMockito.given; import org.jbehave.core.configuration.Configuration; import org.jbehave.core.failures.FailingUponPendingStep; import org.jbehave.core.parsers.gherkin.GherkinStoryParser; import org.jbehave.core.reporters.StoryReporterBuilder; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; package com.epam.gepard.gherkin.jbehave; /*========================================================================== Copyright 2004-2015 EPAM Systems This file is part of Gepard. Gepard is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Gepard 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 Gepard. If not, see <http://www.gnu.org/licenses/>. ===========================================================================*/ /** * Unit test for {@link ConfigurationFactory}. * @author Adam_Csaba_Kiraly */ public class ConfigurationFactoryTest { @Mock private StoryParserFactory storyParserFactory; @Mock
private StoryReporterBuilderFactory storyReporterBuilderFactory;
epam/Gepard
gepard-gherkin-jbehave/src/test/java/com/epam/gepard/gherkin/jbehave/ConfigurationFactoryTest.java
// Path: gepard-gherkin-jbehave/src/main/java/com/epam/gepard/gherkin/jbehave/helper/PendingStepStrategyFactory.java // public class PendingStepStrategyFactory { // // /** // * Creates a new instance of {@link FailingUponPendingStep}. // * @return a new instance of {@link FailingUponPendingStep} // */ // public FailingUponPendingStep createFailingUponPendingStep() { // return new FailingUponPendingStep(); // } // // } // // Path: gepard-gherkin-jbehave/src/main/java/com/epam/gepard/gherkin/jbehave/helper/StoryParserFactory.java // public class StoryParserFactory { // // /** // * Creates a new instance of {@link GherkinStoryParser}. // * @return a new instance of {@link GherkinStoryParser} // */ // public GherkinStoryParser createGherkinStoryParser() { // return new GherkinStoryParser(); // } // } // // Path: gepard-gherkin-jbehave/src/main/java/com/epam/gepard/gherkin/jbehave/helper/StoryReporterBuilderFactory.java // public class StoryReporterBuilderFactory { // // /** // * Creates a new {@link StoryReporterBuilder} using {@link com.epam.gepard.gherkin.jbehave.JBehaveStoryReporter}. // * @param testCase the test case to use for reporting // * @return the new instance // */ // public StoryReporterBuilder createForTestCase(final JBehaveTestCase testCase) { // URL codeLocation = CodeLocations.codeLocationFromPath(""); // return new StoryReporterBuilder().withCodeLocation(codeLocation).withRelativeDirectory("").withReporters(new JBehaveStoryReporter(testCase)); // } // }
import org.mockito.internal.util.reflection.Whitebox; import com.epam.gepard.gherkin.jbehave.helper.PendingStepStrategyFactory; import com.epam.gepard.gherkin.jbehave.helper.StoryParserFactory; import com.epam.gepard.gherkin.jbehave.helper.StoryReporterBuilderFactory; import static org.junit.Assert.assertEquals; import static org.mockito.BDDMockito.given; import org.jbehave.core.configuration.Configuration; import org.jbehave.core.failures.FailingUponPendingStep; import org.jbehave.core.parsers.gherkin.GherkinStoryParser; import org.jbehave.core.reporters.StoryReporterBuilder; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations;
package com.epam.gepard.gherkin.jbehave; /*========================================================================== Copyright 2004-2015 EPAM Systems This file is part of Gepard. Gepard is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Gepard 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 Gepard. If not, see <http://www.gnu.org/licenses/>. ===========================================================================*/ /** * Unit test for {@link ConfigurationFactory}. * @author Adam_Csaba_Kiraly */ public class ConfigurationFactoryTest { @Mock private StoryParserFactory storyParserFactory; @Mock private StoryReporterBuilderFactory storyReporterBuilderFactory; @Mock
// Path: gepard-gherkin-jbehave/src/main/java/com/epam/gepard/gherkin/jbehave/helper/PendingStepStrategyFactory.java // public class PendingStepStrategyFactory { // // /** // * Creates a new instance of {@link FailingUponPendingStep}. // * @return a new instance of {@link FailingUponPendingStep} // */ // public FailingUponPendingStep createFailingUponPendingStep() { // return new FailingUponPendingStep(); // } // // } // // Path: gepard-gherkin-jbehave/src/main/java/com/epam/gepard/gherkin/jbehave/helper/StoryParserFactory.java // public class StoryParserFactory { // // /** // * Creates a new instance of {@link GherkinStoryParser}. // * @return a new instance of {@link GherkinStoryParser} // */ // public GherkinStoryParser createGherkinStoryParser() { // return new GherkinStoryParser(); // } // } // // Path: gepard-gherkin-jbehave/src/main/java/com/epam/gepard/gherkin/jbehave/helper/StoryReporterBuilderFactory.java // public class StoryReporterBuilderFactory { // // /** // * Creates a new {@link StoryReporterBuilder} using {@link com.epam.gepard.gherkin.jbehave.JBehaveStoryReporter}. // * @param testCase the test case to use for reporting // * @return the new instance // */ // public StoryReporterBuilder createForTestCase(final JBehaveTestCase testCase) { // URL codeLocation = CodeLocations.codeLocationFromPath(""); // return new StoryReporterBuilder().withCodeLocation(codeLocation).withRelativeDirectory("").withReporters(new JBehaveStoryReporter(testCase)); // } // } // Path: gepard-gherkin-jbehave/src/test/java/com/epam/gepard/gherkin/jbehave/ConfigurationFactoryTest.java import org.mockito.internal.util.reflection.Whitebox; import com.epam.gepard.gherkin.jbehave.helper.PendingStepStrategyFactory; import com.epam.gepard.gherkin.jbehave.helper.StoryParserFactory; import com.epam.gepard.gherkin.jbehave.helper.StoryReporterBuilderFactory; import static org.junit.Assert.assertEquals; import static org.mockito.BDDMockito.given; import org.jbehave.core.configuration.Configuration; import org.jbehave.core.failures.FailingUponPendingStep; import org.jbehave.core.parsers.gherkin.GherkinStoryParser; import org.jbehave.core.reporters.StoryReporterBuilder; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; package com.epam.gepard.gherkin.jbehave; /*========================================================================== Copyright 2004-2015 EPAM Systems This file is part of Gepard. Gepard is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Gepard 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 Gepard. If not, see <http://www.gnu.org/licenses/>. ===========================================================================*/ /** * Unit test for {@link ConfigurationFactory}. * @author Adam_Csaba_Kiraly */ public class ConfigurationFactoryTest { @Mock private StoryParserFactory storyParserFactory; @Mock private StoryReporterBuilderFactory storyReporterBuilderFactory; @Mock
private PendingStepStrategyFactory pendingStepStrategyFactory;
epam/Gepard
gepard-gherkin-jbehave/src/test/java/com/epam/gepard/gherkin/jbehave/JBehaveStoryReporterTest.java
// Path: gepard-gherkin-jbehave/src/main/java/com/epam/gepard/gherkin/jbehave/helper/IOUtils.java // public class IOUtils { // // /** // * Get the contents of an InputStream as a String using the default character encoding of the platform. // * This method buffers the input internally, so there is no need to use a BufferedInputStream. // * @param inputStream the InputStream to read from // * @return the contents of the inputStream // * @throws IOException - if an I/O error occurs // */ // public String toString(final InputStream inputStream) throws IOException { // return org.apache.commons.io.IOUtils.toString(inputStream); // } // } // // Path: gepard-gherkin-jbehave/src/main/java/com/epam/gepard/gherkin/jbehave/helper/ResourceProvider.java // public class ResourceProvider { // // /** // * Returns the resource with the given path from the classpath. // * @param path the given path of the resource // * @return an {@link InputStream} of the resource, or null if not found // */ // public InputStream getResourceAsStream(final String path) { // return getClass().getClassLoader().getResourceAsStream(path); // } // // }
import org.junit.Test; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; import org.mockito.internal.util.reflection.Whitebox; import com.epam.gepard.gherkin.jbehave.helper.IOUtils; import com.epam.gepard.gherkin.jbehave.helper.ResourceProvider; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import java.io.IOException; import java.io.InputStream; import java.util.HashMap; import java.util.Map; import org.jbehave.core.model.Story; import org.junit.Before;
package com.epam.gepard.gherkin.jbehave; /*========================================================================== Copyright 2004-2015 EPAM Systems This file is part of Gepard. Gepard is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Gepard 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 Gepard. If not, see <http://www.gnu.org/licenses/>. ===========================================================================*/ /** * Unit test for {@link JBehaveStoryReporter}. * @author Adam_Csaba_Kiraly */ public class JBehaveStoryReporterTest { private static final String AFTER_STORIES_PATH = "AfterStories"; private static final String BEFORE_STORIES_PATH = "BeforeStories"; @Mock private JBehaveTestCase jBehaveTestCase; @Mock
// Path: gepard-gherkin-jbehave/src/main/java/com/epam/gepard/gherkin/jbehave/helper/IOUtils.java // public class IOUtils { // // /** // * Get the contents of an InputStream as a String using the default character encoding of the platform. // * This method buffers the input internally, so there is no need to use a BufferedInputStream. // * @param inputStream the InputStream to read from // * @return the contents of the inputStream // * @throws IOException - if an I/O error occurs // */ // public String toString(final InputStream inputStream) throws IOException { // return org.apache.commons.io.IOUtils.toString(inputStream); // } // } // // Path: gepard-gherkin-jbehave/src/main/java/com/epam/gepard/gherkin/jbehave/helper/ResourceProvider.java // public class ResourceProvider { // // /** // * Returns the resource with the given path from the classpath. // * @param path the given path of the resource // * @return an {@link InputStream} of the resource, or null if not found // */ // public InputStream getResourceAsStream(final String path) { // return getClass().getClassLoader().getResourceAsStream(path); // } // // } // Path: gepard-gherkin-jbehave/src/test/java/com/epam/gepard/gherkin/jbehave/JBehaveStoryReporterTest.java import org.junit.Test; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; import org.mockito.internal.util.reflection.Whitebox; import com.epam.gepard.gherkin.jbehave.helper.IOUtils; import com.epam.gepard.gherkin.jbehave.helper.ResourceProvider; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import java.io.IOException; import java.io.InputStream; import java.util.HashMap; import java.util.Map; import org.jbehave.core.model.Story; import org.junit.Before; package com.epam.gepard.gherkin.jbehave; /*========================================================================== Copyright 2004-2015 EPAM Systems This file is part of Gepard. Gepard is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Gepard 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 Gepard. If not, see <http://www.gnu.org/licenses/>. ===========================================================================*/ /** * Unit test for {@link JBehaveStoryReporter}. * @author Adam_Csaba_Kiraly */ public class JBehaveStoryReporterTest { private static final String AFTER_STORIES_PATH = "AfterStories"; private static final String BEFORE_STORIES_PATH = "BeforeStories"; @Mock private JBehaveTestCase jBehaveTestCase; @Mock
private IOUtils ioUtils;
epam/Gepard
gepard-gherkin-jbehave/src/test/java/com/epam/gepard/gherkin/jbehave/JBehaveStoryReporterTest.java
// Path: gepard-gherkin-jbehave/src/main/java/com/epam/gepard/gherkin/jbehave/helper/IOUtils.java // public class IOUtils { // // /** // * Get the contents of an InputStream as a String using the default character encoding of the platform. // * This method buffers the input internally, so there is no need to use a BufferedInputStream. // * @param inputStream the InputStream to read from // * @return the contents of the inputStream // * @throws IOException - if an I/O error occurs // */ // public String toString(final InputStream inputStream) throws IOException { // return org.apache.commons.io.IOUtils.toString(inputStream); // } // } // // Path: gepard-gherkin-jbehave/src/main/java/com/epam/gepard/gherkin/jbehave/helper/ResourceProvider.java // public class ResourceProvider { // // /** // * Returns the resource with the given path from the classpath. // * @param path the given path of the resource // * @return an {@link InputStream} of the resource, or null if not found // */ // public InputStream getResourceAsStream(final String path) { // return getClass().getClassLoader().getResourceAsStream(path); // } // // }
import org.junit.Test; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; import org.mockito.internal.util.reflection.Whitebox; import com.epam.gepard.gherkin.jbehave.helper.IOUtils; import com.epam.gepard.gherkin.jbehave.helper.ResourceProvider; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import java.io.IOException; import java.io.InputStream; import java.util.HashMap; import java.util.Map; import org.jbehave.core.model.Story; import org.junit.Before;
package com.epam.gepard.gherkin.jbehave; /*========================================================================== Copyright 2004-2015 EPAM Systems This file is part of Gepard. Gepard is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Gepard 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 Gepard. If not, see <http://www.gnu.org/licenses/>. ===========================================================================*/ /** * Unit test for {@link JBehaveStoryReporter}. * @author Adam_Csaba_Kiraly */ public class JBehaveStoryReporterTest { private static final String AFTER_STORIES_PATH = "AfterStories"; private static final String BEFORE_STORIES_PATH = "BeforeStories"; @Mock private JBehaveTestCase jBehaveTestCase; @Mock private IOUtils ioUtils; @Mock
// Path: gepard-gherkin-jbehave/src/main/java/com/epam/gepard/gherkin/jbehave/helper/IOUtils.java // public class IOUtils { // // /** // * Get the contents of an InputStream as a String using the default character encoding of the platform. // * This method buffers the input internally, so there is no need to use a BufferedInputStream. // * @param inputStream the InputStream to read from // * @return the contents of the inputStream // * @throws IOException - if an I/O error occurs // */ // public String toString(final InputStream inputStream) throws IOException { // return org.apache.commons.io.IOUtils.toString(inputStream); // } // } // // Path: gepard-gherkin-jbehave/src/main/java/com/epam/gepard/gherkin/jbehave/helper/ResourceProvider.java // public class ResourceProvider { // // /** // * Returns the resource with the given path from the classpath. // * @param path the given path of the resource // * @return an {@link InputStream} of the resource, or null if not found // */ // public InputStream getResourceAsStream(final String path) { // return getClass().getClassLoader().getResourceAsStream(path); // } // // } // Path: gepard-gherkin-jbehave/src/test/java/com/epam/gepard/gherkin/jbehave/JBehaveStoryReporterTest.java import org.junit.Test; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; import org.mockito.internal.util.reflection.Whitebox; import com.epam.gepard.gherkin.jbehave.helper.IOUtils; import com.epam.gepard.gherkin.jbehave.helper.ResourceProvider; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import java.io.IOException; import java.io.InputStream; import java.util.HashMap; import java.util.Map; import org.jbehave.core.model.Story; import org.junit.Before; package com.epam.gepard.gherkin.jbehave; /*========================================================================== Copyright 2004-2015 EPAM Systems This file is part of Gepard. Gepard is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Gepard 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 Gepard. If not, see <http://www.gnu.org/licenses/>. ===========================================================================*/ /** * Unit test for {@link JBehaveStoryReporter}. * @author Adam_Csaba_Kiraly */ public class JBehaveStoryReporterTest { private static final String AFTER_STORIES_PATH = "AfterStories"; private static final String BEFORE_STORIES_PATH = "BeforeStories"; @Mock private JBehaveTestCase jBehaveTestCase; @Mock private IOUtils ioUtils; @Mock
private ResourceProvider resourceProvider;
epam/Gepard
gepard-gherkin-jbehave/src/main/java/com/epam/gepard/gherkin/jbehave/JBehaveStoryReporter.java
// Path: gepard-gherkin-jbehave/src/main/java/com/epam/gepard/gherkin/jbehave/helper/IOUtils.java // public class IOUtils { // // /** // * Get the contents of an InputStream as a String using the default character encoding of the platform. // * This method buffers the input internally, so there is no need to use a BufferedInputStream. // * @param inputStream the InputStream to read from // * @return the contents of the inputStream // * @throws IOException - if an I/O error occurs // */ // public String toString(final InputStream inputStream) throws IOException { // return org.apache.commons.io.IOUtils.toString(inputStream); // } // } // // Path: gepard-gherkin-jbehave/src/main/java/com/epam/gepard/gherkin/jbehave/helper/ResourceProvider.java // public class ResourceProvider { // // /** // * Returns the resource with the given path from the classpath. // * @param path the given path of the resource // * @return an {@link InputStream} of the resource, or null if not found // */ // public InputStream getResourceAsStream(final String path) { // return getClass().getClassLoader().getResourceAsStream(path); // } // // }
import com.epam.gepard.gherkin.jbehave.helper.ResourceProvider; import com.epam.gepard.util.Util; import java.io.IOException; import java.io.InputStream; import java.util.Map; import com.epam.gepard.logger.HtmlRunReporter; import org.jbehave.core.model.Story; import org.jbehave.core.reporters.NullStoryReporter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.epam.gepard.gherkin.jbehave.helper.IOUtils;
package com.epam.gepard.gherkin.jbehave; /*========================================================================== Copyright 2004-2015 EPAM Systems This file is part of Gepard. Gepard is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Gepard 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 Gepard. If not, see <http://www.gnu.org/licenses/>. ===========================================================================*/ /** * Used for logging the events of the test case. * @author Adam_Csaba_Kiraly */ public class JBehaveStoryReporter extends NullStoryReporter { private static final String COULD_NOT_READ_FILE = "Could not read file: "; private static final String FILE_NOT_FOUND = "File not found: "; private static final String AFTER_STORIES_PATH = "AfterStories"; private static final String BEFORE_STORIES_PATH = "BeforeStories"; private static final Logger LOGGER = LoggerFactory.getLogger(JBehaveStoryReporter.class); private final JBehaveTestCase jBehaveTestCase; private final Util util = new Util();
// Path: gepard-gherkin-jbehave/src/main/java/com/epam/gepard/gherkin/jbehave/helper/IOUtils.java // public class IOUtils { // // /** // * Get the contents of an InputStream as a String using the default character encoding of the platform. // * This method buffers the input internally, so there is no need to use a BufferedInputStream. // * @param inputStream the InputStream to read from // * @return the contents of the inputStream // * @throws IOException - if an I/O error occurs // */ // public String toString(final InputStream inputStream) throws IOException { // return org.apache.commons.io.IOUtils.toString(inputStream); // } // } // // Path: gepard-gherkin-jbehave/src/main/java/com/epam/gepard/gherkin/jbehave/helper/ResourceProvider.java // public class ResourceProvider { // // /** // * Returns the resource with the given path from the classpath. // * @param path the given path of the resource // * @return an {@link InputStream} of the resource, or null if not found // */ // public InputStream getResourceAsStream(final String path) { // return getClass().getClassLoader().getResourceAsStream(path); // } // // } // Path: gepard-gherkin-jbehave/src/main/java/com/epam/gepard/gherkin/jbehave/JBehaveStoryReporter.java import com.epam.gepard.gherkin.jbehave.helper.ResourceProvider; import com.epam.gepard.util.Util; import java.io.IOException; import java.io.InputStream; import java.util.Map; import com.epam.gepard.logger.HtmlRunReporter; import org.jbehave.core.model.Story; import org.jbehave.core.reporters.NullStoryReporter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.epam.gepard.gherkin.jbehave.helper.IOUtils; package com.epam.gepard.gherkin.jbehave; /*========================================================================== Copyright 2004-2015 EPAM Systems This file is part of Gepard. Gepard is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Gepard 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 Gepard. If not, see <http://www.gnu.org/licenses/>. ===========================================================================*/ /** * Used for logging the events of the test case. * @author Adam_Csaba_Kiraly */ public class JBehaveStoryReporter extends NullStoryReporter { private static final String COULD_NOT_READ_FILE = "Could not read file: "; private static final String FILE_NOT_FOUND = "File not found: "; private static final String AFTER_STORIES_PATH = "AfterStories"; private static final String BEFORE_STORIES_PATH = "BeforeStories"; private static final Logger LOGGER = LoggerFactory.getLogger(JBehaveStoryReporter.class); private final JBehaveTestCase jBehaveTestCase; private final Util util = new Util();
private final IOUtils ioUtils = new IOUtils();
epam/Gepard
gepard-gherkin-jbehave/src/main/java/com/epam/gepard/gherkin/jbehave/JBehaveStoryReporter.java
// Path: gepard-gherkin-jbehave/src/main/java/com/epam/gepard/gherkin/jbehave/helper/IOUtils.java // public class IOUtils { // // /** // * Get the contents of an InputStream as a String using the default character encoding of the platform. // * This method buffers the input internally, so there is no need to use a BufferedInputStream. // * @param inputStream the InputStream to read from // * @return the contents of the inputStream // * @throws IOException - if an I/O error occurs // */ // public String toString(final InputStream inputStream) throws IOException { // return org.apache.commons.io.IOUtils.toString(inputStream); // } // } // // Path: gepard-gherkin-jbehave/src/main/java/com/epam/gepard/gherkin/jbehave/helper/ResourceProvider.java // public class ResourceProvider { // // /** // * Returns the resource with the given path from the classpath. // * @param path the given path of the resource // * @return an {@link InputStream} of the resource, or null if not found // */ // public InputStream getResourceAsStream(final String path) { // return getClass().getClassLoader().getResourceAsStream(path); // } // // }
import com.epam.gepard.gherkin.jbehave.helper.ResourceProvider; import com.epam.gepard.util.Util; import java.io.IOException; import java.io.InputStream; import java.util.Map; import com.epam.gepard.logger.HtmlRunReporter; import org.jbehave.core.model.Story; import org.jbehave.core.reporters.NullStoryReporter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.epam.gepard.gherkin.jbehave.helper.IOUtils;
package com.epam.gepard.gherkin.jbehave; /*========================================================================== Copyright 2004-2015 EPAM Systems This file is part of Gepard. Gepard is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Gepard 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 Gepard. If not, see <http://www.gnu.org/licenses/>. ===========================================================================*/ /** * Used for logging the events of the test case. * @author Adam_Csaba_Kiraly */ public class JBehaveStoryReporter extends NullStoryReporter { private static final String COULD_NOT_READ_FILE = "Could not read file: "; private static final String FILE_NOT_FOUND = "File not found: "; private static final String AFTER_STORIES_PATH = "AfterStories"; private static final String BEFORE_STORIES_PATH = "BeforeStories"; private static final Logger LOGGER = LoggerFactory.getLogger(JBehaveStoryReporter.class); private final JBehaveTestCase jBehaveTestCase; private final Util util = new Util(); private final IOUtils ioUtils = new IOUtils();
// Path: gepard-gherkin-jbehave/src/main/java/com/epam/gepard/gherkin/jbehave/helper/IOUtils.java // public class IOUtils { // // /** // * Get the contents of an InputStream as a String using the default character encoding of the platform. // * This method buffers the input internally, so there is no need to use a BufferedInputStream. // * @param inputStream the InputStream to read from // * @return the contents of the inputStream // * @throws IOException - if an I/O error occurs // */ // public String toString(final InputStream inputStream) throws IOException { // return org.apache.commons.io.IOUtils.toString(inputStream); // } // } // // Path: gepard-gherkin-jbehave/src/main/java/com/epam/gepard/gherkin/jbehave/helper/ResourceProvider.java // public class ResourceProvider { // // /** // * Returns the resource with the given path from the classpath. // * @param path the given path of the resource // * @return an {@link InputStream} of the resource, or null if not found // */ // public InputStream getResourceAsStream(final String path) { // return getClass().getClassLoader().getResourceAsStream(path); // } // // } // Path: gepard-gherkin-jbehave/src/main/java/com/epam/gepard/gherkin/jbehave/JBehaveStoryReporter.java import com.epam.gepard.gherkin.jbehave.helper.ResourceProvider; import com.epam.gepard.util.Util; import java.io.IOException; import java.io.InputStream; import java.util.Map; import com.epam.gepard.logger.HtmlRunReporter; import org.jbehave.core.model.Story; import org.jbehave.core.reporters.NullStoryReporter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.epam.gepard.gherkin.jbehave.helper.IOUtils; package com.epam.gepard.gherkin.jbehave; /*========================================================================== Copyright 2004-2015 EPAM Systems This file is part of Gepard. Gepard is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Gepard 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 Gepard. If not, see <http://www.gnu.org/licenses/>. ===========================================================================*/ /** * Used for logging the events of the test case. * @author Adam_Csaba_Kiraly */ public class JBehaveStoryReporter extends NullStoryReporter { private static final String COULD_NOT_READ_FILE = "Could not read file: "; private static final String FILE_NOT_FOUND = "File not found: "; private static final String AFTER_STORIES_PATH = "AfterStories"; private static final String BEFORE_STORIES_PATH = "BeforeStories"; private static final Logger LOGGER = LoggerFactory.getLogger(JBehaveStoryReporter.class); private final JBehaveTestCase jBehaveTestCase; private final Util util = new Util(); private final IOUtils ioUtils = new IOUtils();
private final ResourceProvider resourceProvider = new ResourceProvider();
epam/Gepard
gepard-gherkin-jbehave/src/test/java/com/epam/gepard/gherkin/jbehave/GepardEmbedderTest.java
// Path: gepard-gherkin-jbehave/src/main/java/com/epam/gepard/gherkin/jbehave/helper/InstanceStepsFactoryCreator.java // public class InstanceStepsFactoryCreator { // // /** // * Creates an {@link InstanceStepsFactory} with the given {@link Configuration} for the given {@link com.epam.gepard.gherkin.jbehave.JBehaveTestCase}. // * @param configuration the configuration to use // * @param testCase the test case which will be used in the step creation process // * @return a new instance of {@link InstanceStepsFactory} // */ // public InstanceStepsFactory createForTestCase(final Configuration configuration, final JBehaveTestCase testCase) { // return new InstanceStepsFactory(configuration, testCase); // } // // }
import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; import com.epam.gepard.gherkin.jbehave.helper.InstanceStepsFactoryCreator; import static java.util.Arrays.asList; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.verify; import org.jbehave.core.configuration.Configuration; import org.jbehave.core.embedder.Embedder; import org.jbehave.core.embedder.EmbedderControls; import org.jbehave.core.embedder.NullEmbedderMonitor; import org.junit.Before; import org.junit.Test; import org.mockito.InjectMocks;
package com.epam.gepard.gherkin.jbehave; /*========================================================================== Copyright 2004-2015 EPAM Systems This file is part of Gepard. Gepard is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Gepard 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 Gepard. If not, see <http://www.gnu.org/licenses/>. ===========================================================================*/ /** * Unit test for {@link GepardEmbedder}. * @author Adam_Csaba_Kiraly * */ public class GepardEmbedderTest { @Mock private Embedder embedder; @Mock private ConfigurationFactory configurationFactory; @InjectMocks private GepardEmbedder underTest; @Mock private EmbedderControls embedderControls; @Mock private JBehaveTestCase testCase; @Mock
// Path: gepard-gherkin-jbehave/src/main/java/com/epam/gepard/gherkin/jbehave/helper/InstanceStepsFactoryCreator.java // public class InstanceStepsFactoryCreator { // // /** // * Creates an {@link InstanceStepsFactory} with the given {@link Configuration} for the given {@link com.epam.gepard.gherkin.jbehave.JBehaveTestCase}. // * @param configuration the configuration to use // * @param testCase the test case which will be used in the step creation process // * @return a new instance of {@link InstanceStepsFactory} // */ // public InstanceStepsFactory createForTestCase(final Configuration configuration, final JBehaveTestCase testCase) { // return new InstanceStepsFactory(configuration, testCase); // } // // } // Path: gepard-gherkin-jbehave/src/test/java/com/epam/gepard/gherkin/jbehave/GepardEmbedderTest.java import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; import com.epam.gepard.gherkin.jbehave.helper.InstanceStepsFactoryCreator; import static java.util.Arrays.asList; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.verify; import org.jbehave.core.configuration.Configuration; import org.jbehave.core.embedder.Embedder; import org.jbehave.core.embedder.EmbedderControls; import org.jbehave.core.embedder.NullEmbedderMonitor; import org.junit.Before; import org.junit.Test; import org.mockito.InjectMocks; package com.epam.gepard.gherkin.jbehave; /*========================================================================== Copyright 2004-2015 EPAM Systems This file is part of Gepard. Gepard is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Gepard 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 Gepard. If not, see <http://www.gnu.org/licenses/>. ===========================================================================*/ /** * Unit test for {@link GepardEmbedder}. * @author Adam_Csaba_Kiraly * */ public class GepardEmbedderTest { @Mock private Embedder embedder; @Mock private ConfigurationFactory configurationFactory; @InjectMocks private GepardEmbedder underTest; @Mock private EmbedderControls embedderControls; @Mock private JBehaveTestCase testCase; @Mock
private InstanceStepsFactoryCreator instanceStepsFactoryCreator;
alwaysallthetime/ADNLib
ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/AppDotNetClientTask.java
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/request/AppDotNetRequest.java // public abstract class AppDotNetRequest { // public static final String CONTENT_TYPE_FORM = "application/x-www-form-urlencoded"; // public static final String CONTENT_TYPE_JSON = "application/json"; // // protected static final String HEADER_CONTENT_TYPE = "Content-Type"; // protected static final Gson gson = AppDotNetGson.getInstance(); // // private static final String TAG = "AppDotNetRequest"; // // protected URL url; // protected AppDotNetResponseHandler handler; // protected boolean authenticated; // protected String method; // protected boolean hasBody = false; // if true, writeBody will be called // // private String fixedLengthBody; // may be unused even if hasBody is true, e.g. image upload // // protected AppDotNetRequest(AppDotNetResponseHandler handler, boolean authenticated, String requestMethod, QueryParameters queryParameters, // Uri baseUri, String... pathComponents) { // this.handler = handler; // this.authenticated = authenticated; // method = requestMethod; // url = buildUrl(baseUri, queryParameters, pathComponents); // } // // public URL getUrl() { // return url; // } // // public AppDotNetResponseHandler getHandler() { // return handler; // } // // public boolean isAuthenticated() { // return authenticated; // } // // public String getMethod() { // return method; // } // // public boolean hasBody() { // return hasBody; // } // // protected URL buildUrl(Uri baseUri, QueryParameters queryParameters, String... pathComponents) { // final Uri.Builder builder = baseUri.buildUpon(); // // // concatenate path components together // for (String pathComponent : pathComponents) { // builder.appendEncodedPath(pathComponent); // } // // if (queryParameters != null) { // // add all specified parameters to query string // for (Map.Entry<String, String> entry : queryParameters.entrySet()) { // builder.appendQueryParameter(entry.getKey(), entry.getValue()); // } // } // // try { // return new URL(builder.toString()); // } catch (MalformedURLException e) { // Log.e(TAG, "Failed to construct URL", e); // handler.onError(e); // return null; // } // } // // protected void setBody(String body) { // fixedLengthBody = body; // hasBody = true; // } // // public abstract void writeBody(HttpURLConnection connection) throws IOException; // // protected void writeFixedLengthBody(HttpURLConnection connection) throws IOException { // final byte[] bodyBytes = fixedLengthBody.getBytes("UTF-8"); // connection.setFixedLengthStreamingMode(bodyBytes.length); // // final OutputStream outputStream = connection.getOutputStream(); // outputStream.write(bodyBytes); // outputStream.close(); // } // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/AppDotNetResponseHandler.java // public abstract class AppDotNetResponseHandler<T extends IAppDotNetObject> { // private static final String TAG = "AppDotNetResponseHandler"; // // private final Gson gson; // private final Type responseType; // // // subclasses must call this constructor and initialize responseType since there is no default constructor // protected AppDotNetResponseHandler(TypeToken typeToken) { // gson = AppDotNetGson.getInstance(); // responseType = typeToken.getType(); // } // // protected <T> T parseResponse(Reader reader) { // return gson.fromJson(reader, responseType); // } // // public abstract void handleResponse(Reader reader); // // public abstract void onSuccess(T responseData); // // public void onError(Exception error) { // Log.e(TAG, error.getMessage(), error); // } // }
import android.content.Context; import android.content.Intent; import android.os.AsyncTask; import android.util.Log; import com.alwaysallthetime.adnlib.request.AppDotNetRequest; import com.alwaysallthetime.adnlib.response.AppDotNetResponseHandler; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.net.HttpURLConnection; import java.net.URL; import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.SSLSocketFactory;
package com.alwaysallthetime.adnlib; class AppDotNetClientTask extends AsyncTask<AppDotNetRequest, Void, Integer> { private static final String TAG = "AppDotNetClientTask"; private final String authorizationHeader; private final String languageHeader; private final SSLSocketFactory sslSocketFactory; private final Context context; public AppDotNetClientTask(Context context, String authorizationHeader, String languageHeader, SSLSocketFactory sslSocketFactory) { this.context = context; this.authorizationHeader = authorizationHeader; this.languageHeader = languageHeader; this.sslSocketFactory = sslSocketFactory; } public AppDotNetClientTask(Context context, String authorizationHeader, SSLSocketFactory sslSocketFactory) { this(context, authorizationHeader, null, sslSocketFactory); } public AppDotNetClientTask(Context context, String authorizationHeader) { this(context, authorizationHeader, null); } @Override protected Integer doInBackground(AppDotNetRequest... requests) { //the number of requests is always 1 AppDotNetRequest request = requests[0];
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/request/AppDotNetRequest.java // public abstract class AppDotNetRequest { // public static final String CONTENT_TYPE_FORM = "application/x-www-form-urlencoded"; // public static final String CONTENT_TYPE_JSON = "application/json"; // // protected static final String HEADER_CONTENT_TYPE = "Content-Type"; // protected static final Gson gson = AppDotNetGson.getInstance(); // // private static final String TAG = "AppDotNetRequest"; // // protected URL url; // protected AppDotNetResponseHandler handler; // protected boolean authenticated; // protected String method; // protected boolean hasBody = false; // if true, writeBody will be called // // private String fixedLengthBody; // may be unused even if hasBody is true, e.g. image upload // // protected AppDotNetRequest(AppDotNetResponseHandler handler, boolean authenticated, String requestMethod, QueryParameters queryParameters, // Uri baseUri, String... pathComponents) { // this.handler = handler; // this.authenticated = authenticated; // method = requestMethod; // url = buildUrl(baseUri, queryParameters, pathComponents); // } // // public URL getUrl() { // return url; // } // // public AppDotNetResponseHandler getHandler() { // return handler; // } // // public boolean isAuthenticated() { // return authenticated; // } // // public String getMethod() { // return method; // } // // public boolean hasBody() { // return hasBody; // } // // protected URL buildUrl(Uri baseUri, QueryParameters queryParameters, String... pathComponents) { // final Uri.Builder builder = baseUri.buildUpon(); // // // concatenate path components together // for (String pathComponent : pathComponents) { // builder.appendEncodedPath(pathComponent); // } // // if (queryParameters != null) { // // add all specified parameters to query string // for (Map.Entry<String, String> entry : queryParameters.entrySet()) { // builder.appendQueryParameter(entry.getKey(), entry.getValue()); // } // } // // try { // return new URL(builder.toString()); // } catch (MalformedURLException e) { // Log.e(TAG, "Failed to construct URL", e); // handler.onError(e); // return null; // } // } // // protected void setBody(String body) { // fixedLengthBody = body; // hasBody = true; // } // // public abstract void writeBody(HttpURLConnection connection) throws IOException; // // protected void writeFixedLengthBody(HttpURLConnection connection) throws IOException { // final byte[] bodyBytes = fixedLengthBody.getBytes("UTF-8"); // connection.setFixedLengthStreamingMode(bodyBytes.length); // // final OutputStream outputStream = connection.getOutputStream(); // outputStream.write(bodyBytes); // outputStream.close(); // } // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/AppDotNetResponseHandler.java // public abstract class AppDotNetResponseHandler<T extends IAppDotNetObject> { // private static final String TAG = "AppDotNetResponseHandler"; // // private final Gson gson; // private final Type responseType; // // // subclasses must call this constructor and initialize responseType since there is no default constructor // protected AppDotNetResponseHandler(TypeToken typeToken) { // gson = AppDotNetGson.getInstance(); // responseType = typeToken.getType(); // } // // protected <T> T parseResponse(Reader reader) { // return gson.fromJson(reader, responseType); // } // // public abstract void handleResponse(Reader reader); // // public abstract void onSuccess(T responseData); // // public void onError(Exception error) { // Log.e(TAG, error.getMessage(), error); // } // } // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/AppDotNetClientTask.java import android.content.Context; import android.content.Intent; import android.os.AsyncTask; import android.util.Log; import com.alwaysallthetime.adnlib.request.AppDotNetRequest; import com.alwaysallthetime.adnlib.response.AppDotNetResponseHandler; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.net.HttpURLConnection; import java.net.URL; import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.SSLSocketFactory; package com.alwaysallthetime.adnlib; class AppDotNetClientTask extends AsyncTask<AppDotNetRequest, Void, Integer> { private static final String TAG = "AppDotNetClientTask"; private final String authorizationHeader; private final String languageHeader; private final SSLSocketFactory sslSocketFactory; private final Context context; public AppDotNetClientTask(Context context, String authorizationHeader, String languageHeader, SSLSocketFactory sslSocketFactory) { this.context = context; this.authorizationHeader = authorizationHeader; this.languageHeader = languageHeader; this.sslSocketFactory = sslSocketFactory; } public AppDotNetClientTask(Context context, String authorizationHeader, SSLSocketFactory sslSocketFactory) { this(context, authorizationHeader, null, sslSocketFactory); } public AppDotNetClientTask(Context context, String authorizationHeader) { this(context, authorizationHeader, null); } @Override protected Integer doInBackground(AppDotNetRequest... requests) { //the number of requests is always 1 AppDotNetRequest request = requests[0];
final AppDotNetResponseHandler handler = request.getHandler();
alwaysallthetime/ADNLib
ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/User.java
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/gson/AppDotNetGson.java // public class AppDotNetGson { // static Gson adapterSafeInstance; // // private static Gson instance; // private static Gson persistenceInstance; // // static { // final GsonBuilder builder = new GsonBuilder() // .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES) // .registerTypeAdapter(Date.class, new Iso8601DateTypeAdapter()); // // persistenceInstance = builder.create(); // // adapterSafeInstance = builder // .addSerializationExclusionStrategy(new IncludeFieldsByDefaultSerializationExclusionStrategy()) // .create(); // // instance = builder // .registerTypeHierarchyAdapter(Annotatable.class, new AnnotatableSerializer()) // .registerTypeAdapter(Count.class, new CountDeserializer()) // .create(); // } // // /** // * A Gson instance for serializing to and deserializing from the App.net API. // * // * Fields that shouldn't be sent to the API are excluded from serialization, e.g. createdAt. // * // * @return a Gson instance // */ // public static Gson getInstance() { // return instance; // } // // /** // * A Gson instance suitable for disk persistence, in that it will serialize and deserialize all fields. // * // * @return a Gson instance // */ // public static Gson getPersistenceInstance() { // return persistenceInstance; // } // // /** // * A Gson instance without certain customer adapters. This allows those adapters to get the "default" serialization // * before modifying it. // * // * @return a Gson instance // */ // static Gson getAdapterSafeInstance() { // return adapterSafeInstance; // } // // private static <T extends IAppDotNetObject> T copy(IAppDotNetObject object, Gson gson) { // final JsonElement json = gson.toJsonTree(object); // return (T) gson.fromJson(json, object.getClass()); // } // // public static <T extends IAppDotNetObject> T copy(IAppDotNetObject object) { // return copy(object, persistenceInstance); // } // // public static <T extends IAppDotNetObject> T copyForWriting(IAppDotNetObject object) { // return copy(object, instance); // } // }
import com.alwaysallthetime.adnlib.gson.AppDotNetGson; import com.google.gson.annotations.Expose; import java.util.Date;
@Expose(serialize = false) private Image coverImage; @Expose(serialize = false) private String type; @Expose(serialize = false) private Date createdAt; @Expose(serialize = false) private Counts counts; @Expose(serialize = false) private boolean followsYou; @Expose(serialize = false) private boolean youBlocked; @Expose(serialize = false) private boolean youFollow; @Expose(serialize = false) private boolean youMuted; @Expose(serialize = false) private boolean youCanSubscribe; @Expose(serialize = false) private boolean youCanFollow; @Expose(serialize = false) private String verifiedDomain; @Expose(serialize = false) private String canonicalUrl; public User() { description = new Description(); } public User copyForWriting() {
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/gson/AppDotNetGson.java // public class AppDotNetGson { // static Gson adapterSafeInstance; // // private static Gson instance; // private static Gson persistenceInstance; // // static { // final GsonBuilder builder = new GsonBuilder() // .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES) // .registerTypeAdapter(Date.class, new Iso8601DateTypeAdapter()); // // persistenceInstance = builder.create(); // // adapterSafeInstance = builder // .addSerializationExclusionStrategy(new IncludeFieldsByDefaultSerializationExclusionStrategy()) // .create(); // // instance = builder // .registerTypeHierarchyAdapter(Annotatable.class, new AnnotatableSerializer()) // .registerTypeAdapter(Count.class, new CountDeserializer()) // .create(); // } // // /** // * A Gson instance for serializing to and deserializing from the App.net API. // * // * Fields that shouldn't be sent to the API are excluded from serialization, e.g. createdAt. // * // * @return a Gson instance // */ // public static Gson getInstance() { // return instance; // } // // /** // * A Gson instance suitable for disk persistence, in that it will serialize and deserialize all fields. // * // * @return a Gson instance // */ // public static Gson getPersistenceInstance() { // return persistenceInstance; // } // // /** // * A Gson instance without certain customer adapters. This allows those adapters to get the "default" serialization // * before modifying it. // * // * @return a Gson instance // */ // static Gson getAdapterSafeInstance() { // return adapterSafeInstance; // } // // private static <T extends IAppDotNetObject> T copy(IAppDotNetObject object, Gson gson) { // final JsonElement json = gson.toJsonTree(object); // return (T) gson.fromJson(json, object.getClass()); // } // // public static <T extends IAppDotNetObject> T copy(IAppDotNetObject object) { // return copy(object, persistenceInstance); // } // // public static <T extends IAppDotNetObject> T copyForWriting(IAppDotNetObject object) { // return copy(object, instance); // } // } // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/User.java import com.alwaysallthetime.adnlib.gson.AppDotNetGson; import com.google.gson.annotations.Expose; import java.util.Date; @Expose(serialize = false) private Image coverImage; @Expose(serialize = false) private String type; @Expose(serialize = false) private Date createdAt; @Expose(serialize = false) private Counts counts; @Expose(serialize = false) private boolean followsYou; @Expose(serialize = false) private boolean youBlocked; @Expose(serialize = false) private boolean youFollow; @Expose(serialize = false) private boolean youMuted; @Expose(serialize = false) private boolean youCanSubscribe; @Expose(serialize = false) private boolean youCanFollow; @Expose(serialize = false) private String verifiedDomain; @Expose(serialize = false) private String canonicalUrl; public User() { description = new Description(); } public User copyForWriting() {
final User copy = AppDotNetGson.copyForWriting(this);
alwaysallthetime/ADNLib
ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/gson/AppDotNetGson.java
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/AbstractPost.java // public class AbstractPost extends Annotatable { // @Expose(serialize = false) // private User user; // @Expose(serialize = false) // private Date createdAt; // private String text; // @Expose(serialize = false) // private String html; // @Expose(serialize = false) // private App source; // private String replyTo; // @Expose(serialize = false) // private String threadId; // @Expose(serialize = false) // private int numReplies; // private Entities entities; // @Expose(serialize = false) // private boolean isDeleted; // private boolean machineOnly; // // public AbstractPost() {} // // public AbstractPost(String text) { // this.text = text; // this.machineOnly = false; // } // // public AbstractPost(boolean machineOnly) { // this.machineOnly = machineOnly; // } // // public User getUser() { // return user; // } // // public Date getCreatedAt() { // return createdAt; // } // // public String getText() { // return text; // } // // public void setText(String text) { // this.text = text; // } // // public String getHtml() { // return html; // } // // public App getSource() { // return source; // } // // public String getReplyTo() { // return replyTo; // } // // public void setReplyTo(String replyTo) { // this.replyTo = replyTo; // } // // public String getThreadId() { // return threadId; // } // // public int getNumReplies() { // return numReplies; // } // // public Entities getEntities() { // return entities; // } // // public void setEntities(Entities entities) { // this.entities = entities; // } // // public boolean isDeleted() { // return isDeleted; // } // // public boolean isMachineOnly() { // return machineOnly; // } // // public void setMachineOnly(boolean machineOnly) { // this.machineOnly = machineOnly; // } // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/Annotatable.java // public abstract class Annotatable implements IPageableAppDotNetIdObject { // @Expose(serialize = false) // protected String id; // @Expose(serialize = false) // protected String paginationId; // protected ArrayList<Annotation> annotations; // // public String getId() { // return id; // } // // @Override // public String getPaginationId() { // return paginationId; // } // // public boolean hasAnnotations() { // return annotations != null && annotations.size() > 0; // } // // public ArrayList<Annotation> getAnnotations() { // return annotations; // } // // public void setAnnotations(ArrayList<Annotation> annotations) { // this.annotations = annotations; // } // // public boolean addAnnotation(Annotation annotation) { // if (annotations == null) // annotations = new ArrayList<Annotation>(); // // return annotations.add(annotation); // } // // public Annotation removeAnnotation(int index) { // if (annotations == null) // return null; // // return annotations.remove(index); // } // // public void clearAnnotations() { // annotations = null; // } // // public Annotation getFirstAnnotationOfType(String annotationType) { // if(annotations != null) { // for(Annotation a : annotations) { // if(a.getType().equals(annotationType)) { // return a; // } // } // } // return null; // } // // public List<Annotation> getAnnotationsOfType(String annotationType) { // ArrayList<Annotation> typedAnnotations = new ArrayList<Annotation>(); // if(annotations != null) { // for(Annotation a : annotations) { // if(a.getType().equals(annotationType)) { // typedAnnotations.add(a); // } // } // } // return typedAnnotations; // } // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/Count.java // public class Count implements IAppDotNetObject { // private int value; // // public Count(int value) { // this.value = value; // } // // public int getValue() { // return value; // } // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/IAppDotNetObject.java // public interface IAppDotNetObject {}
import com.alwaysallthetime.adnlib.data.AbstractPost; import com.alwaysallthetime.adnlib.data.Annotatable; import com.alwaysallthetime.adnlib.data.Count; import com.alwaysallthetime.adnlib.data.IAppDotNetObject; import com.google.gson.FieldNamingPolicy; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonElement; import java.util.Date;
package com.alwaysallthetime.adnlib.gson; public class AppDotNetGson { static Gson adapterSafeInstance; private static Gson instance; private static Gson persistenceInstance; static { final GsonBuilder builder = new GsonBuilder() .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES) .registerTypeAdapter(Date.class, new Iso8601DateTypeAdapter()); persistenceInstance = builder.create(); adapterSafeInstance = builder .addSerializationExclusionStrategy(new IncludeFieldsByDefaultSerializationExclusionStrategy()) .create(); instance = builder
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/AbstractPost.java // public class AbstractPost extends Annotatable { // @Expose(serialize = false) // private User user; // @Expose(serialize = false) // private Date createdAt; // private String text; // @Expose(serialize = false) // private String html; // @Expose(serialize = false) // private App source; // private String replyTo; // @Expose(serialize = false) // private String threadId; // @Expose(serialize = false) // private int numReplies; // private Entities entities; // @Expose(serialize = false) // private boolean isDeleted; // private boolean machineOnly; // // public AbstractPost() {} // // public AbstractPost(String text) { // this.text = text; // this.machineOnly = false; // } // // public AbstractPost(boolean machineOnly) { // this.machineOnly = machineOnly; // } // // public User getUser() { // return user; // } // // public Date getCreatedAt() { // return createdAt; // } // // public String getText() { // return text; // } // // public void setText(String text) { // this.text = text; // } // // public String getHtml() { // return html; // } // // public App getSource() { // return source; // } // // public String getReplyTo() { // return replyTo; // } // // public void setReplyTo(String replyTo) { // this.replyTo = replyTo; // } // // public String getThreadId() { // return threadId; // } // // public int getNumReplies() { // return numReplies; // } // // public Entities getEntities() { // return entities; // } // // public void setEntities(Entities entities) { // this.entities = entities; // } // // public boolean isDeleted() { // return isDeleted; // } // // public boolean isMachineOnly() { // return machineOnly; // } // // public void setMachineOnly(boolean machineOnly) { // this.machineOnly = machineOnly; // } // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/Annotatable.java // public abstract class Annotatable implements IPageableAppDotNetIdObject { // @Expose(serialize = false) // protected String id; // @Expose(serialize = false) // protected String paginationId; // protected ArrayList<Annotation> annotations; // // public String getId() { // return id; // } // // @Override // public String getPaginationId() { // return paginationId; // } // // public boolean hasAnnotations() { // return annotations != null && annotations.size() > 0; // } // // public ArrayList<Annotation> getAnnotations() { // return annotations; // } // // public void setAnnotations(ArrayList<Annotation> annotations) { // this.annotations = annotations; // } // // public boolean addAnnotation(Annotation annotation) { // if (annotations == null) // annotations = new ArrayList<Annotation>(); // // return annotations.add(annotation); // } // // public Annotation removeAnnotation(int index) { // if (annotations == null) // return null; // // return annotations.remove(index); // } // // public void clearAnnotations() { // annotations = null; // } // // public Annotation getFirstAnnotationOfType(String annotationType) { // if(annotations != null) { // for(Annotation a : annotations) { // if(a.getType().equals(annotationType)) { // return a; // } // } // } // return null; // } // // public List<Annotation> getAnnotationsOfType(String annotationType) { // ArrayList<Annotation> typedAnnotations = new ArrayList<Annotation>(); // if(annotations != null) { // for(Annotation a : annotations) { // if(a.getType().equals(annotationType)) { // typedAnnotations.add(a); // } // } // } // return typedAnnotations; // } // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/Count.java // public class Count implements IAppDotNetObject { // private int value; // // public Count(int value) { // this.value = value; // } // // public int getValue() { // return value; // } // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/IAppDotNetObject.java // public interface IAppDotNetObject {} // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/gson/AppDotNetGson.java import com.alwaysallthetime.adnlib.data.AbstractPost; import com.alwaysallthetime.adnlib.data.Annotatable; import com.alwaysallthetime.adnlib.data.Count; import com.alwaysallthetime.adnlib.data.IAppDotNetObject; import com.google.gson.FieldNamingPolicy; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonElement; import java.util.Date; package com.alwaysallthetime.adnlib.gson; public class AppDotNetGson { static Gson adapterSafeInstance; private static Gson instance; private static Gson persistenceInstance; static { final GsonBuilder builder = new GsonBuilder() .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES) .registerTypeAdapter(Date.class, new Iso8601DateTypeAdapter()); persistenceInstance = builder.create(); adapterSafeInstance = builder .addSerializationExclusionStrategy(new IncludeFieldsByDefaultSerializationExclusionStrategy()) .create(); instance = builder
.registerTypeHierarchyAdapter(Annotatable.class, new AnnotatableSerializer())
alwaysallthetime/ADNLib
ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/gson/AppDotNetGson.java
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/AbstractPost.java // public class AbstractPost extends Annotatable { // @Expose(serialize = false) // private User user; // @Expose(serialize = false) // private Date createdAt; // private String text; // @Expose(serialize = false) // private String html; // @Expose(serialize = false) // private App source; // private String replyTo; // @Expose(serialize = false) // private String threadId; // @Expose(serialize = false) // private int numReplies; // private Entities entities; // @Expose(serialize = false) // private boolean isDeleted; // private boolean machineOnly; // // public AbstractPost() {} // // public AbstractPost(String text) { // this.text = text; // this.machineOnly = false; // } // // public AbstractPost(boolean machineOnly) { // this.machineOnly = machineOnly; // } // // public User getUser() { // return user; // } // // public Date getCreatedAt() { // return createdAt; // } // // public String getText() { // return text; // } // // public void setText(String text) { // this.text = text; // } // // public String getHtml() { // return html; // } // // public App getSource() { // return source; // } // // public String getReplyTo() { // return replyTo; // } // // public void setReplyTo(String replyTo) { // this.replyTo = replyTo; // } // // public String getThreadId() { // return threadId; // } // // public int getNumReplies() { // return numReplies; // } // // public Entities getEntities() { // return entities; // } // // public void setEntities(Entities entities) { // this.entities = entities; // } // // public boolean isDeleted() { // return isDeleted; // } // // public boolean isMachineOnly() { // return machineOnly; // } // // public void setMachineOnly(boolean machineOnly) { // this.machineOnly = machineOnly; // } // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/Annotatable.java // public abstract class Annotatable implements IPageableAppDotNetIdObject { // @Expose(serialize = false) // protected String id; // @Expose(serialize = false) // protected String paginationId; // protected ArrayList<Annotation> annotations; // // public String getId() { // return id; // } // // @Override // public String getPaginationId() { // return paginationId; // } // // public boolean hasAnnotations() { // return annotations != null && annotations.size() > 0; // } // // public ArrayList<Annotation> getAnnotations() { // return annotations; // } // // public void setAnnotations(ArrayList<Annotation> annotations) { // this.annotations = annotations; // } // // public boolean addAnnotation(Annotation annotation) { // if (annotations == null) // annotations = new ArrayList<Annotation>(); // // return annotations.add(annotation); // } // // public Annotation removeAnnotation(int index) { // if (annotations == null) // return null; // // return annotations.remove(index); // } // // public void clearAnnotations() { // annotations = null; // } // // public Annotation getFirstAnnotationOfType(String annotationType) { // if(annotations != null) { // for(Annotation a : annotations) { // if(a.getType().equals(annotationType)) { // return a; // } // } // } // return null; // } // // public List<Annotation> getAnnotationsOfType(String annotationType) { // ArrayList<Annotation> typedAnnotations = new ArrayList<Annotation>(); // if(annotations != null) { // for(Annotation a : annotations) { // if(a.getType().equals(annotationType)) { // typedAnnotations.add(a); // } // } // } // return typedAnnotations; // } // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/Count.java // public class Count implements IAppDotNetObject { // private int value; // // public Count(int value) { // this.value = value; // } // // public int getValue() { // return value; // } // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/IAppDotNetObject.java // public interface IAppDotNetObject {}
import com.alwaysallthetime.adnlib.data.AbstractPost; import com.alwaysallthetime.adnlib.data.Annotatable; import com.alwaysallthetime.adnlib.data.Count; import com.alwaysallthetime.adnlib.data.IAppDotNetObject; import com.google.gson.FieldNamingPolicy; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonElement; import java.util.Date;
package com.alwaysallthetime.adnlib.gson; public class AppDotNetGson { static Gson adapterSafeInstance; private static Gson instance; private static Gson persistenceInstance; static { final GsonBuilder builder = new GsonBuilder() .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES) .registerTypeAdapter(Date.class, new Iso8601DateTypeAdapter()); persistenceInstance = builder.create(); adapterSafeInstance = builder .addSerializationExclusionStrategy(new IncludeFieldsByDefaultSerializationExclusionStrategy()) .create(); instance = builder .registerTypeHierarchyAdapter(Annotatable.class, new AnnotatableSerializer())
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/AbstractPost.java // public class AbstractPost extends Annotatable { // @Expose(serialize = false) // private User user; // @Expose(serialize = false) // private Date createdAt; // private String text; // @Expose(serialize = false) // private String html; // @Expose(serialize = false) // private App source; // private String replyTo; // @Expose(serialize = false) // private String threadId; // @Expose(serialize = false) // private int numReplies; // private Entities entities; // @Expose(serialize = false) // private boolean isDeleted; // private boolean machineOnly; // // public AbstractPost() {} // // public AbstractPost(String text) { // this.text = text; // this.machineOnly = false; // } // // public AbstractPost(boolean machineOnly) { // this.machineOnly = machineOnly; // } // // public User getUser() { // return user; // } // // public Date getCreatedAt() { // return createdAt; // } // // public String getText() { // return text; // } // // public void setText(String text) { // this.text = text; // } // // public String getHtml() { // return html; // } // // public App getSource() { // return source; // } // // public String getReplyTo() { // return replyTo; // } // // public void setReplyTo(String replyTo) { // this.replyTo = replyTo; // } // // public String getThreadId() { // return threadId; // } // // public int getNumReplies() { // return numReplies; // } // // public Entities getEntities() { // return entities; // } // // public void setEntities(Entities entities) { // this.entities = entities; // } // // public boolean isDeleted() { // return isDeleted; // } // // public boolean isMachineOnly() { // return machineOnly; // } // // public void setMachineOnly(boolean machineOnly) { // this.machineOnly = machineOnly; // } // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/Annotatable.java // public abstract class Annotatable implements IPageableAppDotNetIdObject { // @Expose(serialize = false) // protected String id; // @Expose(serialize = false) // protected String paginationId; // protected ArrayList<Annotation> annotations; // // public String getId() { // return id; // } // // @Override // public String getPaginationId() { // return paginationId; // } // // public boolean hasAnnotations() { // return annotations != null && annotations.size() > 0; // } // // public ArrayList<Annotation> getAnnotations() { // return annotations; // } // // public void setAnnotations(ArrayList<Annotation> annotations) { // this.annotations = annotations; // } // // public boolean addAnnotation(Annotation annotation) { // if (annotations == null) // annotations = new ArrayList<Annotation>(); // // return annotations.add(annotation); // } // // public Annotation removeAnnotation(int index) { // if (annotations == null) // return null; // // return annotations.remove(index); // } // // public void clearAnnotations() { // annotations = null; // } // // public Annotation getFirstAnnotationOfType(String annotationType) { // if(annotations != null) { // for(Annotation a : annotations) { // if(a.getType().equals(annotationType)) { // return a; // } // } // } // return null; // } // // public List<Annotation> getAnnotationsOfType(String annotationType) { // ArrayList<Annotation> typedAnnotations = new ArrayList<Annotation>(); // if(annotations != null) { // for(Annotation a : annotations) { // if(a.getType().equals(annotationType)) { // typedAnnotations.add(a); // } // } // } // return typedAnnotations; // } // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/Count.java // public class Count implements IAppDotNetObject { // private int value; // // public Count(int value) { // this.value = value; // } // // public int getValue() { // return value; // } // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/IAppDotNetObject.java // public interface IAppDotNetObject {} // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/gson/AppDotNetGson.java import com.alwaysallthetime.adnlib.data.AbstractPost; import com.alwaysallthetime.adnlib.data.Annotatable; import com.alwaysallthetime.adnlib.data.Count; import com.alwaysallthetime.adnlib.data.IAppDotNetObject; import com.google.gson.FieldNamingPolicy; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonElement; import java.util.Date; package com.alwaysallthetime.adnlib.gson; public class AppDotNetGson { static Gson adapterSafeInstance; private static Gson instance; private static Gson persistenceInstance; static { final GsonBuilder builder = new GsonBuilder() .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES) .registerTypeAdapter(Date.class, new Iso8601DateTypeAdapter()); persistenceInstance = builder.create(); adapterSafeInstance = builder .addSerializationExclusionStrategy(new IncludeFieldsByDefaultSerializationExclusionStrategy()) .create(); instance = builder .registerTypeHierarchyAdapter(Annotatable.class, new AnnotatableSerializer())
.registerTypeAdapter(Count.class, new CountDeserializer())
alwaysallthetime/ADNLib
ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/request/AppDotNetApiFileUploadRequest.java
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/File.java // public class File extends Annotatable { // @Expose(serialize = false) // private boolean complete; // @Expose(serialize = false) // private String createdAt; // @Expose(serialize = false) // private Map<String, DerivedFile> derivedFiles; // @Expose(serialize = false) // private String fileToken; // @Expose(serialize = false) // private boolean fileTokenRead; // @Expose(serialize = false) // private ImageInfo imageInfo; // private String kind; // @Expose(serialize = false) // private String mimeType; // private String name; // @SerializedName("public") // private boolean isPublic; // @Expose(serialize = false) // private String sha1; // @Expose(serialize = false) // private int size; // @Expose(serialize = false) // private Source source; // @Expose(serialize = false) // private int totalSize; // private String type; // @Expose(serialize = false) // private String url; // @Expose(serialize = false) // private String urlExpires; // @Expose(serialize = false) // private String urlPermanent; // @Expose(serialize = false) // private String urlShort; // @Expose(serialize = false) // private User user; // // public File() {} // // public File(String kind, String type, String name, boolean isPublic) { // this.kind = kind; // this.type = type; // this.name = name; // this.isPublic = isPublic; // } // // public boolean isComplete() { // return complete; // } // // public String getCreatedAt() { // return createdAt; // } // // public Map<String, DerivedFile> getDerivedFiles() { // return derivedFiles; // } // // public String getFileToken() { // return fileToken; // } // // public boolean isFileTokenRead() { // return fileTokenRead; // } // // public ImageInfo getImageInfo() { // return imageInfo; // } // // public String getKind() { // return kind; // } // // public String getMimeType() { // return mimeType; // } // // public String getName() { // return name; // } // // public boolean isPublic() { // return isPublic; // } // // public String getSha1() { // return sha1; // } // // public int getSize() { // return size; // } // // public Source getSource() { // return source; // } // // public int getTotalSize() { // return totalSize; // } // // public String getType() { // return type; // } // // public String getUrl() { // return url; // } // // public String getUrlExpires() { // return urlExpires; // } // // public String getUrlPermanent() { // return urlPermanent; // } // // public String getUrlShort() { // return urlShort; // } // // public User getUser() { // return user; // } // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/AppDotNetResponseHandler.java // public abstract class AppDotNetResponseHandler<T extends IAppDotNetObject> { // private static final String TAG = "AppDotNetResponseHandler"; // // private final Gson gson; // private final Type responseType; // // // subclasses must call this constructor and initialize responseType since there is no default constructor // protected AppDotNetResponseHandler(TypeToken typeToken) { // gson = AppDotNetGson.getInstance(); // responseType = typeToken.getType(); // } // // protected <T> T parseResponse(Reader reader) { // return gson.fromJson(reader, responseType); // } // // public abstract void handleResponse(Reader reader); // // public abstract void onSuccess(T responseData); // // public void onError(Exception error) { // Log.e(TAG, error.getMessage(), error); // } // }
import com.alwaysallthetime.adnlib.data.File; import com.alwaysallthetime.adnlib.response.AppDotNetResponseHandler; import java.io.IOException; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.net.HttpURLConnection;
package com.alwaysallthetime.adnlib.request; public class AppDotNetApiFileUploadRequest extends AppDotNetApiUploadRequest { private File file; private String mimeType;
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/File.java // public class File extends Annotatable { // @Expose(serialize = false) // private boolean complete; // @Expose(serialize = false) // private String createdAt; // @Expose(serialize = false) // private Map<String, DerivedFile> derivedFiles; // @Expose(serialize = false) // private String fileToken; // @Expose(serialize = false) // private boolean fileTokenRead; // @Expose(serialize = false) // private ImageInfo imageInfo; // private String kind; // @Expose(serialize = false) // private String mimeType; // private String name; // @SerializedName("public") // private boolean isPublic; // @Expose(serialize = false) // private String sha1; // @Expose(serialize = false) // private int size; // @Expose(serialize = false) // private Source source; // @Expose(serialize = false) // private int totalSize; // private String type; // @Expose(serialize = false) // private String url; // @Expose(serialize = false) // private String urlExpires; // @Expose(serialize = false) // private String urlPermanent; // @Expose(serialize = false) // private String urlShort; // @Expose(serialize = false) // private User user; // // public File() {} // // public File(String kind, String type, String name, boolean isPublic) { // this.kind = kind; // this.type = type; // this.name = name; // this.isPublic = isPublic; // } // // public boolean isComplete() { // return complete; // } // // public String getCreatedAt() { // return createdAt; // } // // public Map<String, DerivedFile> getDerivedFiles() { // return derivedFiles; // } // // public String getFileToken() { // return fileToken; // } // // public boolean isFileTokenRead() { // return fileTokenRead; // } // // public ImageInfo getImageInfo() { // return imageInfo; // } // // public String getKind() { // return kind; // } // // public String getMimeType() { // return mimeType; // } // // public String getName() { // return name; // } // // public boolean isPublic() { // return isPublic; // } // // public String getSha1() { // return sha1; // } // // public int getSize() { // return size; // } // // public Source getSource() { // return source; // } // // public int getTotalSize() { // return totalSize; // } // // public String getType() { // return type; // } // // public String getUrl() { // return url; // } // // public String getUrlExpires() { // return urlExpires; // } // // public String getUrlPermanent() { // return urlPermanent; // } // // public String getUrlShort() { // return urlShort; // } // // public User getUser() { // return user; // } // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/AppDotNetResponseHandler.java // public abstract class AppDotNetResponseHandler<T extends IAppDotNetObject> { // private static final String TAG = "AppDotNetResponseHandler"; // // private final Gson gson; // private final Type responseType; // // // subclasses must call this constructor and initialize responseType since there is no default constructor // protected AppDotNetResponseHandler(TypeToken typeToken) { // gson = AppDotNetGson.getInstance(); // responseType = typeToken.getType(); // } // // protected <T> T parseResponse(Reader reader) { // return gson.fromJson(reader, responseType); // } // // public abstract void handleResponse(Reader reader); // // public abstract void onSuccess(T responseData); // // public void onError(Exception error) { // Log.e(TAG, error.getMessage(), error); // } // } // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/request/AppDotNetApiFileUploadRequest.java import com.alwaysallthetime.adnlib.data.File; import com.alwaysallthetime.adnlib.response.AppDotNetResponseHandler; import java.io.IOException; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.net.HttpURLConnection; package com.alwaysallthetime.adnlib.request; public class AppDotNetApiFileUploadRequest extends AppDotNetApiUploadRequest { private File file; private String mimeType;
public AppDotNetApiFileUploadRequest(AppDotNetResponseHandler handler, File file, byte[] fileData, String mimeType, String... pathComponents) {
alwaysallthetime/ADNLib
ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/AppDotNetResponseHandler.java
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/IAppDotNetObject.java // public interface IAppDotNetObject {} // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/gson/AppDotNetGson.java // public class AppDotNetGson { // static Gson adapterSafeInstance; // // private static Gson instance; // private static Gson persistenceInstance; // // static { // final GsonBuilder builder = new GsonBuilder() // .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES) // .registerTypeAdapter(Date.class, new Iso8601DateTypeAdapter()); // // persistenceInstance = builder.create(); // // adapterSafeInstance = builder // .addSerializationExclusionStrategy(new IncludeFieldsByDefaultSerializationExclusionStrategy()) // .create(); // // instance = builder // .registerTypeHierarchyAdapter(Annotatable.class, new AnnotatableSerializer()) // .registerTypeAdapter(Count.class, new CountDeserializer()) // .create(); // } // // /** // * A Gson instance for serializing to and deserializing from the App.net API. // * // * Fields that shouldn't be sent to the API are excluded from serialization, e.g. createdAt. // * // * @return a Gson instance // */ // public static Gson getInstance() { // return instance; // } // // /** // * A Gson instance suitable for disk persistence, in that it will serialize and deserialize all fields. // * // * @return a Gson instance // */ // public static Gson getPersistenceInstance() { // return persistenceInstance; // } // // /** // * A Gson instance without certain customer adapters. This allows those adapters to get the "default" serialization // * before modifying it. // * // * @return a Gson instance // */ // static Gson getAdapterSafeInstance() { // return adapterSafeInstance; // } // // private static <T extends IAppDotNetObject> T copy(IAppDotNetObject object, Gson gson) { // final JsonElement json = gson.toJsonTree(object); // return (T) gson.fromJson(json, object.getClass()); // } // // public static <T extends IAppDotNetObject> T copy(IAppDotNetObject object) { // return copy(object, persistenceInstance); // } // // public static <T extends IAppDotNetObject> T copyForWriting(IAppDotNetObject object) { // return copy(object, instance); // } // }
import android.util.Log; import com.alwaysallthetime.adnlib.data.IAppDotNetObject; import com.alwaysallthetime.adnlib.gson.AppDotNetGson; import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import java.io.Reader; import java.lang.reflect.Type;
package com.alwaysallthetime.adnlib.response; public abstract class AppDotNetResponseHandler<T extends IAppDotNetObject> { private static final String TAG = "AppDotNetResponseHandler"; private final Gson gson; private final Type responseType; // subclasses must call this constructor and initialize responseType since there is no default constructor protected AppDotNetResponseHandler(TypeToken typeToken) {
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/IAppDotNetObject.java // public interface IAppDotNetObject {} // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/gson/AppDotNetGson.java // public class AppDotNetGson { // static Gson adapterSafeInstance; // // private static Gson instance; // private static Gson persistenceInstance; // // static { // final GsonBuilder builder = new GsonBuilder() // .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES) // .registerTypeAdapter(Date.class, new Iso8601DateTypeAdapter()); // // persistenceInstance = builder.create(); // // adapterSafeInstance = builder // .addSerializationExclusionStrategy(new IncludeFieldsByDefaultSerializationExclusionStrategy()) // .create(); // // instance = builder // .registerTypeHierarchyAdapter(Annotatable.class, new AnnotatableSerializer()) // .registerTypeAdapter(Count.class, new CountDeserializer()) // .create(); // } // // /** // * A Gson instance for serializing to and deserializing from the App.net API. // * // * Fields that shouldn't be sent to the API are excluded from serialization, e.g. createdAt. // * // * @return a Gson instance // */ // public static Gson getInstance() { // return instance; // } // // /** // * A Gson instance suitable for disk persistence, in that it will serialize and deserialize all fields. // * // * @return a Gson instance // */ // public static Gson getPersistenceInstance() { // return persistenceInstance; // } // // /** // * A Gson instance without certain customer adapters. This allows those adapters to get the "default" serialization // * before modifying it. // * // * @return a Gson instance // */ // static Gson getAdapterSafeInstance() { // return adapterSafeInstance; // } // // private static <T extends IAppDotNetObject> T copy(IAppDotNetObject object, Gson gson) { // final JsonElement json = gson.toJsonTree(object); // return (T) gson.fromJson(json, object.getClass()); // } // // public static <T extends IAppDotNetObject> T copy(IAppDotNetObject object) { // return copy(object, persistenceInstance); // } // // public static <T extends IAppDotNetObject> T copyForWriting(IAppDotNetObject object) { // return copy(object, instance); // } // } // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/AppDotNetResponseHandler.java import android.util.Log; import com.alwaysallthetime.adnlib.data.IAppDotNetObject; import com.alwaysallthetime.adnlib.gson.AppDotNetGson; import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import java.io.Reader; import java.lang.reflect.Type; package com.alwaysallthetime.adnlib.response; public abstract class AppDotNetResponseHandler<T extends IAppDotNetObject> { private static final String TAG = "AppDotNetResponseHandler"; private final Gson gson; private final Type responseType; // subclasses must call this constructor and initialize responseType since there is no default constructor protected AppDotNetResponseHandler(TypeToken typeToken) {
gson = AppDotNetGson.getInstance();
alwaysallthetime/ADNLib
ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/PostListResponseHandler.java
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/PostList.java // public class PostList extends ArrayList<Post> implements IPageableAppDotNetObjectList<Post> {} // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/ResponseEnvelope.java // public class ResponseEnvelope<T extends IAppDotNetObject> implements IAppDotNetObject { // private ResponseMeta meta; // private T data; // // public ResponseMeta getMeta() { // return meta; // } // // public T getData() { // return data; // } // }
import com.alwaysallthetime.adnlib.data.PostList; import com.alwaysallthetime.adnlib.data.ResponseEnvelope; import com.google.gson.reflect.TypeToken;
package com.alwaysallthetime.adnlib.response; public abstract class PostListResponseHandler extends AppDotNetResponseEnvelopeHandler<PostList> { protected PostListResponseHandler() {
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/PostList.java // public class PostList extends ArrayList<Post> implements IPageableAppDotNetObjectList<Post> {} // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/ResponseEnvelope.java // public class ResponseEnvelope<T extends IAppDotNetObject> implements IAppDotNetObject { // private ResponseMeta meta; // private T data; // // public ResponseMeta getMeta() { // return meta; // } // // public T getData() { // return data; // } // } // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/PostListResponseHandler.java import com.alwaysallthetime.adnlib.data.PostList; import com.alwaysallthetime.adnlib.data.ResponseEnvelope; import com.google.gson.reflect.TypeToken; package com.alwaysallthetime.adnlib.response; public abstract class PostListResponseHandler extends AppDotNetResponseEnvelopeHandler<PostList> { protected PostListResponseHandler() {
super(new TypeToken<ResponseEnvelope<PostList>>(){});
alwaysallthetime/ADNLib
ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/CountResponseHandler.java
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/Count.java // public class Count implements IAppDotNetObject { // private int value; // // public Count(int value) { // this.value = value; // } // // public int getValue() { // return value; // } // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/ResponseEnvelope.java // public class ResponseEnvelope<T extends IAppDotNetObject> implements IAppDotNetObject { // private ResponseMeta meta; // private T data; // // public ResponseMeta getMeta() { // return meta; // } // // public T getData() { // return data; // } // }
import com.alwaysallthetime.adnlib.data.Count; import com.alwaysallthetime.adnlib.data.ResponseEnvelope; import com.google.gson.reflect.TypeToken;
package com.alwaysallthetime.adnlib.response; public abstract class CountResponseHandler extends AppDotNetResponseEnvelopeHandler<Count> { protected CountResponseHandler() {
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/Count.java // public class Count implements IAppDotNetObject { // private int value; // // public Count(int value) { // this.value = value; // } // // public int getValue() { // return value; // } // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/ResponseEnvelope.java // public class ResponseEnvelope<T extends IAppDotNetObject> implements IAppDotNetObject { // private ResponseMeta meta; // private T data; // // public ResponseMeta getMeta() { // return meta; // } // // public T getData() { // return data; // } // } // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/CountResponseHandler.java import com.alwaysallthetime.adnlib.data.Count; import com.alwaysallthetime.adnlib.data.ResponseEnvelope; import com.google.gson.reflect.TypeToken; package com.alwaysallthetime.adnlib.response; public abstract class CountResponseHandler extends AppDotNetResponseEnvelopeHandler<Count> { protected CountResponseHandler() {
super(new TypeToken<ResponseEnvelope<Count>>(){});
alwaysallthetime/ADNLib
ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/UserListResponseHandler.java
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/ResponseEnvelope.java // public class ResponseEnvelope<T extends IAppDotNetObject> implements IAppDotNetObject { // private ResponseMeta meta; // private T data; // // public ResponseMeta getMeta() { // return meta; // } // // public T getData() { // return data; // } // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/UserList.java // public class UserList extends ArrayList<User> implements IPageableAppDotNetObjectList<User> {}
import com.alwaysallthetime.adnlib.data.ResponseEnvelope; import com.alwaysallthetime.adnlib.data.UserList; import com.google.gson.reflect.TypeToken;
package com.alwaysallthetime.adnlib.response; public abstract class UserListResponseHandler extends AppDotNetResponseEnvelopeHandler<UserList> { protected UserListResponseHandler() {
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/ResponseEnvelope.java // public class ResponseEnvelope<T extends IAppDotNetObject> implements IAppDotNetObject { // private ResponseMeta meta; // private T data; // // public ResponseMeta getMeta() { // return meta; // } // // public T getData() { // return data; // } // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/UserList.java // public class UserList extends ArrayList<User> implements IPageableAppDotNetObjectList<User> {} // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/UserListResponseHandler.java import com.alwaysallthetime.adnlib.data.ResponseEnvelope; import com.alwaysallthetime.adnlib.data.UserList; import com.google.gson.reflect.TypeToken; package com.alwaysallthetime.adnlib.response; public abstract class UserListResponseHandler extends AppDotNetResponseEnvelopeHandler<UserList> { protected UserListResponseHandler() {
super(new TypeToken<ResponseEnvelope<UserList>>(){});
alwaysallthetime/ADNLib
ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/LoginResponseHandler.java
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/AccessToken.java // public class AccessToken implements IAppDotNetObject { // private String accessToken; // private Token token; // private String error; // private String errorSlug; // // public String getAccessToken() { // return accessToken; // } // // public Token getToken() { // return token; // } // // public String getError() { // return error; // } // // public String getErrorSlug() { // return errorSlug; // } // // public boolean isError() { // return error != null; // } // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/Token.java // public class Token implements IPageableAppDotNetObject { // private App app; // private String clientId; // private String[] scopes; // private Limits limits; // private Storage storage; // private User user; // private String inviteLink; // private String paginationId; // // public App getApp() { // return app; // } // // public String getClientId() { // return clientId; // } // // public String[] getScopes() { // return scopes; // } // // public Limits getLimits() { // return limits; // } // // public Storage getStorage() { // return storage; // } // // public User getUser() { // return user; // } // // public String getInviteLink() { // return inviteLink; // } // // @Override // public String getPaginationId() { // return paginationId; // } // // public static class Limits { // private int following; // private long maxFileSize; // // protected Limits() { // } // // public int getFollowing() { // return following; // } // // public long getMaxFileSize() { // return maxFileSize; // } // } // // public static class Storage { // private long available; // private long used; // // protected Storage() { // } // // public long getAvailable() { // return available; // } // // public long getUsed() { // return used; // } // } // }
import com.alwaysallthetime.adnlib.data.AccessToken; import com.alwaysallthetime.adnlib.data.Token; import com.google.gson.reflect.TypeToken; import java.io.Reader;
package com.alwaysallthetime.adnlib.response; public abstract class LoginResponseHandler extends AppDotNetResponseHandler<AccessToken> { protected LoginResponseHandler() { super(new TypeToken<AccessToken>(){}); } @Override protected <T> T parseResponse(Reader reader) { return null; } @Override public void handleResponse(Reader reader) {} @Override public void onSuccess(AccessToken accessToken) { onSuccess(accessToken.getAccessToken(), accessToken.getToken()); }
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/AccessToken.java // public class AccessToken implements IAppDotNetObject { // private String accessToken; // private Token token; // private String error; // private String errorSlug; // // public String getAccessToken() { // return accessToken; // } // // public Token getToken() { // return token; // } // // public String getError() { // return error; // } // // public String getErrorSlug() { // return errorSlug; // } // // public boolean isError() { // return error != null; // } // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/Token.java // public class Token implements IPageableAppDotNetObject { // private App app; // private String clientId; // private String[] scopes; // private Limits limits; // private Storage storage; // private User user; // private String inviteLink; // private String paginationId; // // public App getApp() { // return app; // } // // public String getClientId() { // return clientId; // } // // public String[] getScopes() { // return scopes; // } // // public Limits getLimits() { // return limits; // } // // public Storage getStorage() { // return storage; // } // // public User getUser() { // return user; // } // // public String getInviteLink() { // return inviteLink; // } // // @Override // public String getPaginationId() { // return paginationId; // } // // public static class Limits { // private int following; // private long maxFileSize; // // protected Limits() { // } // // public int getFollowing() { // return following; // } // // public long getMaxFileSize() { // return maxFileSize; // } // } // // public static class Storage { // private long available; // private long used; // // protected Storage() { // } // // public long getAvailable() { // return available; // } // // public long getUsed() { // return used; // } // } // } // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/LoginResponseHandler.java import com.alwaysallthetime.adnlib.data.AccessToken; import com.alwaysallthetime.adnlib.data.Token; import com.google.gson.reflect.TypeToken; import java.io.Reader; package com.alwaysallthetime.adnlib.response; public abstract class LoginResponseHandler extends AppDotNetResponseHandler<AccessToken> { protected LoginResponseHandler() { super(new TypeToken<AccessToken>(){}); } @Override protected <T> T parseResponse(Reader reader) { return null; } @Override public void handleResponse(Reader reader) {} @Override public void onSuccess(AccessToken accessToken) { onSuccess(accessToken.getAccessToken(), accessToken.getToken()); }
public abstract void onSuccess(String accessToken, Token token);
alwaysallthetime/ADNLib
ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/Channel.java
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/gson/AppDotNetGson.java // public class AppDotNetGson { // static Gson adapterSafeInstance; // // private static Gson instance; // private static Gson persistenceInstance; // // static { // final GsonBuilder builder = new GsonBuilder() // .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES) // .registerTypeAdapter(Date.class, new Iso8601DateTypeAdapter()); // // persistenceInstance = builder.create(); // // adapterSafeInstance = builder // .addSerializationExclusionStrategy(new IncludeFieldsByDefaultSerializationExclusionStrategy()) // .create(); // // instance = builder // .registerTypeHierarchyAdapter(Annotatable.class, new AnnotatableSerializer()) // .registerTypeAdapter(Count.class, new CountDeserializer()) // .create(); // } // // /** // * A Gson instance for serializing to and deserializing from the App.net API. // * // * Fields that shouldn't be sent to the API are excluded from serialization, e.g. createdAt. // * // * @return a Gson instance // */ // public static Gson getInstance() { // return instance; // } // // /** // * A Gson instance suitable for disk persistence, in that it will serialize and deserialize all fields. // * // * @return a Gson instance // */ // public static Gson getPersistenceInstance() { // return persistenceInstance; // } // // /** // * A Gson instance without certain customer adapters. This allows those adapters to get the "default" serialization // * before modifying it. // * // * @return a Gson instance // */ // static Gson getAdapterSafeInstance() { // return adapterSafeInstance; // } // // private static <T extends IAppDotNetObject> T copy(IAppDotNetObject object, Gson gson) { // final JsonElement json = gson.toJsonTree(object); // return (T) gson.fromJson(json, object.getClass()); // } // // public static <T extends IAppDotNetObject> T copy(IAppDotNetObject object) { // return copy(object, persistenceInstance); // } // // public static <T extends IAppDotNetObject> T copyForWriting(IAppDotNetObject object) { // return copy(object, instance); // } // }
import com.alwaysallthetime.adnlib.gson.AppDotNetGson; import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName;
private boolean youMuted; @Expose(serialize = false) private boolean youSubscribed; @Expose(serialize = false) private boolean youCanEdit; @Expose(serialize = false) private boolean hasUnread; @Expose(serialize = false) private String recentMessageId; @Expose(serialize = false) private Message recentMessage; @Expose(serialize = false) private StreamMarker marker; public Channel(String type, boolean immutable) { this.type = type; counts = new Counts(); readers = new Acl(immutable); writers = new Acl(immutable); } public Channel(String type) { this(type, true); } public Channel() { this(null, true); } public Channel copyForWriting() {
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/gson/AppDotNetGson.java // public class AppDotNetGson { // static Gson adapterSafeInstance; // // private static Gson instance; // private static Gson persistenceInstance; // // static { // final GsonBuilder builder = new GsonBuilder() // .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES) // .registerTypeAdapter(Date.class, new Iso8601DateTypeAdapter()); // // persistenceInstance = builder.create(); // // adapterSafeInstance = builder // .addSerializationExclusionStrategy(new IncludeFieldsByDefaultSerializationExclusionStrategy()) // .create(); // // instance = builder // .registerTypeHierarchyAdapter(Annotatable.class, new AnnotatableSerializer()) // .registerTypeAdapter(Count.class, new CountDeserializer()) // .create(); // } // // /** // * A Gson instance for serializing to and deserializing from the App.net API. // * // * Fields that shouldn't be sent to the API are excluded from serialization, e.g. createdAt. // * // * @return a Gson instance // */ // public static Gson getInstance() { // return instance; // } // // /** // * A Gson instance suitable for disk persistence, in that it will serialize and deserialize all fields. // * // * @return a Gson instance // */ // public static Gson getPersistenceInstance() { // return persistenceInstance; // } // // /** // * A Gson instance without certain customer adapters. This allows those adapters to get the "default" serialization // * before modifying it. // * // * @return a Gson instance // */ // static Gson getAdapterSafeInstance() { // return adapterSafeInstance; // } // // private static <T extends IAppDotNetObject> T copy(IAppDotNetObject object, Gson gson) { // final JsonElement json = gson.toJsonTree(object); // return (T) gson.fromJson(json, object.getClass()); // } // // public static <T extends IAppDotNetObject> T copy(IAppDotNetObject object) { // return copy(object, persistenceInstance); // } // // public static <T extends IAppDotNetObject> T copyForWriting(IAppDotNetObject object) { // return copy(object, instance); // } // } // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/Channel.java import com.alwaysallthetime.adnlib.gson.AppDotNetGson; import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; private boolean youMuted; @Expose(serialize = false) private boolean youSubscribed; @Expose(serialize = false) private boolean youCanEdit; @Expose(serialize = false) private boolean hasUnread; @Expose(serialize = false) private String recentMessageId; @Expose(serialize = false) private Message recentMessage; @Expose(serialize = false) private StreamMarker marker; public Channel(String type, boolean immutable) { this.type = type; counts = new Counts(); readers = new Acl(immutable); writers = new Acl(immutable); } public Channel(String type) { this(type, true); } public Channel() { this(null, true); } public Channel copyForWriting() {
final Channel copy = AppDotNetGson.copyForWriting(this);
alwaysallthetime/ADNLib
ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/ChannelListResponseHandler.java
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/ChannelList.java // public class ChannelList extends ArrayList<Channel> implements IPageableAppDotNetObjectList<Channel> {} // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/PostList.java // public class PostList extends ArrayList<Post> implements IPageableAppDotNetObjectList<Post> {} // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/ResponseEnvelope.java // public class ResponseEnvelope<T extends IAppDotNetObject> implements IAppDotNetObject { // private ResponseMeta meta; // private T data; // // public ResponseMeta getMeta() { // return meta; // } // // public T getData() { // return data; // } // }
import com.alwaysallthetime.adnlib.data.ChannelList; import com.alwaysallthetime.adnlib.data.PostList; import com.alwaysallthetime.adnlib.data.ResponseEnvelope; import com.google.gson.reflect.TypeToken;
package com.alwaysallthetime.adnlib.response; public abstract class ChannelListResponseHandler extends AppDotNetResponseEnvelopeHandler<ChannelList> { protected ChannelListResponseHandler() {
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/ChannelList.java // public class ChannelList extends ArrayList<Channel> implements IPageableAppDotNetObjectList<Channel> {} // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/PostList.java // public class PostList extends ArrayList<Post> implements IPageableAppDotNetObjectList<Post> {} // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/ResponseEnvelope.java // public class ResponseEnvelope<T extends IAppDotNetObject> implements IAppDotNetObject { // private ResponseMeta meta; // private T data; // // public ResponseMeta getMeta() { // return meta; // } // // public T getData() { // return data; // } // } // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/ChannelListResponseHandler.java import com.alwaysallthetime.adnlib.data.ChannelList; import com.alwaysallthetime.adnlib.data.PostList; import com.alwaysallthetime.adnlib.data.ResponseEnvelope; import com.google.gson.reflect.TypeToken; package com.alwaysallthetime.adnlib.response; public abstract class ChannelListResponseHandler extends AppDotNetResponseEnvelopeHandler<ChannelList> { protected ChannelListResponseHandler() {
super(new TypeToken<ResponseEnvelope<ChannelList>>(){});
alwaysallthetime/ADNLib
ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/IdListResponseHandler.java
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/IdList.java // public class IdList extends ArrayList<String> implements IAppDotNetObject {} // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/ResponseEnvelope.java // public class ResponseEnvelope<T extends IAppDotNetObject> implements IAppDotNetObject { // private ResponseMeta meta; // private T data; // // public ResponseMeta getMeta() { // return meta; // } // // public T getData() { // return data; // } // }
import com.alwaysallthetime.adnlib.data.IdList; import com.alwaysallthetime.adnlib.data.ResponseEnvelope; import com.google.gson.reflect.TypeToken;
package com.alwaysallthetime.adnlib.response; public abstract class IdListResponseHandler extends AppDotNetResponseEnvelopeHandler<IdList> { protected IdListResponseHandler() {
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/IdList.java // public class IdList extends ArrayList<String> implements IAppDotNetObject {} // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/ResponseEnvelope.java // public class ResponseEnvelope<T extends IAppDotNetObject> implements IAppDotNetObject { // private ResponseMeta meta; // private T data; // // public ResponseMeta getMeta() { // return meta; // } // // public T getData() { // return data; // } // } // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/IdListResponseHandler.java import com.alwaysallthetime.adnlib.data.IdList; import com.alwaysallthetime.adnlib.data.ResponseEnvelope; import com.google.gson.reflect.TypeToken; package com.alwaysallthetime.adnlib.response; public abstract class IdListResponseHandler extends AppDotNetResponseEnvelopeHandler<IdList> { protected IdListResponseHandler() {
super(new TypeToken<ResponseEnvelope<IdList>>(){});
alwaysallthetime/ADNLib
ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/resourceStream/ResourceStreamSerializer.java
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/IPageableAppDotNetObject.java // public interface IPageableAppDotNetObject extends IAppDotNetObject { // public String getPaginationId(); // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/gson/AppDotNetGson.java // public class AppDotNetGson { // static Gson adapterSafeInstance; // // private static Gson instance; // private static Gson persistenceInstance; // // static { // final GsonBuilder builder = new GsonBuilder() // .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES) // .registerTypeAdapter(Date.class, new Iso8601DateTypeAdapter()); // // persistenceInstance = builder.create(); // // adapterSafeInstance = builder // .addSerializationExclusionStrategy(new IncludeFieldsByDefaultSerializationExclusionStrategy()) // .create(); // // instance = builder // .registerTypeHierarchyAdapter(Annotatable.class, new AnnotatableSerializer()) // .registerTypeAdapter(Count.class, new CountDeserializer()) // .create(); // } // // /** // * A Gson instance for serializing to and deserializing from the App.net API. // * // * Fields that shouldn't be sent to the API are excluded from serialization, e.g. createdAt. // * // * @return a Gson instance // */ // public static Gson getInstance() { // return instance; // } // // /** // * A Gson instance suitable for disk persistence, in that it will serialize and deserialize all fields. // * // * @return a Gson instance // */ // public static Gson getPersistenceInstance() { // return persistenceInstance; // } // // /** // * A Gson instance without certain customer adapters. This allows those adapters to get the "default" serialization // * before modifying it. // * // * @return a Gson instance // */ // static Gson getAdapterSafeInstance() { // return adapterSafeInstance; // } // // private static <T extends IAppDotNetObject> T copy(IAppDotNetObject object, Gson gson) { // final JsonElement json = gson.toJsonTree(object); // return (T) gson.fromJson(json, object.getClass()); // } // // public static <T extends IAppDotNetObject> T copy(IAppDotNetObject object) { // return copy(object, persistenceInstance); // } // // public static <T extends IAppDotNetObject> T copyForWriting(IAppDotNetObject object) { // return copy(object, instance); // } // }
import android.content.SharedPreferences; import com.alwaysallthetime.adnlib.data.IPageableAppDotNetObject; import com.alwaysallthetime.adnlib.gson.AppDotNetGson; import com.google.gson.Gson; import java.util.ArrayList;
package com.alwaysallthetime.adnlib.resourceStream; public class ResourceStreamSerializer { public static void serialize(SharedPreferences preferences, String key, ResourceStream resourceStream) {
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/IPageableAppDotNetObject.java // public interface IPageableAppDotNetObject extends IAppDotNetObject { // public String getPaginationId(); // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/gson/AppDotNetGson.java // public class AppDotNetGson { // static Gson adapterSafeInstance; // // private static Gson instance; // private static Gson persistenceInstance; // // static { // final GsonBuilder builder = new GsonBuilder() // .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES) // .registerTypeAdapter(Date.class, new Iso8601DateTypeAdapter()); // // persistenceInstance = builder.create(); // // adapterSafeInstance = builder // .addSerializationExclusionStrategy(new IncludeFieldsByDefaultSerializationExclusionStrategy()) // .create(); // // instance = builder // .registerTypeHierarchyAdapter(Annotatable.class, new AnnotatableSerializer()) // .registerTypeAdapter(Count.class, new CountDeserializer()) // .create(); // } // // /** // * A Gson instance for serializing to and deserializing from the App.net API. // * // * Fields that shouldn't be sent to the API are excluded from serialization, e.g. createdAt. // * // * @return a Gson instance // */ // public static Gson getInstance() { // return instance; // } // // /** // * A Gson instance suitable for disk persistence, in that it will serialize and deserialize all fields. // * // * @return a Gson instance // */ // public static Gson getPersistenceInstance() { // return persistenceInstance; // } // // /** // * A Gson instance without certain customer adapters. This allows those adapters to get the "default" serialization // * before modifying it. // * // * @return a Gson instance // */ // static Gson getAdapterSafeInstance() { // return adapterSafeInstance; // } // // private static <T extends IAppDotNetObject> T copy(IAppDotNetObject object, Gson gson) { // final JsonElement json = gson.toJsonTree(object); // return (T) gson.fromJson(json, object.getClass()); // } // // public static <T extends IAppDotNetObject> T copy(IAppDotNetObject object) { // return copy(object, persistenceInstance); // } // // public static <T extends IAppDotNetObject> T copyForWriting(IAppDotNetObject object) { // return copy(object, instance); // } // } // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/resourceStream/ResourceStreamSerializer.java import android.content.SharedPreferences; import com.alwaysallthetime.adnlib.data.IPageableAppDotNetObject; import com.alwaysallthetime.adnlib.gson.AppDotNetGson; import com.google.gson.Gson; import java.util.ArrayList; package com.alwaysallthetime.adnlib.resourceStream; public class ResourceStreamSerializer { public static void serialize(SharedPreferences preferences, String key, ResourceStream resourceStream) {
String resourceStreamJson = AppDotNetGson.getInstance().toJson(resourceStream);
alwaysallthetime/ADNLib
ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/resourceStream/ResourceStreamSerializer.java
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/IPageableAppDotNetObject.java // public interface IPageableAppDotNetObject extends IAppDotNetObject { // public String getPaginationId(); // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/gson/AppDotNetGson.java // public class AppDotNetGson { // static Gson adapterSafeInstance; // // private static Gson instance; // private static Gson persistenceInstance; // // static { // final GsonBuilder builder = new GsonBuilder() // .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES) // .registerTypeAdapter(Date.class, new Iso8601DateTypeAdapter()); // // persistenceInstance = builder.create(); // // adapterSafeInstance = builder // .addSerializationExclusionStrategy(new IncludeFieldsByDefaultSerializationExclusionStrategy()) // .create(); // // instance = builder // .registerTypeHierarchyAdapter(Annotatable.class, new AnnotatableSerializer()) // .registerTypeAdapter(Count.class, new CountDeserializer()) // .create(); // } // // /** // * A Gson instance for serializing to and deserializing from the App.net API. // * // * Fields that shouldn't be sent to the API are excluded from serialization, e.g. createdAt. // * // * @return a Gson instance // */ // public static Gson getInstance() { // return instance; // } // // /** // * A Gson instance suitable for disk persistence, in that it will serialize and deserialize all fields. // * // * @return a Gson instance // */ // public static Gson getPersistenceInstance() { // return persistenceInstance; // } // // /** // * A Gson instance without certain customer adapters. This allows those adapters to get the "default" serialization // * before modifying it. // * // * @return a Gson instance // */ // static Gson getAdapterSafeInstance() { // return adapterSafeInstance; // } // // private static <T extends IAppDotNetObject> T copy(IAppDotNetObject object, Gson gson) { // final JsonElement json = gson.toJsonTree(object); // return (T) gson.fromJson(json, object.getClass()); // } // // public static <T extends IAppDotNetObject> T copy(IAppDotNetObject object) { // return copy(object, persistenceInstance); // } // // public static <T extends IAppDotNetObject> T copyForWriting(IAppDotNetObject object) { // return copy(object, instance); // } // }
import android.content.SharedPreferences; import com.alwaysallthetime.adnlib.data.IPageableAppDotNetObject; import com.alwaysallthetime.adnlib.gson.AppDotNetGson; import com.google.gson.Gson; import java.util.ArrayList;
package com.alwaysallthetime.adnlib.resourceStream; public class ResourceStreamSerializer { public static void serialize(SharedPreferences preferences, String key, ResourceStream resourceStream) { String resourceStreamJson = AppDotNetGson.getInstance().toJson(resourceStream); String objectsJson = AppDotNetGson.getPersistenceInstance().toJson(resourceStream.getObjects()); SharedPreferences.Editor edit = preferences.edit(); edit.putString(key, resourceStreamJson); edit.putString(key + "_objects", objectsJson); edit.commit(); } public static void remove(SharedPreferences preferences, String key) { SharedPreferences.Editor edit = preferences.edit(); edit.remove(key); edit.remove(key + "_objects"); edit.commit(); } public static ResourceStream deserializeStream(SharedPreferences preferences, String key, Class resourceStreamType, Class objectType) { String json = preferences.getString(key, null); if(json != null) { ResourceStream stream = (ResourceStream) AppDotNetGson.getInstance().fromJson(json, resourceStreamType); Gson gson = AppDotNetGson.getPersistenceInstance(); String objectsJson = preferences.getString(key + "_objects", null);
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/IPageableAppDotNetObject.java // public interface IPageableAppDotNetObject extends IAppDotNetObject { // public String getPaginationId(); // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/gson/AppDotNetGson.java // public class AppDotNetGson { // static Gson adapterSafeInstance; // // private static Gson instance; // private static Gson persistenceInstance; // // static { // final GsonBuilder builder = new GsonBuilder() // .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES) // .registerTypeAdapter(Date.class, new Iso8601DateTypeAdapter()); // // persistenceInstance = builder.create(); // // adapterSafeInstance = builder // .addSerializationExclusionStrategy(new IncludeFieldsByDefaultSerializationExclusionStrategy()) // .create(); // // instance = builder // .registerTypeHierarchyAdapter(Annotatable.class, new AnnotatableSerializer()) // .registerTypeAdapter(Count.class, new CountDeserializer()) // .create(); // } // // /** // * A Gson instance for serializing to and deserializing from the App.net API. // * // * Fields that shouldn't be sent to the API are excluded from serialization, e.g. createdAt. // * // * @return a Gson instance // */ // public static Gson getInstance() { // return instance; // } // // /** // * A Gson instance suitable for disk persistence, in that it will serialize and deserialize all fields. // * // * @return a Gson instance // */ // public static Gson getPersistenceInstance() { // return persistenceInstance; // } // // /** // * A Gson instance without certain customer adapters. This allows those adapters to get the "default" serialization // * before modifying it. // * // * @return a Gson instance // */ // static Gson getAdapterSafeInstance() { // return adapterSafeInstance; // } // // private static <T extends IAppDotNetObject> T copy(IAppDotNetObject object, Gson gson) { // final JsonElement json = gson.toJsonTree(object); // return (T) gson.fromJson(json, object.getClass()); // } // // public static <T extends IAppDotNetObject> T copy(IAppDotNetObject object) { // return copy(object, persistenceInstance); // } // // public static <T extends IAppDotNetObject> T copyForWriting(IAppDotNetObject object) { // return copy(object, instance); // } // } // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/resourceStream/ResourceStreamSerializer.java import android.content.SharedPreferences; import com.alwaysallthetime.adnlib.data.IPageableAppDotNetObject; import com.alwaysallthetime.adnlib.gson.AppDotNetGson; import com.google.gson.Gson; import java.util.ArrayList; package com.alwaysallthetime.adnlib.resourceStream; public class ResourceStreamSerializer { public static void serialize(SharedPreferences preferences, String key, ResourceStream resourceStream) { String resourceStreamJson = AppDotNetGson.getInstance().toJson(resourceStream); String objectsJson = AppDotNetGson.getPersistenceInstance().toJson(resourceStream.getObjects()); SharedPreferences.Editor edit = preferences.edit(); edit.putString(key, resourceStreamJson); edit.putString(key + "_objects", objectsJson); edit.commit(); } public static void remove(SharedPreferences preferences, String key) { SharedPreferences.Editor edit = preferences.edit(); edit.remove(key); edit.remove(key + "_objects"); edit.commit(); } public static ResourceStream deserializeStream(SharedPreferences preferences, String key, Class resourceStreamType, Class objectType) { String json = preferences.getString(key, null); if(json != null) { ResourceStream stream = (ResourceStream) AppDotNetGson.getInstance().fromJson(json, resourceStreamType); Gson gson = AppDotNetGson.getPersistenceInstance(); String objectsJson = preferences.getString(key + "_objects", null);
ArrayList<IPageableAppDotNetObject> objects = (ArrayList<IPageableAppDotNetObject>) gson.fromJson(objectsJson, objectType);
alwaysallthetime/ADNLib
ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/AppDotNetResponseException.java
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/ResponseMeta.java // public class ResponseMeta { // private int code; // private String errorMessage; // private String errorSlug; // private String errorId; // private String maxId; // private String minId; // private boolean more; // // public int getCode() { // return code; // } // // public String getErrorMessage() { // return errorMessage; // } // // public String getErrorSlug() { // return errorSlug; // } // // public String getErrorId() { // return errorId; // } // // public String getMaxId() { // return maxId; // } // // public String getMinId() { // return minId; // } // // public boolean isMore() { // return more; // } // }
import com.alwaysallthetime.adnlib.data.ResponseMeta;
package com.alwaysallthetime.adnlib; public class AppDotNetResponseException extends AppDotNetClientException { private int status; private String errorMessage; private String errorSlug; private String errorId; public AppDotNetResponseException(String detailMessage, int status) { super(String.format("%s (%s)", detailMessage, status)); this.errorMessage = detailMessage; this.status = status; }
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/ResponseMeta.java // public class ResponseMeta { // private int code; // private String errorMessage; // private String errorSlug; // private String errorId; // private String maxId; // private String minId; // private boolean more; // // public int getCode() { // return code; // } // // public String getErrorMessage() { // return errorMessage; // } // // public String getErrorSlug() { // return errorSlug; // } // // public String getErrorId() { // return errorId; // } // // public String getMaxId() { // return maxId; // } // // public String getMinId() { // return minId; // } // // public boolean isMore() { // return more; // } // } // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/AppDotNetResponseException.java import com.alwaysallthetime.adnlib.data.ResponseMeta; package com.alwaysallthetime.adnlib; public class AppDotNetResponseException extends AppDotNetClientException { private int status; private String errorMessage; private String errorSlug; private String errorId; public AppDotNetResponseException(String detailMessage, int status) { super(String.format("%s (%s)", detailMessage, status)); this.errorMessage = detailMessage; this.status = status; }
public AppDotNetResponseException(ResponseMeta responseMeta) {
alwaysallthetime/ADNLib
ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/ChannelResponseHandler.java
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/Channel.java // public class Channel extends Annotatable { // @Expose(serialize = false) // private Counts counts; // private String type; // @Expose(serialize = false) // private User owner; // private Acl readers; // private Acl writers; // @Expose(serialize = false) // private boolean youMuted; // @Expose(serialize = false) // private boolean youSubscribed; // @Expose(serialize = false) // private boolean youCanEdit; // @Expose(serialize = false) // private boolean hasUnread; // @Expose(serialize = false) // private String recentMessageId; // @Expose(serialize = false) // private Message recentMessage; // @Expose(serialize = false) // private StreamMarker marker; // // public Channel(String type, boolean immutable) { // this.type = type; // counts = new Counts(); // readers = new Acl(immutable); // writers = new Acl(immutable); // } // // public Channel(String type) { // this(type, true); // } // // public Channel() { // this(null, true); // } // // public Channel copyForWriting() { // final Channel copy = AppDotNetGson.copyForWriting(this); // copy.id = this.id; // copy.setType(null); // copy.clearAnnotations(); // // if (copy.getReaders().isImmutable()) // copy.setReaders(null); // // if (copy.getWriters().isImmutable()) // copy.setWriters(null); // // return copy; // } // // public int getMessageCount() { // return counts.messages; // } // // public int getSubscriberCount() { // return counts.subscribers; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public User getOwner() { // return owner; // } // // public Acl getReaders() { // return readers; // } // // public void setReaders(Acl readers) { // this.readers = readers; // } // // public Acl getWriters() { // return writers; // } // // public void setWriters(Acl writers) { // this.writers = writers; // } // // public boolean isMuted() { // return youMuted; // } // // public boolean isSubscribed() { // return youSubscribed; // } // // public boolean isEditable() { // return youCanEdit; // } // // public boolean isUnread() { // return hasUnread; // } // // public String getRecentMessageId() { // return recentMessageId; // } // // public Message getRecentMessage() { // return recentMessage; // } // // public StreamMarker getMarker() { // return marker; // } // // public void setMarker(StreamMarker marker) { // this.marker = marker; // } // // private static class Counts { // private int messages; // private int subscribers; // } // // public static class Acl { // private boolean anyUser; // private boolean immutable = true; // @SerializedName("public") // private boolean publicAccess; // private String[] userIds; // @Expose(serialize = false) // private boolean you; // // public Acl() {} // // public Acl(boolean immutable) { // this.immutable = immutable; // } // // public boolean isAnyUser() { // return anyUser; // } // // public void setAnyUser(boolean anyUser) { // this.anyUser = anyUser; // // if (anyUser) { // publicAccess = false; // userIds = null; // } // } // // public boolean isImmutable() { // return immutable; // } // // public void setImmutable(boolean immutable) { // this.immutable = immutable; // } // // public boolean isPublic() { // return publicAccess; // } // // public void setPublic(boolean publicAccess) { // this.publicAccess = publicAccess; // // if (publicAccess) { // anyUser = false; // userIds = null; // } // } // // public String[] getUserIds() { // return userIds; // } // // public void setUserIds(String[] userIds) { // this.userIds = userIds; // // if (userIds != null) { // anyUser = false; // publicAccess = false; // } // } // // public boolean isCurrentUserAuthorized() { // return you; // } // } // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/ResponseEnvelope.java // public class ResponseEnvelope<T extends IAppDotNetObject> implements IAppDotNetObject { // private ResponseMeta meta; // private T data; // // public ResponseMeta getMeta() { // return meta; // } // // public T getData() { // return data; // } // }
import com.alwaysallthetime.adnlib.data.Channel; import com.alwaysallthetime.adnlib.data.ResponseEnvelope; import com.google.gson.reflect.TypeToken;
package com.alwaysallthetime.adnlib.response; public abstract class ChannelResponseHandler extends AppDotNetResponseEnvelopeHandler<Channel> { protected ChannelResponseHandler() {
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/Channel.java // public class Channel extends Annotatable { // @Expose(serialize = false) // private Counts counts; // private String type; // @Expose(serialize = false) // private User owner; // private Acl readers; // private Acl writers; // @Expose(serialize = false) // private boolean youMuted; // @Expose(serialize = false) // private boolean youSubscribed; // @Expose(serialize = false) // private boolean youCanEdit; // @Expose(serialize = false) // private boolean hasUnread; // @Expose(serialize = false) // private String recentMessageId; // @Expose(serialize = false) // private Message recentMessage; // @Expose(serialize = false) // private StreamMarker marker; // // public Channel(String type, boolean immutable) { // this.type = type; // counts = new Counts(); // readers = new Acl(immutable); // writers = new Acl(immutable); // } // // public Channel(String type) { // this(type, true); // } // // public Channel() { // this(null, true); // } // // public Channel copyForWriting() { // final Channel copy = AppDotNetGson.copyForWriting(this); // copy.id = this.id; // copy.setType(null); // copy.clearAnnotations(); // // if (copy.getReaders().isImmutable()) // copy.setReaders(null); // // if (copy.getWriters().isImmutable()) // copy.setWriters(null); // // return copy; // } // // public int getMessageCount() { // return counts.messages; // } // // public int getSubscriberCount() { // return counts.subscribers; // } // // public String getType() { // return type; // } // // public void setType(String type) { // this.type = type; // } // // public User getOwner() { // return owner; // } // // public Acl getReaders() { // return readers; // } // // public void setReaders(Acl readers) { // this.readers = readers; // } // // public Acl getWriters() { // return writers; // } // // public void setWriters(Acl writers) { // this.writers = writers; // } // // public boolean isMuted() { // return youMuted; // } // // public boolean isSubscribed() { // return youSubscribed; // } // // public boolean isEditable() { // return youCanEdit; // } // // public boolean isUnread() { // return hasUnread; // } // // public String getRecentMessageId() { // return recentMessageId; // } // // public Message getRecentMessage() { // return recentMessage; // } // // public StreamMarker getMarker() { // return marker; // } // // public void setMarker(StreamMarker marker) { // this.marker = marker; // } // // private static class Counts { // private int messages; // private int subscribers; // } // // public static class Acl { // private boolean anyUser; // private boolean immutable = true; // @SerializedName("public") // private boolean publicAccess; // private String[] userIds; // @Expose(serialize = false) // private boolean you; // // public Acl() {} // // public Acl(boolean immutable) { // this.immutable = immutable; // } // // public boolean isAnyUser() { // return anyUser; // } // // public void setAnyUser(boolean anyUser) { // this.anyUser = anyUser; // // if (anyUser) { // publicAccess = false; // userIds = null; // } // } // // public boolean isImmutable() { // return immutable; // } // // public void setImmutable(boolean immutable) { // this.immutable = immutable; // } // // public boolean isPublic() { // return publicAccess; // } // // public void setPublic(boolean publicAccess) { // this.publicAccess = publicAccess; // // if (publicAccess) { // anyUser = false; // userIds = null; // } // } // // public String[] getUserIds() { // return userIds; // } // // public void setUserIds(String[] userIds) { // this.userIds = userIds; // // if (userIds != null) { // anyUser = false; // publicAccess = false; // } // } // // public boolean isCurrentUserAuthorized() { // return you; // } // } // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/ResponseEnvelope.java // public class ResponseEnvelope<T extends IAppDotNetObject> implements IAppDotNetObject { // private ResponseMeta meta; // private T data; // // public ResponseMeta getMeta() { // return meta; // } // // public T getData() { // return data; // } // } // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/ChannelResponseHandler.java import com.alwaysallthetime.adnlib.data.Channel; import com.alwaysallthetime.adnlib.data.ResponseEnvelope; import com.google.gson.reflect.TypeToken; package com.alwaysallthetime.adnlib.response; public abstract class ChannelResponseHandler extends AppDotNetResponseEnvelopeHandler<Channel> { protected ChannelResponseHandler() {
super(new TypeToken<ResponseEnvelope<Channel>>(){});
alwaysallthetime/ADNLib
ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/AppDotNetNoResponseHandler.java
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/IAppDotNetObject.java // public interface IAppDotNetObject {} // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/ResponseEnvelope.java // public class ResponseEnvelope<T extends IAppDotNetObject> implements IAppDotNetObject { // private ResponseMeta meta; // private T data; // // public ResponseMeta getMeta() { // return meta; // } // // public T getData() { // return data; // } // }
import com.alwaysallthetime.adnlib.data.IAppDotNetObject; import com.alwaysallthetime.adnlib.data.ResponseEnvelope; import com.google.gson.reflect.TypeToken;
package com.alwaysallthetime.adnlib.response; public class AppDotNetNoResponseHandler extends AppDotNetResponseEnvelopeHandler { public AppDotNetNoResponseHandler() {
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/IAppDotNetObject.java // public interface IAppDotNetObject {} // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/ResponseEnvelope.java // public class ResponseEnvelope<T extends IAppDotNetObject> implements IAppDotNetObject { // private ResponseMeta meta; // private T data; // // public ResponseMeta getMeta() { // return meta; // } // // public T getData() { // return data; // } // } // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/AppDotNetNoResponseHandler.java import com.alwaysallthetime.adnlib.data.IAppDotNetObject; import com.alwaysallthetime.adnlib.data.ResponseEnvelope; import com.google.gson.reflect.TypeToken; package com.alwaysallthetime.adnlib.response; public class AppDotNetNoResponseHandler extends AppDotNetResponseEnvelopeHandler { public AppDotNetNoResponseHandler() {
super(new TypeToken<ResponseEnvelope>(){});
alwaysallthetime/ADNLib
ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/AppDotNetNoResponseHandler.java
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/IAppDotNetObject.java // public interface IAppDotNetObject {} // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/ResponseEnvelope.java // public class ResponseEnvelope<T extends IAppDotNetObject> implements IAppDotNetObject { // private ResponseMeta meta; // private T data; // // public ResponseMeta getMeta() { // return meta; // } // // public T getData() { // return data; // } // }
import com.alwaysallthetime.adnlib.data.IAppDotNetObject; import com.alwaysallthetime.adnlib.data.ResponseEnvelope; import com.google.gson.reflect.TypeToken;
package com.alwaysallthetime.adnlib.response; public class AppDotNetNoResponseHandler extends AppDotNetResponseEnvelopeHandler { public AppDotNetNoResponseHandler() { super(new TypeToken<ResponseEnvelope>(){}); } @Override
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/IAppDotNetObject.java // public interface IAppDotNetObject {} // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/ResponseEnvelope.java // public class ResponseEnvelope<T extends IAppDotNetObject> implements IAppDotNetObject { // private ResponseMeta meta; // private T data; // // public ResponseMeta getMeta() { // return meta; // } // // public T getData() { // return data; // } // } // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/AppDotNetNoResponseHandler.java import com.alwaysallthetime.adnlib.data.IAppDotNetObject; import com.alwaysallthetime.adnlib.data.ResponseEnvelope; import com.google.gson.reflect.TypeToken; package com.alwaysallthetime.adnlib.response; public class AppDotNetNoResponseHandler extends AppDotNetResponseEnvelopeHandler { public AppDotNetNoResponseHandler() { super(new TypeToken<ResponseEnvelope>(){}); } @Override
public void onSuccess(IAppDotNetObject responseData) {}
alwaysallthetime/ADNLib
ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/request/AppDotNetApiImageUploadRequest.java
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/QueryParameters.java // public class QueryParameters extends HashMap<String, String> { // // very unlikely you'd ever need more than 4 query parameters on one request // private static final int INITIAL_CAPACITY = 4; // private static final float LOAD_FACTOR = 1.0f; // // /** // * Get a new QueryParameters that consists of two sets of QueryParamters combined. // * // * Since it is possible that there will be conflicting parameters, the second set will be applied // * "on top of" the first set, i.e. the topParameters can override the bottomParameters // * // * @param bottomParameters // * @param topParameters // * @return a new QueryParamters consisting of the values form both specified QueryParameters objects. // */ // public static QueryParameters getCombinedParameters(QueryParameters bottomParameters, QueryParameters topParameters) { // QueryParameters newParams = new QueryParameters(); // newParams.putAll(bottomParameters); // newParams.putAll(topParameters); // return newParams; // } // // public QueryParameters() { // this(INITIAL_CAPACITY, LOAD_FACTOR); // } // // protected QueryParameters(int capacity, float loadFactor) { // super(capacity, loadFactor); // } // // public QueryParameters(IQueryParameter... queryParameters) { // super(INITIAL_CAPACITY + queryParameters.length, LOAD_FACTOR); // put(queryParameters); // } // // public void put(IQueryParameter... queryParameters) { // for (IQueryParameter queryParameter : queryParameters) { // put(queryParameter.getName(), queryParameter.getValue()); // } // } // // protected String getCommaDelimitedString(List<String> strings, int bestGuessMaxLength) { // final StringBuilder buffer = new StringBuilder(strings.size() * bestGuessMaxLength); // for(final String str : strings) { // buffer.append(str); // buffer.append(','); // } // // return buffer.substring(0, buffer.length() - 1); // } // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/AppDotNetResponseHandler.java // public abstract class AppDotNetResponseHandler<T extends IAppDotNetObject> { // private static final String TAG = "AppDotNetResponseHandler"; // // private final Gson gson; // private final Type responseType; // // // subclasses must call this constructor and initialize responseType since there is no default constructor // protected AppDotNetResponseHandler(TypeToken typeToken) { // gson = AppDotNetGson.getInstance(); // responseType = typeToken.getType(); // } // // protected <T> T parseResponse(Reader reader) { // return gson.fromJson(reader, responseType); // } // // public abstract void handleResponse(Reader reader); // // public abstract void onSuccess(T responseData); // // public void onError(Exception error) { // Log.e(TAG, error.getMessage(), error); // } // }
import com.alwaysallthetime.adnlib.QueryParameters; import com.alwaysallthetime.adnlib.response.AppDotNetResponseHandler; import java.io.IOException; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.net.HttpURLConnection;
package com.alwaysallthetime.adnlib.request; public class AppDotNetApiImageUploadRequest extends AppDotNetApiUploadRequest { public AppDotNetApiImageUploadRequest(AppDotNetResponseHandler handler, String filename, byte[] image, int offset,
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/QueryParameters.java // public class QueryParameters extends HashMap<String, String> { // // very unlikely you'd ever need more than 4 query parameters on one request // private static final int INITIAL_CAPACITY = 4; // private static final float LOAD_FACTOR = 1.0f; // // /** // * Get a new QueryParameters that consists of two sets of QueryParamters combined. // * // * Since it is possible that there will be conflicting parameters, the second set will be applied // * "on top of" the first set, i.e. the topParameters can override the bottomParameters // * // * @param bottomParameters // * @param topParameters // * @return a new QueryParamters consisting of the values form both specified QueryParameters objects. // */ // public static QueryParameters getCombinedParameters(QueryParameters bottomParameters, QueryParameters topParameters) { // QueryParameters newParams = new QueryParameters(); // newParams.putAll(bottomParameters); // newParams.putAll(topParameters); // return newParams; // } // // public QueryParameters() { // this(INITIAL_CAPACITY, LOAD_FACTOR); // } // // protected QueryParameters(int capacity, float loadFactor) { // super(capacity, loadFactor); // } // // public QueryParameters(IQueryParameter... queryParameters) { // super(INITIAL_CAPACITY + queryParameters.length, LOAD_FACTOR); // put(queryParameters); // } // // public void put(IQueryParameter... queryParameters) { // for (IQueryParameter queryParameter : queryParameters) { // put(queryParameter.getName(), queryParameter.getValue()); // } // } // // protected String getCommaDelimitedString(List<String> strings, int bestGuessMaxLength) { // final StringBuilder buffer = new StringBuilder(strings.size() * bestGuessMaxLength); // for(final String str : strings) { // buffer.append(str); // buffer.append(','); // } // // return buffer.substring(0, buffer.length() - 1); // } // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/AppDotNetResponseHandler.java // public abstract class AppDotNetResponseHandler<T extends IAppDotNetObject> { // private static final String TAG = "AppDotNetResponseHandler"; // // private final Gson gson; // private final Type responseType; // // // subclasses must call this constructor and initialize responseType since there is no default constructor // protected AppDotNetResponseHandler(TypeToken typeToken) { // gson = AppDotNetGson.getInstance(); // responseType = typeToken.getType(); // } // // protected <T> T parseResponse(Reader reader) { // return gson.fromJson(reader, responseType); // } // // public abstract void handleResponse(Reader reader); // // public abstract void onSuccess(T responseData); // // public void onError(Exception error) { // Log.e(TAG, error.getMessage(), error); // } // } // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/request/AppDotNetApiImageUploadRequest.java import com.alwaysallthetime.adnlib.QueryParameters; import com.alwaysallthetime.adnlib.response.AppDotNetResponseHandler; import java.io.IOException; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.net.HttpURLConnection; package com.alwaysallthetime.adnlib.request; public class AppDotNetApiImageUploadRequest extends AppDotNetApiUploadRequest { public AppDotNetApiImageUploadRequest(AppDotNetResponseHandler handler, String filename, byte[] image, int offset,
int count, QueryParameters queryParameters, String... pathComponents) {
alwaysallthetime/ADNLib
ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/FileListResponseHandler.java
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/FileList.java // public class FileList extends ArrayList<File> implements IPageableAppDotNetObjectList<File> {} // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/ResponseEnvelope.java // public class ResponseEnvelope<T extends IAppDotNetObject> implements IAppDotNetObject { // private ResponseMeta meta; // private T data; // // public ResponseMeta getMeta() { // return meta; // } // // public T getData() { // return data; // } // }
import com.alwaysallthetime.adnlib.data.FileList; import com.alwaysallthetime.adnlib.data.ResponseEnvelope; import com.google.gson.reflect.TypeToken;
package com.alwaysallthetime.adnlib.response; public abstract class FileListResponseHandler extends AppDotNetResponseEnvelopeHandler<FileList> { protected FileListResponseHandler() {
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/FileList.java // public class FileList extends ArrayList<File> implements IPageableAppDotNetObjectList<File> {} // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/ResponseEnvelope.java // public class ResponseEnvelope<T extends IAppDotNetObject> implements IAppDotNetObject { // private ResponseMeta meta; // private T data; // // public ResponseMeta getMeta() { // return meta; // } // // public T getData() { // return data; // } // } // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/FileListResponseHandler.java import com.alwaysallthetime.adnlib.data.FileList; import com.alwaysallthetime.adnlib.data.ResponseEnvelope; import com.google.gson.reflect.TypeToken; package com.alwaysallthetime.adnlib.response; public abstract class FileListResponseHandler extends AppDotNetResponseEnvelopeHandler<FileList> { protected FileListResponseHandler() {
super(new TypeToken<ResponseEnvelope<FileList>>(){});
alwaysallthetime/ADNLib
ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/MessageListResponseHandler.java
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/MessageList.java // public class MessageList extends ArrayList<Message> implements IPageableAppDotNetObjectList<Message> {} // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/ResponseEnvelope.java // public class ResponseEnvelope<T extends IAppDotNetObject> implements IAppDotNetObject { // private ResponseMeta meta; // private T data; // // public ResponseMeta getMeta() { // return meta; // } // // public T getData() { // return data; // } // }
import com.alwaysallthetime.adnlib.data.MessageList; import com.alwaysallthetime.adnlib.data.ResponseEnvelope; import com.google.gson.reflect.TypeToken;
package com.alwaysallthetime.adnlib.response; public abstract class MessageListResponseHandler extends AppDotNetResponseEnvelopeHandler<MessageList> { protected MessageListResponseHandler() {
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/MessageList.java // public class MessageList extends ArrayList<Message> implements IPageableAppDotNetObjectList<Message> {} // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/ResponseEnvelope.java // public class ResponseEnvelope<T extends IAppDotNetObject> implements IAppDotNetObject { // private ResponseMeta meta; // private T data; // // public ResponseMeta getMeta() { // return meta; // } // // public T getData() { // return data; // } // } // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/MessageListResponseHandler.java import com.alwaysallthetime.adnlib.data.MessageList; import com.alwaysallthetime.adnlib.data.ResponseEnvelope; import com.google.gson.reflect.TypeToken; package com.alwaysallthetime.adnlib.response; public abstract class MessageListResponseHandler extends AppDotNetResponseEnvelopeHandler<MessageList> { protected MessageListResponseHandler() {
super(new TypeToken<ResponseEnvelope<MessageList>>(){});
alwaysallthetime/ADNLib
ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/StreamMarkerListResponseHandler.java
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/ResponseEnvelope.java // public class ResponseEnvelope<T extends IAppDotNetObject> implements IAppDotNetObject { // private ResponseMeta meta; // private T data; // // public ResponseMeta getMeta() { // return meta; // } // // public T getData() { // return data; // } // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/StreamMarkerList.java // public class StreamMarkerList extends ArrayList<StreamMarker> implements IAppDotNetObjectList<StreamMarker> {}
import com.alwaysallthetime.adnlib.data.ResponseEnvelope; import com.alwaysallthetime.adnlib.data.StreamMarkerList; import com.google.gson.reflect.TypeToken;
package com.alwaysallthetime.adnlib.response; public abstract class StreamMarkerListResponseHandler extends AppDotNetResponseEnvelopeHandler<StreamMarkerList> { protected StreamMarkerListResponseHandler() {
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/ResponseEnvelope.java // public class ResponseEnvelope<T extends IAppDotNetObject> implements IAppDotNetObject { // private ResponseMeta meta; // private T data; // // public ResponseMeta getMeta() { // return meta; // } // // public T getData() { // return data; // } // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/StreamMarkerList.java // public class StreamMarkerList extends ArrayList<StreamMarker> implements IAppDotNetObjectList<StreamMarker> {} // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/StreamMarkerListResponseHandler.java import com.alwaysallthetime.adnlib.data.ResponseEnvelope; import com.alwaysallthetime.adnlib.data.StreamMarkerList; import com.google.gson.reflect.TypeToken; package com.alwaysallthetime.adnlib.response; public abstract class StreamMarkerListResponseHandler extends AppDotNetResponseEnvelopeHandler<StreamMarkerList> { protected StreamMarkerListResponseHandler() {
super(new TypeToken<ResponseEnvelope<StreamMarkerList>>(){});
alwaysallthetime/ADNLib
ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/PlaceListResponseHandler.java
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/PlaceList.java // public class PlaceList extends ArrayList<Place> implements IAppDotNetObjectList<Place> {} // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/ResponseEnvelope.java // public class ResponseEnvelope<T extends IAppDotNetObject> implements IAppDotNetObject { // private ResponseMeta meta; // private T data; // // public ResponseMeta getMeta() { // return meta; // } // // public T getData() { // return data; // } // }
import com.alwaysallthetime.adnlib.data.PlaceList; import com.alwaysallthetime.adnlib.data.ResponseEnvelope; import com.google.gson.reflect.TypeToken;
package com.alwaysallthetime.adnlib.response; public abstract class PlaceListResponseHandler extends AppDotNetResponseEnvelopeHandler<PlaceList> { protected PlaceListResponseHandler() {
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/PlaceList.java // public class PlaceList extends ArrayList<Place> implements IAppDotNetObjectList<Place> {} // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/ResponseEnvelope.java // public class ResponseEnvelope<T extends IAppDotNetObject> implements IAppDotNetObject { // private ResponseMeta meta; // private T data; // // public ResponseMeta getMeta() { // return meta; // } // // public T getData() { // return data; // } // } // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/PlaceListResponseHandler.java import com.alwaysallthetime.adnlib.data.PlaceList; import com.alwaysallthetime.adnlib.data.ResponseEnvelope; import com.google.gson.reflect.TypeToken; package com.alwaysallthetime.adnlib.response; public abstract class PlaceListResponseHandler extends AppDotNetResponseEnvelopeHandler<PlaceList> { protected PlaceListResponseHandler() {
super(new TypeToken<ResponseEnvelope<PlaceList>>(){});
alwaysallthetime/ADNLib
ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/UserResponseHandler.java
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/ResponseEnvelope.java // public class ResponseEnvelope<T extends IAppDotNetObject> implements IAppDotNetObject { // private ResponseMeta meta; // private T data; // // public ResponseMeta getMeta() { // return meta; // } // // public T getData() { // return data; // } // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/User.java // public class User extends Annotatable { // @Expose(serialize = false) // private String username; // private String name; // private Description description; // private String timezone; // private String locale; // @Expose(serialize = false) // private Image avatarImage; // @Expose(serialize = false) // private Image coverImage; // @Expose(serialize = false) // private String type; // @Expose(serialize = false) // private Date createdAt; // @Expose(serialize = false) // private Counts counts; // @Expose(serialize = false) // private boolean followsYou; // @Expose(serialize = false) // private boolean youBlocked; // @Expose(serialize = false) // private boolean youFollow; // @Expose(serialize = false) // private boolean youMuted; // @Expose(serialize = false) // private boolean youCanSubscribe; // @Expose(serialize = false) // private boolean youCanFollow; // @Expose(serialize = false) // private String verifiedDomain; // @Expose(serialize = false) // private String canonicalUrl; // // public User() { // description = new Description(); // } // // public User copyForWriting() { // final User copy = AppDotNetGson.copyForWriting(this); // copy.getDescription().clearEntities(); // copy.clearAnnotations(); // return copy; // } // // public String getUsername() { // return username; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Description getDescription() { // return description; // } // // public void setDescription(Description description) { // this.description = description; // } // // public String getTimezone() { // return timezone; // } // // public void setTimezone(String timezone) { // this.timezone = timezone; // } // // public String getLocale() { // return locale; // } // // public void setLocale(String locale) { // this.locale = locale; // } // // public Image getAvatarImage() { // return avatarImage; // } // // public Image getCoverImage() { // return coverImage; // } // // public String getType() { // return type; // } // // public Date getCreatedAt() { // return createdAt; // } // // public Counts getCounts() { // return counts; // } // // public boolean isFollowingYou() { // return followsYou; // } // // public boolean isBlocked() { // return youBlocked; // } // // public boolean isFollowed() { // return youFollow; // } // // public boolean isMuted() { // return youMuted; // } // // public boolean isSubscribable() { // return youCanSubscribe; // } // // public boolean isFollowable() { // return youCanFollow; // } // // public String getVerifiedDomain() { // return verifiedDomain; // } // // public String getCanonicalUrl() { // return canonicalUrl; // } // // public static class Description { // private String text; // @Expose(serialize = false) // private String html; // private Entities entities; // // public String getText() { // return text; // } // // public void setText(String text) { // this.text = text; // } // // public String getHtml() { // return html; // } // // public Entities getEntities() { // return entities; // } // // public void setEntities(Entities entities) { // this.entities = entities; // } // // public void clearEntities() { // entities = null; // } // } // // public static class Counts { // private int following; // private int followers; // private int posts; // private int stars; // // protected Counts() { // } // // public int getFollowing() { // return following; // } // // public int getFollowers() { // return followers; // } // // public int getPosts() { // return posts; // } // // public int getStars() { // return stars; // } // } // }
import com.alwaysallthetime.adnlib.data.ResponseEnvelope; import com.alwaysallthetime.adnlib.data.User; import com.google.gson.reflect.TypeToken;
package com.alwaysallthetime.adnlib.response; public abstract class UserResponseHandler extends AppDotNetResponseEnvelopeHandler<User> { protected UserResponseHandler() {
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/ResponseEnvelope.java // public class ResponseEnvelope<T extends IAppDotNetObject> implements IAppDotNetObject { // private ResponseMeta meta; // private T data; // // public ResponseMeta getMeta() { // return meta; // } // // public T getData() { // return data; // } // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/User.java // public class User extends Annotatable { // @Expose(serialize = false) // private String username; // private String name; // private Description description; // private String timezone; // private String locale; // @Expose(serialize = false) // private Image avatarImage; // @Expose(serialize = false) // private Image coverImage; // @Expose(serialize = false) // private String type; // @Expose(serialize = false) // private Date createdAt; // @Expose(serialize = false) // private Counts counts; // @Expose(serialize = false) // private boolean followsYou; // @Expose(serialize = false) // private boolean youBlocked; // @Expose(serialize = false) // private boolean youFollow; // @Expose(serialize = false) // private boolean youMuted; // @Expose(serialize = false) // private boolean youCanSubscribe; // @Expose(serialize = false) // private boolean youCanFollow; // @Expose(serialize = false) // private String verifiedDomain; // @Expose(serialize = false) // private String canonicalUrl; // // public User() { // description = new Description(); // } // // public User copyForWriting() { // final User copy = AppDotNetGson.copyForWriting(this); // copy.getDescription().clearEntities(); // copy.clearAnnotations(); // return copy; // } // // public String getUsername() { // return username; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Description getDescription() { // return description; // } // // public void setDescription(Description description) { // this.description = description; // } // // public String getTimezone() { // return timezone; // } // // public void setTimezone(String timezone) { // this.timezone = timezone; // } // // public String getLocale() { // return locale; // } // // public void setLocale(String locale) { // this.locale = locale; // } // // public Image getAvatarImage() { // return avatarImage; // } // // public Image getCoverImage() { // return coverImage; // } // // public String getType() { // return type; // } // // public Date getCreatedAt() { // return createdAt; // } // // public Counts getCounts() { // return counts; // } // // public boolean isFollowingYou() { // return followsYou; // } // // public boolean isBlocked() { // return youBlocked; // } // // public boolean isFollowed() { // return youFollow; // } // // public boolean isMuted() { // return youMuted; // } // // public boolean isSubscribable() { // return youCanSubscribe; // } // // public boolean isFollowable() { // return youCanFollow; // } // // public String getVerifiedDomain() { // return verifiedDomain; // } // // public String getCanonicalUrl() { // return canonicalUrl; // } // // public static class Description { // private String text; // @Expose(serialize = false) // private String html; // private Entities entities; // // public String getText() { // return text; // } // // public void setText(String text) { // this.text = text; // } // // public String getHtml() { // return html; // } // // public Entities getEntities() { // return entities; // } // // public void setEntities(Entities entities) { // this.entities = entities; // } // // public void clearEntities() { // entities = null; // } // } // // public static class Counts { // private int following; // private int followers; // private int posts; // private int stars; // // protected Counts() { // } // // public int getFollowing() { // return following; // } // // public int getFollowers() { // return followers; // } // // public int getPosts() { // return posts; // } // // public int getStars() { // return stars; // } // } // } // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/UserResponseHandler.java import com.alwaysallthetime.adnlib.data.ResponseEnvelope; import com.alwaysallthetime.adnlib.data.User; import com.google.gson.reflect.TypeToken; package com.alwaysallthetime.adnlib.response; public abstract class UserResponseHandler extends AppDotNetResponseEnvelopeHandler<User> { protected UserResponseHandler() {
super(new TypeToken<ResponseEnvelope<User>>(){});
alwaysallthetime/ADNLib
ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/AppDotNetBaseResponseEnvelopeHandler.java
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/AppDotNetResponseException.java // public class AppDotNetResponseException extends AppDotNetClientException { // private int status; // private String errorMessage; // private String errorSlug; // private String errorId; // // public AppDotNetResponseException(String detailMessage, int status) { // super(String.format("%s (%s)", detailMessage, status)); // this.errorMessage = detailMessage; // this.status = status; // } // // public AppDotNetResponseException(ResponseMeta responseMeta) { // this(responseMeta.getErrorMessage(), responseMeta.getCode()); // this.errorSlug = responseMeta.getErrorSlug(); // this.errorId = responseMeta.getErrorId(); // } // // public AppDotNetResponseException(String errorMessage, String errorSlug) { // super(errorMessage); // this.errorMessage = errorMessage; // this.errorSlug = errorSlug; // } // // public int getStatus() { // return status; // } // // public String getErrorMessage() { // return errorMessage; // } // // public String getErrorSlug() { // return errorSlug; // } // // public String getErrorId() { // return errorId; // } // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/IAppDotNetObject.java // public interface IAppDotNetObject {} // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/ResponseEnvelope.java // public class ResponseEnvelope<T extends IAppDotNetObject> implements IAppDotNetObject { // private ResponseMeta meta; // private T data; // // public ResponseMeta getMeta() { // return meta; // } // // public T getData() { // return data; // } // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/ResponseMeta.java // public class ResponseMeta { // private int code; // private String errorMessage; // private String errorSlug; // private String errorId; // private String maxId; // private String minId; // private boolean more; // // public int getCode() { // return code; // } // // public String getErrorMessage() { // return errorMessage; // } // // public String getErrorSlug() { // return errorSlug; // } // // public String getErrorId() { // return errorId; // } // // public String getMaxId() { // return maxId; // } // // public String getMinId() { // return minId; // } // // public boolean isMore() { // return more; // } // }
import com.alwaysallthetime.adnlib.AppDotNetResponseException; import com.alwaysallthetime.adnlib.data.IAppDotNetObject; import com.alwaysallthetime.adnlib.data.ResponseEnvelope; import com.alwaysallthetime.adnlib.data.ResponseMeta; import com.google.gson.reflect.TypeToken; import java.io.Reader; import java.net.HttpURLConnection;
package com.alwaysallthetime.adnlib.response; public abstract class AppDotNetBaseResponseEnvelopeHandler<T extends IAppDotNetObject> extends AppDotNetResponseHandler<T> { protected ResponseMeta responseMeta; protected AppDotNetBaseResponseEnvelopeHandler(TypeToken typeToken) { super(typeToken); } @Override public void handleResponse(Reader reader) {
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/AppDotNetResponseException.java // public class AppDotNetResponseException extends AppDotNetClientException { // private int status; // private String errorMessage; // private String errorSlug; // private String errorId; // // public AppDotNetResponseException(String detailMessage, int status) { // super(String.format("%s (%s)", detailMessage, status)); // this.errorMessage = detailMessage; // this.status = status; // } // // public AppDotNetResponseException(ResponseMeta responseMeta) { // this(responseMeta.getErrorMessage(), responseMeta.getCode()); // this.errorSlug = responseMeta.getErrorSlug(); // this.errorId = responseMeta.getErrorId(); // } // // public AppDotNetResponseException(String errorMessage, String errorSlug) { // super(errorMessage); // this.errorMessage = errorMessage; // this.errorSlug = errorSlug; // } // // public int getStatus() { // return status; // } // // public String getErrorMessage() { // return errorMessage; // } // // public String getErrorSlug() { // return errorSlug; // } // // public String getErrorId() { // return errorId; // } // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/IAppDotNetObject.java // public interface IAppDotNetObject {} // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/ResponseEnvelope.java // public class ResponseEnvelope<T extends IAppDotNetObject> implements IAppDotNetObject { // private ResponseMeta meta; // private T data; // // public ResponseMeta getMeta() { // return meta; // } // // public T getData() { // return data; // } // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/ResponseMeta.java // public class ResponseMeta { // private int code; // private String errorMessage; // private String errorSlug; // private String errorId; // private String maxId; // private String minId; // private boolean more; // // public int getCode() { // return code; // } // // public String getErrorMessage() { // return errorMessage; // } // // public String getErrorSlug() { // return errorSlug; // } // // public String getErrorId() { // return errorId; // } // // public String getMaxId() { // return maxId; // } // // public String getMinId() { // return minId; // } // // public boolean isMore() { // return more; // } // } // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/AppDotNetBaseResponseEnvelopeHandler.java import com.alwaysallthetime.adnlib.AppDotNetResponseException; import com.alwaysallthetime.adnlib.data.IAppDotNetObject; import com.alwaysallthetime.adnlib.data.ResponseEnvelope; import com.alwaysallthetime.adnlib.data.ResponseMeta; import com.google.gson.reflect.TypeToken; import java.io.Reader; import java.net.HttpURLConnection; package com.alwaysallthetime.adnlib.response; public abstract class AppDotNetBaseResponseEnvelopeHandler<T extends IAppDotNetObject> extends AppDotNetResponseHandler<T> { protected ResponseMeta responseMeta; protected AppDotNetBaseResponseEnvelopeHandler(TypeToken typeToken) { super(typeToken); } @Override public void handleResponse(Reader reader) {
final ResponseEnvelope<T> response = parseResponse(reader);
alwaysallthetime/ADNLib
ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/AppDotNetBaseResponseEnvelopeHandler.java
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/AppDotNetResponseException.java // public class AppDotNetResponseException extends AppDotNetClientException { // private int status; // private String errorMessage; // private String errorSlug; // private String errorId; // // public AppDotNetResponseException(String detailMessage, int status) { // super(String.format("%s (%s)", detailMessage, status)); // this.errorMessage = detailMessage; // this.status = status; // } // // public AppDotNetResponseException(ResponseMeta responseMeta) { // this(responseMeta.getErrorMessage(), responseMeta.getCode()); // this.errorSlug = responseMeta.getErrorSlug(); // this.errorId = responseMeta.getErrorId(); // } // // public AppDotNetResponseException(String errorMessage, String errorSlug) { // super(errorMessage); // this.errorMessage = errorMessage; // this.errorSlug = errorSlug; // } // // public int getStatus() { // return status; // } // // public String getErrorMessage() { // return errorMessage; // } // // public String getErrorSlug() { // return errorSlug; // } // // public String getErrorId() { // return errorId; // } // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/IAppDotNetObject.java // public interface IAppDotNetObject {} // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/ResponseEnvelope.java // public class ResponseEnvelope<T extends IAppDotNetObject> implements IAppDotNetObject { // private ResponseMeta meta; // private T data; // // public ResponseMeta getMeta() { // return meta; // } // // public T getData() { // return data; // } // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/ResponseMeta.java // public class ResponseMeta { // private int code; // private String errorMessage; // private String errorSlug; // private String errorId; // private String maxId; // private String minId; // private boolean more; // // public int getCode() { // return code; // } // // public String getErrorMessage() { // return errorMessage; // } // // public String getErrorSlug() { // return errorSlug; // } // // public String getErrorId() { // return errorId; // } // // public String getMaxId() { // return maxId; // } // // public String getMinId() { // return minId; // } // // public boolean isMore() { // return more; // } // }
import com.alwaysallthetime.adnlib.AppDotNetResponseException; import com.alwaysallthetime.adnlib.data.IAppDotNetObject; import com.alwaysallthetime.adnlib.data.ResponseEnvelope; import com.alwaysallthetime.adnlib.data.ResponseMeta; import com.google.gson.reflect.TypeToken; import java.io.Reader; import java.net.HttpURLConnection;
package com.alwaysallthetime.adnlib.response; public abstract class AppDotNetBaseResponseEnvelopeHandler<T extends IAppDotNetObject> extends AppDotNetResponseHandler<T> { protected ResponseMeta responseMeta; protected AppDotNetBaseResponseEnvelopeHandler(TypeToken typeToken) { super(typeToken); } @Override public void handleResponse(Reader reader) { final ResponseEnvelope<T> response = parseResponse(reader); responseMeta = response.getMeta(); if (responseMeta.getCode() != HttpURLConnection.HTTP_OK) {
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/AppDotNetResponseException.java // public class AppDotNetResponseException extends AppDotNetClientException { // private int status; // private String errorMessage; // private String errorSlug; // private String errorId; // // public AppDotNetResponseException(String detailMessage, int status) { // super(String.format("%s (%s)", detailMessage, status)); // this.errorMessage = detailMessage; // this.status = status; // } // // public AppDotNetResponseException(ResponseMeta responseMeta) { // this(responseMeta.getErrorMessage(), responseMeta.getCode()); // this.errorSlug = responseMeta.getErrorSlug(); // this.errorId = responseMeta.getErrorId(); // } // // public AppDotNetResponseException(String errorMessage, String errorSlug) { // super(errorMessage); // this.errorMessage = errorMessage; // this.errorSlug = errorSlug; // } // // public int getStatus() { // return status; // } // // public String getErrorMessage() { // return errorMessage; // } // // public String getErrorSlug() { // return errorSlug; // } // // public String getErrorId() { // return errorId; // } // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/IAppDotNetObject.java // public interface IAppDotNetObject {} // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/ResponseEnvelope.java // public class ResponseEnvelope<T extends IAppDotNetObject> implements IAppDotNetObject { // private ResponseMeta meta; // private T data; // // public ResponseMeta getMeta() { // return meta; // } // // public T getData() { // return data; // } // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/ResponseMeta.java // public class ResponseMeta { // private int code; // private String errorMessage; // private String errorSlug; // private String errorId; // private String maxId; // private String minId; // private boolean more; // // public int getCode() { // return code; // } // // public String getErrorMessage() { // return errorMessage; // } // // public String getErrorSlug() { // return errorSlug; // } // // public String getErrorId() { // return errorId; // } // // public String getMaxId() { // return maxId; // } // // public String getMinId() { // return minId; // } // // public boolean isMore() { // return more; // } // } // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/AppDotNetBaseResponseEnvelopeHandler.java import com.alwaysallthetime.adnlib.AppDotNetResponseException; import com.alwaysallthetime.adnlib.data.IAppDotNetObject; import com.alwaysallthetime.adnlib.data.ResponseEnvelope; import com.alwaysallthetime.adnlib.data.ResponseMeta; import com.google.gson.reflect.TypeToken; import java.io.Reader; import java.net.HttpURLConnection; package com.alwaysallthetime.adnlib.response; public abstract class AppDotNetBaseResponseEnvelopeHandler<T extends IAppDotNetObject> extends AppDotNetResponseHandler<T> { protected ResponseMeta responseMeta; protected AppDotNetBaseResponseEnvelopeHandler(TypeToken typeToken) { super(typeToken); } @Override public void handleResponse(Reader reader) { final ResponseEnvelope<T> response = parseResponse(reader); responseMeta = response.getMeta(); if (responseMeta.getCode() != HttpURLConnection.HTTP_OK) {
onError(new AppDotNetResponseException(responseMeta));
alwaysallthetime/ADNLib
ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/StreamMarkerResponseHandler.java
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/ResponseEnvelope.java // public class ResponseEnvelope<T extends IAppDotNetObject> implements IAppDotNetObject { // private ResponseMeta meta; // private T data; // // public ResponseMeta getMeta() { // return meta; // } // // public T getData() { // return data; // } // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/StreamMarker.java // public class StreamMarker implements IAppDotNetObject { // private String id; // @Expose(serialize = false) // private String lastReadId; // private String name; // private int percentage; // @Expose(serialize = false) // private Date updatedAt; // @Expose(serialize = false) // private String version; // // public StreamMarker() {} // // public StreamMarker(String id, String name, int percentage) { // this.id = id; // this.name = name; // this.percentage = percentage; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getLastReadId() { // return lastReadId; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public int getPercentage() { // return percentage; // } // // public void setPercentage(int percentage) { // this.percentage = percentage; // } // // public Date getUpdatedAt() { // return updatedAt; // } // // public String getVersion() { // return version; // } // }
import com.alwaysallthetime.adnlib.data.ResponseEnvelope; import com.alwaysallthetime.adnlib.data.StreamMarker; import com.google.gson.reflect.TypeToken;
package com.alwaysallthetime.adnlib.response; /** * Created by brambley on 10/8/13. */ public abstract class StreamMarkerResponseHandler extends AppDotNetResponseEnvelopeHandler<StreamMarker> { protected StreamMarkerResponseHandler() {
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/ResponseEnvelope.java // public class ResponseEnvelope<T extends IAppDotNetObject> implements IAppDotNetObject { // private ResponseMeta meta; // private T data; // // public ResponseMeta getMeta() { // return meta; // } // // public T getData() { // return data; // } // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/StreamMarker.java // public class StreamMarker implements IAppDotNetObject { // private String id; // @Expose(serialize = false) // private String lastReadId; // private String name; // private int percentage; // @Expose(serialize = false) // private Date updatedAt; // @Expose(serialize = false) // private String version; // // public StreamMarker() {} // // public StreamMarker(String id, String name, int percentage) { // this.id = id; // this.name = name; // this.percentage = percentage; // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public String getLastReadId() { // return lastReadId; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public int getPercentage() { // return percentage; // } // // public void setPercentage(int percentage) { // this.percentage = percentage; // } // // public Date getUpdatedAt() { // return updatedAt; // } // // public String getVersion() { // return version; // } // } // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/StreamMarkerResponseHandler.java import com.alwaysallthetime.adnlib.data.ResponseEnvelope; import com.alwaysallthetime.adnlib.data.StreamMarker; import com.google.gson.reflect.TypeToken; package com.alwaysallthetime.adnlib.response; /** * Created by brambley on 10/8/13. */ public abstract class StreamMarkerResponseHandler extends AppDotNetResponseEnvelopeHandler<StreamMarker> { protected StreamMarkerResponseHandler() {
super(new TypeToken<ResponseEnvelope<StreamMarker>>(){});
alwaysallthetime/ADNLib
ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/request/AppDotNetApiJsonRequest.java
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/QueryParameters.java // public class QueryParameters extends HashMap<String, String> { // // very unlikely you'd ever need more than 4 query parameters on one request // private static final int INITIAL_CAPACITY = 4; // private static final float LOAD_FACTOR = 1.0f; // // /** // * Get a new QueryParameters that consists of two sets of QueryParamters combined. // * // * Since it is possible that there will be conflicting parameters, the second set will be applied // * "on top of" the first set, i.e. the topParameters can override the bottomParameters // * // * @param bottomParameters // * @param topParameters // * @return a new QueryParamters consisting of the values form both specified QueryParameters objects. // */ // public static QueryParameters getCombinedParameters(QueryParameters bottomParameters, QueryParameters topParameters) { // QueryParameters newParams = new QueryParameters(); // newParams.putAll(bottomParameters); // newParams.putAll(topParameters); // return newParams; // } // // public QueryParameters() { // this(INITIAL_CAPACITY, LOAD_FACTOR); // } // // protected QueryParameters(int capacity, float loadFactor) { // super(capacity, loadFactor); // } // // public QueryParameters(IQueryParameter... queryParameters) { // super(INITIAL_CAPACITY + queryParameters.length, LOAD_FACTOR); // put(queryParameters); // } // // public void put(IQueryParameter... queryParameters) { // for (IQueryParameter queryParameter : queryParameters) { // put(queryParameter.getName(), queryParameter.getValue()); // } // } // // protected String getCommaDelimitedString(List<String> strings, int bestGuessMaxLength) { // final StringBuilder buffer = new StringBuilder(strings.size() * bestGuessMaxLength); // for(final String str : strings) { // buffer.append(str); // buffer.append(','); // } // // return buffer.substring(0, buffer.length() - 1); // } // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/IAppDotNetObject.java // public interface IAppDotNetObject {} // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/AppDotNetResponseHandler.java // public abstract class AppDotNetResponseHandler<T extends IAppDotNetObject> { // private static final String TAG = "AppDotNetResponseHandler"; // // private final Gson gson; // private final Type responseType; // // // subclasses must call this constructor and initialize responseType since there is no default constructor // protected AppDotNetResponseHandler(TypeToken typeToken) { // gson = AppDotNetGson.getInstance(); // responseType = typeToken.getType(); // } // // protected <T> T parseResponse(Reader reader) { // return gson.fromJson(reader, responseType); // } // // public abstract void handleResponse(Reader reader); // // public abstract void onSuccess(T responseData); // // public void onError(Exception error) { // Log.e(TAG, error.getMessage(), error); // } // }
import com.alwaysallthetime.adnlib.QueryParameters; import com.alwaysallthetime.adnlib.data.IAppDotNetObject; import com.alwaysallthetime.adnlib.response.AppDotNetResponseHandler; import java.io.IOException; import java.net.HttpURLConnection; import java.util.Map;
package com.alwaysallthetime.adnlib.request; public class AppDotNetApiJsonRequest extends AppDotNetApiRequest { public AppDotNetApiJsonRequest(AppDotNetResponseHandler handler, String requestMethod, IAppDotNetObject body,
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/QueryParameters.java // public class QueryParameters extends HashMap<String, String> { // // very unlikely you'd ever need more than 4 query parameters on one request // private static final int INITIAL_CAPACITY = 4; // private static final float LOAD_FACTOR = 1.0f; // // /** // * Get a new QueryParameters that consists of two sets of QueryParamters combined. // * // * Since it is possible that there will be conflicting parameters, the second set will be applied // * "on top of" the first set, i.e. the topParameters can override the bottomParameters // * // * @param bottomParameters // * @param topParameters // * @return a new QueryParamters consisting of the values form both specified QueryParameters objects. // */ // public static QueryParameters getCombinedParameters(QueryParameters bottomParameters, QueryParameters topParameters) { // QueryParameters newParams = new QueryParameters(); // newParams.putAll(bottomParameters); // newParams.putAll(topParameters); // return newParams; // } // // public QueryParameters() { // this(INITIAL_CAPACITY, LOAD_FACTOR); // } // // protected QueryParameters(int capacity, float loadFactor) { // super(capacity, loadFactor); // } // // public QueryParameters(IQueryParameter... queryParameters) { // super(INITIAL_CAPACITY + queryParameters.length, LOAD_FACTOR); // put(queryParameters); // } // // public void put(IQueryParameter... queryParameters) { // for (IQueryParameter queryParameter : queryParameters) { // put(queryParameter.getName(), queryParameter.getValue()); // } // } // // protected String getCommaDelimitedString(List<String> strings, int bestGuessMaxLength) { // final StringBuilder buffer = new StringBuilder(strings.size() * bestGuessMaxLength); // for(final String str : strings) { // buffer.append(str); // buffer.append(','); // } // // return buffer.substring(0, buffer.length() - 1); // } // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/IAppDotNetObject.java // public interface IAppDotNetObject {} // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/AppDotNetResponseHandler.java // public abstract class AppDotNetResponseHandler<T extends IAppDotNetObject> { // private static final String TAG = "AppDotNetResponseHandler"; // // private final Gson gson; // private final Type responseType; // // // subclasses must call this constructor and initialize responseType since there is no default constructor // protected AppDotNetResponseHandler(TypeToken typeToken) { // gson = AppDotNetGson.getInstance(); // responseType = typeToken.getType(); // } // // protected <T> T parseResponse(Reader reader) { // return gson.fromJson(reader, responseType); // } // // public abstract void handleResponse(Reader reader); // // public abstract void onSuccess(T responseData); // // public void onError(Exception error) { // Log.e(TAG, error.getMessage(), error); // } // } // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/request/AppDotNetApiJsonRequest.java import com.alwaysallthetime.adnlib.QueryParameters; import com.alwaysallthetime.adnlib.data.IAppDotNetObject; import com.alwaysallthetime.adnlib.response.AppDotNetResponseHandler; import java.io.IOException; import java.net.HttpURLConnection; import java.util.Map; package com.alwaysallthetime.adnlib.request; public class AppDotNetApiJsonRequest extends AppDotNetApiRequest { public AppDotNetApiJsonRequest(AppDotNetResponseHandler handler, String requestMethod, IAppDotNetObject body,
QueryParameters queryParameters, String... pathComponents) {
alwaysallthetime/ADNLib
ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/request/AppDotNetOAuthRequest.java
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/AppDotNetResponseHandler.java // public abstract class AppDotNetResponseHandler<T extends IAppDotNetObject> { // private static final String TAG = "AppDotNetResponseHandler"; // // private final Gson gson; // private final Type responseType; // // // subclasses must call this constructor and initialize responseType since there is no default constructor // protected AppDotNetResponseHandler(TypeToken typeToken) { // gson = AppDotNetGson.getInstance(); // responseType = typeToken.getType(); // } // // protected <T> T parseResponse(Reader reader) { // return gson.fromJson(reader, responseType); // } // // public abstract void handleResponse(Reader reader); // // public abstract void onSuccess(T responseData); // // public void onError(Exception error) { // Log.e(TAG, error.getMessage(), error); // } // }
import java.util.List; import android.net.Uri; import com.alwaysallthetime.adnlib.response.AppDotNetResponseHandler; import org.apache.http.NameValuePair;
package com.alwaysallthetime.adnlib.request; public class AppDotNetOAuthRequest extends AppDotNetFormRequest { private static final String ADN_OAUTH_BASE_URL = "https://account.app.net/oauth/"; private static final Uri ADN_OAUTH_BASE = Uri.parse(ADN_OAUTH_BASE_URL);
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/AppDotNetResponseHandler.java // public abstract class AppDotNetResponseHandler<T extends IAppDotNetObject> { // private static final String TAG = "AppDotNetResponseHandler"; // // private final Gson gson; // private final Type responseType; // // // subclasses must call this constructor and initialize responseType since there is no default constructor // protected AppDotNetResponseHandler(TypeToken typeToken) { // gson = AppDotNetGson.getInstance(); // responseType = typeToken.getType(); // } // // protected <T> T parseResponse(Reader reader) { // return gson.fromJson(reader, responseType); // } // // public abstract void handleResponse(Reader reader); // // public abstract void onSuccess(T responseData); // // public void onError(Exception error) { // Log.e(TAG, error.getMessage(), error); // } // } // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/request/AppDotNetOAuthRequest.java import java.util.List; import android.net.Uri; import com.alwaysallthetime.adnlib.response.AppDotNetResponseHandler; import org.apache.http.NameValuePair; package com.alwaysallthetime.adnlib.request; public class AppDotNetOAuthRequest extends AppDotNetFormRequest { private static final String ADN_OAUTH_BASE_URL = "https://account.app.net/oauth/"; private static final Uri ADN_OAUTH_BASE = Uri.parse(ADN_OAUTH_BASE_URL);
public AppDotNetOAuthRequest(AppDotNetResponseHandler handler, List<? extends NameValuePair> body, String... pathComponents) {
alwaysallthetime/ADNLib
ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/InteractionListResponseHandler.java
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/InteractionList.java // public class InteractionList extends ArrayList<Interaction> implements IPageableAppDotNetObjectList<Interaction> {} // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/ResponseEnvelope.java // public class ResponseEnvelope<T extends IAppDotNetObject> implements IAppDotNetObject { // private ResponseMeta meta; // private T data; // // public ResponseMeta getMeta() { // return meta; // } // // public T getData() { // return data; // } // }
import com.alwaysallthetime.adnlib.data.InteractionList; import com.alwaysallthetime.adnlib.data.ResponseEnvelope; import com.google.gson.reflect.TypeToken;
package com.alwaysallthetime.adnlib.response; public abstract class InteractionListResponseHandler extends AppDotNetResponseEnvelopeHandler<InteractionList> { protected InteractionListResponseHandler() {
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/InteractionList.java // public class InteractionList extends ArrayList<Interaction> implements IPageableAppDotNetObjectList<Interaction> {} // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/ResponseEnvelope.java // public class ResponseEnvelope<T extends IAppDotNetObject> implements IAppDotNetObject { // private ResponseMeta meta; // private T data; // // public ResponseMeta getMeta() { // return meta; // } // // public T getData() { // return data; // } // } // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/InteractionListResponseHandler.java import com.alwaysallthetime.adnlib.data.InteractionList; import com.alwaysallthetime.adnlib.data.ResponseEnvelope; import com.google.gson.reflect.TypeToken; package com.alwaysallthetime.adnlib.response; public abstract class InteractionListResponseHandler extends AppDotNetResponseEnvelopeHandler<InteractionList> { protected InteractionListResponseHandler() {
super(new TypeToken<ResponseEnvelope<InteractionList>>(){});
alwaysallthetime/ADNLib
ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/InteractionResourceStreamResponseHandler.java
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/InteractionList.java // public class InteractionList extends ArrayList<Interaction> implements IPageableAppDotNetObjectList<Interaction> {} // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/ResponseEnvelope.java // public class ResponseEnvelope<T extends IAppDotNetObject> implements IAppDotNetObject { // private ResponseMeta meta; // private T data; // // public ResponseMeta getMeta() { // return meta; // } // // public T getData() { // return data; // } // }
import com.alwaysallthetime.adnlib.data.InteractionList; import com.alwaysallthetime.adnlib.data.ResponseEnvelope; import com.google.gson.reflect.TypeToken;
package com.alwaysallthetime.adnlib.response; public abstract class InteractionResourceStreamResponseHandler<T> extends ResourceStreamResponseHandler<InteractionList> { protected InteractionResourceStreamResponseHandler() {
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/InteractionList.java // public class InteractionList extends ArrayList<Interaction> implements IPageableAppDotNetObjectList<Interaction> {} // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/ResponseEnvelope.java // public class ResponseEnvelope<T extends IAppDotNetObject> implements IAppDotNetObject { // private ResponseMeta meta; // private T data; // // public ResponseMeta getMeta() { // return meta; // } // // public T getData() { // return data; // } // } // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/InteractionResourceStreamResponseHandler.java import com.alwaysallthetime.adnlib.data.InteractionList; import com.alwaysallthetime.adnlib.data.ResponseEnvelope; import com.google.gson.reflect.TypeToken; package com.alwaysallthetime.adnlib.response; public abstract class InteractionResourceStreamResponseHandler<T> extends ResourceStreamResponseHandler<InteractionList> { protected InteractionResourceStreamResponseHandler() {
super(new TypeToken<ResponseEnvelope<? extends InteractionList>>(){});
alwaysallthetime/ADNLib
ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/ConfigurationResponseHandler.java
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/Configuration.java // public class Configuration implements IAppDotNetObject { // private TextConfiguration text; // private ResourceConfiguration user; // private ResourceConfiguration file; // private ResourceConfiguration post; // private ResourceConfiguration message; // private ResourceConfiguration channel; // // public TextConfiguration getText() { // return text; // } // // public ResourceConfiguration getUser() { // return user; // } // // public ResourceConfiguration getFile() { // return file; // } // // public ResourceConfiguration getPost() { // return post; // } // // public ResourceConfiguration getMessage() { // return message; // } // // public ResourceConfiguration getChannel() { // return channel; // } // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/ResponseEnvelope.java // public class ResponseEnvelope<T extends IAppDotNetObject> implements IAppDotNetObject { // private ResponseMeta meta; // private T data; // // public ResponseMeta getMeta() { // return meta; // } // // public T getData() { // return data; // } // }
import com.alwaysallthetime.adnlib.data.Configuration; import com.alwaysallthetime.adnlib.data.ResponseEnvelope; import com.google.gson.reflect.TypeToken;
package com.alwaysallthetime.adnlib.response; public abstract class ConfigurationResponseHandler extends AppDotNetResponseEnvelopeHandler<Configuration> { protected ConfigurationResponseHandler() {
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/Configuration.java // public class Configuration implements IAppDotNetObject { // private TextConfiguration text; // private ResourceConfiguration user; // private ResourceConfiguration file; // private ResourceConfiguration post; // private ResourceConfiguration message; // private ResourceConfiguration channel; // // public TextConfiguration getText() { // return text; // } // // public ResourceConfiguration getUser() { // return user; // } // // public ResourceConfiguration getFile() { // return file; // } // // public ResourceConfiguration getPost() { // return post; // } // // public ResourceConfiguration getMessage() { // return message; // } // // public ResourceConfiguration getChannel() { // return channel; // } // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/ResponseEnvelope.java // public class ResponseEnvelope<T extends IAppDotNetObject> implements IAppDotNetObject { // private ResponseMeta meta; // private T data; // // public ResponseMeta getMeta() { // return meta; // } // // public T getData() { // return data; // } // } // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/ConfigurationResponseHandler.java import com.alwaysallthetime.adnlib.data.Configuration; import com.alwaysallthetime.adnlib.data.ResponseEnvelope; import com.google.gson.reflect.TypeToken; package com.alwaysallthetime.adnlib.response; public abstract class ConfigurationResponseHandler extends AppDotNetResponseEnvelopeHandler<Configuration> { protected ConfigurationResponseHandler() {
super(new TypeToken<ResponseEnvelope<Configuration>>(){});
alwaysallthetime/ADNLib
ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/MessageResponseHandler.java
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/Message.java // public class Message extends AbstractPost { // @Expose(serialize = false) // private String channelId; // // public Message() {} // // public Message(String text) { // super(text); // } // // public Message(boolean machineOnly) { // super(machineOnly); // } // // public String getChannelId() { // return channelId; // } // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/ResponseEnvelope.java // public class ResponseEnvelope<T extends IAppDotNetObject> implements IAppDotNetObject { // private ResponseMeta meta; // private T data; // // public ResponseMeta getMeta() { // return meta; // } // // public T getData() { // return data; // } // }
import com.alwaysallthetime.adnlib.data.Message; import com.alwaysallthetime.adnlib.data.ResponseEnvelope; import com.google.gson.reflect.TypeToken;
package com.alwaysallthetime.adnlib.response; public abstract class MessageResponseHandler extends AppDotNetResponseEnvelopeHandler<Message> { protected MessageResponseHandler() {
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/Message.java // public class Message extends AbstractPost { // @Expose(serialize = false) // private String channelId; // // public Message() {} // // public Message(String text) { // super(text); // } // // public Message(boolean machineOnly) { // super(machineOnly); // } // // public String getChannelId() { // return channelId; // } // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/ResponseEnvelope.java // public class ResponseEnvelope<T extends IAppDotNetObject> implements IAppDotNetObject { // private ResponseMeta meta; // private T data; // // public ResponseMeta getMeta() { // return meta; // } // // public T getData() { // return data; // } // } // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/MessageResponseHandler.java import com.alwaysallthetime.adnlib.data.Message; import com.alwaysallthetime.adnlib.data.ResponseEnvelope; import com.google.gson.reflect.TypeToken; package com.alwaysallthetime.adnlib.response; public abstract class MessageResponseHandler extends AppDotNetResponseEnvelopeHandler<Message> { protected MessageResponseHandler() {
super(new TypeToken<ResponseEnvelope<Message>>(){});
alwaysallthetime/ADNLib
ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/AppDotNetObjectCloner.java
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/IAppDotNetObject.java // public interface IAppDotNetObject {} // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/gson/AppDotNetGson.java // public class AppDotNetGson { // static Gson adapterSafeInstance; // // private static Gson instance; // private static Gson persistenceInstance; // // static { // final GsonBuilder builder = new GsonBuilder() // .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES) // .registerTypeAdapter(Date.class, new Iso8601DateTypeAdapter()); // // persistenceInstance = builder.create(); // // adapterSafeInstance = builder // .addSerializationExclusionStrategy(new IncludeFieldsByDefaultSerializationExclusionStrategy()) // .create(); // // instance = builder // .registerTypeHierarchyAdapter(Annotatable.class, new AnnotatableSerializer()) // .registerTypeAdapter(Count.class, new CountDeserializer()) // .create(); // } // // /** // * A Gson instance for serializing to and deserializing from the App.net API. // * // * Fields that shouldn't be sent to the API are excluded from serialization, e.g. createdAt. // * // * @return a Gson instance // */ // public static Gson getInstance() { // return instance; // } // // /** // * A Gson instance suitable for disk persistence, in that it will serialize and deserialize all fields. // * // * @return a Gson instance // */ // public static Gson getPersistenceInstance() { // return persistenceInstance; // } // // /** // * A Gson instance without certain customer adapters. This allows those adapters to get the "default" serialization // * before modifying it. // * // * @return a Gson instance // */ // static Gson getAdapterSafeInstance() { // return adapterSafeInstance; // } // // private static <T extends IAppDotNetObject> T copy(IAppDotNetObject object, Gson gson) { // final JsonElement json = gson.toJsonTree(object); // return (T) gson.fromJson(json, object.getClass()); // } // // public static <T extends IAppDotNetObject> T copy(IAppDotNetObject object) { // return copy(object, persistenceInstance); // } // // public static <T extends IAppDotNetObject> T copyForWriting(IAppDotNetObject object) { // return copy(object, instance); // } // }
import com.alwaysallthetime.adnlib.data.IAppDotNetObject; import com.alwaysallthetime.adnlib.gson.AppDotNetGson; import com.google.gson.Gson;
package com.alwaysallthetime.adnlib; public class AppDotNetObjectCloner { public static Object getClone(IAppDotNetObject object) {
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/IAppDotNetObject.java // public interface IAppDotNetObject {} // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/gson/AppDotNetGson.java // public class AppDotNetGson { // static Gson adapterSafeInstance; // // private static Gson instance; // private static Gson persistenceInstance; // // static { // final GsonBuilder builder = new GsonBuilder() // .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES) // .registerTypeAdapter(Date.class, new Iso8601DateTypeAdapter()); // // persistenceInstance = builder.create(); // // adapterSafeInstance = builder // .addSerializationExclusionStrategy(new IncludeFieldsByDefaultSerializationExclusionStrategy()) // .create(); // // instance = builder // .registerTypeHierarchyAdapter(Annotatable.class, new AnnotatableSerializer()) // .registerTypeAdapter(Count.class, new CountDeserializer()) // .create(); // } // // /** // * A Gson instance for serializing to and deserializing from the App.net API. // * // * Fields that shouldn't be sent to the API are excluded from serialization, e.g. createdAt. // * // * @return a Gson instance // */ // public static Gson getInstance() { // return instance; // } // // /** // * A Gson instance suitable for disk persistence, in that it will serialize and deserialize all fields. // * // * @return a Gson instance // */ // public static Gson getPersistenceInstance() { // return persistenceInstance; // } // // /** // * A Gson instance without certain customer adapters. This allows those adapters to get the "default" serialization // * before modifying it. // * // * @return a Gson instance // */ // static Gson getAdapterSafeInstance() { // return adapterSafeInstance; // } // // private static <T extends IAppDotNetObject> T copy(IAppDotNetObject object, Gson gson) { // final JsonElement json = gson.toJsonTree(object); // return (T) gson.fromJson(json, object.getClass()); // } // // public static <T extends IAppDotNetObject> T copy(IAppDotNetObject object) { // return copy(object, persistenceInstance); // } // // public static <T extends IAppDotNetObject> T copyForWriting(IAppDotNetObject object) { // return copy(object, instance); // } // } // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/AppDotNetObjectCloner.java import com.alwaysallthetime.adnlib.data.IAppDotNetObject; import com.alwaysallthetime.adnlib.gson.AppDotNetGson; import com.google.gson.Gson; package com.alwaysallthetime.adnlib; public class AppDotNetObjectCloner { public static Object getClone(IAppDotNetObject object) {
Gson gson = AppDotNetGson.getPersistenceInstance();
alwaysallthetime/ADNLib
ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/PlaceResponseHandler.java
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/Place.java // public class Place implements IAppDotNetObject { // protected String factualId; // protected String name; // protected String address; // protected String addressExtended; // protected String locality; // protected String region; // protected String adminRegion; // protected String postTown; // protected String poBox; // protected String postcode; // protected String countryCode; // protected Double latitude; // protected Double longitude; // protected Boolean isOpen; // protected String telephone; // protected String fax; // protected String website; // protected ArrayList<Category> categories; // // public String getFactualId() { // return factualId; // } // // public String getName() { // return name; // } // // public String getAddress() { // return address; // } // // public String getAddressExtended() { // return addressExtended; // } // // public String getLocality() { // return locality; // } // // public String getRegion() { // return region; // } // // public String getAdminRegion() { // return adminRegion; // } // // public String getPostTown() { // return postTown; // } // // public String getPoBox() { // return poBox; // } // // public String getPostcode() { // return postcode; // } // // public String getCountryCode() { // return countryCode; // } // // public Double getLatitude() { // return latitude; // } // // public Double getLongitude() { // return longitude; // } // // public Boolean isOpen() { // return isOpen; // } // // public String getTelephone() { // return telephone; // } // // public String getFax() { // return fax; // } // // public String getWebsite() { // return website; // } // // public ArrayList<Category> getCategories() { // return categories; // } // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/ResponseEnvelope.java // public class ResponseEnvelope<T extends IAppDotNetObject> implements IAppDotNetObject { // private ResponseMeta meta; // private T data; // // public ResponseMeta getMeta() { // return meta; // } // // public T getData() { // return data; // } // }
import com.alwaysallthetime.adnlib.data.Place; import com.alwaysallthetime.adnlib.data.ResponseEnvelope; import com.google.gson.reflect.TypeToken;
package com.alwaysallthetime.adnlib.response; public abstract class PlaceResponseHandler extends AppDotNetResponseEnvelopeHandler<Place> { protected PlaceResponseHandler() {
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/Place.java // public class Place implements IAppDotNetObject { // protected String factualId; // protected String name; // protected String address; // protected String addressExtended; // protected String locality; // protected String region; // protected String adminRegion; // protected String postTown; // protected String poBox; // protected String postcode; // protected String countryCode; // protected Double latitude; // protected Double longitude; // protected Boolean isOpen; // protected String telephone; // protected String fax; // protected String website; // protected ArrayList<Category> categories; // // public String getFactualId() { // return factualId; // } // // public String getName() { // return name; // } // // public String getAddress() { // return address; // } // // public String getAddressExtended() { // return addressExtended; // } // // public String getLocality() { // return locality; // } // // public String getRegion() { // return region; // } // // public String getAdminRegion() { // return adminRegion; // } // // public String getPostTown() { // return postTown; // } // // public String getPoBox() { // return poBox; // } // // public String getPostcode() { // return postcode; // } // // public String getCountryCode() { // return countryCode; // } // // public Double getLatitude() { // return latitude; // } // // public Double getLongitude() { // return longitude; // } // // public Boolean isOpen() { // return isOpen; // } // // public String getTelephone() { // return telephone; // } // // public String getFax() { // return fax; // } // // public String getWebsite() { // return website; // } // // public ArrayList<Category> getCategories() { // return categories; // } // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/ResponseEnvelope.java // public class ResponseEnvelope<T extends IAppDotNetObject> implements IAppDotNetObject { // private ResponseMeta meta; // private T data; // // public ResponseMeta getMeta() { // return meta; // } // // public T getData() { // return data; // } // } // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/PlaceResponseHandler.java import com.alwaysallthetime.adnlib.data.Place; import com.alwaysallthetime.adnlib.data.ResponseEnvelope; import com.google.gson.reflect.TypeToken; package com.alwaysallthetime.adnlib.response; public abstract class PlaceResponseHandler extends AppDotNetResponseEnvelopeHandler<Place> { protected PlaceResponseHandler() {
super(new TypeToken<ResponseEnvelope<Place>>(){});
alwaysallthetime/ADNLib
ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/PostResponseHandler.java
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/Post.java // public class Post extends AbstractPost { // @Expose(serialize = false) // private String canonicalUrl; // @Expose(serialize = false) // private int numStars; // @Expose(serialize = false) // private int numReposts; // @Expose(serialize = false) // private boolean youStarred; // @Expose(serialize = false) // private User[] starredBy; // @Expose(serialize = false) // private boolean youReposted; // @Expose(serialize = false) // private User[] reposters; // @Expose(serialize = false) // private Post repostOf; // // public Post() {} // // public Post(String text) { // super(text); // } // // public Post(boolean machineOnly) { // super(machineOnly); // } // // public String getCanonicalUrl() { // return canonicalUrl; // } // // public int getNumStars() { // return numStars; // } // // public int getNumReposts() { // return numReposts; // } // // public boolean isStarredByYou() { // return youStarred; // } // // public User[] getStarredBy() { // return starredBy; // } // // public boolean isRepostedByYou() { // return youReposted; // } // // public User[] getReposters() { // return reposters; // } // // public Post getRepostOf() { // return repostOf; // } // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/ResponseEnvelope.java // public class ResponseEnvelope<T extends IAppDotNetObject> implements IAppDotNetObject { // private ResponseMeta meta; // private T data; // // public ResponseMeta getMeta() { // return meta; // } // // public T getData() { // return data; // } // }
import com.alwaysallthetime.adnlib.data.Post; import com.alwaysallthetime.adnlib.data.ResponseEnvelope; import com.google.gson.reflect.TypeToken;
package com.alwaysallthetime.adnlib.response; public abstract class PostResponseHandler extends AppDotNetResponseEnvelopeHandler<Post> { protected PostResponseHandler() {
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/Post.java // public class Post extends AbstractPost { // @Expose(serialize = false) // private String canonicalUrl; // @Expose(serialize = false) // private int numStars; // @Expose(serialize = false) // private int numReposts; // @Expose(serialize = false) // private boolean youStarred; // @Expose(serialize = false) // private User[] starredBy; // @Expose(serialize = false) // private boolean youReposted; // @Expose(serialize = false) // private User[] reposters; // @Expose(serialize = false) // private Post repostOf; // // public Post() {} // // public Post(String text) { // super(text); // } // // public Post(boolean machineOnly) { // super(machineOnly); // } // // public String getCanonicalUrl() { // return canonicalUrl; // } // // public int getNumStars() { // return numStars; // } // // public int getNumReposts() { // return numReposts; // } // // public boolean isStarredByYou() { // return youStarred; // } // // public User[] getStarredBy() { // return starredBy; // } // // public boolean isRepostedByYou() { // return youReposted; // } // // public User[] getReposters() { // return reposters; // } // // public Post getRepostOf() { // return repostOf; // } // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/ResponseEnvelope.java // public class ResponseEnvelope<T extends IAppDotNetObject> implements IAppDotNetObject { // private ResponseMeta meta; // private T data; // // public ResponseMeta getMeta() { // return meta; // } // // public T getData() { // return data; // } // } // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/PostResponseHandler.java import com.alwaysallthetime.adnlib.data.Post; import com.alwaysallthetime.adnlib.data.ResponseEnvelope; import com.google.gson.reflect.TypeToken; package com.alwaysallthetime.adnlib.response; public abstract class PostResponseHandler extends AppDotNetResponseEnvelopeHandler<Post> { protected PostResponseHandler() {
super(new TypeToken<ResponseEnvelope<Post>>(){});
alwaysallthetime/ADNLib
ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/FileResponseHandler.java
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/File.java // public class File extends Annotatable { // @Expose(serialize = false) // private boolean complete; // @Expose(serialize = false) // private String createdAt; // @Expose(serialize = false) // private Map<String, DerivedFile> derivedFiles; // @Expose(serialize = false) // private String fileToken; // @Expose(serialize = false) // private boolean fileTokenRead; // @Expose(serialize = false) // private ImageInfo imageInfo; // private String kind; // @Expose(serialize = false) // private String mimeType; // private String name; // @SerializedName("public") // private boolean isPublic; // @Expose(serialize = false) // private String sha1; // @Expose(serialize = false) // private int size; // @Expose(serialize = false) // private Source source; // @Expose(serialize = false) // private int totalSize; // private String type; // @Expose(serialize = false) // private String url; // @Expose(serialize = false) // private String urlExpires; // @Expose(serialize = false) // private String urlPermanent; // @Expose(serialize = false) // private String urlShort; // @Expose(serialize = false) // private User user; // // public File() {} // // public File(String kind, String type, String name, boolean isPublic) { // this.kind = kind; // this.type = type; // this.name = name; // this.isPublic = isPublic; // } // // public boolean isComplete() { // return complete; // } // // public String getCreatedAt() { // return createdAt; // } // // public Map<String, DerivedFile> getDerivedFiles() { // return derivedFiles; // } // // public String getFileToken() { // return fileToken; // } // // public boolean isFileTokenRead() { // return fileTokenRead; // } // // public ImageInfo getImageInfo() { // return imageInfo; // } // // public String getKind() { // return kind; // } // // public String getMimeType() { // return mimeType; // } // // public String getName() { // return name; // } // // public boolean isPublic() { // return isPublic; // } // // public String getSha1() { // return sha1; // } // // public int getSize() { // return size; // } // // public Source getSource() { // return source; // } // // public int getTotalSize() { // return totalSize; // } // // public String getType() { // return type; // } // // public String getUrl() { // return url; // } // // public String getUrlExpires() { // return urlExpires; // } // // public String getUrlPermanent() { // return urlPermanent; // } // // public String getUrlShort() { // return urlShort; // } // // public User getUser() { // return user; // } // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/ResponseEnvelope.java // public class ResponseEnvelope<T extends IAppDotNetObject> implements IAppDotNetObject { // private ResponseMeta meta; // private T data; // // public ResponseMeta getMeta() { // return meta; // } // // public T getData() { // return data; // } // }
import com.alwaysallthetime.adnlib.data.File; import com.alwaysallthetime.adnlib.data.ResponseEnvelope; import com.google.gson.reflect.TypeToken;
package com.alwaysallthetime.adnlib.response; public abstract class FileResponseHandler extends AppDotNetResponseEnvelopeHandler<File> { protected FileResponseHandler() {
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/File.java // public class File extends Annotatable { // @Expose(serialize = false) // private boolean complete; // @Expose(serialize = false) // private String createdAt; // @Expose(serialize = false) // private Map<String, DerivedFile> derivedFiles; // @Expose(serialize = false) // private String fileToken; // @Expose(serialize = false) // private boolean fileTokenRead; // @Expose(serialize = false) // private ImageInfo imageInfo; // private String kind; // @Expose(serialize = false) // private String mimeType; // private String name; // @SerializedName("public") // private boolean isPublic; // @Expose(serialize = false) // private String sha1; // @Expose(serialize = false) // private int size; // @Expose(serialize = false) // private Source source; // @Expose(serialize = false) // private int totalSize; // private String type; // @Expose(serialize = false) // private String url; // @Expose(serialize = false) // private String urlExpires; // @Expose(serialize = false) // private String urlPermanent; // @Expose(serialize = false) // private String urlShort; // @Expose(serialize = false) // private User user; // // public File() {} // // public File(String kind, String type, String name, boolean isPublic) { // this.kind = kind; // this.type = type; // this.name = name; // this.isPublic = isPublic; // } // // public boolean isComplete() { // return complete; // } // // public String getCreatedAt() { // return createdAt; // } // // public Map<String, DerivedFile> getDerivedFiles() { // return derivedFiles; // } // // public String getFileToken() { // return fileToken; // } // // public boolean isFileTokenRead() { // return fileTokenRead; // } // // public ImageInfo getImageInfo() { // return imageInfo; // } // // public String getKind() { // return kind; // } // // public String getMimeType() { // return mimeType; // } // // public String getName() { // return name; // } // // public boolean isPublic() { // return isPublic; // } // // public String getSha1() { // return sha1; // } // // public int getSize() { // return size; // } // // public Source getSource() { // return source; // } // // public int getTotalSize() { // return totalSize; // } // // public String getType() { // return type; // } // // public String getUrl() { // return url; // } // // public String getUrlExpires() { // return urlExpires; // } // // public String getUrlPermanent() { // return urlPermanent; // } // // public String getUrlShort() { // return urlShort; // } // // public User getUser() { // return user; // } // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/ResponseEnvelope.java // public class ResponseEnvelope<T extends IAppDotNetObject> implements IAppDotNetObject { // private ResponseMeta meta; // private T data; // // public ResponseMeta getMeta() { // return meta; // } // // public T getData() { // return data; // } // } // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/FileResponseHandler.java import com.alwaysallthetime.adnlib.data.File; import com.alwaysallthetime.adnlib.data.ResponseEnvelope; import com.google.gson.reflect.TypeToken; package com.alwaysallthetime.adnlib.response; public abstract class FileResponseHandler extends AppDotNetResponseEnvelopeHandler<File> { protected FileResponseHandler() {
super(new TypeToken<ResponseEnvelope<File>>(){});
alwaysallthetime/ADNLib
ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/TokenResponseHandler.java
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/ResponseEnvelope.java // public class ResponseEnvelope<T extends IAppDotNetObject> implements IAppDotNetObject { // private ResponseMeta meta; // private T data; // // public ResponseMeta getMeta() { // return meta; // } // // public T getData() { // return data; // } // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/Token.java // public class Token implements IPageableAppDotNetObject { // private App app; // private String clientId; // private String[] scopes; // private Limits limits; // private Storage storage; // private User user; // private String inviteLink; // private String paginationId; // // public App getApp() { // return app; // } // // public String getClientId() { // return clientId; // } // // public String[] getScopes() { // return scopes; // } // // public Limits getLimits() { // return limits; // } // // public Storage getStorage() { // return storage; // } // // public User getUser() { // return user; // } // // public String getInviteLink() { // return inviteLink; // } // // @Override // public String getPaginationId() { // return paginationId; // } // // public static class Limits { // private int following; // private long maxFileSize; // // protected Limits() { // } // // public int getFollowing() { // return following; // } // // public long getMaxFileSize() { // return maxFileSize; // } // } // // public static class Storage { // private long available; // private long used; // // protected Storage() { // } // // public long getAvailable() { // return available; // } // // public long getUsed() { // return used; // } // } // }
import com.alwaysallthetime.adnlib.data.ResponseEnvelope; import com.alwaysallthetime.adnlib.data.Token; import com.google.gson.reflect.TypeToken;
package com.alwaysallthetime.adnlib.response; public abstract class TokenResponseHandler extends AppDotNetResponseEnvelopeHandler<Token> { protected TokenResponseHandler() {
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/ResponseEnvelope.java // public class ResponseEnvelope<T extends IAppDotNetObject> implements IAppDotNetObject { // private ResponseMeta meta; // private T data; // // public ResponseMeta getMeta() { // return meta; // } // // public T getData() { // return data; // } // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/data/Token.java // public class Token implements IPageableAppDotNetObject { // private App app; // private String clientId; // private String[] scopes; // private Limits limits; // private Storage storage; // private User user; // private String inviteLink; // private String paginationId; // // public App getApp() { // return app; // } // // public String getClientId() { // return clientId; // } // // public String[] getScopes() { // return scopes; // } // // public Limits getLimits() { // return limits; // } // // public Storage getStorage() { // return storage; // } // // public User getUser() { // return user; // } // // public String getInviteLink() { // return inviteLink; // } // // @Override // public String getPaginationId() { // return paginationId; // } // // public static class Limits { // private int following; // private long maxFileSize; // // protected Limits() { // } // // public int getFollowing() { // return following; // } // // public long getMaxFileSize() { // return maxFileSize; // } // } // // public static class Storage { // private long available; // private long used; // // protected Storage() { // } // // public long getAvailable() { // return available; // } // // public long getUsed() { // return used; // } // } // } // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/TokenResponseHandler.java import com.alwaysallthetime.adnlib.data.ResponseEnvelope; import com.alwaysallthetime.adnlib.data.Token; import com.google.gson.reflect.TypeToken; package com.alwaysallthetime.adnlib.response; public abstract class TokenResponseHandler extends AppDotNetResponseEnvelopeHandler<Token> { protected TokenResponseHandler() {
super(new TypeToken<ResponseEnvelope<Token>>(){});
alwaysallthetime/ADNLib
ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/request/AppDotNetRequest.java
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/QueryParameters.java // public class QueryParameters extends HashMap<String, String> { // // very unlikely you'd ever need more than 4 query parameters on one request // private static final int INITIAL_CAPACITY = 4; // private static final float LOAD_FACTOR = 1.0f; // // /** // * Get a new QueryParameters that consists of two sets of QueryParamters combined. // * // * Since it is possible that there will be conflicting parameters, the second set will be applied // * "on top of" the first set, i.e. the topParameters can override the bottomParameters // * // * @param bottomParameters // * @param topParameters // * @return a new QueryParamters consisting of the values form both specified QueryParameters objects. // */ // public static QueryParameters getCombinedParameters(QueryParameters bottomParameters, QueryParameters topParameters) { // QueryParameters newParams = new QueryParameters(); // newParams.putAll(bottomParameters); // newParams.putAll(topParameters); // return newParams; // } // // public QueryParameters() { // this(INITIAL_CAPACITY, LOAD_FACTOR); // } // // protected QueryParameters(int capacity, float loadFactor) { // super(capacity, loadFactor); // } // // public QueryParameters(IQueryParameter... queryParameters) { // super(INITIAL_CAPACITY + queryParameters.length, LOAD_FACTOR); // put(queryParameters); // } // // public void put(IQueryParameter... queryParameters) { // for (IQueryParameter queryParameter : queryParameters) { // put(queryParameter.getName(), queryParameter.getValue()); // } // } // // protected String getCommaDelimitedString(List<String> strings, int bestGuessMaxLength) { // final StringBuilder buffer = new StringBuilder(strings.size() * bestGuessMaxLength); // for(final String str : strings) { // buffer.append(str); // buffer.append(','); // } // // return buffer.substring(0, buffer.length() - 1); // } // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/gson/AppDotNetGson.java // public class AppDotNetGson { // static Gson adapterSafeInstance; // // private static Gson instance; // private static Gson persistenceInstance; // // static { // final GsonBuilder builder = new GsonBuilder() // .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES) // .registerTypeAdapter(Date.class, new Iso8601DateTypeAdapter()); // // persistenceInstance = builder.create(); // // adapterSafeInstance = builder // .addSerializationExclusionStrategy(new IncludeFieldsByDefaultSerializationExclusionStrategy()) // .create(); // // instance = builder // .registerTypeHierarchyAdapter(Annotatable.class, new AnnotatableSerializer()) // .registerTypeAdapter(Count.class, new CountDeserializer()) // .create(); // } // // /** // * A Gson instance for serializing to and deserializing from the App.net API. // * // * Fields that shouldn't be sent to the API are excluded from serialization, e.g. createdAt. // * // * @return a Gson instance // */ // public static Gson getInstance() { // return instance; // } // // /** // * A Gson instance suitable for disk persistence, in that it will serialize and deserialize all fields. // * // * @return a Gson instance // */ // public static Gson getPersistenceInstance() { // return persistenceInstance; // } // // /** // * A Gson instance without certain customer adapters. This allows those adapters to get the "default" serialization // * before modifying it. // * // * @return a Gson instance // */ // static Gson getAdapterSafeInstance() { // return adapterSafeInstance; // } // // private static <T extends IAppDotNetObject> T copy(IAppDotNetObject object, Gson gson) { // final JsonElement json = gson.toJsonTree(object); // return (T) gson.fromJson(json, object.getClass()); // } // // public static <T extends IAppDotNetObject> T copy(IAppDotNetObject object) { // return copy(object, persistenceInstance); // } // // public static <T extends IAppDotNetObject> T copyForWriting(IAppDotNetObject object) { // return copy(object, instance); // } // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/AppDotNetResponseHandler.java // public abstract class AppDotNetResponseHandler<T extends IAppDotNetObject> { // private static final String TAG = "AppDotNetResponseHandler"; // // private final Gson gson; // private final Type responseType; // // // subclasses must call this constructor and initialize responseType since there is no default constructor // protected AppDotNetResponseHandler(TypeToken typeToken) { // gson = AppDotNetGson.getInstance(); // responseType = typeToken.getType(); // } // // protected <T> T parseResponse(Reader reader) { // return gson.fromJson(reader, responseType); // } // // public abstract void handleResponse(Reader reader); // // public abstract void onSuccess(T responseData); // // public void onError(Exception error) { // Log.e(TAG, error.getMessage(), error); // } // }
import android.net.Uri; import android.util.Log; import com.alwaysallthetime.adnlib.QueryParameters; import com.alwaysallthetime.adnlib.gson.AppDotNetGson; import com.alwaysallthetime.adnlib.response.AppDotNetResponseHandler; import com.google.gson.Gson; import java.io.IOException; import java.io.OutputStream; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; import java.util.Map;
package com.alwaysallthetime.adnlib.request; public abstract class AppDotNetRequest { public static final String CONTENT_TYPE_FORM = "application/x-www-form-urlencoded"; public static final String CONTENT_TYPE_JSON = "application/json"; protected static final String HEADER_CONTENT_TYPE = "Content-Type";
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/QueryParameters.java // public class QueryParameters extends HashMap<String, String> { // // very unlikely you'd ever need more than 4 query parameters on one request // private static final int INITIAL_CAPACITY = 4; // private static final float LOAD_FACTOR = 1.0f; // // /** // * Get a new QueryParameters that consists of two sets of QueryParamters combined. // * // * Since it is possible that there will be conflicting parameters, the second set will be applied // * "on top of" the first set, i.e. the topParameters can override the bottomParameters // * // * @param bottomParameters // * @param topParameters // * @return a new QueryParamters consisting of the values form both specified QueryParameters objects. // */ // public static QueryParameters getCombinedParameters(QueryParameters bottomParameters, QueryParameters topParameters) { // QueryParameters newParams = new QueryParameters(); // newParams.putAll(bottomParameters); // newParams.putAll(topParameters); // return newParams; // } // // public QueryParameters() { // this(INITIAL_CAPACITY, LOAD_FACTOR); // } // // protected QueryParameters(int capacity, float loadFactor) { // super(capacity, loadFactor); // } // // public QueryParameters(IQueryParameter... queryParameters) { // super(INITIAL_CAPACITY + queryParameters.length, LOAD_FACTOR); // put(queryParameters); // } // // public void put(IQueryParameter... queryParameters) { // for (IQueryParameter queryParameter : queryParameters) { // put(queryParameter.getName(), queryParameter.getValue()); // } // } // // protected String getCommaDelimitedString(List<String> strings, int bestGuessMaxLength) { // final StringBuilder buffer = new StringBuilder(strings.size() * bestGuessMaxLength); // for(final String str : strings) { // buffer.append(str); // buffer.append(','); // } // // return buffer.substring(0, buffer.length() - 1); // } // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/gson/AppDotNetGson.java // public class AppDotNetGson { // static Gson adapterSafeInstance; // // private static Gson instance; // private static Gson persistenceInstance; // // static { // final GsonBuilder builder = new GsonBuilder() // .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES) // .registerTypeAdapter(Date.class, new Iso8601DateTypeAdapter()); // // persistenceInstance = builder.create(); // // adapterSafeInstance = builder // .addSerializationExclusionStrategy(new IncludeFieldsByDefaultSerializationExclusionStrategy()) // .create(); // // instance = builder // .registerTypeHierarchyAdapter(Annotatable.class, new AnnotatableSerializer()) // .registerTypeAdapter(Count.class, new CountDeserializer()) // .create(); // } // // /** // * A Gson instance for serializing to and deserializing from the App.net API. // * // * Fields that shouldn't be sent to the API are excluded from serialization, e.g. createdAt. // * // * @return a Gson instance // */ // public static Gson getInstance() { // return instance; // } // // /** // * A Gson instance suitable for disk persistence, in that it will serialize and deserialize all fields. // * // * @return a Gson instance // */ // public static Gson getPersistenceInstance() { // return persistenceInstance; // } // // /** // * A Gson instance without certain customer adapters. This allows those adapters to get the "default" serialization // * before modifying it. // * // * @return a Gson instance // */ // static Gson getAdapterSafeInstance() { // return adapterSafeInstance; // } // // private static <T extends IAppDotNetObject> T copy(IAppDotNetObject object, Gson gson) { // final JsonElement json = gson.toJsonTree(object); // return (T) gson.fromJson(json, object.getClass()); // } // // public static <T extends IAppDotNetObject> T copy(IAppDotNetObject object) { // return copy(object, persistenceInstance); // } // // public static <T extends IAppDotNetObject> T copyForWriting(IAppDotNetObject object) { // return copy(object, instance); // } // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/AppDotNetResponseHandler.java // public abstract class AppDotNetResponseHandler<T extends IAppDotNetObject> { // private static final String TAG = "AppDotNetResponseHandler"; // // private final Gson gson; // private final Type responseType; // // // subclasses must call this constructor and initialize responseType since there is no default constructor // protected AppDotNetResponseHandler(TypeToken typeToken) { // gson = AppDotNetGson.getInstance(); // responseType = typeToken.getType(); // } // // protected <T> T parseResponse(Reader reader) { // return gson.fromJson(reader, responseType); // } // // public abstract void handleResponse(Reader reader); // // public abstract void onSuccess(T responseData); // // public void onError(Exception error) { // Log.e(TAG, error.getMessage(), error); // } // } // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/request/AppDotNetRequest.java import android.net.Uri; import android.util.Log; import com.alwaysallthetime.adnlib.QueryParameters; import com.alwaysallthetime.adnlib.gson.AppDotNetGson; import com.alwaysallthetime.adnlib.response.AppDotNetResponseHandler; import com.google.gson.Gson; import java.io.IOException; import java.io.OutputStream; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; import java.util.Map; package com.alwaysallthetime.adnlib.request; public abstract class AppDotNetRequest { public static final String CONTENT_TYPE_FORM = "application/x-www-form-urlencoded"; public static final String CONTENT_TYPE_JSON = "application/json"; protected static final String HEADER_CONTENT_TYPE = "Content-Type";
protected static final Gson gson = AppDotNetGson.getInstance();
alwaysallthetime/ADNLib
ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/request/AppDotNetRequest.java
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/QueryParameters.java // public class QueryParameters extends HashMap<String, String> { // // very unlikely you'd ever need more than 4 query parameters on one request // private static final int INITIAL_CAPACITY = 4; // private static final float LOAD_FACTOR = 1.0f; // // /** // * Get a new QueryParameters that consists of two sets of QueryParamters combined. // * // * Since it is possible that there will be conflicting parameters, the second set will be applied // * "on top of" the first set, i.e. the topParameters can override the bottomParameters // * // * @param bottomParameters // * @param topParameters // * @return a new QueryParamters consisting of the values form both specified QueryParameters objects. // */ // public static QueryParameters getCombinedParameters(QueryParameters bottomParameters, QueryParameters topParameters) { // QueryParameters newParams = new QueryParameters(); // newParams.putAll(bottomParameters); // newParams.putAll(topParameters); // return newParams; // } // // public QueryParameters() { // this(INITIAL_CAPACITY, LOAD_FACTOR); // } // // protected QueryParameters(int capacity, float loadFactor) { // super(capacity, loadFactor); // } // // public QueryParameters(IQueryParameter... queryParameters) { // super(INITIAL_CAPACITY + queryParameters.length, LOAD_FACTOR); // put(queryParameters); // } // // public void put(IQueryParameter... queryParameters) { // for (IQueryParameter queryParameter : queryParameters) { // put(queryParameter.getName(), queryParameter.getValue()); // } // } // // protected String getCommaDelimitedString(List<String> strings, int bestGuessMaxLength) { // final StringBuilder buffer = new StringBuilder(strings.size() * bestGuessMaxLength); // for(final String str : strings) { // buffer.append(str); // buffer.append(','); // } // // return buffer.substring(0, buffer.length() - 1); // } // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/gson/AppDotNetGson.java // public class AppDotNetGson { // static Gson adapterSafeInstance; // // private static Gson instance; // private static Gson persistenceInstance; // // static { // final GsonBuilder builder = new GsonBuilder() // .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES) // .registerTypeAdapter(Date.class, new Iso8601DateTypeAdapter()); // // persistenceInstance = builder.create(); // // adapterSafeInstance = builder // .addSerializationExclusionStrategy(new IncludeFieldsByDefaultSerializationExclusionStrategy()) // .create(); // // instance = builder // .registerTypeHierarchyAdapter(Annotatable.class, new AnnotatableSerializer()) // .registerTypeAdapter(Count.class, new CountDeserializer()) // .create(); // } // // /** // * A Gson instance for serializing to and deserializing from the App.net API. // * // * Fields that shouldn't be sent to the API are excluded from serialization, e.g. createdAt. // * // * @return a Gson instance // */ // public static Gson getInstance() { // return instance; // } // // /** // * A Gson instance suitable for disk persistence, in that it will serialize and deserialize all fields. // * // * @return a Gson instance // */ // public static Gson getPersistenceInstance() { // return persistenceInstance; // } // // /** // * A Gson instance without certain customer adapters. This allows those adapters to get the "default" serialization // * before modifying it. // * // * @return a Gson instance // */ // static Gson getAdapterSafeInstance() { // return adapterSafeInstance; // } // // private static <T extends IAppDotNetObject> T copy(IAppDotNetObject object, Gson gson) { // final JsonElement json = gson.toJsonTree(object); // return (T) gson.fromJson(json, object.getClass()); // } // // public static <T extends IAppDotNetObject> T copy(IAppDotNetObject object) { // return copy(object, persistenceInstance); // } // // public static <T extends IAppDotNetObject> T copyForWriting(IAppDotNetObject object) { // return copy(object, instance); // } // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/AppDotNetResponseHandler.java // public abstract class AppDotNetResponseHandler<T extends IAppDotNetObject> { // private static final String TAG = "AppDotNetResponseHandler"; // // private final Gson gson; // private final Type responseType; // // // subclasses must call this constructor and initialize responseType since there is no default constructor // protected AppDotNetResponseHandler(TypeToken typeToken) { // gson = AppDotNetGson.getInstance(); // responseType = typeToken.getType(); // } // // protected <T> T parseResponse(Reader reader) { // return gson.fromJson(reader, responseType); // } // // public abstract void handleResponse(Reader reader); // // public abstract void onSuccess(T responseData); // // public void onError(Exception error) { // Log.e(TAG, error.getMessage(), error); // } // }
import android.net.Uri; import android.util.Log; import com.alwaysallthetime.adnlib.QueryParameters; import com.alwaysallthetime.adnlib.gson.AppDotNetGson; import com.alwaysallthetime.adnlib.response.AppDotNetResponseHandler; import com.google.gson.Gson; import java.io.IOException; import java.io.OutputStream; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; import java.util.Map;
package com.alwaysallthetime.adnlib.request; public abstract class AppDotNetRequest { public static final String CONTENT_TYPE_FORM = "application/x-www-form-urlencoded"; public static final String CONTENT_TYPE_JSON = "application/json"; protected static final String HEADER_CONTENT_TYPE = "Content-Type"; protected static final Gson gson = AppDotNetGson.getInstance(); private static final String TAG = "AppDotNetRequest"; protected URL url;
// Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/QueryParameters.java // public class QueryParameters extends HashMap<String, String> { // // very unlikely you'd ever need more than 4 query parameters on one request // private static final int INITIAL_CAPACITY = 4; // private static final float LOAD_FACTOR = 1.0f; // // /** // * Get a new QueryParameters that consists of two sets of QueryParamters combined. // * // * Since it is possible that there will be conflicting parameters, the second set will be applied // * "on top of" the first set, i.e. the topParameters can override the bottomParameters // * // * @param bottomParameters // * @param topParameters // * @return a new QueryParamters consisting of the values form both specified QueryParameters objects. // */ // public static QueryParameters getCombinedParameters(QueryParameters bottomParameters, QueryParameters topParameters) { // QueryParameters newParams = new QueryParameters(); // newParams.putAll(bottomParameters); // newParams.putAll(topParameters); // return newParams; // } // // public QueryParameters() { // this(INITIAL_CAPACITY, LOAD_FACTOR); // } // // protected QueryParameters(int capacity, float loadFactor) { // super(capacity, loadFactor); // } // // public QueryParameters(IQueryParameter... queryParameters) { // super(INITIAL_CAPACITY + queryParameters.length, LOAD_FACTOR); // put(queryParameters); // } // // public void put(IQueryParameter... queryParameters) { // for (IQueryParameter queryParameter : queryParameters) { // put(queryParameter.getName(), queryParameter.getValue()); // } // } // // protected String getCommaDelimitedString(List<String> strings, int bestGuessMaxLength) { // final StringBuilder buffer = new StringBuilder(strings.size() * bestGuessMaxLength); // for(final String str : strings) { // buffer.append(str); // buffer.append(','); // } // // return buffer.substring(0, buffer.length() - 1); // } // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/gson/AppDotNetGson.java // public class AppDotNetGson { // static Gson adapterSafeInstance; // // private static Gson instance; // private static Gson persistenceInstance; // // static { // final GsonBuilder builder = new GsonBuilder() // .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES) // .registerTypeAdapter(Date.class, new Iso8601DateTypeAdapter()); // // persistenceInstance = builder.create(); // // adapterSafeInstance = builder // .addSerializationExclusionStrategy(new IncludeFieldsByDefaultSerializationExclusionStrategy()) // .create(); // // instance = builder // .registerTypeHierarchyAdapter(Annotatable.class, new AnnotatableSerializer()) // .registerTypeAdapter(Count.class, new CountDeserializer()) // .create(); // } // // /** // * A Gson instance for serializing to and deserializing from the App.net API. // * // * Fields that shouldn't be sent to the API are excluded from serialization, e.g. createdAt. // * // * @return a Gson instance // */ // public static Gson getInstance() { // return instance; // } // // /** // * A Gson instance suitable for disk persistence, in that it will serialize and deserialize all fields. // * // * @return a Gson instance // */ // public static Gson getPersistenceInstance() { // return persistenceInstance; // } // // /** // * A Gson instance without certain customer adapters. This allows those adapters to get the "default" serialization // * before modifying it. // * // * @return a Gson instance // */ // static Gson getAdapterSafeInstance() { // return adapterSafeInstance; // } // // private static <T extends IAppDotNetObject> T copy(IAppDotNetObject object, Gson gson) { // final JsonElement json = gson.toJsonTree(object); // return (T) gson.fromJson(json, object.getClass()); // } // // public static <T extends IAppDotNetObject> T copy(IAppDotNetObject object) { // return copy(object, persistenceInstance); // } // // public static <T extends IAppDotNetObject> T copyForWriting(IAppDotNetObject object) { // return copy(object, instance); // } // } // // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/response/AppDotNetResponseHandler.java // public abstract class AppDotNetResponseHandler<T extends IAppDotNetObject> { // private static final String TAG = "AppDotNetResponseHandler"; // // private final Gson gson; // private final Type responseType; // // // subclasses must call this constructor and initialize responseType since there is no default constructor // protected AppDotNetResponseHandler(TypeToken typeToken) { // gson = AppDotNetGson.getInstance(); // responseType = typeToken.getType(); // } // // protected <T> T parseResponse(Reader reader) { // return gson.fromJson(reader, responseType); // } // // public abstract void handleResponse(Reader reader); // // public abstract void onSuccess(T responseData); // // public void onError(Exception error) { // Log.e(TAG, error.getMessage(), error); // } // } // Path: ADNLibModule/src/main/java/com/alwaysallthetime/adnlib/request/AppDotNetRequest.java import android.net.Uri; import android.util.Log; import com.alwaysallthetime.adnlib.QueryParameters; import com.alwaysallthetime.adnlib.gson.AppDotNetGson; import com.alwaysallthetime.adnlib.response.AppDotNetResponseHandler; import com.google.gson.Gson; import java.io.IOException; import java.io.OutputStream; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; import java.util.Map; package com.alwaysallthetime.adnlib.request; public abstract class AppDotNetRequest { public static final String CONTENT_TYPE_FORM = "application/x-www-form-urlencoded"; public static final String CONTENT_TYPE_JSON = "application/json"; protected static final String HEADER_CONTENT_TYPE = "Content-Type"; protected static final Gson gson = AppDotNetGson.getInstance(); private static final String TAG = "AppDotNetRequest"; protected URL url;
protected AppDotNetResponseHandler handler;
edgware/edgware
fabric.lib/src/fabric/registry/impl/AbstractFactory.java
// Path: fabric.lib/src/fabric/registry/exception/PersistenceException.java // public class PersistenceException extends Exception { // // /** Copyright notice. */ // public static final String copyrightNotice = "(C) Copyright IBM Corp. 2009"; // // private static final long serialVersionUID = 1L; // // private String errorMessage = null; // private int errorCode = 0; // private String sqlState = null; // // /** // * // */ // public PersistenceException() { // } // // /** // * // * @param msg // */ // public PersistenceException(String msg) { // super(msg); // } // // /** // * // * @param detailMessage // * @param throwable // */ // public PersistenceException(String detailMessage, Throwable throwable) { // super(detailMessage, throwable); // } // // /** // * // * @param throwable // */ // public PersistenceException(Throwable throwable) { // super(throwable); // } // // /** // * // * @param message // * @param errorMessage // * @param errorCode // * @param sqlState // */ // public PersistenceException(String message, String errorMessage, int errorCode, String sqlState) { // super(message); // // this.errorMessage = errorMessage; // this.errorCode = errorCode; // this.sqlState = sqlState; // } // // /** // * // * @return // */ // public int getErrorCode() { // return errorCode; // } // // /** // * // * @param errorCode // */ // public void setErrorCode(int errorCode) { // this.errorCode = errorCode; // } // // /** // * // * @return // */ // public String getErrorMessage() { // return errorMessage; // } // // /** // * // * @param errorMessage // */ // public void setErrorMessage(String errorMessage) { // this.errorMessage = errorMessage; // } // // /** // * // * @return // */ // public String getSqlState() { // return sqlState; // } // // /** // * // * @param sqlState // */ // public void setSqlState(String sqlState) { // this.sqlState = sqlState; // } // }
import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.StringTokenizer; import java.util.logging.Level; import java.util.logging.Logger; import fabric.Fabric; import fabric.registry.QueryScope; import fabric.registry.RegistryObject; import fabric.registry.exception.DuplicateKeyException; import fabric.registry.exception.IncompleteObjectException; import fabric.registry.exception.MalformedPredicateException; import fabric.registry.exception.PersistenceException; import fabric.registry.persistence.IPersistenceResultRow; import fabric.registry.persistence.PersistenceManager;
/* * (C) Copyright IBM Corp. 2009, 2012 * * LICENSE: Eclipse Public License v1.0 * http://www.eclipse.org/legal/epl-v10.html */ package fabric.registry.impl; /** */ public abstract class AbstractFactory extends Fabric { public AbstractFactory() { super(Logger.getLogger("fabric.registry")); } /** Copyright notice. */ public static final String copyrightNotice = "(C) Copyright IBM Corp. 2009, 2012"; /* Indicates if queries are to be local or distributed */ protected QueryScope queryScope = QueryScope.DISTRIBUTED; /* * Abstract methods */ /** * Get the INSERT SQL statement which is particular to a given registry object. */ public abstract String getInsertSql(RegistryObject obj); /** * * Get the UPDATE SQL statement which is particular to a given registry object. * * @param obj * @return */ public abstract String getUpdateSql(RegistryObject obj); /** * * Get the DELETE SQL statement which is particular to a given registry object. * * @param obj * @return */ public abstract String getDeleteSql(RegistryObject obj); /** * * @param rs * @return * @throws PersistenceException */
// Path: fabric.lib/src/fabric/registry/exception/PersistenceException.java // public class PersistenceException extends Exception { // // /** Copyright notice. */ // public static final String copyrightNotice = "(C) Copyright IBM Corp. 2009"; // // private static final long serialVersionUID = 1L; // // private String errorMessage = null; // private int errorCode = 0; // private String sqlState = null; // // /** // * // */ // public PersistenceException() { // } // // /** // * // * @param msg // */ // public PersistenceException(String msg) { // super(msg); // } // // /** // * // * @param detailMessage // * @param throwable // */ // public PersistenceException(String detailMessage, Throwable throwable) { // super(detailMessage, throwable); // } // // /** // * // * @param throwable // */ // public PersistenceException(Throwable throwable) { // super(throwable); // } // // /** // * // * @param message // * @param errorMessage // * @param errorCode // * @param sqlState // */ // public PersistenceException(String message, String errorMessage, int errorCode, String sqlState) { // super(message); // // this.errorMessage = errorMessage; // this.errorCode = errorCode; // this.sqlState = sqlState; // } // // /** // * // * @return // */ // public int getErrorCode() { // return errorCode; // } // // /** // * // * @param errorCode // */ // public void setErrorCode(int errorCode) { // this.errorCode = errorCode; // } // // /** // * // * @return // */ // public String getErrorMessage() { // return errorMessage; // } // // /** // * // * @param errorMessage // */ // public void setErrorMessage(String errorMessage) { // this.errorMessage = errorMessage; // } // // /** // * // * @return // */ // public String getSqlState() { // return sqlState; // } // // /** // * // * @param sqlState // */ // public void setSqlState(String sqlState) { // this.sqlState = sqlState; // } // } // Path: fabric.lib/src/fabric/registry/impl/AbstractFactory.java import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.StringTokenizer; import java.util.logging.Level; import java.util.logging.Logger; import fabric.Fabric; import fabric.registry.QueryScope; import fabric.registry.RegistryObject; import fabric.registry.exception.DuplicateKeyException; import fabric.registry.exception.IncompleteObjectException; import fabric.registry.exception.MalformedPredicateException; import fabric.registry.exception.PersistenceException; import fabric.registry.persistence.IPersistenceResultRow; import fabric.registry.persistence.PersistenceManager; /* * (C) Copyright IBM Corp. 2009, 2012 * * LICENSE: Eclipse Public License v1.0 * http://www.eclipse.org/legal/epl-v10.html */ package fabric.registry.impl; /** */ public abstract class AbstractFactory extends Fabric { public AbstractFactory() { super(Logger.getLogger("fabric.registry")); } /** Copyright notice. */ public static final String copyrightNotice = "(C) Copyright IBM Corp. 2009, 2012"; /* Indicates if queries are to be local or distributed */ protected QueryScope queryScope = QueryScope.DISTRIBUTED; /* * Abstract methods */ /** * Get the INSERT SQL statement which is particular to a given registry object. */ public abstract String getInsertSql(RegistryObject obj); /** * * Get the UPDATE SQL statement which is particular to a given registry object. * * @param obj * @return */ public abstract String getUpdateSql(RegistryObject obj); /** * * Get the DELETE SQL statement which is particular to a given registry object. * * @param obj * @return */ public abstract String getDeleteSql(RegistryObject obj); /** * * @param rs * @return * @throws PersistenceException */
public abstract RegistryObject create(IPersistenceResultRow row) throws PersistenceException;
edgware/edgware
fabric.lib/src/fabric/registry/impl/TaskSubscriptionFactoryImpl.java
// Path: fabric.lib/src/fabric/registry/exception/PersistenceException.java // public class PersistenceException extends Exception { // // /** Copyright notice. */ // public static final String copyrightNotice = "(C) Copyright IBM Corp. 2009"; // // private static final long serialVersionUID = 1L; // // private String errorMessage = null; // private int errorCode = 0; // private String sqlState = null; // // /** // * // */ // public PersistenceException() { // } // // /** // * // * @param msg // */ // public PersistenceException(String msg) { // super(msg); // } // // /** // * // * @param detailMessage // * @param throwable // */ // public PersistenceException(String detailMessage, Throwable throwable) { // super(detailMessage, throwable); // } // // /** // * // * @param throwable // */ // public PersistenceException(Throwable throwable) { // super(throwable); // } // // /** // * // * @param message // * @param errorMessage // * @param errorCode // * @param sqlState // */ // public PersistenceException(String message, String errorMessage, int errorCode, String sqlState) { // super(message); // // this.errorMessage = errorMessage; // this.errorCode = errorCode; // this.sqlState = sqlState; // } // // /** // * // * @return // */ // public int getErrorCode() { // return errorCode; // } // // /** // * // * @param errorCode // */ // public void setErrorCode(int errorCode) { // this.errorCode = errorCode; // } // // /** // * // * @return // */ // public String getErrorMessage() { // return errorMessage; // } // // /** // * // * @param errorMessage // */ // public void setErrorMessage(String errorMessage) { // this.errorMessage = errorMessage; // } // // /** // * // * @return // */ // public String getSqlState() { // return sqlState; // } // // /** // * // * @param sqlState // */ // public void setSqlState(String sqlState) { // this.sqlState = sqlState; // } // }
import fabric.registry.FabricRegistry; import fabric.registry.QueryScope; import fabric.registry.RegistryObject; import fabric.registry.TaskSubscription; import fabric.registry.TaskSubscriptionFactory; import fabric.registry.exception.DuplicateKeyException; import fabric.registry.exception.IncompleteObjectException; import fabric.registry.exception.PersistenceException; import fabric.registry.exception.RegistryQueryException; import fabric.registry.persistence.IPersistenceResultRow; import fabric.registry.persistence.PersistenceManager;
/* * (C) Copyright IBM Corp. 2009 * * LICENSE: Eclipse Public License v1.0 * http://www.eclipse.org/legal/epl-v10.html */ package fabric.registry.impl; /** * Implementation of the factory for <code>TaskSubscription</code>s. */ public class TaskSubscriptionFactoryImpl extends AbstractFactory implements TaskSubscriptionFactory { /** Copyright notice. */ public static final String copyrightNotice = "(C) Copyright IBM Corp. 2009"; /* * Class constants */ /** Factory for local (singleton) Registry operations */ private static TaskSubscriptionFactoryImpl localQueryInstance = null; /** Factory for distributed (Gaian) Registry operations */ private static TaskSubscriptionFactoryImpl remoteQueryInstance = null; /* * Queries */ /** Select records using an arbitrary WHERE clause */ private String PREDICATE_QUERY = null; /** Select all records */ private String SELECT_ALL_TASK_ACTORS = null; /** Select all records for a particular task Id */ private String SELECT_SUBSCRIPTIONS_BY_TASK = null; /** Delete records for a particular task ID */ private static String DELETE_SUBSCRIPTIONS_BY_TASK = "delete from " + FabricRegistry.TASK_SUBSCRIPTIONS + " where TASK_ID='%s'"; /* * Static initialisation */ static { localQueryInstance = new TaskSubscriptionFactoryImpl(QueryScope.LOCAL); remoteQueryInstance = new TaskSubscriptionFactoryImpl(QueryScope.DISTRIBUTED); } private TaskSubscriptionFactoryImpl(QueryScope queryScope) { this.queryScope = queryScope; PREDICATE_QUERY = format("select * from %s where \\%s", FabricRegistry.TASK_SUBSCRIPTIONS); SELECT_ALL_TASK_ACTORS = format("select * from %s", FabricRegistry.TASK_SUBSCRIPTIONS); SELECT_SUBSCRIPTIONS_BY_TASK = format("select * from %s where TASK_ID='\\%s'", FabricRegistry.TASK_SUBSCRIPTIONS); } public static TaskSubscriptionFactoryImpl getInstance(QueryScope queryScope) { if (queryScope == QueryScope.LOCAL) { return localQueryInstance; } else { return remoteQueryInstance; } } @Override
// Path: fabric.lib/src/fabric/registry/exception/PersistenceException.java // public class PersistenceException extends Exception { // // /** Copyright notice. */ // public static final String copyrightNotice = "(C) Copyright IBM Corp. 2009"; // // private static final long serialVersionUID = 1L; // // private String errorMessage = null; // private int errorCode = 0; // private String sqlState = null; // // /** // * // */ // public PersistenceException() { // } // // /** // * // * @param msg // */ // public PersistenceException(String msg) { // super(msg); // } // // /** // * // * @param detailMessage // * @param throwable // */ // public PersistenceException(String detailMessage, Throwable throwable) { // super(detailMessage, throwable); // } // // /** // * // * @param throwable // */ // public PersistenceException(Throwable throwable) { // super(throwable); // } // // /** // * // * @param message // * @param errorMessage // * @param errorCode // * @param sqlState // */ // public PersistenceException(String message, String errorMessage, int errorCode, String sqlState) { // super(message); // // this.errorMessage = errorMessage; // this.errorCode = errorCode; // this.sqlState = sqlState; // } // // /** // * // * @return // */ // public int getErrorCode() { // return errorCode; // } // // /** // * // * @param errorCode // */ // public void setErrorCode(int errorCode) { // this.errorCode = errorCode; // } // // /** // * // * @return // */ // public String getErrorMessage() { // return errorMessage; // } // // /** // * // * @param errorMessage // */ // public void setErrorMessage(String errorMessage) { // this.errorMessage = errorMessage; // } // // /** // * // * @return // */ // public String getSqlState() { // return sqlState; // } // // /** // * // * @param sqlState // */ // public void setSqlState(String sqlState) { // this.sqlState = sqlState; // } // } // Path: fabric.lib/src/fabric/registry/impl/TaskSubscriptionFactoryImpl.java import fabric.registry.FabricRegistry; import fabric.registry.QueryScope; import fabric.registry.RegistryObject; import fabric.registry.TaskSubscription; import fabric.registry.TaskSubscriptionFactory; import fabric.registry.exception.DuplicateKeyException; import fabric.registry.exception.IncompleteObjectException; import fabric.registry.exception.PersistenceException; import fabric.registry.exception.RegistryQueryException; import fabric.registry.persistence.IPersistenceResultRow; import fabric.registry.persistence.PersistenceManager; /* * (C) Copyright IBM Corp. 2009 * * LICENSE: Eclipse Public License v1.0 * http://www.eclipse.org/legal/epl-v10.html */ package fabric.registry.impl; /** * Implementation of the factory for <code>TaskSubscription</code>s. */ public class TaskSubscriptionFactoryImpl extends AbstractFactory implements TaskSubscriptionFactory { /** Copyright notice. */ public static final String copyrightNotice = "(C) Copyright IBM Corp. 2009"; /* * Class constants */ /** Factory for local (singleton) Registry operations */ private static TaskSubscriptionFactoryImpl localQueryInstance = null; /** Factory for distributed (Gaian) Registry operations */ private static TaskSubscriptionFactoryImpl remoteQueryInstance = null; /* * Queries */ /** Select records using an arbitrary WHERE clause */ private String PREDICATE_QUERY = null; /** Select all records */ private String SELECT_ALL_TASK_ACTORS = null; /** Select all records for a particular task Id */ private String SELECT_SUBSCRIPTIONS_BY_TASK = null; /** Delete records for a particular task ID */ private static String DELETE_SUBSCRIPTIONS_BY_TASK = "delete from " + FabricRegistry.TASK_SUBSCRIPTIONS + " where TASK_ID='%s'"; /* * Static initialisation */ static { localQueryInstance = new TaskSubscriptionFactoryImpl(QueryScope.LOCAL); remoteQueryInstance = new TaskSubscriptionFactoryImpl(QueryScope.DISTRIBUTED); } private TaskSubscriptionFactoryImpl(QueryScope queryScope) { this.queryScope = queryScope; PREDICATE_QUERY = format("select * from %s where \\%s", FabricRegistry.TASK_SUBSCRIPTIONS); SELECT_ALL_TASK_ACTORS = format("select * from %s", FabricRegistry.TASK_SUBSCRIPTIONS); SELECT_SUBSCRIPTIONS_BY_TASK = format("select * from %s where TASK_ID='\\%s'", FabricRegistry.TASK_SUBSCRIPTIONS); } public static TaskSubscriptionFactoryImpl getInstance(QueryScope queryScope) { if (queryScope == QueryScope.LOCAL) { return localQueryInstance; } else { return remoteQueryInstance; } } @Override
public RegistryObject create(IPersistenceResultRow row) throws PersistenceException {
edgware/edgware
fabric.lib/src/fabric/registry/impl/DefaultConfigFactoryImpl.java
// Path: fabric.lib/src/fabric/registry/exception/PersistenceException.java // public class PersistenceException extends Exception { // // /** Copyright notice. */ // public static final String copyrightNotice = "(C) Copyright IBM Corp. 2009"; // // private static final long serialVersionUID = 1L; // // private String errorMessage = null; // private int errorCode = 0; // private String sqlState = null; // // /** // * // */ // public PersistenceException() { // } // // /** // * // * @param msg // */ // public PersistenceException(String msg) { // super(msg); // } // // /** // * // * @param detailMessage // * @param throwable // */ // public PersistenceException(String detailMessage, Throwable throwable) { // super(detailMessage, throwable); // } // // /** // * // * @param throwable // */ // public PersistenceException(Throwable throwable) { // super(throwable); // } // // /** // * // * @param message // * @param errorMessage // * @param errorCode // * @param sqlState // */ // public PersistenceException(String message, String errorMessage, int errorCode, String sqlState) { // super(message); // // this.errorMessage = errorMessage; // this.errorCode = errorCode; // this.sqlState = sqlState; // } // // /** // * // * @return // */ // public int getErrorCode() { // return errorCode; // } // // /** // * // * @param errorCode // */ // public void setErrorCode(int errorCode) { // this.errorCode = errorCode; // } // // /** // * // * @return // */ // public String getErrorMessage() { // return errorMessage; // } // // /** // * // * @param errorMessage // */ // public void setErrorMessage(String errorMessage) { // this.errorMessage = errorMessage; // } // // /** // * // * @return // */ // public String getSqlState() { // return sqlState; // } // // /** // * // * @param sqlState // */ // public void setSqlState(String sqlState) { // this.sqlState = sqlState; // } // }
import fabric.registry.DefaultConfig; import fabric.registry.DefaultConfigFactory; import fabric.registry.FabricRegistry; import fabric.registry.QueryScope; import fabric.registry.RegistryObject; import fabric.registry.exception.DuplicateKeyException; import fabric.registry.exception.IncompleteObjectException; import fabric.registry.exception.PersistenceException; import fabric.registry.exception.RegistryQueryException; import fabric.registry.persistence.IPersistenceResultRow;
/* * (C) Copyright IBM Corp. 2014 * * LICENSE: Eclipse Public License v1.0 * http://www.eclipse.org/legal/epl-v10.html */ package fabric.registry.impl; /** * Implementation of the factory for <code>DefaultConfig</code>s. */ public class DefaultConfigFactoryImpl extends AbstractFactory implements DefaultConfigFactory { /** Copyright notice. */ public static final String copyrightNotice = "(C) Copyright IBM Corp. 2014"; /** Factory for centralised (singleton) Registry operations */ private static DefaultConfigFactoryImpl localQueryInstance = null; /** Factory for distributed (gaian) Registry operations */ private static DefaultConfigFactoryImpl remoteQueryInstance = null; /* * Queries */ /** Select all records */ private String SELECT_ALL_QUERY = null; /** Select records by name */ private String BY_NAME_QUERY = null; /** Select records using an arbitrary WHERE clause */ private String PREDICATE_QUERY = null; static { localQueryInstance = new DefaultConfigFactoryImpl(QueryScope.LOCAL); remoteQueryInstance = new DefaultConfigFactoryImpl(QueryScope.DISTRIBUTED); } public static DefaultConfigFactory getInstance(QueryScope queryScope) { if (queryScope == QueryScope.LOCAL) { return localQueryInstance; } else { return remoteQueryInstance; } } private DefaultConfigFactoryImpl(QueryScope queryScope) { this.queryScope = queryScope; SELECT_ALL_QUERY = format("select * from %s", FabricRegistry.DEFAULT_CONFIG); BY_NAME_QUERY = format("select * from %s where NAME='\\%s'", FabricRegistry.DEFAULT_CONFIG); PREDICATE_QUERY = format("select * from %s where \\%s", FabricRegistry.DEFAULT_CONFIG); } /* * (non-Javadoc) * @see fabric.registry.impl.AbstractFactory#create(java.sql.ResultSet) */ @Override
// Path: fabric.lib/src/fabric/registry/exception/PersistenceException.java // public class PersistenceException extends Exception { // // /** Copyright notice. */ // public static final String copyrightNotice = "(C) Copyright IBM Corp. 2009"; // // private static final long serialVersionUID = 1L; // // private String errorMessage = null; // private int errorCode = 0; // private String sqlState = null; // // /** // * // */ // public PersistenceException() { // } // // /** // * // * @param msg // */ // public PersistenceException(String msg) { // super(msg); // } // // /** // * // * @param detailMessage // * @param throwable // */ // public PersistenceException(String detailMessage, Throwable throwable) { // super(detailMessage, throwable); // } // // /** // * // * @param throwable // */ // public PersistenceException(Throwable throwable) { // super(throwable); // } // // /** // * // * @param message // * @param errorMessage // * @param errorCode // * @param sqlState // */ // public PersistenceException(String message, String errorMessage, int errorCode, String sqlState) { // super(message); // // this.errorMessage = errorMessage; // this.errorCode = errorCode; // this.sqlState = sqlState; // } // // /** // * // * @return // */ // public int getErrorCode() { // return errorCode; // } // // /** // * // * @param errorCode // */ // public void setErrorCode(int errorCode) { // this.errorCode = errorCode; // } // // /** // * // * @return // */ // public String getErrorMessage() { // return errorMessage; // } // // /** // * // * @param errorMessage // */ // public void setErrorMessage(String errorMessage) { // this.errorMessage = errorMessage; // } // // /** // * // * @return // */ // public String getSqlState() { // return sqlState; // } // // /** // * // * @param sqlState // */ // public void setSqlState(String sqlState) { // this.sqlState = sqlState; // } // } // Path: fabric.lib/src/fabric/registry/impl/DefaultConfigFactoryImpl.java import fabric.registry.DefaultConfig; import fabric.registry.DefaultConfigFactory; import fabric.registry.FabricRegistry; import fabric.registry.QueryScope; import fabric.registry.RegistryObject; import fabric.registry.exception.DuplicateKeyException; import fabric.registry.exception.IncompleteObjectException; import fabric.registry.exception.PersistenceException; import fabric.registry.exception.RegistryQueryException; import fabric.registry.persistence.IPersistenceResultRow; /* * (C) Copyright IBM Corp. 2014 * * LICENSE: Eclipse Public License v1.0 * http://www.eclipse.org/legal/epl-v10.html */ package fabric.registry.impl; /** * Implementation of the factory for <code>DefaultConfig</code>s. */ public class DefaultConfigFactoryImpl extends AbstractFactory implements DefaultConfigFactory { /** Copyright notice. */ public static final String copyrightNotice = "(C) Copyright IBM Corp. 2014"; /** Factory for centralised (singleton) Registry operations */ private static DefaultConfigFactoryImpl localQueryInstance = null; /** Factory for distributed (gaian) Registry operations */ private static DefaultConfigFactoryImpl remoteQueryInstance = null; /* * Queries */ /** Select all records */ private String SELECT_ALL_QUERY = null; /** Select records by name */ private String BY_NAME_QUERY = null; /** Select records using an arbitrary WHERE clause */ private String PREDICATE_QUERY = null; static { localQueryInstance = new DefaultConfigFactoryImpl(QueryScope.LOCAL); remoteQueryInstance = new DefaultConfigFactoryImpl(QueryScope.DISTRIBUTED); } public static DefaultConfigFactory getInstance(QueryScope queryScope) { if (queryScope == QueryScope.LOCAL) { return localQueryInstance; } else { return remoteQueryInstance; } } private DefaultConfigFactoryImpl(QueryScope queryScope) { this.queryScope = queryScope; SELECT_ALL_QUERY = format("select * from %s", FabricRegistry.DEFAULT_CONFIG); BY_NAME_QUERY = format("select * from %s where NAME='\\%s'", FabricRegistry.DEFAULT_CONFIG); PREDICATE_QUERY = format("select * from %s where \\%s", FabricRegistry.DEFAULT_CONFIG); } /* * (non-Javadoc) * @see fabric.registry.impl.AbstractFactory#create(java.sql.ResultSet) */ @Override
public RegistryObject create(IPersistenceResultRow row) throws PersistenceException {
edgware/edgware
fabric.lib/src/fabric/registry/impl/TaskFactoryImpl.java
// Path: fabric.lib/src/fabric/registry/exception/PersistenceException.java // public class PersistenceException extends Exception { // // /** Copyright notice. */ // public static final String copyrightNotice = "(C) Copyright IBM Corp. 2009"; // // private static final long serialVersionUID = 1L; // // private String errorMessage = null; // private int errorCode = 0; // private String sqlState = null; // // /** // * // */ // public PersistenceException() { // } // // /** // * // * @param msg // */ // public PersistenceException(String msg) { // super(msg); // } // // /** // * // * @param detailMessage // * @param throwable // */ // public PersistenceException(String detailMessage, Throwable throwable) { // super(detailMessage, throwable); // } // // /** // * // * @param throwable // */ // public PersistenceException(Throwable throwable) { // super(throwable); // } // // /** // * // * @param message // * @param errorMessage // * @param errorCode // * @param sqlState // */ // public PersistenceException(String message, String errorMessage, int errorCode, String sqlState) { // super(message); // // this.errorMessage = errorMessage; // this.errorCode = errorCode; // this.sqlState = sqlState; // } // // /** // * // * @return // */ // public int getErrorCode() { // return errorCode; // } // // /** // * // * @param errorCode // */ // public void setErrorCode(int errorCode) { // this.errorCode = errorCode; // } // // /** // * // * @return // */ // public String getErrorMessage() { // return errorMessage; // } // // /** // * // * @param errorMessage // */ // public void setErrorMessage(String errorMessage) { // this.errorMessage = errorMessage; // } // // /** // * // * @return // */ // public String getSqlState() { // return sqlState; // } // // /** // * // * @param sqlState // */ // public void setSqlState(String sqlState) { // this.sqlState = sqlState; // } // }
import fabric.registry.FabricRegistry; import fabric.registry.QueryScope; import fabric.registry.RegistryObject; import fabric.registry.Task; import fabric.registry.TaskFactory; import fabric.registry.exception.DuplicateKeyException; import fabric.registry.exception.IncompleteObjectException; import fabric.registry.exception.PersistenceException; import fabric.registry.exception.RegistryQueryException; import fabric.registry.persistence.IPersistenceResultRow;
/* * (C) Copyright IBM Corp. 2009 * * LICENSE: Eclipse Public License v1.0 * http://www.eclipse.org/legal/epl-v10.html */ package fabric.registry.impl; /** * Implementation of the factory for <code>Task</code>'s. */ public class TaskFactoryImpl extends AbstractFactory implements TaskFactory { /** Copyright notice. */ public static final String copyrightNotice = "(C) Copyright IBM Corp. 2009"; /** Factory for local (singleton) Registry operations */ private static TaskFactoryImpl localQueryInstance = null; /** Factory for remote (gaian) Registry operations */ private static TaskFactoryImpl remoteQueryInstance = null; /* * Queries */ /** Select all records */ private String SELECT_ALL_QUERY = null; /** Select a particular record */ private String BY_ID_QUERY = null; /** Select records using an arbitrary WHERE clause */ private String PREDICATE_QUERY = null; /* * Static initialisation */ static { localQueryInstance = new TaskFactoryImpl(QueryScope.LOCAL); remoteQueryInstance = new TaskFactoryImpl(QueryScope.DISTRIBUTED); } private TaskFactoryImpl(QueryScope queryScope) { this.queryScope = queryScope; SELECT_ALL_QUERY = format("select * from %s", FabricRegistry.TASKS); /** Select a particular record */ BY_ID_QUERY = format("select * from %s where TASK_ID='\\%s'", FabricRegistry.TASKS); /** Select records using an arbitrary WHERE clause */ PREDICATE_QUERY = format("select * from %s where \\%s", FabricRegistry.TASKS); } public static TaskFactory getInstance(QueryScope queryScope) { if (queryScope == QueryScope.LOCAL) { return localQueryInstance; } else { return remoteQueryInstance; } } @Override
// Path: fabric.lib/src/fabric/registry/exception/PersistenceException.java // public class PersistenceException extends Exception { // // /** Copyright notice. */ // public static final String copyrightNotice = "(C) Copyright IBM Corp. 2009"; // // private static final long serialVersionUID = 1L; // // private String errorMessage = null; // private int errorCode = 0; // private String sqlState = null; // // /** // * // */ // public PersistenceException() { // } // // /** // * // * @param msg // */ // public PersistenceException(String msg) { // super(msg); // } // // /** // * // * @param detailMessage // * @param throwable // */ // public PersistenceException(String detailMessage, Throwable throwable) { // super(detailMessage, throwable); // } // // /** // * // * @param throwable // */ // public PersistenceException(Throwable throwable) { // super(throwable); // } // // /** // * // * @param message // * @param errorMessage // * @param errorCode // * @param sqlState // */ // public PersistenceException(String message, String errorMessage, int errorCode, String sqlState) { // super(message); // // this.errorMessage = errorMessage; // this.errorCode = errorCode; // this.sqlState = sqlState; // } // // /** // * // * @return // */ // public int getErrorCode() { // return errorCode; // } // // /** // * // * @param errorCode // */ // public void setErrorCode(int errorCode) { // this.errorCode = errorCode; // } // // /** // * // * @return // */ // public String getErrorMessage() { // return errorMessage; // } // // /** // * // * @param errorMessage // */ // public void setErrorMessage(String errorMessage) { // this.errorMessage = errorMessage; // } // // /** // * // * @return // */ // public String getSqlState() { // return sqlState; // } // // /** // * // * @param sqlState // */ // public void setSqlState(String sqlState) { // this.sqlState = sqlState; // } // } // Path: fabric.lib/src/fabric/registry/impl/TaskFactoryImpl.java import fabric.registry.FabricRegistry; import fabric.registry.QueryScope; import fabric.registry.RegistryObject; import fabric.registry.Task; import fabric.registry.TaskFactory; import fabric.registry.exception.DuplicateKeyException; import fabric.registry.exception.IncompleteObjectException; import fabric.registry.exception.PersistenceException; import fabric.registry.exception.RegistryQueryException; import fabric.registry.persistence.IPersistenceResultRow; /* * (C) Copyright IBM Corp. 2009 * * LICENSE: Eclipse Public License v1.0 * http://www.eclipse.org/legal/epl-v10.html */ package fabric.registry.impl; /** * Implementation of the factory for <code>Task</code>'s. */ public class TaskFactoryImpl extends AbstractFactory implements TaskFactory { /** Copyright notice. */ public static final String copyrightNotice = "(C) Copyright IBM Corp. 2009"; /** Factory for local (singleton) Registry operations */ private static TaskFactoryImpl localQueryInstance = null; /** Factory for remote (gaian) Registry operations */ private static TaskFactoryImpl remoteQueryInstance = null; /* * Queries */ /** Select all records */ private String SELECT_ALL_QUERY = null; /** Select a particular record */ private String BY_ID_QUERY = null; /** Select records using an arbitrary WHERE clause */ private String PREDICATE_QUERY = null; /* * Static initialisation */ static { localQueryInstance = new TaskFactoryImpl(QueryScope.LOCAL); remoteQueryInstance = new TaskFactoryImpl(QueryScope.DISTRIBUTED); } private TaskFactoryImpl(QueryScope queryScope) { this.queryScope = queryScope; SELECT_ALL_QUERY = format("select * from %s", FabricRegistry.TASKS); /** Select a particular record */ BY_ID_QUERY = format("select * from %s where TASK_ID='\\%s'", FabricRegistry.TASKS); /** Select records using an arbitrary WHERE clause */ PREDICATE_QUERY = format("select * from %s where \\%s", FabricRegistry.TASKS); } public static TaskFactory getInstance(QueryScope queryScope) { if (queryScope == QueryScope.LOCAL) { return localQueryInstance; } else { return remoteQueryInstance; } } @Override
public RegistryObject create(IPersistenceResultRow row) throws PersistenceException {
edgware/edgware
fabric.lib/src/fabric/registry/impl/ActorPluginFactoryImpl.java
// Path: fabric.lib/src/fabric/registry/exception/PersistenceException.java // public class PersistenceException extends Exception { // // /** Copyright notice. */ // public static final String copyrightNotice = "(C) Copyright IBM Corp. 2009"; // // private static final long serialVersionUID = 1L; // // private String errorMessage = null; // private int errorCode = 0; // private String sqlState = null; // // /** // * // */ // public PersistenceException() { // } // // /** // * // * @param msg // */ // public PersistenceException(String msg) { // super(msg); // } // // /** // * // * @param detailMessage // * @param throwable // */ // public PersistenceException(String detailMessage, Throwable throwable) { // super(detailMessage, throwable); // } // // /** // * // * @param throwable // */ // public PersistenceException(Throwable throwable) { // super(throwable); // } // // /** // * // * @param message // * @param errorMessage // * @param errorCode // * @param sqlState // */ // public PersistenceException(String message, String errorMessage, int errorCode, String sqlState) { // super(message); // // this.errorMessage = errorMessage; // this.errorCode = errorCode; // this.sqlState = sqlState; // } // // /** // * // * @return // */ // public int getErrorCode() { // return errorCode; // } // // /** // * // * @param errorCode // */ // public void setErrorCode(int errorCode) { // this.errorCode = errorCode; // } // // /** // * // * @return // */ // public String getErrorMessage() { // return errorMessage; // } // // /** // * // * @param errorMessage // */ // public void setErrorMessage(String errorMessage) { // this.errorMessage = errorMessage; // } // // /** // * // * @return // */ // public String getSqlState() { // return sqlState; // } // // /** // * // * @param sqlState // */ // public void setSqlState(String sqlState) { // this.sqlState = sqlState; // } // }
import fabric.registry.ActorPlugin; import fabric.registry.ActorPluginFactory; import fabric.registry.FabricPlugin; import fabric.registry.FabricRegistry; import fabric.registry.QueryScope; import fabric.registry.RegistryObject; import fabric.registry.exception.DuplicateKeyException; import fabric.registry.exception.IncompleteObjectException; import fabric.registry.exception.PersistenceException; import fabric.registry.exception.RegistryQueryException; import fabric.registry.persistence.IPersistenceResultRow;
/* * (C) Copyright IBM Corp. 2014 * * LICENSE: Eclipse Public License v1.0 * http://www.eclipse.org/legal/epl-v10.html */ package fabric.registry.impl; public class ActorPluginFactoryImpl extends AbstractFactory implements ActorPluginFactory { /** Copyright notice. */ public static final String copyrightNotice = "(C) Copyright IBM Corp. 2014"; /** Factory for local (singleton) Registry operations */ private static ActorPluginFactoryImpl localQueryInstance = null; /** Factory for remote (distributed) Registry operations */ private static ActorPluginFactoryImpl remoteQueryInstance = null; /* * Queries */ /** Select all records */ private String SELECT_ALL_QUERY_ACTOR_PLUGINS = null; /** Select all records for a particular node */ private String BY_NODE_QUERY_ACTOR_PLUGINS = null; /** Select records using an arbitrary WHERE clause */ private String PREDICATE_QUERY_ACTOR_PLUGINS = null; /* * Static initialisation */ static { localQueryInstance = new ActorPluginFactoryImpl(QueryScope.LOCAL); remoteQueryInstance = new ActorPluginFactoryImpl(QueryScope.DISTRIBUTED); } public static ActorPluginFactoryImpl getInstance(QueryScope queryScope) { if (queryScope == QueryScope.LOCAL) { return localQueryInstance; } else { return remoteQueryInstance; } } private ActorPluginFactoryImpl(QueryScope queryScope) { this.queryScope = queryScope; SELECT_ALL_QUERY_ACTOR_PLUGINS = format("select * from %s", FabricRegistry.ACTOR_PLUGINS); BY_NODE_QUERY_ACTOR_PLUGINS = format("select * from %s where NODE_ID='\\%s'", FabricRegistry.ACTOR_PLUGINS); PREDICATE_QUERY_ACTOR_PLUGINS = format("select * from %s where \\%s", FabricRegistry.ACTOR_PLUGINS); } @Override
// Path: fabric.lib/src/fabric/registry/exception/PersistenceException.java // public class PersistenceException extends Exception { // // /** Copyright notice. */ // public static final String copyrightNotice = "(C) Copyright IBM Corp. 2009"; // // private static final long serialVersionUID = 1L; // // private String errorMessage = null; // private int errorCode = 0; // private String sqlState = null; // // /** // * // */ // public PersistenceException() { // } // // /** // * // * @param msg // */ // public PersistenceException(String msg) { // super(msg); // } // // /** // * // * @param detailMessage // * @param throwable // */ // public PersistenceException(String detailMessage, Throwable throwable) { // super(detailMessage, throwable); // } // // /** // * // * @param throwable // */ // public PersistenceException(Throwable throwable) { // super(throwable); // } // // /** // * // * @param message // * @param errorMessage // * @param errorCode // * @param sqlState // */ // public PersistenceException(String message, String errorMessage, int errorCode, String sqlState) { // super(message); // // this.errorMessage = errorMessage; // this.errorCode = errorCode; // this.sqlState = sqlState; // } // // /** // * // * @return // */ // public int getErrorCode() { // return errorCode; // } // // /** // * // * @param errorCode // */ // public void setErrorCode(int errorCode) { // this.errorCode = errorCode; // } // // /** // * // * @return // */ // public String getErrorMessage() { // return errorMessage; // } // // /** // * // * @param errorMessage // */ // public void setErrorMessage(String errorMessage) { // this.errorMessage = errorMessage; // } // // /** // * // * @return // */ // public String getSqlState() { // return sqlState; // } // // /** // * // * @param sqlState // */ // public void setSqlState(String sqlState) { // this.sqlState = sqlState; // } // } // Path: fabric.lib/src/fabric/registry/impl/ActorPluginFactoryImpl.java import fabric.registry.ActorPlugin; import fabric.registry.ActorPluginFactory; import fabric.registry.FabricPlugin; import fabric.registry.FabricRegistry; import fabric.registry.QueryScope; import fabric.registry.RegistryObject; import fabric.registry.exception.DuplicateKeyException; import fabric.registry.exception.IncompleteObjectException; import fabric.registry.exception.PersistenceException; import fabric.registry.exception.RegistryQueryException; import fabric.registry.persistence.IPersistenceResultRow; /* * (C) Copyright IBM Corp. 2014 * * LICENSE: Eclipse Public License v1.0 * http://www.eclipse.org/legal/epl-v10.html */ package fabric.registry.impl; public class ActorPluginFactoryImpl extends AbstractFactory implements ActorPluginFactory { /** Copyright notice. */ public static final String copyrightNotice = "(C) Copyright IBM Corp. 2014"; /** Factory for local (singleton) Registry operations */ private static ActorPluginFactoryImpl localQueryInstance = null; /** Factory for remote (distributed) Registry operations */ private static ActorPluginFactoryImpl remoteQueryInstance = null; /* * Queries */ /** Select all records */ private String SELECT_ALL_QUERY_ACTOR_PLUGINS = null; /** Select all records for a particular node */ private String BY_NODE_QUERY_ACTOR_PLUGINS = null; /** Select records using an arbitrary WHERE clause */ private String PREDICATE_QUERY_ACTOR_PLUGINS = null; /* * Static initialisation */ static { localQueryInstance = new ActorPluginFactoryImpl(QueryScope.LOCAL); remoteQueryInstance = new ActorPluginFactoryImpl(QueryScope.DISTRIBUTED); } public static ActorPluginFactoryImpl getInstance(QueryScope queryScope) { if (queryScope == QueryScope.LOCAL) { return localQueryInstance; } else { return remoteQueryInstance; } } private ActorPluginFactoryImpl(QueryScope queryScope) { this.queryScope = queryScope; SELECT_ALL_QUERY_ACTOR_PLUGINS = format("select * from %s", FabricRegistry.ACTOR_PLUGINS); BY_NODE_QUERY_ACTOR_PLUGINS = format("select * from %s where NODE_ID='\\%s'", FabricRegistry.ACTOR_PLUGINS); PREDICATE_QUERY_ACTOR_PLUGINS = format("select * from %s where \\%s", FabricRegistry.ACTOR_PLUGINS); } @Override
public RegistryObject create(IPersistenceResultRow row) throws PersistenceException {
edgware/edgware
fabric.lib/src/fabric/registry/impl/FabricPluginFactoryImpl.java
// Path: fabric.lib/src/fabric/registry/exception/PersistenceException.java // public class PersistenceException extends Exception { // // /** Copyright notice. */ // public static final String copyrightNotice = "(C) Copyright IBM Corp. 2009"; // // private static final long serialVersionUID = 1L; // // private String errorMessage = null; // private int errorCode = 0; // private String sqlState = null; // // /** // * // */ // public PersistenceException() { // } // // /** // * // * @param msg // */ // public PersistenceException(String msg) { // super(msg); // } // // /** // * // * @param detailMessage // * @param throwable // */ // public PersistenceException(String detailMessage, Throwable throwable) { // super(detailMessage, throwable); // } // // /** // * // * @param throwable // */ // public PersistenceException(Throwable throwable) { // super(throwable); // } // // /** // * // * @param message // * @param errorMessage // * @param errorCode // * @param sqlState // */ // public PersistenceException(String message, String errorMessage, int errorCode, String sqlState) { // super(message); // // this.errorMessage = errorMessage; // this.errorCode = errorCode; // this.sqlState = sqlState; // } // // /** // * // * @return // */ // public int getErrorCode() { // return errorCode; // } // // /** // * // * @param errorCode // */ // public void setErrorCode(int errorCode) { // this.errorCode = errorCode; // } // // /** // * // * @return // */ // public String getErrorMessage() { // return errorMessage; // } // // /** // * // * @param errorMessage // */ // public void setErrorMessage(String errorMessage) { // this.errorMessage = errorMessage; // } // // /** // * // * @return // */ // public String getSqlState() { // return sqlState; // } // // /** // * // * @param sqlState // */ // public void setSqlState(String sqlState) { // this.sqlState = sqlState; // } // }
import fabric.registry.FabricPlugin; import fabric.registry.FabricPluginFactory; import fabric.registry.FabricRegistry; import fabric.registry.QueryScope; import fabric.registry.RegistryObject; import fabric.registry.exception.DuplicateKeyException; import fabric.registry.exception.IncompleteObjectException; import fabric.registry.exception.PersistenceException; import fabric.registry.exception.RegistryQueryException; import fabric.registry.persistence.IPersistenceResultRow;
if (plugin.getShadow() != null) { FabricPlugin shadow = (FabricPlugin) plugin.getShadow(); buf.append("NODE_ID='").append(shadow.getNodeId()).append("' AND "); buf.append("NAME='").append(shadow.getName()).append('\''); } else { buf.append("NODE_ID='").append(plugin.getNodeId()).append("' AND "); buf.append("NAME='").append(plugin.getName()).append('\''); } } return buf.toString(); } @Override public String getInsertSql(RegistryObject obj) { StringBuilder buf = new StringBuilder(); if (obj instanceof FabricPlugin) { FabricPlugin plugin = (FabricPlugin) obj; buf.append("insert into "); buf.append(FabricRegistry.FABLET_PLUGINS); buf.append(" values("); buf.append('\'').append(plugin.getNodeId()).append('\'').append(','); buf.append('\'').append(plugin.getName()).append('\'').append(','); buf.append(nullOrString(plugin.getFamilyName())).append(','); buf.append(nullOrString(plugin.getDescription())).append(','); buf.append(nullOrString(plugin.getArguments())).append(')'); } return buf.toString(); } @Override
// Path: fabric.lib/src/fabric/registry/exception/PersistenceException.java // public class PersistenceException extends Exception { // // /** Copyright notice. */ // public static final String copyrightNotice = "(C) Copyright IBM Corp. 2009"; // // private static final long serialVersionUID = 1L; // // private String errorMessage = null; // private int errorCode = 0; // private String sqlState = null; // // /** // * // */ // public PersistenceException() { // } // // /** // * // * @param msg // */ // public PersistenceException(String msg) { // super(msg); // } // // /** // * // * @param detailMessage // * @param throwable // */ // public PersistenceException(String detailMessage, Throwable throwable) { // super(detailMessage, throwable); // } // // /** // * // * @param throwable // */ // public PersistenceException(Throwable throwable) { // super(throwable); // } // // /** // * // * @param message // * @param errorMessage // * @param errorCode // * @param sqlState // */ // public PersistenceException(String message, String errorMessage, int errorCode, String sqlState) { // super(message); // // this.errorMessage = errorMessage; // this.errorCode = errorCode; // this.sqlState = sqlState; // } // // /** // * // * @return // */ // public int getErrorCode() { // return errorCode; // } // // /** // * // * @param errorCode // */ // public void setErrorCode(int errorCode) { // this.errorCode = errorCode; // } // // /** // * // * @return // */ // public String getErrorMessage() { // return errorMessage; // } // // /** // * // * @param errorMessage // */ // public void setErrorMessage(String errorMessage) { // this.errorMessage = errorMessage; // } // // /** // * // * @return // */ // public String getSqlState() { // return sqlState; // } // // /** // * // * @param sqlState // */ // public void setSqlState(String sqlState) { // this.sqlState = sqlState; // } // } // Path: fabric.lib/src/fabric/registry/impl/FabricPluginFactoryImpl.java import fabric.registry.FabricPlugin; import fabric.registry.FabricPluginFactory; import fabric.registry.FabricRegistry; import fabric.registry.QueryScope; import fabric.registry.RegistryObject; import fabric.registry.exception.DuplicateKeyException; import fabric.registry.exception.IncompleteObjectException; import fabric.registry.exception.PersistenceException; import fabric.registry.exception.RegistryQueryException; import fabric.registry.persistence.IPersistenceResultRow; if (plugin.getShadow() != null) { FabricPlugin shadow = (FabricPlugin) plugin.getShadow(); buf.append("NODE_ID='").append(shadow.getNodeId()).append("' AND "); buf.append("NAME='").append(shadow.getName()).append('\''); } else { buf.append("NODE_ID='").append(plugin.getNodeId()).append("' AND "); buf.append("NAME='").append(plugin.getName()).append('\''); } } return buf.toString(); } @Override public String getInsertSql(RegistryObject obj) { StringBuilder buf = new StringBuilder(); if (obj instanceof FabricPlugin) { FabricPlugin plugin = (FabricPlugin) obj; buf.append("insert into "); buf.append(FabricRegistry.FABLET_PLUGINS); buf.append(" values("); buf.append('\'').append(plugin.getNodeId()).append('\'').append(','); buf.append('\'').append(plugin.getName()).append('\'').append(','); buf.append(nullOrString(plugin.getFamilyName())).append(','); buf.append(nullOrString(plugin.getDescription())).append(','); buf.append(nullOrString(plugin.getArguments())).append(')'); } return buf.toString(); } @Override
public RegistryObject create(IPersistenceResultRow row) throws PersistenceException {
edgware/edgware
fabric.lib/src/fabric/registry/impl/NodeConfigFactoryImpl.java
// Path: fabric.lib/src/fabric/registry/exception/PersistenceException.java // public class PersistenceException extends Exception { // // /** Copyright notice. */ // public static final String copyrightNotice = "(C) Copyright IBM Corp. 2009"; // // private static final long serialVersionUID = 1L; // // private String errorMessage = null; // private int errorCode = 0; // private String sqlState = null; // // /** // * // */ // public PersistenceException() { // } // // /** // * // * @param msg // */ // public PersistenceException(String msg) { // super(msg); // } // // /** // * // * @param detailMessage // * @param throwable // */ // public PersistenceException(String detailMessage, Throwable throwable) { // super(detailMessage, throwable); // } // // /** // * // * @param throwable // */ // public PersistenceException(Throwable throwable) { // super(throwable); // } // // /** // * // * @param message // * @param errorMessage // * @param errorCode // * @param sqlState // */ // public PersistenceException(String message, String errorMessage, int errorCode, String sqlState) { // super(message); // // this.errorMessage = errorMessage; // this.errorCode = errorCode; // this.sqlState = sqlState; // } // // /** // * // * @return // */ // public int getErrorCode() { // return errorCode; // } // // /** // * // * @param errorCode // */ // public void setErrorCode(int errorCode) { // this.errorCode = errorCode; // } // // /** // * // * @return // */ // public String getErrorMessage() { // return errorMessage; // } // // /** // * // * @param errorMessage // */ // public void setErrorMessage(String errorMessage) { // this.errorMessage = errorMessage; // } // // /** // * // * @return // */ // public String getSqlState() { // return sqlState; // } // // /** // * // * @param sqlState // */ // public void setSqlState(String sqlState) { // this.sqlState = sqlState; // } // }
import fabric.registry.FabricRegistry; import fabric.registry.NodeConfig; import fabric.registry.NodeConfigFactory; import fabric.registry.QueryScope; import fabric.registry.RegistryObject; import fabric.registry.exception.DuplicateKeyException; import fabric.registry.exception.IncompleteObjectException; import fabric.registry.exception.PersistenceException; import fabric.registry.exception.RegistryQueryException; import fabric.registry.persistence.IPersistenceResultRow;
/* * (C) Copyright IBM Corp. 2014 * * LICENSE: Eclipse Public License v1.0 * http://www.eclipse.org/legal/epl-v10.html */ package fabric.registry.impl; /** * Implementation of the factory for <code>NodeConfig</code>s. */ public class NodeConfigFactoryImpl extends AbstractFactory implements NodeConfigFactory { /** Copyright notice. */ public static final String copyrightNotice = "(C) Copyright IBM Corp. 2014"; /** Factory for centralised (singleton) Registry operations */ private static NodeConfigFactoryImpl localQueryInstance = null; /** Factory for distributed (gaian) Registry operations */ private static NodeConfigFactoryImpl remoteQueryInstance = null; /* * Queries */ /** Select all records */ private String SELECT_ALL_QUERY = null; /** Select records by name */ private String BY_NODE_AND_NAME_QUERY = null; /** Select records using an arbitrary WHERE clause */ private String PREDICATE_QUERY = null; static { localQueryInstance = new NodeConfigFactoryImpl(QueryScope.LOCAL); remoteQueryInstance = new NodeConfigFactoryImpl(QueryScope.DISTRIBUTED); } public static NodeConfigFactory getInstance(QueryScope queryScope) { if (queryScope == QueryScope.LOCAL) { return localQueryInstance; } else { return remoteQueryInstance; } } private NodeConfigFactoryImpl(QueryScope queryScope) { this.queryScope = queryScope; SELECT_ALL_QUERY = format("select * from %s", FabricRegistry.NODE_CONFIG); BY_NODE_AND_NAME_QUERY = format("select * from %s where NODE_ID='\\%s' and NAME='\\%s'", FabricRegistry.NODE_CONFIG); PREDICATE_QUERY = format("select * from %s where \\%s", FabricRegistry.NODE_CONFIG); } /* * (non-Javadoc) * @see fabric.registry.impl.AbstractFactory#create(java.sql.ResultSet) */ @Override
// Path: fabric.lib/src/fabric/registry/exception/PersistenceException.java // public class PersistenceException extends Exception { // // /** Copyright notice. */ // public static final String copyrightNotice = "(C) Copyright IBM Corp. 2009"; // // private static final long serialVersionUID = 1L; // // private String errorMessage = null; // private int errorCode = 0; // private String sqlState = null; // // /** // * // */ // public PersistenceException() { // } // // /** // * // * @param msg // */ // public PersistenceException(String msg) { // super(msg); // } // // /** // * // * @param detailMessage // * @param throwable // */ // public PersistenceException(String detailMessage, Throwable throwable) { // super(detailMessage, throwable); // } // // /** // * // * @param throwable // */ // public PersistenceException(Throwable throwable) { // super(throwable); // } // // /** // * // * @param message // * @param errorMessage // * @param errorCode // * @param sqlState // */ // public PersistenceException(String message, String errorMessage, int errorCode, String sqlState) { // super(message); // // this.errorMessage = errorMessage; // this.errorCode = errorCode; // this.sqlState = sqlState; // } // // /** // * // * @return // */ // public int getErrorCode() { // return errorCode; // } // // /** // * // * @param errorCode // */ // public void setErrorCode(int errorCode) { // this.errorCode = errorCode; // } // // /** // * // * @return // */ // public String getErrorMessage() { // return errorMessage; // } // // /** // * // * @param errorMessage // */ // public void setErrorMessage(String errorMessage) { // this.errorMessage = errorMessage; // } // // /** // * // * @return // */ // public String getSqlState() { // return sqlState; // } // // /** // * // * @param sqlState // */ // public void setSqlState(String sqlState) { // this.sqlState = sqlState; // } // } // Path: fabric.lib/src/fabric/registry/impl/NodeConfigFactoryImpl.java import fabric.registry.FabricRegistry; import fabric.registry.NodeConfig; import fabric.registry.NodeConfigFactory; import fabric.registry.QueryScope; import fabric.registry.RegistryObject; import fabric.registry.exception.DuplicateKeyException; import fabric.registry.exception.IncompleteObjectException; import fabric.registry.exception.PersistenceException; import fabric.registry.exception.RegistryQueryException; import fabric.registry.persistence.IPersistenceResultRow; /* * (C) Copyright IBM Corp. 2014 * * LICENSE: Eclipse Public License v1.0 * http://www.eclipse.org/legal/epl-v10.html */ package fabric.registry.impl; /** * Implementation of the factory for <code>NodeConfig</code>s. */ public class NodeConfigFactoryImpl extends AbstractFactory implements NodeConfigFactory { /** Copyright notice. */ public static final String copyrightNotice = "(C) Copyright IBM Corp. 2014"; /** Factory for centralised (singleton) Registry operations */ private static NodeConfigFactoryImpl localQueryInstance = null; /** Factory for distributed (gaian) Registry operations */ private static NodeConfigFactoryImpl remoteQueryInstance = null; /* * Queries */ /** Select all records */ private String SELECT_ALL_QUERY = null; /** Select records by name */ private String BY_NODE_AND_NAME_QUERY = null; /** Select records using an arbitrary WHERE clause */ private String PREDICATE_QUERY = null; static { localQueryInstance = new NodeConfigFactoryImpl(QueryScope.LOCAL); remoteQueryInstance = new NodeConfigFactoryImpl(QueryScope.DISTRIBUTED); } public static NodeConfigFactory getInstance(QueryScope queryScope) { if (queryScope == QueryScope.LOCAL) { return localQueryInstance; } else { return remoteQueryInstance; } } private NodeConfigFactoryImpl(QueryScope queryScope) { this.queryScope = queryScope; SELECT_ALL_QUERY = format("select * from %s", FabricRegistry.NODE_CONFIG); BY_NODE_AND_NAME_QUERY = format("select * from %s where NODE_ID='\\%s' and NAME='\\%s'", FabricRegistry.NODE_CONFIG); PREDICATE_QUERY = format("select * from %s where \\%s", FabricRegistry.NODE_CONFIG); } /* * (non-Javadoc) * @see fabric.registry.impl.AbstractFactory#create(java.sql.ResultSet) */ @Override
public RegistryObject create(IPersistenceResultRow row) throws PersistenceException {
edgware/edgware
fabric.lib/src/fabric/registry/impl/SystemFactoryImpl.java
// Path: fabric.lib/src/fabric/registry/exception/PersistenceException.java // public class PersistenceException extends Exception { // // /** Copyright notice. */ // public static final String copyrightNotice = "(C) Copyright IBM Corp. 2009"; // // private static final long serialVersionUID = 1L; // // private String errorMessage = null; // private int errorCode = 0; // private String sqlState = null; // // /** // * // */ // public PersistenceException() { // } // // /** // * // * @param msg // */ // public PersistenceException(String msg) { // super(msg); // } // // /** // * // * @param detailMessage // * @param throwable // */ // public PersistenceException(String detailMessage, Throwable throwable) { // super(detailMessage, throwable); // } // // /** // * // * @param throwable // */ // public PersistenceException(Throwable throwable) { // super(throwable); // } // // /** // * // * @param message // * @param errorMessage // * @param errorCode // * @param sqlState // */ // public PersistenceException(String message, String errorMessage, int errorCode, String sqlState) { // super(message); // // this.errorMessage = errorMessage; // this.errorCode = errorCode; // this.sqlState = sqlState; // } // // /** // * // * @return // */ // public int getErrorCode() { // return errorCode; // } // // /** // * // * @param errorCode // */ // public void setErrorCode(int errorCode) { // this.errorCode = errorCode; // } // // /** // * // * @return // */ // public String getErrorMessage() { // return errorMessage; // } // // /** // * // * @param errorMessage // */ // public void setErrorMessage(String errorMessage) { // this.errorMessage = errorMessage; // } // // /** // * // * @return // */ // public String getSqlState() { // return sqlState; // } // // /** // * // * @param sqlState // */ // public void setSqlState(String sqlState) { // this.sqlState = sqlState; // } // }
import fabric.registry.FabricRegistry; import fabric.registry.QueryScope; import fabric.registry.RegistryObject; import fabric.registry.System; import fabric.registry.SystemFactory; import fabric.registry.exception.DuplicateKeyException; import fabric.registry.exception.IncompleteObjectException; import fabric.registry.exception.PersistenceException; import fabric.registry.exception.RegistryQueryException; import fabric.registry.persistence.IPersistenceResultRow;
* @param readiness * @param availability * @param latitude * @param longitude * @param altitude * @param bearing * @param velocity * @param description * @param attributes * @param attributesURI * @return */ private System createSystem(String platformID, String systemId, String typeID, String kind, String credentials, String readiness, String availability, double latitude, double longitude, double altitude, double bearing, double velocity, String description, String attributes, String attributesURI) { System s = new SystemImpl(platformID, systemId, typeID, "SERVICE", credentials, readiness, availability, latitude, longitude, altitude, bearing, velocity, description, attributes, attributesURI); return s; } /** * @see fabric.registry.SystemFactory#getAll() */ @Override public System[] getAll() { System[] systems = null; try { systems = runQuery(SELECT_ALL_QUERY);
// Path: fabric.lib/src/fabric/registry/exception/PersistenceException.java // public class PersistenceException extends Exception { // // /** Copyright notice. */ // public static final String copyrightNotice = "(C) Copyright IBM Corp. 2009"; // // private static final long serialVersionUID = 1L; // // private String errorMessage = null; // private int errorCode = 0; // private String sqlState = null; // // /** // * // */ // public PersistenceException() { // } // // /** // * // * @param msg // */ // public PersistenceException(String msg) { // super(msg); // } // // /** // * // * @param detailMessage // * @param throwable // */ // public PersistenceException(String detailMessage, Throwable throwable) { // super(detailMessage, throwable); // } // // /** // * // * @param throwable // */ // public PersistenceException(Throwable throwable) { // super(throwable); // } // // /** // * // * @param message // * @param errorMessage // * @param errorCode // * @param sqlState // */ // public PersistenceException(String message, String errorMessage, int errorCode, String sqlState) { // super(message); // // this.errorMessage = errorMessage; // this.errorCode = errorCode; // this.sqlState = sqlState; // } // // /** // * // * @return // */ // public int getErrorCode() { // return errorCode; // } // // /** // * // * @param errorCode // */ // public void setErrorCode(int errorCode) { // this.errorCode = errorCode; // } // // /** // * // * @return // */ // public String getErrorMessage() { // return errorMessage; // } // // /** // * // * @param errorMessage // */ // public void setErrorMessage(String errorMessage) { // this.errorMessage = errorMessage; // } // // /** // * // * @return // */ // public String getSqlState() { // return sqlState; // } // // /** // * // * @param sqlState // */ // public void setSqlState(String sqlState) { // this.sqlState = sqlState; // } // } // Path: fabric.lib/src/fabric/registry/impl/SystemFactoryImpl.java import fabric.registry.FabricRegistry; import fabric.registry.QueryScope; import fabric.registry.RegistryObject; import fabric.registry.System; import fabric.registry.SystemFactory; import fabric.registry.exception.DuplicateKeyException; import fabric.registry.exception.IncompleteObjectException; import fabric.registry.exception.PersistenceException; import fabric.registry.exception.RegistryQueryException; import fabric.registry.persistence.IPersistenceResultRow; * @param readiness * @param availability * @param latitude * @param longitude * @param altitude * @param bearing * @param velocity * @param description * @param attributes * @param attributesURI * @return */ private System createSystem(String platformID, String systemId, String typeID, String kind, String credentials, String readiness, String availability, double latitude, double longitude, double altitude, double bearing, double velocity, String description, String attributes, String attributesURI) { System s = new SystemImpl(platformID, systemId, typeID, "SERVICE", credentials, readiness, availability, latitude, longitude, altitude, bearing, velocity, description, attributes, attributesURI); return s; } /** * @see fabric.registry.SystemFactory#getAll() */ @Override public System[] getAll() { System[] systems = null; try { systems = runQuery(SELECT_ALL_QUERY);
} catch (PersistenceException e) {
edgware/edgware
fabric.lib/src/fabric/registry/impl/PlatformFactoryImpl.java
// Path: fabric.lib/src/fabric/registry/exception/PersistenceException.java // public class PersistenceException extends Exception { // // /** Copyright notice. */ // public static final String copyrightNotice = "(C) Copyright IBM Corp. 2009"; // // private static final long serialVersionUID = 1L; // // private String errorMessage = null; // private int errorCode = 0; // private String sqlState = null; // // /** // * // */ // public PersistenceException() { // } // // /** // * // * @param msg // */ // public PersistenceException(String msg) { // super(msg); // } // // /** // * // * @param detailMessage // * @param throwable // */ // public PersistenceException(String detailMessage, Throwable throwable) { // super(detailMessage, throwable); // } // // /** // * // * @param throwable // */ // public PersistenceException(Throwable throwable) { // super(throwable); // } // // /** // * // * @param message // * @param errorMessage // * @param errorCode // * @param sqlState // */ // public PersistenceException(String message, String errorMessage, int errorCode, String sqlState) { // super(message); // // this.errorMessage = errorMessage; // this.errorCode = errorCode; // this.sqlState = sqlState; // } // // /** // * // * @return // */ // public int getErrorCode() { // return errorCode; // } // // /** // * // * @param errorCode // */ // public void setErrorCode(int errorCode) { // this.errorCode = errorCode; // } // // /** // * // * @return // */ // public String getErrorMessage() { // return errorMessage; // } // // /** // * // * @param errorMessage // */ // public void setErrorMessage(String errorMessage) { // this.errorMessage = errorMessage; // } // // /** // * // * @return // */ // public String getSqlState() { // return sqlState; // } // // /** // * // * @param sqlState // */ // public void setSqlState(String sqlState) { // this.sqlState = sqlState; // } // }
import fabric.registry.FabricRegistry; import fabric.registry.Platform; import fabric.registry.PlatformFactory; import fabric.registry.QueryScope; import fabric.registry.RegistryObject; import fabric.registry.exception.DuplicateKeyException; import fabric.registry.exception.IncompleteObjectException; import fabric.registry.exception.PersistenceException; import fabric.registry.exception.RegistryQueryException; import fabric.registry.persistence.IPersistenceResultRow;
/* * (C) Copyright IBM Corp. 2009 * * LICENSE: Eclipse Public License v1.0 * http://www.eclipse.org/legal/epl-v10.html */ package fabric.registry.impl; /** * Implementation of the factory for <code>Platform</code>'s. */ public class PlatformFactoryImpl extends AbstractFactory implements PlatformFactory { /** Copyright notice. */ public static final String copyrightNotice = "(C) Copyright IBM Corp. 2009"; /* * Constants */ /** Factory for local (singleton) Registry operations */ private static PlatformFactoryImpl localQueryInstance = null; /** Factory for remote (distributed) Registry operations */ private static PlatformFactoryImpl remoteQueryInstance = null; /* * Queries */ /** Select all records */ private String SELECT_ALL_QUERY = null; /** Select a record by ID */ private String BY_ID_QUERY = null; /** Select records by node ID */ private String BY_NODE_QUERY = null; /** Select records by type ID */ private String BY_TYPE_QUERY = null; /** Select records using an arbitrary WHERE clause */ private String PREDICATE_QUERY = null; /* * Static initialisation */ static { localQueryInstance = new PlatformFactoryImpl(QueryScope.LOCAL); remoteQueryInstance = new PlatformFactoryImpl(QueryScope.DISTRIBUTED); } public static PlatformFactoryImpl getInstance(QueryScope queryScope) { if (queryScope == QueryScope.LOCAL) { return localQueryInstance; } else { return remoteQueryInstance; } } private PlatformFactoryImpl(QueryScope queryScope) { this.queryScope = queryScope; SELECT_ALL_QUERY = format("select * from %s", FabricRegistry.PLATFORMS); BY_ID_QUERY = format("select * from %s where PLATFORM_ID='\\%s'", FabricRegistry.PLATFORMS); BY_NODE_QUERY = format("select * from %s where NODE_ID='\\%s'", FabricRegistry.PLATFORMS); BY_TYPE_QUERY = format("select * from %s where TYPE_ID='\\%s'", FabricRegistry.PLATFORMS); PREDICATE_QUERY = format("select * from %s where \\%s", FabricRegistry.PLATFORMS); } @Override
// Path: fabric.lib/src/fabric/registry/exception/PersistenceException.java // public class PersistenceException extends Exception { // // /** Copyright notice. */ // public static final String copyrightNotice = "(C) Copyright IBM Corp. 2009"; // // private static final long serialVersionUID = 1L; // // private String errorMessage = null; // private int errorCode = 0; // private String sqlState = null; // // /** // * // */ // public PersistenceException() { // } // // /** // * // * @param msg // */ // public PersistenceException(String msg) { // super(msg); // } // // /** // * // * @param detailMessage // * @param throwable // */ // public PersistenceException(String detailMessage, Throwable throwable) { // super(detailMessage, throwable); // } // // /** // * // * @param throwable // */ // public PersistenceException(Throwable throwable) { // super(throwable); // } // // /** // * // * @param message // * @param errorMessage // * @param errorCode // * @param sqlState // */ // public PersistenceException(String message, String errorMessage, int errorCode, String sqlState) { // super(message); // // this.errorMessage = errorMessage; // this.errorCode = errorCode; // this.sqlState = sqlState; // } // // /** // * // * @return // */ // public int getErrorCode() { // return errorCode; // } // // /** // * // * @param errorCode // */ // public void setErrorCode(int errorCode) { // this.errorCode = errorCode; // } // // /** // * // * @return // */ // public String getErrorMessage() { // return errorMessage; // } // // /** // * // * @param errorMessage // */ // public void setErrorMessage(String errorMessage) { // this.errorMessage = errorMessage; // } // // /** // * // * @return // */ // public String getSqlState() { // return sqlState; // } // // /** // * // * @param sqlState // */ // public void setSqlState(String sqlState) { // this.sqlState = sqlState; // } // } // Path: fabric.lib/src/fabric/registry/impl/PlatformFactoryImpl.java import fabric.registry.FabricRegistry; import fabric.registry.Platform; import fabric.registry.PlatformFactory; import fabric.registry.QueryScope; import fabric.registry.RegistryObject; import fabric.registry.exception.DuplicateKeyException; import fabric.registry.exception.IncompleteObjectException; import fabric.registry.exception.PersistenceException; import fabric.registry.exception.RegistryQueryException; import fabric.registry.persistence.IPersistenceResultRow; /* * (C) Copyright IBM Corp. 2009 * * LICENSE: Eclipse Public License v1.0 * http://www.eclipse.org/legal/epl-v10.html */ package fabric.registry.impl; /** * Implementation of the factory for <code>Platform</code>'s. */ public class PlatformFactoryImpl extends AbstractFactory implements PlatformFactory { /** Copyright notice. */ public static final String copyrightNotice = "(C) Copyright IBM Corp. 2009"; /* * Constants */ /** Factory for local (singleton) Registry operations */ private static PlatformFactoryImpl localQueryInstance = null; /** Factory for remote (distributed) Registry operations */ private static PlatformFactoryImpl remoteQueryInstance = null; /* * Queries */ /** Select all records */ private String SELECT_ALL_QUERY = null; /** Select a record by ID */ private String BY_ID_QUERY = null; /** Select records by node ID */ private String BY_NODE_QUERY = null; /** Select records by type ID */ private String BY_TYPE_QUERY = null; /** Select records using an arbitrary WHERE clause */ private String PREDICATE_QUERY = null; /* * Static initialisation */ static { localQueryInstance = new PlatformFactoryImpl(QueryScope.LOCAL); remoteQueryInstance = new PlatformFactoryImpl(QueryScope.DISTRIBUTED); } public static PlatformFactoryImpl getInstance(QueryScope queryScope) { if (queryScope == QueryScope.LOCAL) { return localQueryInstance; } else { return remoteQueryInstance; } } private PlatformFactoryImpl(QueryScope queryScope) { this.queryScope = queryScope; SELECT_ALL_QUERY = format("select * from %s", FabricRegistry.PLATFORMS); BY_ID_QUERY = format("select * from %s where PLATFORM_ID='\\%s'", FabricRegistry.PLATFORMS); BY_NODE_QUERY = format("select * from %s where NODE_ID='\\%s'", FabricRegistry.PLATFORMS); BY_TYPE_QUERY = format("select * from %s where TYPE_ID='\\%s'", FabricRegistry.PLATFORMS); PREDICATE_QUERY = format("select * from %s where \\%s", FabricRegistry.PLATFORMS); } @Override
public RegistryObject create(IPersistenceResultRow row) throws PersistenceException {
edgware/edgware
fabric.lib/src/fabric/registry/impl/NodeIpMappingFactoryImpl.java
// Path: fabric.lib/src/fabric/registry/exception/PersistenceException.java // public class PersistenceException extends Exception { // // /** Copyright notice. */ // public static final String copyrightNotice = "(C) Copyright IBM Corp. 2009"; // // private static final long serialVersionUID = 1L; // // private String errorMessage = null; // private int errorCode = 0; // private String sqlState = null; // // /** // * // */ // public PersistenceException() { // } // // /** // * // * @param msg // */ // public PersistenceException(String msg) { // super(msg); // } // // /** // * // * @param detailMessage // * @param throwable // */ // public PersistenceException(String detailMessage, Throwable throwable) { // super(detailMessage, throwable); // } // // /** // * // * @param throwable // */ // public PersistenceException(Throwable throwable) { // super(throwable); // } // // /** // * // * @param message // * @param errorMessage // * @param errorCode // * @param sqlState // */ // public PersistenceException(String message, String errorMessage, int errorCode, String sqlState) { // super(message); // // this.errorMessage = errorMessage; // this.errorCode = errorCode; // this.sqlState = sqlState; // } // // /** // * // * @return // */ // public int getErrorCode() { // return errorCode; // } // // /** // * // * @param errorCode // */ // public void setErrorCode(int errorCode) { // this.errorCode = errorCode; // } // // /** // * // * @return // */ // public String getErrorMessage() { // return errorMessage; // } // // /** // * // * @param errorMessage // */ // public void setErrorMessage(String errorMessage) { // this.errorMessage = errorMessage; // } // // /** // * // * @return // */ // public String getSqlState() { // return sqlState; // } // // /** // * // * @param sqlState // */ // public void setSqlState(String sqlState) { // this.sqlState = sqlState; // } // }
import fabric.registry.FabricRegistry; import fabric.registry.NodeIpMapping; import fabric.registry.NodeIpMappingFactory; import fabric.registry.QueryScope; import fabric.registry.RegistryObject; import fabric.registry.exception.DuplicateKeyException; import fabric.registry.exception.IncompleteObjectException; import fabric.registry.exception.PersistenceException; import fabric.registry.persistence.IPersistenceResultRow;
/* * (C) Copyright IBM Corp. 2009 * * LICENSE: Eclipse Public License v1.0 * http://www.eclipse.org/legal/epl-v10.html */ package fabric.registry.impl; /** * Factory used to create NodeIpMapping objects and persist them in the Fabric Registry. */ public class NodeIpMappingFactoryImpl extends AbstractFactory implements NodeIpMappingFactory { /** Copyright notice. */ public static final String copyrightNotice = "(C) Copyright IBM Corp. 2009"; /* * Class fields */ /** Factory for local (singleton) Registry operations */ private static NodeIpMappingFactoryImpl localQueryInstance = null; /** Factory for distributed (Gaian) Registry operations */ private static NodeIpMappingFactoryImpl remoteQueryInstance = null; /* Query definitions */ /** Select all records. */ private String SELECT_ALL_QUERY = null; /** Select records matching a specified node ID. */ private String BY_ID_QUERY = null; /** Select records matching a specified node ID and node Interface. */ private String BY_ID_AND_INTERFACE_QUERY = null; /** Select records using an arbitrary SQL <code>WHERE</code> clause. */ private String PREDICATE_QUERY = null; /* * Class static initialization */ static { /* Create an instance for local (singleton) Registry operations */ localQueryInstance = new NodeIpMappingFactoryImpl(QueryScope.LOCAL); /* Create an instance for distributed (Gaian) Registry operations */ remoteQueryInstance = new NodeIpMappingFactoryImpl(QueryScope.DISTRIBUTED); } /* * Class methods */ private NodeIpMappingFactoryImpl(QueryScope queryScope) { this.queryScope = queryScope; /* Build the predefined queries to reflect the selected tables */ SELECT_ALL_QUERY = format("select * from %s", FabricRegistry.NODE_IP_MAPPING); BY_ID_QUERY = format("select * from %s where NODE_ID='\\%s'", FabricRegistry.NODE_IP_MAPPING); BY_ID_AND_INTERFACE_QUERY = format("select * from %s where NODE_ID='\\%s' AND NODE_INTERFACE='\\%s'", FabricRegistry.NODE_IP_MAPPING); PREDICATE_QUERY = format("select * from %s where \\%s", FabricRegistry.NODE_IP_MAPPING); } /** * Get the singleton instance of this factory. * * @return an instance of the factory. */ public static NodeIpMappingFactoryImpl getInstance(QueryScope queryScope) { if (queryScope == QueryScope.LOCAL) { return localQueryInstance; } else { return remoteQueryInstance; } } @Override
// Path: fabric.lib/src/fabric/registry/exception/PersistenceException.java // public class PersistenceException extends Exception { // // /** Copyright notice. */ // public static final String copyrightNotice = "(C) Copyright IBM Corp. 2009"; // // private static final long serialVersionUID = 1L; // // private String errorMessage = null; // private int errorCode = 0; // private String sqlState = null; // // /** // * // */ // public PersistenceException() { // } // // /** // * // * @param msg // */ // public PersistenceException(String msg) { // super(msg); // } // // /** // * // * @param detailMessage // * @param throwable // */ // public PersistenceException(String detailMessage, Throwable throwable) { // super(detailMessage, throwable); // } // // /** // * // * @param throwable // */ // public PersistenceException(Throwable throwable) { // super(throwable); // } // // /** // * // * @param message // * @param errorMessage // * @param errorCode // * @param sqlState // */ // public PersistenceException(String message, String errorMessage, int errorCode, String sqlState) { // super(message); // // this.errorMessage = errorMessage; // this.errorCode = errorCode; // this.sqlState = sqlState; // } // // /** // * // * @return // */ // public int getErrorCode() { // return errorCode; // } // // /** // * // * @param errorCode // */ // public void setErrorCode(int errorCode) { // this.errorCode = errorCode; // } // // /** // * // * @return // */ // public String getErrorMessage() { // return errorMessage; // } // // /** // * // * @param errorMessage // */ // public void setErrorMessage(String errorMessage) { // this.errorMessage = errorMessage; // } // // /** // * // * @return // */ // public String getSqlState() { // return sqlState; // } // // /** // * // * @param sqlState // */ // public void setSqlState(String sqlState) { // this.sqlState = sqlState; // } // } // Path: fabric.lib/src/fabric/registry/impl/NodeIpMappingFactoryImpl.java import fabric.registry.FabricRegistry; import fabric.registry.NodeIpMapping; import fabric.registry.NodeIpMappingFactory; import fabric.registry.QueryScope; import fabric.registry.RegistryObject; import fabric.registry.exception.DuplicateKeyException; import fabric.registry.exception.IncompleteObjectException; import fabric.registry.exception.PersistenceException; import fabric.registry.persistence.IPersistenceResultRow; /* * (C) Copyright IBM Corp. 2009 * * LICENSE: Eclipse Public License v1.0 * http://www.eclipse.org/legal/epl-v10.html */ package fabric.registry.impl; /** * Factory used to create NodeIpMapping objects and persist them in the Fabric Registry. */ public class NodeIpMappingFactoryImpl extends AbstractFactory implements NodeIpMappingFactory { /** Copyright notice. */ public static final String copyrightNotice = "(C) Copyright IBM Corp. 2009"; /* * Class fields */ /** Factory for local (singleton) Registry operations */ private static NodeIpMappingFactoryImpl localQueryInstance = null; /** Factory for distributed (Gaian) Registry operations */ private static NodeIpMappingFactoryImpl remoteQueryInstance = null; /* Query definitions */ /** Select all records. */ private String SELECT_ALL_QUERY = null; /** Select records matching a specified node ID. */ private String BY_ID_QUERY = null; /** Select records matching a specified node ID and node Interface. */ private String BY_ID_AND_INTERFACE_QUERY = null; /** Select records using an arbitrary SQL <code>WHERE</code> clause. */ private String PREDICATE_QUERY = null; /* * Class static initialization */ static { /* Create an instance for local (singleton) Registry operations */ localQueryInstance = new NodeIpMappingFactoryImpl(QueryScope.LOCAL); /* Create an instance for distributed (Gaian) Registry operations */ remoteQueryInstance = new NodeIpMappingFactoryImpl(QueryScope.DISTRIBUTED); } /* * Class methods */ private NodeIpMappingFactoryImpl(QueryScope queryScope) { this.queryScope = queryScope; /* Build the predefined queries to reflect the selected tables */ SELECT_ALL_QUERY = format("select * from %s", FabricRegistry.NODE_IP_MAPPING); BY_ID_QUERY = format("select * from %s where NODE_ID='\\%s'", FabricRegistry.NODE_IP_MAPPING); BY_ID_AND_INTERFACE_QUERY = format("select * from %s where NODE_ID='\\%s' AND NODE_INTERFACE='\\%s'", FabricRegistry.NODE_IP_MAPPING); PREDICATE_QUERY = format("select * from %s where \\%s", FabricRegistry.NODE_IP_MAPPING); } /** * Get the singleton instance of this factory. * * @return an instance of the factory. */ public static NodeIpMappingFactoryImpl getInstance(QueryScope queryScope) { if (queryScope == QueryScope.LOCAL) { return localQueryInstance; } else { return remoteQueryInstance; } } @Override
public RegistryObject create(IPersistenceResultRow row) throws PersistenceException {
edgware/edgware
fabric.lib/src/fabric/registry/impl/TaskServiceFactoryImpl.java
// Path: fabric.lib/src/fabric/registry/exception/PersistenceException.java // public class PersistenceException extends Exception { // // /** Copyright notice. */ // public static final String copyrightNotice = "(C) Copyright IBM Corp. 2009"; // // private static final long serialVersionUID = 1L; // // private String errorMessage = null; // private int errorCode = 0; // private String sqlState = null; // // /** // * // */ // public PersistenceException() { // } // // /** // * // * @param msg // */ // public PersistenceException(String msg) { // super(msg); // } // // /** // * // * @param detailMessage // * @param throwable // */ // public PersistenceException(String detailMessage, Throwable throwable) { // super(detailMessage, throwable); // } // // /** // * // * @param throwable // */ // public PersistenceException(Throwable throwable) { // super(throwable); // } // // /** // * // * @param message // * @param errorMessage // * @param errorCode // * @param sqlState // */ // public PersistenceException(String message, String errorMessage, int errorCode, String sqlState) { // super(message); // // this.errorMessage = errorMessage; // this.errorCode = errorCode; // this.sqlState = sqlState; // } // // /** // * // * @return // */ // public int getErrorCode() { // return errorCode; // } // // /** // * // * @param errorCode // */ // public void setErrorCode(int errorCode) { // this.errorCode = errorCode; // } // // /** // * // * @return // */ // public String getErrorMessage() { // return errorMessage; // } // // /** // * // * @param errorMessage // */ // public void setErrorMessage(String errorMessage) { // this.errorMessage = errorMessage; // } // // /** // * // * @return // */ // public String getSqlState() { // return sqlState; // } // // /** // * // * @param sqlState // */ // public void setSqlState(String sqlState) { // this.sqlState = sqlState; // } // }
import fabric.registry.FabricRegistry; import fabric.registry.QueryScope; import fabric.registry.RegistryObject; import fabric.registry.TaskService; import fabric.registry.TaskServiceFactory; import fabric.registry.exception.DuplicateKeyException; import fabric.registry.exception.IncompleteObjectException; import fabric.registry.exception.MalformedPredicateException; import fabric.registry.exception.PersistenceException; import fabric.registry.exception.RegistryQueryException; import fabric.registry.persistence.IPersistenceResultRow; import fabric.registry.persistence.PersistenceManager;
/* * (C) Copyright IBM Corp. 2011 * * LICENSE: Eclipse Public License v1.0 * http://www.eclipse.org/legal/epl-v10.html */ package fabric.registry.impl; /** * Implementation of the factory for <code>TaskService</code>s. */ public class TaskServiceFactoryImpl extends AbstractFactory implements TaskServiceFactory { /** Copyright notice. */ public static final String copyrightNotice = "(C) Copyright IBM Corp. 2011"; /* * Class constants */ /** Factory for local (singleton) Registry operations */ private static TaskServiceFactoryImpl localQueryInstance = null; /** Factory for distributed (Gaian) Registry operations */ private static TaskServiceFactoryImpl remoteQueryInstance = null; /* * Queries */ /** Select records using an arbitrary WHERE clause */ private String PREDICATE_QUERY = null; /** Select all records */ private String SELECT_ALL_SENSOR_FEEDS = null; /** Select records for a particular task Id */ private String SELECT_SENSOR_FEEDS_BY_TASK = null; /** Select a specific task service by ID */ private String SELECT_BY_ID = null; /** Delete records for a particular task */ private static String DELETE_FEEDS_BY_TASK = "delete from " + FabricRegistry.TASK_SYSTEMS + " where TASK_ID='%s'"; /* * Static initialisation */ static { localQueryInstance = new TaskServiceFactoryImpl(QueryScope.LOCAL); remoteQueryInstance = new TaskServiceFactoryImpl(QueryScope.DISTRIBUTED); } private TaskServiceFactoryImpl(QueryScope queryScope) { this.queryScope = queryScope; PREDICATE_QUERY = format("select * from %s where \\%s", FabricRegistry.TASK_SYSTEMS); SELECT_ALL_SENSOR_FEEDS = format("select * from %s", FabricRegistry.TASK_SYSTEMS); SELECT_SENSOR_FEEDS_BY_TASK = format("select * from %s where TASK_ID='\\%s'", FabricRegistry.TASK_SYSTEMS); SELECT_BY_ID = format( "select * from %s where TASK_ID='\\%s' and PLATFORM_ID='\\%s' and SERVICE_ID='\\%s' and DATA_FEED_ID='\\%s'", FabricRegistry.TASK_SYSTEMS); } /** * Get the single instance of this factory. * * @return the factory instance. */ public static TaskServiceFactoryImpl getInstance(QueryScope queryScope) { if (queryScope == QueryScope.LOCAL) { return localQueryInstance; } else { return remoteQueryInstance; } } @Override
// Path: fabric.lib/src/fabric/registry/exception/PersistenceException.java // public class PersistenceException extends Exception { // // /** Copyright notice. */ // public static final String copyrightNotice = "(C) Copyright IBM Corp. 2009"; // // private static final long serialVersionUID = 1L; // // private String errorMessage = null; // private int errorCode = 0; // private String sqlState = null; // // /** // * // */ // public PersistenceException() { // } // // /** // * // * @param msg // */ // public PersistenceException(String msg) { // super(msg); // } // // /** // * // * @param detailMessage // * @param throwable // */ // public PersistenceException(String detailMessage, Throwable throwable) { // super(detailMessage, throwable); // } // // /** // * // * @param throwable // */ // public PersistenceException(Throwable throwable) { // super(throwable); // } // // /** // * // * @param message // * @param errorMessage // * @param errorCode // * @param sqlState // */ // public PersistenceException(String message, String errorMessage, int errorCode, String sqlState) { // super(message); // // this.errorMessage = errorMessage; // this.errorCode = errorCode; // this.sqlState = sqlState; // } // // /** // * // * @return // */ // public int getErrorCode() { // return errorCode; // } // // /** // * // * @param errorCode // */ // public void setErrorCode(int errorCode) { // this.errorCode = errorCode; // } // // /** // * // * @return // */ // public String getErrorMessage() { // return errorMessage; // } // // /** // * // * @param errorMessage // */ // public void setErrorMessage(String errorMessage) { // this.errorMessage = errorMessage; // } // // /** // * // * @return // */ // public String getSqlState() { // return sqlState; // } // // /** // * // * @param sqlState // */ // public void setSqlState(String sqlState) { // this.sqlState = sqlState; // } // } // Path: fabric.lib/src/fabric/registry/impl/TaskServiceFactoryImpl.java import fabric.registry.FabricRegistry; import fabric.registry.QueryScope; import fabric.registry.RegistryObject; import fabric.registry.TaskService; import fabric.registry.TaskServiceFactory; import fabric.registry.exception.DuplicateKeyException; import fabric.registry.exception.IncompleteObjectException; import fabric.registry.exception.MalformedPredicateException; import fabric.registry.exception.PersistenceException; import fabric.registry.exception.RegistryQueryException; import fabric.registry.persistence.IPersistenceResultRow; import fabric.registry.persistence.PersistenceManager; /* * (C) Copyright IBM Corp. 2011 * * LICENSE: Eclipse Public License v1.0 * http://www.eclipse.org/legal/epl-v10.html */ package fabric.registry.impl; /** * Implementation of the factory for <code>TaskService</code>s. */ public class TaskServiceFactoryImpl extends AbstractFactory implements TaskServiceFactory { /** Copyright notice. */ public static final String copyrightNotice = "(C) Copyright IBM Corp. 2011"; /* * Class constants */ /** Factory for local (singleton) Registry operations */ private static TaskServiceFactoryImpl localQueryInstance = null; /** Factory for distributed (Gaian) Registry operations */ private static TaskServiceFactoryImpl remoteQueryInstance = null; /* * Queries */ /** Select records using an arbitrary WHERE clause */ private String PREDICATE_QUERY = null; /** Select all records */ private String SELECT_ALL_SENSOR_FEEDS = null; /** Select records for a particular task Id */ private String SELECT_SENSOR_FEEDS_BY_TASK = null; /** Select a specific task service by ID */ private String SELECT_BY_ID = null; /** Delete records for a particular task */ private static String DELETE_FEEDS_BY_TASK = "delete from " + FabricRegistry.TASK_SYSTEMS + " where TASK_ID='%s'"; /* * Static initialisation */ static { localQueryInstance = new TaskServiceFactoryImpl(QueryScope.LOCAL); remoteQueryInstance = new TaskServiceFactoryImpl(QueryScope.DISTRIBUTED); } private TaskServiceFactoryImpl(QueryScope queryScope) { this.queryScope = queryScope; PREDICATE_QUERY = format("select * from %s where \\%s", FabricRegistry.TASK_SYSTEMS); SELECT_ALL_SENSOR_FEEDS = format("select * from %s", FabricRegistry.TASK_SYSTEMS); SELECT_SENSOR_FEEDS_BY_TASK = format("select * from %s where TASK_ID='\\%s'", FabricRegistry.TASK_SYSTEMS); SELECT_BY_ID = format( "select * from %s where TASK_ID='\\%s' and PLATFORM_ID='\\%s' and SERVICE_ID='\\%s' and DATA_FEED_ID='\\%s'", FabricRegistry.TASK_SYSTEMS); } /** * Get the single instance of this factory. * * @return the factory instance. */ public static TaskServiceFactoryImpl getInstance(QueryScope queryScope) { if (queryScope == QueryScope.LOCAL) { return localQueryInstance; } else { return remoteQueryInstance; } } @Override
public RegistryObject create(IPersistenceResultRow row) throws PersistenceException {
edgware/edgware
fabric.lib/src/fabric/registry/impl/TaskPluginFactoryImpl.java
// Path: fabric.lib/src/fabric/registry/exception/PersistenceException.java // public class PersistenceException extends Exception { // // /** Copyright notice. */ // public static final String copyrightNotice = "(C) Copyright IBM Corp. 2009"; // // private static final long serialVersionUID = 1L; // // private String errorMessage = null; // private int errorCode = 0; // private String sqlState = null; // // /** // * // */ // public PersistenceException() { // } // // /** // * // * @param msg // */ // public PersistenceException(String msg) { // super(msg); // } // // /** // * // * @param detailMessage // * @param throwable // */ // public PersistenceException(String detailMessage, Throwable throwable) { // super(detailMessage, throwable); // } // // /** // * // * @param throwable // */ // public PersistenceException(Throwable throwable) { // super(throwable); // } // // /** // * // * @param message // * @param errorMessage // * @param errorCode // * @param sqlState // */ // public PersistenceException(String message, String errorMessage, int errorCode, String sqlState) { // super(message); // // this.errorMessage = errorMessage; // this.errorCode = errorCode; // this.sqlState = sqlState; // } // // /** // * // * @return // */ // public int getErrorCode() { // return errorCode; // } // // /** // * // * @param errorCode // */ // public void setErrorCode(int errorCode) { // this.errorCode = errorCode; // } // // /** // * // * @return // */ // public String getErrorMessage() { // return errorMessage; // } // // /** // * // * @param errorMessage // */ // public void setErrorMessage(String errorMessage) { // this.errorMessage = errorMessage; // } // // /** // * // * @return // */ // public String getSqlState() { // return sqlState; // } // // /** // * // * @param sqlState // */ // public void setSqlState(String sqlState) { // this.sqlState = sqlState; // } // }
import fabric.registry.FabricPlugin; import fabric.registry.FabricRegistry; import fabric.registry.QueryScope; import fabric.registry.RegistryObject; import fabric.registry.TaskPlugin; import fabric.registry.TaskPluginFactory; import fabric.registry.exception.DuplicateKeyException; import fabric.registry.exception.IncompleteObjectException; import fabric.registry.exception.PersistenceException; import fabric.registry.exception.RegistryQueryException; import fabric.registry.persistence.IPersistenceResultRow;
} } return buf.toString(); } @Override public String getInsertSql(RegistryObject obj) { StringBuilder buf = new StringBuilder(); if (obj instanceof TaskPlugin) { TaskPlugin plugin = (TaskPlugin) obj; buf.append("insert into "); buf.append(FabricRegistry.TASK_PLUGINS); buf.append(" values("); buf.append('\'').append(plugin.getNodeId()).append('\'').append(','); buf.append('\'').append(plugin.getTaskId()).append('\'').append(','); buf.append('\'').append(plugin.getName()).append('\'').append(','); buf.append(nullOrString(plugin.getFamilyName())).append(','); buf.append('\'').append(plugin.getPluginType()).append('\'').append(','); buf.append(plugin.getOrdinal()).append(','); buf.append('\'').append(plugin.getPlatformId()).append('\'').append(','); buf.append('\'').append(plugin.getSensorId()).append('\'').append(','); buf.append('\'').append(plugin.getFeedId()).append('\'').append(','); buf.append(nullOrString(plugin.getDescription())).append(','); buf.append(nullOrString(plugin.getArguments())).append(')'); } return buf.toString(); } @Override
// Path: fabric.lib/src/fabric/registry/exception/PersistenceException.java // public class PersistenceException extends Exception { // // /** Copyright notice. */ // public static final String copyrightNotice = "(C) Copyright IBM Corp. 2009"; // // private static final long serialVersionUID = 1L; // // private String errorMessage = null; // private int errorCode = 0; // private String sqlState = null; // // /** // * // */ // public PersistenceException() { // } // // /** // * // * @param msg // */ // public PersistenceException(String msg) { // super(msg); // } // // /** // * // * @param detailMessage // * @param throwable // */ // public PersistenceException(String detailMessage, Throwable throwable) { // super(detailMessage, throwable); // } // // /** // * // * @param throwable // */ // public PersistenceException(Throwable throwable) { // super(throwable); // } // // /** // * // * @param message // * @param errorMessage // * @param errorCode // * @param sqlState // */ // public PersistenceException(String message, String errorMessage, int errorCode, String sqlState) { // super(message); // // this.errorMessage = errorMessage; // this.errorCode = errorCode; // this.sqlState = sqlState; // } // // /** // * // * @return // */ // public int getErrorCode() { // return errorCode; // } // // /** // * // * @param errorCode // */ // public void setErrorCode(int errorCode) { // this.errorCode = errorCode; // } // // /** // * // * @return // */ // public String getErrorMessage() { // return errorMessage; // } // // /** // * // * @param errorMessage // */ // public void setErrorMessage(String errorMessage) { // this.errorMessage = errorMessage; // } // // /** // * // * @return // */ // public String getSqlState() { // return sqlState; // } // // /** // * // * @param sqlState // */ // public void setSqlState(String sqlState) { // this.sqlState = sqlState; // } // } // Path: fabric.lib/src/fabric/registry/impl/TaskPluginFactoryImpl.java import fabric.registry.FabricPlugin; import fabric.registry.FabricRegistry; import fabric.registry.QueryScope; import fabric.registry.RegistryObject; import fabric.registry.TaskPlugin; import fabric.registry.TaskPluginFactory; import fabric.registry.exception.DuplicateKeyException; import fabric.registry.exception.IncompleteObjectException; import fabric.registry.exception.PersistenceException; import fabric.registry.exception.RegistryQueryException; import fabric.registry.persistence.IPersistenceResultRow; } } return buf.toString(); } @Override public String getInsertSql(RegistryObject obj) { StringBuilder buf = new StringBuilder(); if (obj instanceof TaskPlugin) { TaskPlugin plugin = (TaskPlugin) obj; buf.append("insert into "); buf.append(FabricRegistry.TASK_PLUGINS); buf.append(" values("); buf.append('\'').append(plugin.getNodeId()).append('\'').append(','); buf.append('\'').append(plugin.getTaskId()).append('\'').append(','); buf.append('\'').append(plugin.getName()).append('\'').append(','); buf.append(nullOrString(plugin.getFamilyName())).append(','); buf.append('\'').append(plugin.getPluginType()).append('\'').append(','); buf.append(plugin.getOrdinal()).append(','); buf.append('\'').append(plugin.getPlatformId()).append('\'').append(','); buf.append('\'').append(plugin.getSensorId()).append('\'').append(','); buf.append('\'').append(plugin.getFeedId()).append('\'').append(','); buf.append(nullOrString(plugin.getDescription())).append(','); buf.append(nullOrString(plugin.getArguments())).append(')'); } return buf.toString(); } @Override
public RegistryObject create(IPersistenceResultRow row) throws PersistenceException {
edgware/edgware
fabric.lib/src/fabric/registry/impl/RouteFactoryImpl.java
// Path: fabric.lib/src/fabric/registry/exception/PersistenceException.java // public class PersistenceException extends Exception { // // /** Copyright notice. */ // public static final String copyrightNotice = "(C) Copyright IBM Corp. 2009"; // // private static final long serialVersionUID = 1L; // // private String errorMessage = null; // private int errorCode = 0; // private String sqlState = null; // // /** // * // */ // public PersistenceException() { // } // // /** // * // * @param msg // */ // public PersistenceException(String msg) { // super(msg); // } // // /** // * // * @param detailMessage // * @param throwable // */ // public PersistenceException(String detailMessage, Throwable throwable) { // super(detailMessage, throwable); // } // // /** // * // * @param throwable // */ // public PersistenceException(Throwable throwable) { // super(throwable); // } // // /** // * // * @param message // * @param errorMessage // * @param errorCode // * @param sqlState // */ // public PersistenceException(String message, String errorMessage, int errorCode, String sqlState) { // super(message); // // this.errorMessage = errorMessage; // this.errorCode = errorCode; // this.sqlState = sqlState; // } // // /** // * // * @return // */ // public int getErrorCode() { // return errorCode; // } // // /** // * // * @param errorCode // */ // public void setErrorCode(int errorCode) { // this.errorCode = errorCode; // } // // /** // * // * @return // */ // public String getErrorMessage() { // return errorMessage; // } // // /** // * // * @param errorMessage // */ // public void setErrorMessage(String errorMessage) { // this.errorMessage = errorMessage; // } // // /** // * // * @return // */ // public String getSqlState() { // return sqlState; // } // // /** // * // * @param sqlState // */ // public void setSqlState(String sqlState) { // this.sqlState = sqlState; // } // }
import java.util.logging.Level; import fabric.Fabric; import fabric.FabricBus; import fabric.bus.routing.IRoutingFactory; import fabric.registry.FabricRegistry; import fabric.registry.QueryScope; import fabric.registry.RegistryObject; import fabric.registry.Route; import fabric.registry.RouteFactory; import fabric.registry.exception.DuplicateKeyException; import fabric.registry.exception.IncompleteObjectException; import fabric.registry.exception.PersistenceException; import fabric.registry.exception.RegistryQueryException; import fabric.registry.persistence.IPersistenceResultRow;
/* * (C) Copyright IBM Corp. 2009 * * LICENSE: Eclipse Public License v1.0 * http://www.eclipse.org/legal/epl-v10.html */ package fabric.registry.impl; /** * Implementation of the factory for <code>Route</code>s. */ public class RouteFactoryImpl extends AbstractFactory implements RouteFactory { /** Copyright notice. */ public static final String copyrightNotice = "(C) Copyright IBM Corp. 2009"; /* * Class constants */ /** Factory for centralised (singleton) Registry operations */ private static RouteFactoryImpl localQueryInstance = null; /** Factory for distributed (gaian) Registry operations */ private static RouteFactoryImpl remoteQueryInstance = null; /* * Queries */ /** column selector used in all queries */ private String SELECT_COLUMNS = null; /** Select all records */ private String SELECT_ALL_QUERY = null; /** Select records for a particular starting node */ private String BY_START_NODE_QUERY = null; /** Select records using an arbitrary WHERE clause */ private String PREDICATE_QUERY = null; /* * Static initialisation */ static { localQueryInstance = new RouteFactoryImpl(QueryScope.LOCAL); remoteQueryInstance = new RouteFactoryImpl(QueryScope.DISTRIBUTED); } private RouteFactoryImpl(QueryScope queryScope) { this.queryScope = queryScope; SELECT_COLUMNS = format("r.start_node_id, r.end_node_id, r.ordinal, r.route from %s as r ", FabricRegistry.ROUTES); SELECT_ALL_QUERY = format("select 'all' as type, %s", SELECT_COLUMNS); BY_START_NODE_QUERY = format("select 'byStartNode' as type, %s where START_NODE_ID='\\%s'", SELECT_COLUMNS); PREDICATE_QUERY = format("select 'predicate' as type, %s where \\%s", SELECT_COLUMNS); } public static RouteFactoryImpl getInstance(QueryScope queryScope) { if (queryScope == QueryScope.LOCAL) { return localQueryInstance; } else { return remoteQueryInstance; } } @Override
// Path: fabric.lib/src/fabric/registry/exception/PersistenceException.java // public class PersistenceException extends Exception { // // /** Copyright notice. */ // public static final String copyrightNotice = "(C) Copyright IBM Corp. 2009"; // // private static final long serialVersionUID = 1L; // // private String errorMessage = null; // private int errorCode = 0; // private String sqlState = null; // // /** // * // */ // public PersistenceException() { // } // // /** // * // * @param msg // */ // public PersistenceException(String msg) { // super(msg); // } // // /** // * // * @param detailMessage // * @param throwable // */ // public PersistenceException(String detailMessage, Throwable throwable) { // super(detailMessage, throwable); // } // // /** // * // * @param throwable // */ // public PersistenceException(Throwable throwable) { // super(throwable); // } // // /** // * // * @param message // * @param errorMessage // * @param errorCode // * @param sqlState // */ // public PersistenceException(String message, String errorMessage, int errorCode, String sqlState) { // super(message); // // this.errorMessage = errorMessage; // this.errorCode = errorCode; // this.sqlState = sqlState; // } // // /** // * // * @return // */ // public int getErrorCode() { // return errorCode; // } // // /** // * // * @param errorCode // */ // public void setErrorCode(int errorCode) { // this.errorCode = errorCode; // } // // /** // * // * @return // */ // public String getErrorMessage() { // return errorMessage; // } // // /** // * // * @param errorMessage // */ // public void setErrorMessage(String errorMessage) { // this.errorMessage = errorMessage; // } // // /** // * // * @return // */ // public String getSqlState() { // return sqlState; // } // // /** // * // * @param sqlState // */ // public void setSqlState(String sqlState) { // this.sqlState = sqlState; // } // } // Path: fabric.lib/src/fabric/registry/impl/RouteFactoryImpl.java import java.util.logging.Level; import fabric.Fabric; import fabric.FabricBus; import fabric.bus.routing.IRoutingFactory; import fabric.registry.FabricRegistry; import fabric.registry.QueryScope; import fabric.registry.RegistryObject; import fabric.registry.Route; import fabric.registry.RouteFactory; import fabric.registry.exception.DuplicateKeyException; import fabric.registry.exception.IncompleteObjectException; import fabric.registry.exception.PersistenceException; import fabric.registry.exception.RegistryQueryException; import fabric.registry.persistence.IPersistenceResultRow; /* * (C) Copyright IBM Corp. 2009 * * LICENSE: Eclipse Public License v1.0 * http://www.eclipse.org/legal/epl-v10.html */ package fabric.registry.impl; /** * Implementation of the factory for <code>Route</code>s. */ public class RouteFactoryImpl extends AbstractFactory implements RouteFactory { /** Copyright notice. */ public static final String copyrightNotice = "(C) Copyright IBM Corp. 2009"; /* * Class constants */ /** Factory for centralised (singleton) Registry operations */ private static RouteFactoryImpl localQueryInstance = null; /** Factory for distributed (gaian) Registry operations */ private static RouteFactoryImpl remoteQueryInstance = null; /* * Queries */ /** column selector used in all queries */ private String SELECT_COLUMNS = null; /** Select all records */ private String SELECT_ALL_QUERY = null; /** Select records for a particular starting node */ private String BY_START_NODE_QUERY = null; /** Select records using an arbitrary WHERE clause */ private String PREDICATE_QUERY = null; /* * Static initialisation */ static { localQueryInstance = new RouteFactoryImpl(QueryScope.LOCAL); remoteQueryInstance = new RouteFactoryImpl(QueryScope.DISTRIBUTED); } private RouteFactoryImpl(QueryScope queryScope) { this.queryScope = queryScope; SELECT_COLUMNS = format("r.start_node_id, r.end_node_id, r.ordinal, r.route from %s as r ", FabricRegistry.ROUTES); SELECT_ALL_QUERY = format("select 'all' as type, %s", SELECT_COLUMNS); BY_START_NODE_QUERY = format("select 'byStartNode' as type, %s where START_NODE_ID='\\%s'", SELECT_COLUMNS); PREDICATE_QUERY = format("select 'predicate' as type, %s where \\%s", SELECT_COLUMNS); } public static RouteFactoryImpl getInstance(QueryScope queryScope) { if (queryScope == QueryScope.LOCAL) { return localQueryInstance; } else { return remoteQueryInstance; } } @Override
public RegistryObject create(IPersistenceResultRow row) throws PersistenceException {
edgware/edgware
fabric.lib/src/fabric/registry/impl/TypeFactoryImpl.java
// Path: fabric.lib/src/fabric/registry/exception/PersistenceException.java // public class PersistenceException extends Exception { // // /** Copyright notice. */ // public static final String copyrightNotice = "(C) Copyright IBM Corp. 2009"; // // private static final long serialVersionUID = 1L; // // private String errorMessage = null; // private int errorCode = 0; // private String sqlState = null; // // /** // * // */ // public PersistenceException() { // } // // /** // * // * @param msg // */ // public PersistenceException(String msg) { // super(msg); // } // // /** // * // * @param detailMessage // * @param throwable // */ // public PersistenceException(String detailMessage, Throwable throwable) { // super(detailMessage, throwable); // } // // /** // * // * @param throwable // */ // public PersistenceException(Throwable throwable) { // super(throwable); // } // // /** // * // * @param message // * @param errorMessage // * @param errorCode // * @param sqlState // */ // public PersistenceException(String message, String errorMessage, int errorCode, String sqlState) { // super(message); // // this.errorMessage = errorMessage; // this.errorCode = errorCode; // this.sqlState = sqlState; // } // // /** // * // * @return // */ // public int getErrorCode() { // return errorCode; // } // // /** // * // * @param errorCode // */ // public void setErrorCode(int errorCode) { // this.errorCode = errorCode; // } // // /** // * // * @return // */ // public String getErrorMessage() { // return errorMessage; // } // // /** // * // * @param errorMessage // */ // public void setErrorMessage(String errorMessage) { // this.errorMessage = errorMessage; // } // // /** // * // * @return // */ // public String getSqlState() { // return sqlState; // } // // /** // * // * @param sqlState // */ // public void setSqlState(String sqlState) { // this.sqlState = sqlState; // } // }
import java.util.logging.Level; import fabric.Fabric; import fabric.registry.FabricRegistry; import fabric.registry.QueryScope; import fabric.registry.RegistryObject; import fabric.registry.Type; import fabric.registry.TypeFactory; import fabric.registry.exception.DuplicateKeyException; import fabric.registry.exception.IncompleteObjectException; import fabric.registry.exception.PersistenceException; import fabric.registry.exception.RegistryQueryException; import fabric.registry.persistence.IPersistenceResultRow;
SELECT_ALL_QUERY_SERVICE_TYPES = Fabric.format("select * from %s", FabricRegistry.FEED_TYPES); SELECT_ALL_QUERY_NODE_TYPES = Fabric.format("select * from %s", FabricRegistry.NODE_TYPES); SELECT_ALL_QUERY_PLATFORM_TYPES = Fabric.format("select * from %s", FabricRegistry.PLATFORM_TYPES); SELECT_ALL_QUERY_SYSTEM_TYPES = Fabric.format("select * from %s", FabricRegistry.SYSTEM_TYPES); SELECT_ALL_SERVICE_WIRING = Fabric.format("select * from %s", FabricRegistry.SYSTEM_WIRING); BY_ID_QUERY_ACTOR_TYPE = Fabric.format("select * from %s where TYPE_ID='\\%s'", FabricRegistry.ACTOR_TYPES); BY_ID_QUERY_SERVICE_TYPE = Fabric.format("select * from %s where TYPE_ID='\\%s'", FabricRegistry.FEED_TYPES); BY_ID_QUERY_NODE_TYPE = Fabric.format("select * from %s where TYPE_ID='\\%s'", FabricRegistry.NODE_TYPES); BY_ID_QUERY_PLATFORM_TYPE = Fabric.format("select * from %s where TYPE_ID='\\%s'", FabricRegistry.PLATFORM_TYPES); BY_ID_QUERY_SYSTEM_TYPE = Fabric.format("select * from %s where TYPE_ID='\\%s'", FabricRegistry.SYSTEM_TYPES); PREDICATE_QUERY_ACTOR_TYPES = Fabric.format("select * from %s where \\%s", FabricRegistry.ACTOR_TYPES); PREDICATE_QUERY_SERVICE_TYPES = Fabric.format("select * from %s where \\%s", FabricRegistry.FEED_TYPES); PREDICATE_QUERY_NODE_TYPES = Fabric.format("select * from %s where \\%s", FabricRegistry.NODE_TYPES); PREDICATE_QUERY_PLATFORM_TYPES = Fabric.format("select * from %s where \\%s", FabricRegistry.PLATFORM_TYPES); PREDICATE_QUERY_SYSTEM_TYPES = Fabric.format("select * from %s where \\%s", FabricRegistry.SYSTEM_TYPES); } public static TypeFactory getInstance(QueryScope queryScope) { if (queryScope == QueryScope.LOCAL) { return localQueryInstance; } else { return remoteQueryInstance; } } @Override
// Path: fabric.lib/src/fabric/registry/exception/PersistenceException.java // public class PersistenceException extends Exception { // // /** Copyright notice. */ // public static final String copyrightNotice = "(C) Copyright IBM Corp. 2009"; // // private static final long serialVersionUID = 1L; // // private String errorMessage = null; // private int errorCode = 0; // private String sqlState = null; // // /** // * // */ // public PersistenceException() { // } // // /** // * // * @param msg // */ // public PersistenceException(String msg) { // super(msg); // } // // /** // * // * @param detailMessage // * @param throwable // */ // public PersistenceException(String detailMessage, Throwable throwable) { // super(detailMessage, throwable); // } // // /** // * // * @param throwable // */ // public PersistenceException(Throwable throwable) { // super(throwable); // } // // /** // * // * @param message // * @param errorMessage // * @param errorCode // * @param sqlState // */ // public PersistenceException(String message, String errorMessage, int errorCode, String sqlState) { // super(message); // // this.errorMessage = errorMessage; // this.errorCode = errorCode; // this.sqlState = sqlState; // } // // /** // * // * @return // */ // public int getErrorCode() { // return errorCode; // } // // /** // * // * @param errorCode // */ // public void setErrorCode(int errorCode) { // this.errorCode = errorCode; // } // // /** // * // * @return // */ // public String getErrorMessage() { // return errorMessage; // } // // /** // * // * @param errorMessage // */ // public void setErrorMessage(String errorMessage) { // this.errorMessage = errorMessage; // } // // /** // * // * @return // */ // public String getSqlState() { // return sqlState; // } // // /** // * // * @param sqlState // */ // public void setSqlState(String sqlState) { // this.sqlState = sqlState; // } // } // Path: fabric.lib/src/fabric/registry/impl/TypeFactoryImpl.java import java.util.logging.Level; import fabric.Fabric; import fabric.registry.FabricRegistry; import fabric.registry.QueryScope; import fabric.registry.RegistryObject; import fabric.registry.Type; import fabric.registry.TypeFactory; import fabric.registry.exception.DuplicateKeyException; import fabric.registry.exception.IncompleteObjectException; import fabric.registry.exception.PersistenceException; import fabric.registry.exception.RegistryQueryException; import fabric.registry.persistence.IPersistenceResultRow; SELECT_ALL_QUERY_SERVICE_TYPES = Fabric.format("select * from %s", FabricRegistry.FEED_TYPES); SELECT_ALL_QUERY_NODE_TYPES = Fabric.format("select * from %s", FabricRegistry.NODE_TYPES); SELECT_ALL_QUERY_PLATFORM_TYPES = Fabric.format("select * from %s", FabricRegistry.PLATFORM_TYPES); SELECT_ALL_QUERY_SYSTEM_TYPES = Fabric.format("select * from %s", FabricRegistry.SYSTEM_TYPES); SELECT_ALL_SERVICE_WIRING = Fabric.format("select * from %s", FabricRegistry.SYSTEM_WIRING); BY_ID_QUERY_ACTOR_TYPE = Fabric.format("select * from %s where TYPE_ID='\\%s'", FabricRegistry.ACTOR_TYPES); BY_ID_QUERY_SERVICE_TYPE = Fabric.format("select * from %s where TYPE_ID='\\%s'", FabricRegistry.FEED_TYPES); BY_ID_QUERY_NODE_TYPE = Fabric.format("select * from %s where TYPE_ID='\\%s'", FabricRegistry.NODE_TYPES); BY_ID_QUERY_PLATFORM_TYPE = Fabric.format("select * from %s where TYPE_ID='\\%s'", FabricRegistry.PLATFORM_TYPES); BY_ID_QUERY_SYSTEM_TYPE = Fabric.format("select * from %s where TYPE_ID='\\%s'", FabricRegistry.SYSTEM_TYPES); PREDICATE_QUERY_ACTOR_TYPES = Fabric.format("select * from %s where \\%s", FabricRegistry.ACTOR_TYPES); PREDICATE_QUERY_SERVICE_TYPES = Fabric.format("select * from %s where \\%s", FabricRegistry.FEED_TYPES); PREDICATE_QUERY_NODE_TYPES = Fabric.format("select * from %s where \\%s", FabricRegistry.NODE_TYPES); PREDICATE_QUERY_PLATFORM_TYPES = Fabric.format("select * from %s where \\%s", FabricRegistry.PLATFORM_TYPES); PREDICATE_QUERY_SYSTEM_TYPES = Fabric.format("select * from %s where \\%s", FabricRegistry.SYSTEM_TYPES); } public static TypeFactory getInstance(QueryScope queryScope) { if (queryScope == QueryScope.LOCAL) { return localQueryInstance; } else { return remoteQueryInstance; } } @Override
public RegistryObject create(IPersistenceResultRow row) throws PersistenceException {
edgware/edgware
fabric.lib/src/fabric/registry/impl/ServiceFactoryImpl.java
// Path: fabric.lib/src/fabric/registry/exception/PersistenceException.java // public class PersistenceException extends Exception { // // /** Copyright notice. */ // public static final String copyrightNotice = "(C) Copyright IBM Corp. 2009"; // // private static final long serialVersionUID = 1L; // // private String errorMessage = null; // private int errorCode = 0; // private String sqlState = null; // // /** // * // */ // public PersistenceException() { // } // // /** // * // * @param msg // */ // public PersistenceException(String msg) { // super(msg); // } // // /** // * // * @param detailMessage // * @param throwable // */ // public PersistenceException(String detailMessage, Throwable throwable) { // super(detailMessage, throwable); // } // // /** // * // * @param throwable // */ // public PersistenceException(Throwable throwable) { // super(throwable); // } // // /** // * // * @param message // * @param errorMessage // * @param errorCode // * @param sqlState // */ // public PersistenceException(String message, String errorMessage, int errorCode, String sqlState) { // super(message); // // this.errorMessage = errorMessage; // this.errorCode = errorCode; // this.sqlState = sqlState; // } // // /** // * // * @return // */ // public int getErrorCode() { // return errorCode; // } // // /** // * // * @param errorCode // */ // public void setErrorCode(int errorCode) { // this.errorCode = errorCode; // } // // /** // * // * @return // */ // public String getErrorMessage() { // return errorMessage; // } // // /** // * // * @param errorMessage // */ // public void setErrorMessage(String errorMessage) { // this.errorMessage = errorMessage; // } // // /** // * // * @return // */ // public String getSqlState() { // return sqlState; // } // // /** // * // * @param sqlState // */ // public void setSqlState(String sqlState) { // this.sqlState = sqlState; // } // }
import fabric.Fabric; import fabric.registry.FabricRegistry; import fabric.registry.QueryScope; import fabric.registry.RegistryObject; import fabric.registry.Service; import fabric.registry.ServiceFactory; import fabric.registry.exception.DuplicateKeyException; import fabric.registry.exception.IncompleteObjectException; import fabric.registry.exception.PersistenceException; import fabric.registry.exception.RegistryQueryException; import fabric.registry.persistence.IPersistenceResultRow;
@Override public Service createListener(String platformId, String systemId, String serviceId, String typeId) { return createService(platformId, systemId, serviceId, typeId, Service.MODE_LISTENER, null, null, null, null, null); } /** * @see fabric.registry.ServiceFactory#createService(java.lang.String, java.lang.String, java.lang.String, * java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, * java.lang.String) */ @Override public Service createService(String platformId, String systemId, String id, String typeID, String mode, String credentials, String availability, String description, String attributes, String attributesURI) { Service f = new ServiceImpl(platformId, systemId, id, typeID, mode, credentials, availability, description, attributes, attributesURI); return f; } /** * @see fabric.registry.ServiceFactory#getAllServices() */ @Override public Service[] getAllServices() { Service[] services = null; try { services = queryServices(SELECT_ALL_QUERY);
// Path: fabric.lib/src/fabric/registry/exception/PersistenceException.java // public class PersistenceException extends Exception { // // /** Copyright notice. */ // public static final String copyrightNotice = "(C) Copyright IBM Corp. 2009"; // // private static final long serialVersionUID = 1L; // // private String errorMessage = null; // private int errorCode = 0; // private String sqlState = null; // // /** // * // */ // public PersistenceException() { // } // // /** // * // * @param msg // */ // public PersistenceException(String msg) { // super(msg); // } // // /** // * // * @param detailMessage // * @param throwable // */ // public PersistenceException(String detailMessage, Throwable throwable) { // super(detailMessage, throwable); // } // // /** // * // * @param throwable // */ // public PersistenceException(Throwable throwable) { // super(throwable); // } // // /** // * // * @param message // * @param errorMessage // * @param errorCode // * @param sqlState // */ // public PersistenceException(String message, String errorMessage, int errorCode, String sqlState) { // super(message); // // this.errorMessage = errorMessage; // this.errorCode = errorCode; // this.sqlState = sqlState; // } // // /** // * // * @return // */ // public int getErrorCode() { // return errorCode; // } // // /** // * // * @param errorCode // */ // public void setErrorCode(int errorCode) { // this.errorCode = errorCode; // } // // /** // * // * @return // */ // public String getErrorMessage() { // return errorMessage; // } // // /** // * // * @param errorMessage // */ // public void setErrorMessage(String errorMessage) { // this.errorMessage = errorMessage; // } // // /** // * // * @return // */ // public String getSqlState() { // return sqlState; // } // // /** // * // * @param sqlState // */ // public void setSqlState(String sqlState) { // this.sqlState = sqlState; // } // } // Path: fabric.lib/src/fabric/registry/impl/ServiceFactoryImpl.java import fabric.Fabric; import fabric.registry.FabricRegistry; import fabric.registry.QueryScope; import fabric.registry.RegistryObject; import fabric.registry.Service; import fabric.registry.ServiceFactory; import fabric.registry.exception.DuplicateKeyException; import fabric.registry.exception.IncompleteObjectException; import fabric.registry.exception.PersistenceException; import fabric.registry.exception.RegistryQueryException; import fabric.registry.persistence.IPersistenceResultRow; @Override public Service createListener(String platformId, String systemId, String serviceId, String typeId) { return createService(platformId, systemId, serviceId, typeId, Service.MODE_LISTENER, null, null, null, null, null); } /** * @see fabric.registry.ServiceFactory#createService(java.lang.String, java.lang.String, java.lang.String, * java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, * java.lang.String) */ @Override public Service createService(String platformId, String systemId, String id, String typeID, String mode, String credentials, String availability, String description, String attributes, String attributesURI) { Service f = new ServiceImpl(platformId, systemId, id, typeID, mode, credentials, availability, description, attributes, attributesURI); return f; } /** * @see fabric.registry.ServiceFactory#getAllServices() */ @Override public Service[] getAllServices() { Service[] services = null; try { services = queryServices(SELECT_ALL_QUERY);
} catch (PersistenceException e) {
edgware/edgware
fabric.lib/src/fabric/registry/impl/TaskNodeFactoryImpl.java
// Path: fabric.lib/src/fabric/registry/exception/PersistenceException.java // public class PersistenceException extends Exception { // // /** Copyright notice. */ // public static final String copyrightNotice = "(C) Copyright IBM Corp. 2009"; // // private static final long serialVersionUID = 1L; // // private String errorMessage = null; // private int errorCode = 0; // private String sqlState = null; // // /** // * // */ // public PersistenceException() { // } // // /** // * // * @param msg // */ // public PersistenceException(String msg) { // super(msg); // } // // /** // * // * @param detailMessage // * @param throwable // */ // public PersistenceException(String detailMessage, Throwable throwable) { // super(detailMessage, throwable); // } // // /** // * // * @param throwable // */ // public PersistenceException(Throwable throwable) { // super(throwable); // } // // /** // * // * @param message // * @param errorMessage // * @param errorCode // * @param sqlState // */ // public PersistenceException(String message, String errorMessage, int errorCode, String sqlState) { // super(message); // // this.errorMessage = errorMessage; // this.errorCode = errorCode; // this.sqlState = sqlState; // } // // /** // * // * @return // */ // public int getErrorCode() { // return errorCode; // } // // /** // * // * @param errorCode // */ // public void setErrorCode(int errorCode) { // this.errorCode = errorCode; // } // // /** // * // * @return // */ // public String getErrorMessage() { // return errorMessage; // } // // /** // * // * @param errorMessage // */ // public void setErrorMessage(String errorMessage) { // this.errorMessage = errorMessage; // } // // /** // * // * @return // */ // public String getSqlState() { // return sqlState; // } // // /** // * // * @param sqlState // */ // public void setSqlState(String sqlState) { // this.sqlState = sqlState; // } // }
import fabric.registry.FabricRegistry; import fabric.registry.QueryScope; import fabric.registry.RegistryObject; import fabric.registry.TaskNode; import fabric.registry.TaskNodeFactory; import fabric.registry.exception.DuplicateKeyException; import fabric.registry.exception.IncompleteObjectException; import fabric.registry.exception.PersistenceException; import fabric.registry.exception.RegistryQueryException; import fabric.registry.persistence.IPersistenceResultRow;
/* * (C) Copyright IBM Corp. 2009 * * LICENSE: Eclipse Public License v1.0 * http://www.eclipse.org/legal/epl-v10.html */ package fabric.registry.impl; /** * Implementation of the factory for <code>TaskNode</code>s. */ public class TaskNodeFactoryImpl extends AbstractFactory implements TaskNodeFactory { /** Copyright notice. */ public static final String copyrightNotice = "(C) Copyright IBM Corp. 2009"; /* * Constants */ /** Factory for local (singleton) Registry operations */ private static TaskNodeFactoryImpl localQueryInstance = null; /** Factory for remote (distributed) Registry operations */ private static TaskNodeFactoryImpl remoteQueryInstance = null; /* * Queries */ /** Select all records */ private String SELECT_ALL_QUERY = "select * from " + FabricRegistry.TASK_NODES; /** Select records for a particular task */ private String BY_TASK_QUERY = "select * from " + FabricRegistry.TASK_NODES + " where TASK_ID='"; /** Select records using an arbitrary WHERE clause */ private String PREDICATE_QUERY = "select * from " + FabricRegistry.TASK_NODES + " where "; /* * Static initialisation */ static { localQueryInstance = new TaskNodeFactoryImpl(QueryScope.LOCAL); remoteQueryInstance = new TaskNodeFactoryImpl(QueryScope.DISTRIBUTED); } private TaskNodeFactoryImpl(QueryScope queryScope) { this.queryScope = queryScope; SELECT_ALL_QUERY = format("select * from %s", FabricRegistry.TASK_NODES); BY_TASK_QUERY = format("select * from %s where TASK_ID='\\%s'", FabricRegistry.TASK_NODES); PREDICATE_QUERY = format("select * from %s where \\%s", FabricRegistry.TASK_NODES); } public static TaskNodeFactoryImpl getInstance(QueryScope queryScope) { if (queryScope == QueryScope.LOCAL) { return localQueryInstance; } else { return remoteQueryInstance; } } @Override
// Path: fabric.lib/src/fabric/registry/exception/PersistenceException.java // public class PersistenceException extends Exception { // // /** Copyright notice. */ // public static final String copyrightNotice = "(C) Copyright IBM Corp. 2009"; // // private static final long serialVersionUID = 1L; // // private String errorMessage = null; // private int errorCode = 0; // private String sqlState = null; // // /** // * // */ // public PersistenceException() { // } // // /** // * // * @param msg // */ // public PersistenceException(String msg) { // super(msg); // } // // /** // * // * @param detailMessage // * @param throwable // */ // public PersistenceException(String detailMessage, Throwable throwable) { // super(detailMessage, throwable); // } // // /** // * // * @param throwable // */ // public PersistenceException(Throwable throwable) { // super(throwable); // } // // /** // * // * @param message // * @param errorMessage // * @param errorCode // * @param sqlState // */ // public PersistenceException(String message, String errorMessage, int errorCode, String sqlState) { // super(message); // // this.errorMessage = errorMessage; // this.errorCode = errorCode; // this.sqlState = sqlState; // } // // /** // * // * @return // */ // public int getErrorCode() { // return errorCode; // } // // /** // * // * @param errorCode // */ // public void setErrorCode(int errorCode) { // this.errorCode = errorCode; // } // // /** // * // * @return // */ // public String getErrorMessage() { // return errorMessage; // } // // /** // * // * @param errorMessage // */ // public void setErrorMessage(String errorMessage) { // this.errorMessage = errorMessage; // } // // /** // * // * @return // */ // public String getSqlState() { // return sqlState; // } // // /** // * // * @param sqlState // */ // public void setSqlState(String sqlState) { // this.sqlState = sqlState; // } // } // Path: fabric.lib/src/fabric/registry/impl/TaskNodeFactoryImpl.java import fabric.registry.FabricRegistry; import fabric.registry.QueryScope; import fabric.registry.RegistryObject; import fabric.registry.TaskNode; import fabric.registry.TaskNodeFactory; import fabric.registry.exception.DuplicateKeyException; import fabric.registry.exception.IncompleteObjectException; import fabric.registry.exception.PersistenceException; import fabric.registry.exception.RegistryQueryException; import fabric.registry.persistence.IPersistenceResultRow; /* * (C) Copyright IBM Corp. 2009 * * LICENSE: Eclipse Public License v1.0 * http://www.eclipse.org/legal/epl-v10.html */ package fabric.registry.impl; /** * Implementation of the factory for <code>TaskNode</code>s. */ public class TaskNodeFactoryImpl extends AbstractFactory implements TaskNodeFactory { /** Copyright notice. */ public static final String copyrightNotice = "(C) Copyright IBM Corp. 2009"; /* * Constants */ /** Factory for local (singleton) Registry operations */ private static TaskNodeFactoryImpl localQueryInstance = null; /** Factory for remote (distributed) Registry operations */ private static TaskNodeFactoryImpl remoteQueryInstance = null; /* * Queries */ /** Select all records */ private String SELECT_ALL_QUERY = "select * from " + FabricRegistry.TASK_NODES; /** Select records for a particular task */ private String BY_TASK_QUERY = "select * from " + FabricRegistry.TASK_NODES + " where TASK_ID='"; /** Select records using an arbitrary WHERE clause */ private String PREDICATE_QUERY = "select * from " + FabricRegistry.TASK_NODES + " where "; /* * Static initialisation */ static { localQueryInstance = new TaskNodeFactoryImpl(QueryScope.LOCAL); remoteQueryInstance = new TaskNodeFactoryImpl(QueryScope.DISTRIBUTED); } private TaskNodeFactoryImpl(QueryScope queryScope) { this.queryScope = queryScope; SELECT_ALL_QUERY = format("select * from %s", FabricRegistry.TASK_NODES); BY_TASK_QUERY = format("select * from %s where TASK_ID='\\%s'", FabricRegistry.TASK_NODES); PREDICATE_QUERY = format("select * from %s where \\%s", FabricRegistry.TASK_NODES); } public static TaskNodeFactoryImpl getInstance(QueryScope queryScope) { if (queryScope == QueryScope.LOCAL) { return localQueryInstance; } else { return remoteQueryInstance; } } @Override
public RegistryObject create(IPersistenceResultRow row) throws PersistenceException {
cinchapi/accent4j
src/main/java/com/cinchapi/common/concurrent/ExecutorRaceService.java
// Path: src/main/java/com/cinchapi/common/base/Array.java // public final class Array { // // /** // * Return an array containing all the {@code args}. // * <p> // * This method is just syntactic sugar for easily passing array objects to // * methods that don't take varargs. // * </p> // * // * @param args the elements that should go in the array. // * @return args // */ // @SafeVarargs // public static <T> T[] containing(T... args) { // return args; // } // // /** // * Return a new array that contains the items in the {@code args} array in // * reverse order. // * // * @param args // * @return an array containing the {@code args} in reverse // */ // @SafeVarargs // public static <T> T[] reverse(T... args) { // T[] copy = Arrays.copyOf(args, args.length); // reverseInPlace(copy); // return copy; // } // // /** // * Reverse the order of the items in the {@code args} array in-place (e.g. // * edit the input array). // * // * @param args // */ // @SafeVarargs // public static <T> void reverseInPlace(T... args) { // for (int i = 0; i < args.length / 2; ++i) { // T swap = args[i]; // args[i] = args[args.length - i - 1]; // args[args.length - i - 1] = swap; // } // } // // private Array() {} // // }
import com.google.common.base.Preconditions; import java.util.Arrays; import java.util.concurrent.BlockingQueue; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.Executor; import java.util.concurrent.Executors; import java.util.concurrent.Future; import java.util.concurrent.FutureTask; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.RunnableFuture; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import java.util.stream.Collectors; import com.cinchapi.common.base.Array;
/** * Return the {@link Future} for the first of the {@code headStartTask} and * {@code tasks} to complete; giving the first {@code task} * {@code headStartTime} {@code headStartTimeUnit} to complete before * allowing the remaining {@code tasks} to race. * <p> * Even if the {@code headStartTask} does not finish within the head start * period, it may still finish before the other {@code tasks} and returns * its {@link Future}. * </p> * <p> * The {@link Future} is guaranteed to be {@link Future#isDone()} when this * method returns. * </p> * * @param headStartTime * @param headStartTimeUnit * @param headStartTask * @param tasks * @return the {@link Future} of the completed task * @throws InterruptedException */ public Future<V> raceWithHeadStart(long headStartTime, TimeUnit headStartTimeUnit, Runnable headStartTask, Runnable... tasks) throws InterruptedException { return raceWithHeadStart(headStartTime, headStartTimeUnit, Executors.callable(headStartTask, null), Arrays.stream(tasks).map(Executors::callable) .collect(Collectors.toList())
// Path: src/main/java/com/cinchapi/common/base/Array.java // public final class Array { // // /** // * Return an array containing all the {@code args}. // * <p> // * This method is just syntactic sugar for easily passing array objects to // * methods that don't take varargs. // * </p> // * // * @param args the elements that should go in the array. // * @return args // */ // @SafeVarargs // public static <T> T[] containing(T... args) { // return args; // } // // /** // * Return a new array that contains the items in the {@code args} array in // * reverse order. // * // * @param args // * @return an array containing the {@code args} in reverse // */ // @SafeVarargs // public static <T> T[] reverse(T... args) { // T[] copy = Arrays.copyOf(args, args.length); // reverseInPlace(copy); // return copy; // } // // /** // * Reverse the order of the items in the {@code args} array in-place (e.g. // * edit the input array). // * // * @param args // */ // @SafeVarargs // public static <T> void reverseInPlace(T... args) { // for (int i = 0; i < args.length / 2; ++i) { // T swap = args[i]; // args[i] = args[args.length - i - 1]; // args[args.length - i - 1] = swap; // } // } // // private Array() {} // // } // Path: src/main/java/com/cinchapi/common/concurrent/ExecutorRaceService.java import com.google.common.base.Preconditions; import java.util.Arrays; import java.util.concurrent.BlockingQueue; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.Executor; import java.util.concurrent.Executors; import java.util.concurrent.Future; import java.util.concurrent.FutureTask; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.RunnableFuture; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import java.util.stream.Collectors; import com.cinchapi.common.base.Array; /** * Return the {@link Future} for the first of the {@code headStartTask} and * {@code tasks} to complete; giving the first {@code task} * {@code headStartTime} {@code headStartTimeUnit} to complete before * allowing the remaining {@code tasks} to race. * <p> * Even if the {@code headStartTask} does not finish within the head start * period, it may still finish before the other {@code tasks} and returns * its {@link Future}. * </p> * <p> * The {@link Future} is guaranteed to be {@link Future#isDone()} when this * method returns. * </p> * * @param headStartTime * @param headStartTimeUnit * @param headStartTask * @param tasks * @return the {@link Future} of the completed task * @throws InterruptedException */ public Future<V> raceWithHeadStart(long headStartTime, TimeUnit headStartTimeUnit, Runnable headStartTask, Runnable... tasks) throws InterruptedException { return raceWithHeadStart(headStartTime, headStartTimeUnit, Executors.callable(headStartTask, null), Arrays.stream(tasks).map(Executors::callable) .collect(Collectors.toList())
.toArray(Array.containing()));
cinchapi/accent4j
src/test/java/com/cinchapi/common/base/StringSplitterPerformanceTest.java
// Path: src/main/java/com/cinchapi/common/profile/Benchmark.java // public abstract class Benchmark { // // /** // * The {@link TimeUnit} in which the elapsed time should be expressed when // * returned to the caller. // */ // private final TimeUnit unit; // // /** // * Construct a new instance. // * // * @param unit the desired {@link #unit time unit} // */ // public Benchmark(TimeUnit unit) { // this.unit = unit; // } // // public abstract void action(); // // /** // * Return the average run time of the {@link #action()} over the specified // * number of run {@code times}. // * // * @param times // * @return the average run time // */ // public final double average(int times) { // return (double) run(times) / times; // } // // /** // * Run the {@link #action() action} once and return the elapsed time, // * expressed in the {@link TimeUnit} that was passed into the constructor. // * // * @return the elapsed time // */ // public final long run() { // long start = System.nanoTime(); // action(); // long end = System.nanoTime(); // return unit.convert(end - start, TimeUnit.NANOSECONDS); // } // // /** // * Run the {@link #action action} the specified number of {@times} and // * return the elapsed time, expressed in the {@link TimeUnit} that was // * passed into the constructor. // * // * @param rounds // * @return the elapsed time // */ // public final long run(int times) { // long start = System.nanoTime(); // for (int i = 0; i < times; ++i) { // action(); // } // long end = System.nanoTime(); // return unit.convert(end - start, TimeUnit.NANOSECONDS); // } // // }
import java.util.concurrent.TimeUnit; import org.junit.Assert; import org.junit.Ignore; import org.junit.Test; import com.cinchapi.common.profile.Benchmark;
/* * Copyright (c) 2013-2019 Cinchapi Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cinchapi.common.base; /** * Unit tests to verify that {@link StringSplitter} is faster than alternative * methods. * * @author Jeff Nelson */ public class StringSplitterPerformanceTest { @Test @Ignore public void testSimpleSplit() { String string = "The Gangs All Here,www.youtube.com/embed/VlWsLs8G7Kg,," + "\"Anacostia follows the lives of the residents of ANACOSTIA, " + "a small residential community in Washington D.C. as they " + "navigate through love, betrayal, deception, sex and murder\"," + "ANACOSTIA,3,7,,Webseries,,,"; int rounds = 5000;
// Path: src/main/java/com/cinchapi/common/profile/Benchmark.java // public abstract class Benchmark { // // /** // * The {@link TimeUnit} in which the elapsed time should be expressed when // * returned to the caller. // */ // private final TimeUnit unit; // // /** // * Construct a new instance. // * // * @param unit the desired {@link #unit time unit} // */ // public Benchmark(TimeUnit unit) { // this.unit = unit; // } // // public abstract void action(); // // /** // * Return the average run time of the {@link #action()} over the specified // * number of run {@code times}. // * // * @param times // * @return the average run time // */ // public final double average(int times) { // return (double) run(times) / times; // } // // /** // * Run the {@link #action() action} once and return the elapsed time, // * expressed in the {@link TimeUnit} that was passed into the constructor. // * // * @return the elapsed time // */ // public final long run() { // long start = System.nanoTime(); // action(); // long end = System.nanoTime(); // return unit.convert(end - start, TimeUnit.NANOSECONDS); // } // // /** // * Run the {@link #action action} the specified number of {@times} and // * return the elapsed time, expressed in the {@link TimeUnit} that was // * passed into the constructor. // * // * @param rounds // * @return the elapsed time // */ // public final long run(int times) { // long start = System.nanoTime(); // for (int i = 0; i < times; ++i) { // action(); // } // long end = System.nanoTime(); // return unit.convert(end - start, TimeUnit.NANOSECONDS); // } // // } // Path: src/test/java/com/cinchapi/common/base/StringSplitterPerformanceTest.java import java.util.concurrent.TimeUnit; import org.junit.Assert; import org.junit.Ignore; import org.junit.Test; import com.cinchapi.common.profile.Benchmark; /* * Copyright (c) 2013-2019 Cinchapi Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.cinchapi.common.base; /** * Unit tests to verify that {@link StringSplitter} is faster than alternative * methods. * * @author Jeff Nelson */ public class StringSplitterPerformanceTest { @Test @Ignore public void testSimpleSplit() { String string = "The Gangs All Here,www.youtube.com/embed/VlWsLs8G7Kg,," + "\"Anacostia follows the lives of the residents of ANACOSTIA, " + "a small residential community in Washington D.C. as they " + "navigate through love, betrayal, deception, sex and murder\"," + "ANACOSTIA,3,7,,Webseries,,,"; int rounds = 5000;
Benchmark builtIn = new Benchmark(TimeUnit.MICROSECONDS) {
cinchapi/accent4j
src/test/java/com/cinchapi/common/reflect/ReflectionTest.java
// Path: src/main/java/com/cinchapi/common/base/Array.java // public final class Array { // // /** // * Return an array containing all the {@code args}. // * <p> // * This method is just syntactic sugar for easily passing array objects to // * methods that don't take varargs. // * </p> // * // * @param args the elements that should go in the array. // * @return args // */ // @SafeVarargs // public static <T> T[] containing(T... args) { // return args; // } // // /** // * Return a new array that contains the items in the {@code args} array in // * reverse order. // * // * @param args // * @return an array containing the {@code args} in reverse // */ // @SafeVarargs // public static <T> T[] reverse(T... args) { // T[] copy = Arrays.copyOf(args, args.length); // reverseInPlace(copy); // return copy; // } // // /** // * Reverse the order of the items in the {@code args} array in-place (e.g. // * edit the input array). // * // * @param args // */ // @SafeVarargs // public static <T> void reverseInPlace(T... args) { // for (int i = 0; i < args.length / 2; ++i) { // T swap = args[i]; // args[i] = args[args.length - i - 1]; // args[args.length - i - 1] = swap; // } // } // // private Array() {} // // }
import java.io.FileNotFoundException; import java.io.Serializable; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.Map; import java.util.Random; import java.util.Set; import java.util.concurrent.atomic.AtomicReference; import org.junit.Assert; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import com.cinchapi.common.base.Array; import com.google.common.base.CaseFormat; import com.google.common.base.Predicates; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists;
} } @Test public void testCallMethodWithVarArgs() { Reflection.call(new Foo(), "varArgs", "foo"); Reflection.call(new Foo(), "varArgs2", "foo", "foo", "bar"); Reflection.call(new Foo(), "varArgs"); Reflection.call(new Foo(), "varArgs2", "foo"); Assert.assertTrue(true); // lack of exception means we pass } @Test public void testIsCallableWithReproA() { Assert.assertFalse( Reflection.isCallableWith( Reflection.getMethodUnboxed(Foo.class, "reproA", char.class, CaseFormat[].class), Predicates.alwaysTrue())); } @Test public void testCallOverloadedVarArgsReproA() { Reflection.call(new Foo(), "overloadVarArgs"); Reflection.call(new Foo(), "overloadVarArgs", "a"); Reflection.call(new Foo(), "overloadVarArgs", "a", "b"); } @Test public void testIsCallableWithReproB() {
// Path: src/main/java/com/cinchapi/common/base/Array.java // public final class Array { // // /** // * Return an array containing all the {@code args}. // * <p> // * This method is just syntactic sugar for easily passing array objects to // * methods that don't take varargs. // * </p> // * // * @param args the elements that should go in the array. // * @return args // */ // @SafeVarargs // public static <T> T[] containing(T... args) { // return args; // } // // /** // * Return a new array that contains the items in the {@code args} array in // * reverse order. // * // * @param args // * @return an array containing the {@code args} in reverse // */ // @SafeVarargs // public static <T> T[] reverse(T... args) { // T[] copy = Arrays.copyOf(args, args.length); // reverseInPlace(copy); // return copy; // } // // /** // * Reverse the order of the items in the {@code args} array in-place (e.g. // * edit the input array). // * // * @param args // */ // @SafeVarargs // public static <T> void reverseInPlace(T... args) { // for (int i = 0; i < args.length / 2; ++i) { // T swap = args[i]; // args[i] = args[args.length - i - 1]; // args[args.length - i - 1] = swap; // } // } // // private Array() {} // // } // Path: src/test/java/com/cinchapi/common/reflect/ReflectionTest.java import java.io.FileNotFoundException; import java.io.Serializable; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.Map; import java.util.Random; import java.util.Set; import java.util.concurrent.atomic.AtomicReference; import org.junit.Assert; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import com.cinchapi.common.base.Array; import com.google.common.base.CaseFormat; import com.google.common.base.Predicates; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; } } @Test public void testCallMethodWithVarArgs() { Reflection.call(new Foo(), "varArgs", "foo"); Reflection.call(new Foo(), "varArgs2", "foo", "foo", "bar"); Reflection.call(new Foo(), "varArgs"); Reflection.call(new Foo(), "varArgs2", "foo"); Assert.assertTrue(true); // lack of exception means we pass } @Test public void testIsCallableWithReproA() { Assert.assertFalse( Reflection.isCallableWith( Reflection.getMethodUnboxed(Foo.class, "reproA", char.class, CaseFormat[].class), Predicates.alwaysTrue())); } @Test public void testCallOverloadedVarArgsReproA() { Reflection.call(new Foo(), "overloadVarArgs"); Reflection.call(new Foo(), "overloadVarArgs", "a"); Reflection.call(new Foo(), "overloadVarArgs", "a", "b"); } @Test public void testIsCallableWithReproB() {
Object[] params = (Object[]) java.lang.reflect.Array
reckart/jazzy
src/com/swabunga/spell/engine/GenericTransformator.java
// Path: src/com/swabunga/util/StringUtility.java // public class StringUtility { // public static StringBuffer replace(StringBuffer buf, int start, int end, String text) { // int len = text.length(); // char[] ch = new char[buf.length() + len - (end - start)]; // buf.getChars(0, start, ch, 0); // text.getChars(0, len, ch, start); // buf.getChars(end, buf.length(), ch, start + len); // buf.setLength(0); // buf.append(ch); // return buf; // } // // public static void main(String[] args) { // System.out.println(StringUtility.replace(new StringBuffer(args[0]), Integer.parseInt(args[2]), Integer.parseInt(args[3]), args[1])); // } // }
import java.util.HashMap; import java.util.Vector; import com.swabunga.util.StringUtility; import java.io.*;
} /** * Builds up an char array with the chars in the alphabet of the language as it was read from the * alphabet tag in the phonetic file. * @return char[] An array of chars representing the alphabet or null if no alphabet was available. */ public char[] getReplaceList() { return alphabetString; } /** * Builds the phonetic code of the word. * @param word the word to transform * @return the phonetic transformation of the word */ public String transform(String word) { if (ruleArray == null) return null; TransformationRule rule; StringBuffer str = new StringBuffer(word.toUpperCase()); int strLength = str.length(); int startPos = 0, add = 1; while (startPos < strLength) { add = 1; if (Character.isDigit(str.charAt(startPos))) {
// Path: src/com/swabunga/util/StringUtility.java // public class StringUtility { // public static StringBuffer replace(StringBuffer buf, int start, int end, String text) { // int len = text.length(); // char[] ch = new char[buf.length() + len - (end - start)]; // buf.getChars(0, start, ch, 0); // text.getChars(0, len, ch, start); // buf.getChars(end, buf.length(), ch, start + len); // buf.setLength(0); // buf.append(ch); // return buf; // } // // public static void main(String[] args) { // System.out.println(StringUtility.replace(new StringBuffer(args[0]), Integer.parseInt(args[2]), Integer.parseInt(args[3]), args[1])); // } // } // Path: src/com/swabunga/spell/engine/GenericTransformator.java import java.util.HashMap; import java.util.Vector; import com.swabunga.util.StringUtility; import java.io.*; } /** * Builds up an char array with the chars in the alphabet of the language as it was read from the * alphabet tag in the phonetic file. * @return char[] An array of chars representing the alphabet or null if no alphabet was available. */ public char[] getReplaceList() { return alphabetString; } /** * Builds the phonetic code of the word. * @param word the word to transform * @return the phonetic transformation of the word */ public String transform(String word) { if (ruleArray == null) return null; TransformationRule rule; StringBuffer str = new StringBuffer(word.toUpperCase()); int strLength = str.length(); int startPos = 0, add = 1; while (startPos < strLength) { add = 1; if (Character.isDigit(str.charAt(startPos))) {
StringUtility.replace(str, startPos, startPos + DIGITCODE.length(), DIGITCODE);
reckart/jazzy
src/com/swabunga/spell/examples/SwingFormExample.java
// Path: src/com/swabunga/spell/swing/JSpellApplet.java // public class JSpellApplet extends JApplet { // // private static final String dictionaryFile = "dict/english.0.zip"; // private SpellDictionary dictionary; // JTextArea text = null; // JButton spell = null; // // /** // * @see java.awt.Component#paint(Graphics) // */ // public void paint(Graphics arg0) { // super.paint(arg0); // // } // // /** // * @see java.applet.Applet#init() // */ // public void init() { // super.init(); // // try { // URL resource = null; // ZipInputStream zip = null; // try { // resource = new URL(getCodeBase().toExternalForm() + dictionaryFile); // zip = new ZipInputStream(resource.openStream()); // /* getCodeBase() throws a NullPointerException when run // * outside the context of a browser // */ // } catch (NullPointerException e) { // FileInputStream fin = new FileInputStream(dictionaryFile); // zip = new ZipInputStream(fin); // } // zip.getNextEntry(); // dictionary = new SpellDictionaryHashMap(new BufferedReader(new InputStreamReader(zip))); // // initGUI(); // } catch (MalformedURLException e) { // e.printStackTrace(); // } catch (FileNotFoundException e) { // e.printStackTrace(); // } catch (IOException e) { // e.printStackTrace(); // } // // } // // private void initGUI() { // Container frame = getContentPane(); // GridBagLayout gridbag = new GridBagLayout(); // GridBagConstraints c = new GridBagConstraints(); // frame.setLayout(gridbag); // c.anchor = GridBagConstraints.CENTER; // c.fill = GridBagConstraints.BOTH; // c.insets = new Insets(5, 5, 5, 5); // c.weightx = 1.0; // c.weighty = 1.0; // text = new JTextArea("The quck brwn dog jmped over the fnce."); // text.setLineWrap(true); // text.setWrapStyleWord(true); // addToFrame(frame, text, gridbag, c, 0, 0, 1, 1); // // GridBagConstraints spellcon = new GridBagConstraints(); // spellcon.anchor = GridBagConstraints.NORTH; // spellcon.insets = new Insets(5, 5, 5, 5); // // spell = new JButton("spell check"); // final JTextComponentSpellChecker sc = new JTextComponentSpellChecker(dictionary); // spell.addActionListener(new ActionListener() { // public void actionPerformed(ActionEvent arg0) { // Thread t = new Thread() { // public void run() { // try { // sc.spellCheck(text); // } catch (Exception ex) { // ex.printStackTrace(); // // } // } // }; // t.start(); // } // }); // addToFrame(frame, spell, gridbag, spellcon, 1, 0, 1, 1); // } // // // Helps build gridbaglayout. // private void addToFrame(Container f, Component c, GridBagLayout gbl, GridBagConstraints gbc, int x, int y, int w, int h) { // gbc.gridx = x; // gbc.gridy = y; // gbc.gridwidth = w; // gbc.gridheight = h; // gbl.setConstraints(c, gbc); // f.add(c); // } // }
import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import com.swabunga.spell.swing.JSpellApplet; import javax.swing.*;
/* Jazzy - a Java library for Spell Checking Copyright (C) 2001 Mindaugas Idzelis Full text of license can be found in LICENSE.txt This library 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 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ package com.swabunga.spell.examples; /** This class shows an example of how to use the spell checking capability * for a text area on a swing form. * * @author Jason Height (jheight@chariot.net.au) */ public class SwingFormExample extends JFrame { public SwingFormExample() { setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); addWindowListener(new WindowAdapter() { public void windowClosed(WindowEvent e) { System.exit(0); } });
// Path: src/com/swabunga/spell/swing/JSpellApplet.java // public class JSpellApplet extends JApplet { // // private static final String dictionaryFile = "dict/english.0.zip"; // private SpellDictionary dictionary; // JTextArea text = null; // JButton spell = null; // // /** // * @see java.awt.Component#paint(Graphics) // */ // public void paint(Graphics arg0) { // super.paint(arg0); // // } // // /** // * @see java.applet.Applet#init() // */ // public void init() { // super.init(); // // try { // URL resource = null; // ZipInputStream zip = null; // try { // resource = new URL(getCodeBase().toExternalForm() + dictionaryFile); // zip = new ZipInputStream(resource.openStream()); // /* getCodeBase() throws a NullPointerException when run // * outside the context of a browser // */ // } catch (NullPointerException e) { // FileInputStream fin = new FileInputStream(dictionaryFile); // zip = new ZipInputStream(fin); // } // zip.getNextEntry(); // dictionary = new SpellDictionaryHashMap(new BufferedReader(new InputStreamReader(zip))); // // initGUI(); // } catch (MalformedURLException e) { // e.printStackTrace(); // } catch (FileNotFoundException e) { // e.printStackTrace(); // } catch (IOException e) { // e.printStackTrace(); // } // // } // // private void initGUI() { // Container frame = getContentPane(); // GridBagLayout gridbag = new GridBagLayout(); // GridBagConstraints c = new GridBagConstraints(); // frame.setLayout(gridbag); // c.anchor = GridBagConstraints.CENTER; // c.fill = GridBagConstraints.BOTH; // c.insets = new Insets(5, 5, 5, 5); // c.weightx = 1.0; // c.weighty = 1.0; // text = new JTextArea("The quck brwn dog jmped over the fnce."); // text.setLineWrap(true); // text.setWrapStyleWord(true); // addToFrame(frame, text, gridbag, c, 0, 0, 1, 1); // // GridBagConstraints spellcon = new GridBagConstraints(); // spellcon.anchor = GridBagConstraints.NORTH; // spellcon.insets = new Insets(5, 5, 5, 5); // // spell = new JButton("spell check"); // final JTextComponentSpellChecker sc = new JTextComponentSpellChecker(dictionary); // spell.addActionListener(new ActionListener() { // public void actionPerformed(ActionEvent arg0) { // Thread t = new Thread() { // public void run() { // try { // sc.spellCheck(text); // } catch (Exception ex) { // ex.printStackTrace(); // // } // } // }; // t.start(); // } // }); // addToFrame(frame, spell, gridbag, spellcon, 1, 0, 1, 1); // } // // // Helps build gridbaglayout. // private void addToFrame(Container f, Component c, GridBagLayout gbl, GridBagConstraints gbc, int x, int y, int w, int h) { // gbc.gridx = x; // gbc.gridy = y; // gbc.gridwidth = w; // gbc.gridheight = h; // gbl.setConstraints(c, gbc); // f.add(c); // } // } // Path: src/com/swabunga/spell/examples/SwingFormExample.java import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import com.swabunga.spell.swing.JSpellApplet; import javax.swing.*; /* Jazzy - a Java library for Spell Checking Copyright (C) 2001 Mindaugas Idzelis Full text of license can be found in LICENSE.txt This library 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 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ package com.swabunga.spell.examples; /** This class shows an example of how to use the spell checking capability * for a text area on a swing form. * * @author Jason Height (jheight@chariot.net.au) */ public class SwingFormExample extends JFrame { public SwingFormExample() { setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); addWindowListener(new WindowAdapter() { public void windowClosed(WindowEvent e) { System.exit(0); } });
JSpellApplet spellapplet = new JSpellApplet();
reckart/jazzy
src/com/swabunga/spell/swing/SpellCheckedDocument.java
// Path: src/com/swabunga/spell/engine/SpellDictionary.java // public interface SpellDictionary { // // /** // * Add a word permanently to the dictionary. // * @param word The word to add to the dictionary // */ // public void addWord(String word); // // /** // * Evaluates if the word is correctly spelled against the dictionary. // * @param word The word to verify if it's spelling is OK. // * @return Indicates if the word is present in the dictionary. // */ // public boolean isCorrect(String word); // // /** // * Returns a list of Word objects that are the suggestions to any word. // * If the word is correctly spelled, then this method // * could return just that one word, or it could still return a list // * of words with similar spellings. // * <br/> // * Each suggested word has a score, which is an integer // * that represents how different the suggested word is from the sourceWord. // * If the words are the exactly the same, then the score is 0. // * You can get the dictionary to only return the most similar words by setting // * an appropriately low threshold value. // * If you set the threshold value too low, you may get no suggestions for a given word. // * <p> // * This method is only needed to provide backward compatibility. // * @see #getSuggestions(String, int, int[][]) // * // * @param sourceWord the string that we want to get a list of spelling suggestions for // * @param scoreThreshold Any words that have score less than this number are returned. // * @return List a List of suggested words // * @see com.swabunga.spell.engine.Word // * // */ // public List getSuggestions(String sourceWord, int scoreThreshold); // // /** // * Returns a list of Word objects that are the suggestions to any word. // * If the word is correctly spelled, then this method // * could return just that one word, or it could still return a list // * of words with similar spellings. // * <br/> // * Each suggested word has a score, which is an integer // * that represents how different the suggested word is from the sourceWord. // * If the words are the exactly the same, then the score is 0. // * You can get the dictionary to only return the most similar words by setting // * an appropriately low threshold value. // * If you set the threshold value too low, you may get no suggestions for a given word. // * <p> // * @param sourceWord the string that we want to get a list of spelling suggestions for // * @param scoreThreshold Any words that have score less than this number are returned. // * @param Two dimensional int array used to calculate edit distance. Allocating // * this memory outside of the function will greatly improve efficiency. // * @return List a List of suggested words // * @see com.swabunga.spell.engine.Word // */ // public List getSuggestions(String sourceWord, int scoreThreshold , int[][] matrix); // // }
import java.awt.*; import java.util.StringTokenizer; import com.swabunga.spell.engine.SpellDictionary; import javax.swing.text.*;
/* Jazzy - a Java library for Spell Checking Copyright (C) 2001 Mindaugas Idzelis Full text of license can be found in LICENSE.txt This library 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 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ package com.swabunga.spell.swing; /** * @author Stig Tanggaard * * */ public class SpellCheckedDocument extends DefaultStyledDocument { public static final String ERROR_STYLE = "errorstyle"; Style errorstyle; Style normalstyle; static AttributeSet normal; int checkoffset, checkend; String checkingline;
// Path: src/com/swabunga/spell/engine/SpellDictionary.java // public interface SpellDictionary { // // /** // * Add a word permanently to the dictionary. // * @param word The word to add to the dictionary // */ // public void addWord(String word); // // /** // * Evaluates if the word is correctly spelled against the dictionary. // * @param word The word to verify if it's spelling is OK. // * @return Indicates if the word is present in the dictionary. // */ // public boolean isCorrect(String word); // // /** // * Returns a list of Word objects that are the suggestions to any word. // * If the word is correctly spelled, then this method // * could return just that one word, or it could still return a list // * of words with similar spellings. // * <br/> // * Each suggested word has a score, which is an integer // * that represents how different the suggested word is from the sourceWord. // * If the words are the exactly the same, then the score is 0. // * You can get the dictionary to only return the most similar words by setting // * an appropriately low threshold value. // * If you set the threshold value too low, you may get no suggestions for a given word. // * <p> // * This method is only needed to provide backward compatibility. // * @see #getSuggestions(String, int, int[][]) // * // * @param sourceWord the string that we want to get a list of spelling suggestions for // * @param scoreThreshold Any words that have score less than this number are returned. // * @return List a List of suggested words // * @see com.swabunga.spell.engine.Word // * // */ // public List getSuggestions(String sourceWord, int scoreThreshold); // // /** // * Returns a list of Word objects that are the suggestions to any word. // * If the word is correctly spelled, then this method // * could return just that one word, or it could still return a list // * of words with similar spellings. // * <br/> // * Each suggested word has a score, which is an integer // * that represents how different the suggested word is from the sourceWord. // * If the words are the exactly the same, then the score is 0. // * You can get the dictionary to only return the most similar words by setting // * an appropriately low threshold value. // * If you set the threshold value too low, you may get no suggestions for a given word. // * <p> // * @param sourceWord the string that we want to get a list of spelling suggestions for // * @param scoreThreshold Any words that have score less than this number are returned. // * @param Two dimensional int array used to calculate edit distance. Allocating // * this memory outside of the function will greatly improve efficiency. // * @return List a List of suggested words // * @see com.swabunga.spell.engine.Word // */ // public List getSuggestions(String sourceWord, int scoreThreshold , int[][] matrix); // // } // Path: src/com/swabunga/spell/swing/SpellCheckedDocument.java import java.awt.*; import java.util.StringTokenizer; import com.swabunga.spell.engine.SpellDictionary; import javax.swing.text.*; /* Jazzy - a Java library for Spell Checking Copyright (C) 2001 Mindaugas Idzelis Full text of license can be found in LICENSE.txt This library 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 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ package com.swabunga.spell.swing; /** * @author Stig Tanggaard * * */ public class SpellCheckedDocument extends DefaultStyledDocument { public static final String ERROR_STYLE = "errorstyle"; Style errorstyle; Style normalstyle; static AttributeSet normal; int checkoffset, checkend; String checkingline;
static SpellDictionary dictionary;