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
gaffo/scumd
src/main/java/com/asolutions/scmsshd/ldap/LDAPProjectAuthorizer.java
// Path: src/main/java/com/asolutions/scmsshd/authenticators/LDAPUsernameResolver.java // public class LDAPUsernameResolver { // LDAPBindingProvider provider; // private String userBase; // private String matchingElement; // public LDAPUsernameResolver(LDAPBindingProvider provider, String userBase) { // this(provider, userBase, "cn="); // } // public LDAPUsernameResolver(LDAPBindingProvider provider, String userBase, String matchingElement) { // this.provider = provider; // this.userBase = userBase; // this.matchingElement = matchingElement; // } // // public String resolveUserName(String username) throws NamingException{ // InitialDirContext InitialDirectoryContext = provider.getBinding(); // SearchControls searchCtls = new SearchControls(); // //Specify the search scope // searchCtls.setSearchScope(SearchControls.SUBTREE_SCOPE); // // //specify the LDAP search filter // String searchFilter = "("+matchingElement+username+")"; // // //initialize counter to total the results // // // Search for objects using the filter // NamingEnumeration<SearchResult> answer = InitialDirectoryContext.search(userBase, searchFilter, searchCtls); // SearchResult next = answer.next(); // return next.getNameInNamespace(); // } // } // // Path: src/main/java/com/asolutions/scmsshd/authorizors/AuthorizationLevel.java // public enum AuthorizationLevel { // AUTH_LEVEL_READ_ONLY, // AUTH_LEVEL_READ_WRITE; // } // // Path: src/main/java/com/asolutions/scmsshd/sshd/IProjectAuthorizer.java // public interface IProjectAuthorizer { // // AuthorizationLevel userIsAuthorizedForProject(String username, String project) throws UnparsableProjectException; // // } // // Path: src/main/java/com/asolutions/scmsshd/sshd/UnparsableProjectException.java // public class UnparsableProjectException extends Exception { // // private static final long serialVersionUID = 643951700141491862L; // // public UnparsableProjectException(String reason) { // super(reason); // } // // }
import javax.naming.NamingEnumeration; import javax.naming.NamingException; import javax.naming.directory.Attributes; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.asolutions.scmsshd.authenticators.LDAPUsernameResolver; import com.asolutions.scmsshd.authorizors.AuthorizationLevel; import com.asolutions.scmsshd.sshd.IProjectAuthorizer; import com.asolutions.scmsshd.sshd.UnparsableProjectException;
package com.asolutions.scmsshd.ldap; public class LDAPProjectAuthorizer implements IProjectAuthorizer { protected final Logger log = LoggerFactory.getLogger(getClass()); private String groupBaseDN; private String groupSuffix; private AuthorizationLevel authorizationLevel; private LDAPBindingProvider binding; private LDAPUsernameResolver resolver; public LDAPProjectAuthorizer(String groupBaseDN, String groupSuffix, AuthorizationLevel authorizationLevel, LDAPBindingProvider binding, LDAPUsernameResolver resolver) throws NamingException { this.groupBaseDN = groupBaseDN; this.groupSuffix = groupSuffix; this.authorizationLevel = authorizationLevel; this.binding = binding; this.resolver = resolver; } public AuthorizationLevel userIsAuthorizedForProject(String username, String group)
// Path: src/main/java/com/asolutions/scmsshd/authenticators/LDAPUsernameResolver.java // public class LDAPUsernameResolver { // LDAPBindingProvider provider; // private String userBase; // private String matchingElement; // public LDAPUsernameResolver(LDAPBindingProvider provider, String userBase) { // this(provider, userBase, "cn="); // } // public LDAPUsernameResolver(LDAPBindingProvider provider, String userBase, String matchingElement) { // this.provider = provider; // this.userBase = userBase; // this.matchingElement = matchingElement; // } // // public String resolveUserName(String username) throws NamingException{ // InitialDirContext InitialDirectoryContext = provider.getBinding(); // SearchControls searchCtls = new SearchControls(); // //Specify the search scope // searchCtls.setSearchScope(SearchControls.SUBTREE_SCOPE); // // //specify the LDAP search filter // String searchFilter = "("+matchingElement+username+")"; // // //initialize counter to total the results // // // Search for objects using the filter // NamingEnumeration<SearchResult> answer = InitialDirectoryContext.search(userBase, searchFilter, searchCtls); // SearchResult next = answer.next(); // return next.getNameInNamespace(); // } // } // // Path: src/main/java/com/asolutions/scmsshd/authorizors/AuthorizationLevel.java // public enum AuthorizationLevel { // AUTH_LEVEL_READ_ONLY, // AUTH_LEVEL_READ_WRITE; // } // // Path: src/main/java/com/asolutions/scmsshd/sshd/IProjectAuthorizer.java // public interface IProjectAuthorizer { // // AuthorizationLevel userIsAuthorizedForProject(String username, String project) throws UnparsableProjectException; // // } // // Path: src/main/java/com/asolutions/scmsshd/sshd/UnparsableProjectException.java // public class UnparsableProjectException extends Exception { // // private static final long serialVersionUID = 643951700141491862L; // // public UnparsableProjectException(String reason) { // super(reason); // } // // } // Path: src/main/java/com/asolutions/scmsshd/ldap/LDAPProjectAuthorizer.java import javax.naming.NamingEnumeration; import javax.naming.NamingException; import javax.naming.directory.Attributes; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.asolutions.scmsshd.authenticators.LDAPUsernameResolver; import com.asolutions.scmsshd.authorizors.AuthorizationLevel; import com.asolutions.scmsshd.sshd.IProjectAuthorizer; import com.asolutions.scmsshd.sshd.UnparsableProjectException; package com.asolutions.scmsshd.ldap; public class LDAPProjectAuthorizer implements IProjectAuthorizer { protected final Logger log = LoggerFactory.getLogger(getClass()); private String groupBaseDN; private String groupSuffix; private AuthorizationLevel authorizationLevel; private LDAPBindingProvider binding; private LDAPUsernameResolver resolver; public LDAPProjectAuthorizer(String groupBaseDN, String groupSuffix, AuthorizationLevel authorizationLevel, LDAPBindingProvider binding, LDAPUsernameResolver resolver) throws NamingException { this.groupBaseDN = groupBaseDN; this.groupSuffix = groupSuffix; this.authorizationLevel = authorizationLevel; this.binding = binding; this.resolver = resolver; } public AuthorizationLevel userIsAuthorizedForProject(String username, String group)
throws UnparsableProjectException {
gaffo/scumd
src/test/java/com/asolutions/scmsshd/commands/git/GitSCMCommandHandlerTest.java
// Path: src/test/java/com/asolutions/MockTestCase.java // public class MockTestCase { // // protected Mockery context = new JUnit4Mockery(); // // @Before // public void setupMockery() { // context.setImposteriser(ClassImposteriser.INSTANCE); // } // // @After // public void mockeryAssertIsSatisfied(){ // context.assertIsSatisfied(); // } // // protected void checking(Expectations expectations) { // context.checking(expectations); // } // // } // // Path: src/main/java/com/asolutions/scmsshd/authorizors/AuthorizationLevel.java // public enum AuthorizationLevel { // AUTH_LEVEL_READ_ONLY, // AUTH_LEVEL_READ_WRITE; // } // // Path: src/main/java/com/asolutions/scmsshd/commands/FilteredCommand.java // public class FilteredCommand { // // private String command; // private String argument; // // public FilteredCommand() { // } // // public FilteredCommand(String command, String argument) { // this.command = command; // this.argument = argument; // } // // public void setArgument(String argument) { // this.argument = argument; // } // // public void setCommand(String command) { // this.command = command; // } // // public String getCommand() { // return this.command; // } // // public String getArgument() { // return this.argument; // } // // @Override // public String toString() // { // return "Filtered Command: " + getCommand() + ", " + getArgument(); // } // // } // // Path: src/main/java/com/asolutions/scmsshd/commands/handlers/ISCMCommandHandler.java // public interface ISCMCommandHandler { // // void execute(FilteredCommand filteredCommand, InputStream inputStream, // OutputStream outputStream, OutputStream errorStream, // ExitCallback exitCallback, Properties configuration, AuthorizationLevel authorizationLevel); // // }
import java.io.InputStream; import java.io.OutputStream; import java.util.Properties; import org.apache.sshd.server.CommandFactory.ExitCallback; import org.jmock.Expectations; import org.junit.Test; import com.asolutions.MockTestCase; import com.asolutions.scmsshd.authorizors.AuthorizationLevel; import com.asolutions.scmsshd.commands.FilteredCommand; import com.asolutions.scmsshd.commands.handlers.ISCMCommandHandler;
package com.asolutions.scmsshd.commands.git; public class GitSCMCommandHandlerTest extends MockTestCase { @Test public void testExecuteWithUploadPack() throws Exception {
// Path: src/test/java/com/asolutions/MockTestCase.java // public class MockTestCase { // // protected Mockery context = new JUnit4Mockery(); // // @Before // public void setupMockery() { // context.setImposteriser(ClassImposteriser.INSTANCE); // } // // @After // public void mockeryAssertIsSatisfied(){ // context.assertIsSatisfied(); // } // // protected void checking(Expectations expectations) { // context.checking(expectations); // } // // } // // Path: src/main/java/com/asolutions/scmsshd/authorizors/AuthorizationLevel.java // public enum AuthorizationLevel { // AUTH_LEVEL_READ_ONLY, // AUTH_LEVEL_READ_WRITE; // } // // Path: src/main/java/com/asolutions/scmsshd/commands/FilteredCommand.java // public class FilteredCommand { // // private String command; // private String argument; // // public FilteredCommand() { // } // // public FilteredCommand(String command, String argument) { // this.command = command; // this.argument = argument; // } // // public void setArgument(String argument) { // this.argument = argument; // } // // public void setCommand(String command) { // this.command = command; // } // // public String getCommand() { // return this.command; // } // // public String getArgument() { // return this.argument; // } // // @Override // public String toString() // { // return "Filtered Command: " + getCommand() + ", " + getArgument(); // } // // } // // Path: src/main/java/com/asolutions/scmsshd/commands/handlers/ISCMCommandHandler.java // public interface ISCMCommandHandler { // // void execute(FilteredCommand filteredCommand, InputStream inputStream, // OutputStream outputStream, OutputStream errorStream, // ExitCallback exitCallback, Properties configuration, AuthorizationLevel authorizationLevel); // // } // Path: src/test/java/com/asolutions/scmsshd/commands/git/GitSCMCommandHandlerTest.java import java.io.InputStream; import java.io.OutputStream; import java.util.Properties; import org.apache.sshd.server.CommandFactory.ExitCallback; import org.jmock.Expectations; import org.junit.Test; import com.asolutions.MockTestCase; import com.asolutions.scmsshd.authorizors.AuthorizationLevel; import com.asolutions.scmsshd.commands.FilteredCommand; import com.asolutions.scmsshd.commands.handlers.ISCMCommandHandler; package com.asolutions.scmsshd.commands.git; public class GitSCMCommandHandlerTest extends MockTestCase { @Test public void testExecuteWithUploadPack() throws Exception {
final FilteredCommand filteredCommand = new FilteredCommand("git-upload-pack", "proj-2/git.git");
gaffo/scumd
src/test/java/com/asolutions/scmsshd/commands/git/GitSCMCommandHandlerTest.java
// Path: src/test/java/com/asolutions/MockTestCase.java // public class MockTestCase { // // protected Mockery context = new JUnit4Mockery(); // // @Before // public void setupMockery() { // context.setImposteriser(ClassImposteriser.INSTANCE); // } // // @After // public void mockeryAssertIsSatisfied(){ // context.assertIsSatisfied(); // } // // protected void checking(Expectations expectations) { // context.checking(expectations); // } // // } // // Path: src/main/java/com/asolutions/scmsshd/authorizors/AuthorizationLevel.java // public enum AuthorizationLevel { // AUTH_LEVEL_READ_ONLY, // AUTH_LEVEL_READ_WRITE; // } // // Path: src/main/java/com/asolutions/scmsshd/commands/FilteredCommand.java // public class FilteredCommand { // // private String command; // private String argument; // // public FilteredCommand() { // } // // public FilteredCommand(String command, String argument) { // this.command = command; // this.argument = argument; // } // // public void setArgument(String argument) { // this.argument = argument; // } // // public void setCommand(String command) { // this.command = command; // } // // public String getCommand() { // return this.command; // } // // public String getArgument() { // return this.argument; // } // // @Override // public String toString() // { // return "Filtered Command: " + getCommand() + ", " + getArgument(); // } // // } // // Path: src/main/java/com/asolutions/scmsshd/commands/handlers/ISCMCommandHandler.java // public interface ISCMCommandHandler { // // void execute(FilteredCommand filteredCommand, InputStream inputStream, // OutputStream outputStream, OutputStream errorStream, // ExitCallback exitCallback, Properties configuration, AuthorizationLevel authorizationLevel); // // }
import java.io.InputStream; import java.io.OutputStream; import java.util.Properties; import org.apache.sshd.server.CommandFactory.ExitCallback; import org.jmock.Expectations; import org.junit.Test; import com.asolutions.MockTestCase; import com.asolutions.scmsshd.authorizors.AuthorizationLevel; import com.asolutions.scmsshd.commands.FilteredCommand; import com.asolutions.scmsshd.commands.handlers.ISCMCommandHandler;
package com.asolutions.scmsshd.commands.git; public class GitSCMCommandHandlerTest extends MockTestCase { @Test public void testExecuteWithUploadPack() throws Exception { final FilteredCommand filteredCommand = new FilteredCommand("git-upload-pack", "proj-2/git.git"); final InputStream mockInputStream = context.mock(InputStream.class); final OutputStream mockOutputStream = context.mock(OutputStream.class, "mockOutputStream"); final OutputStream mockErrorStream = context.mock(OutputStream.class, "mockErrorStream"); final ExitCallback mockExitCallback = context.mock(ExitCallback.class);
// Path: src/test/java/com/asolutions/MockTestCase.java // public class MockTestCase { // // protected Mockery context = new JUnit4Mockery(); // // @Before // public void setupMockery() { // context.setImposteriser(ClassImposteriser.INSTANCE); // } // // @After // public void mockeryAssertIsSatisfied(){ // context.assertIsSatisfied(); // } // // protected void checking(Expectations expectations) { // context.checking(expectations); // } // // } // // Path: src/main/java/com/asolutions/scmsshd/authorizors/AuthorizationLevel.java // public enum AuthorizationLevel { // AUTH_LEVEL_READ_ONLY, // AUTH_LEVEL_READ_WRITE; // } // // Path: src/main/java/com/asolutions/scmsshd/commands/FilteredCommand.java // public class FilteredCommand { // // private String command; // private String argument; // // public FilteredCommand() { // } // // public FilteredCommand(String command, String argument) { // this.command = command; // this.argument = argument; // } // // public void setArgument(String argument) { // this.argument = argument; // } // // public void setCommand(String command) { // this.command = command; // } // // public String getCommand() { // return this.command; // } // // public String getArgument() { // return this.argument; // } // // @Override // public String toString() // { // return "Filtered Command: " + getCommand() + ", " + getArgument(); // } // // } // // Path: src/main/java/com/asolutions/scmsshd/commands/handlers/ISCMCommandHandler.java // public interface ISCMCommandHandler { // // void execute(FilteredCommand filteredCommand, InputStream inputStream, // OutputStream outputStream, OutputStream errorStream, // ExitCallback exitCallback, Properties configuration, AuthorizationLevel authorizationLevel); // // } // Path: src/test/java/com/asolutions/scmsshd/commands/git/GitSCMCommandHandlerTest.java import java.io.InputStream; import java.io.OutputStream; import java.util.Properties; import org.apache.sshd.server.CommandFactory.ExitCallback; import org.jmock.Expectations; import org.junit.Test; import com.asolutions.MockTestCase; import com.asolutions.scmsshd.authorizors.AuthorizationLevel; import com.asolutions.scmsshd.commands.FilteredCommand; import com.asolutions.scmsshd.commands.handlers.ISCMCommandHandler; package com.asolutions.scmsshd.commands.git; public class GitSCMCommandHandlerTest extends MockTestCase { @Test public void testExecuteWithUploadPack() throws Exception { final FilteredCommand filteredCommand = new FilteredCommand("git-upload-pack", "proj-2/git.git"); final InputStream mockInputStream = context.mock(InputStream.class); final OutputStream mockOutputStream = context.mock(OutputStream.class, "mockOutputStream"); final OutputStream mockErrorStream = context.mock(OutputStream.class, "mockErrorStream"); final ExitCallback mockExitCallback = context.mock(ExitCallback.class);
final ISCMCommandHandler mockUploadPackHandler = context.mock(ISCMCommandHandler.class, "mockUploadPackHandler");
gaffo/scumd
src/test/java/com/asolutions/scmsshd/commands/git/GitSCMCommandHandlerTest.java
// Path: src/test/java/com/asolutions/MockTestCase.java // public class MockTestCase { // // protected Mockery context = new JUnit4Mockery(); // // @Before // public void setupMockery() { // context.setImposteriser(ClassImposteriser.INSTANCE); // } // // @After // public void mockeryAssertIsSatisfied(){ // context.assertIsSatisfied(); // } // // protected void checking(Expectations expectations) { // context.checking(expectations); // } // // } // // Path: src/main/java/com/asolutions/scmsshd/authorizors/AuthorizationLevel.java // public enum AuthorizationLevel { // AUTH_LEVEL_READ_ONLY, // AUTH_LEVEL_READ_WRITE; // } // // Path: src/main/java/com/asolutions/scmsshd/commands/FilteredCommand.java // public class FilteredCommand { // // private String command; // private String argument; // // public FilteredCommand() { // } // // public FilteredCommand(String command, String argument) { // this.command = command; // this.argument = argument; // } // // public void setArgument(String argument) { // this.argument = argument; // } // // public void setCommand(String command) { // this.command = command; // } // // public String getCommand() { // return this.command; // } // // public String getArgument() { // return this.argument; // } // // @Override // public String toString() // { // return "Filtered Command: " + getCommand() + ", " + getArgument(); // } // // } // // Path: src/main/java/com/asolutions/scmsshd/commands/handlers/ISCMCommandHandler.java // public interface ISCMCommandHandler { // // void execute(FilteredCommand filteredCommand, InputStream inputStream, // OutputStream outputStream, OutputStream errorStream, // ExitCallback exitCallback, Properties configuration, AuthorizationLevel authorizationLevel); // // }
import java.io.InputStream; import java.io.OutputStream; import java.util.Properties; import org.apache.sshd.server.CommandFactory.ExitCallback; import org.jmock.Expectations; import org.junit.Test; import com.asolutions.MockTestCase; import com.asolutions.scmsshd.authorizors.AuthorizationLevel; import com.asolutions.scmsshd.commands.FilteredCommand; import com.asolutions.scmsshd.commands.handlers.ISCMCommandHandler;
package com.asolutions.scmsshd.commands.git; public class GitSCMCommandHandlerTest extends MockTestCase { @Test public void testExecuteWithUploadPack() throws Exception { final FilteredCommand filteredCommand = new FilteredCommand("git-upload-pack", "proj-2/git.git"); final InputStream mockInputStream = context.mock(InputStream.class); final OutputStream mockOutputStream = context.mock(OutputStream.class, "mockOutputStream"); final OutputStream mockErrorStream = context.mock(OutputStream.class, "mockErrorStream"); final ExitCallback mockExitCallback = context.mock(ExitCallback.class); final ISCMCommandHandler mockUploadPackHandler = context.mock(ISCMCommandHandler.class, "mockUploadPackHandler"); final ISCMCommandHandler mockFetchPackHandler = context.mock(ISCMCommandHandler.class, "mockFetchPackHandler"); final Properties mockProperties = context.mock(Properties.class); checking(new Expectations(){{
// Path: src/test/java/com/asolutions/MockTestCase.java // public class MockTestCase { // // protected Mockery context = new JUnit4Mockery(); // // @Before // public void setupMockery() { // context.setImposteriser(ClassImposteriser.INSTANCE); // } // // @After // public void mockeryAssertIsSatisfied(){ // context.assertIsSatisfied(); // } // // protected void checking(Expectations expectations) { // context.checking(expectations); // } // // } // // Path: src/main/java/com/asolutions/scmsshd/authorizors/AuthorizationLevel.java // public enum AuthorizationLevel { // AUTH_LEVEL_READ_ONLY, // AUTH_LEVEL_READ_WRITE; // } // // Path: src/main/java/com/asolutions/scmsshd/commands/FilteredCommand.java // public class FilteredCommand { // // private String command; // private String argument; // // public FilteredCommand() { // } // // public FilteredCommand(String command, String argument) { // this.command = command; // this.argument = argument; // } // // public void setArgument(String argument) { // this.argument = argument; // } // // public void setCommand(String command) { // this.command = command; // } // // public String getCommand() { // return this.command; // } // // public String getArgument() { // return this.argument; // } // // @Override // public String toString() // { // return "Filtered Command: " + getCommand() + ", " + getArgument(); // } // // } // // Path: src/main/java/com/asolutions/scmsshd/commands/handlers/ISCMCommandHandler.java // public interface ISCMCommandHandler { // // void execute(FilteredCommand filteredCommand, InputStream inputStream, // OutputStream outputStream, OutputStream errorStream, // ExitCallback exitCallback, Properties configuration, AuthorizationLevel authorizationLevel); // // } // Path: src/test/java/com/asolutions/scmsshd/commands/git/GitSCMCommandHandlerTest.java import java.io.InputStream; import java.io.OutputStream; import java.util.Properties; import org.apache.sshd.server.CommandFactory.ExitCallback; import org.jmock.Expectations; import org.junit.Test; import com.asolutions.MockTestCase; import com.asolutions.scmsshd.authorizors.AuthorizationLevel; import com.asolutions.scmsshd.commands.FilteredCommand; import com.asolutions.scmsshd.commands.handlers.ISCMCommandHandler; package com.asolutions.scmsshd.commands.git; public class GitSCMCommandHandlerTest extends MockTestCase { @Test public void testExecuteWithUploadPack() throws Exception { final FilteredCommand filteredCommand = new FilteredCommand("git-upload-pack", "proj-2/git.git"); final InputStream mockInputStream = context.mock(InputStream.class); final OutputStream mockOutputStream = context.mock(OutputStream.class, "mockOutputStream"); final OutputStream mockErrorStream = context.mock(OutputStream.class, "mockErrorStream"); final ExitCallback mockExitCallback = context.mock(ExitCallback.class); final ISCMCommandHandler mockUploadPackHandler = context.mock(ISCMCommandHandler.class, "mockUploadPackHandler"); final ISCMCommandHandler mockFetchPackHandler = context.mock(ISCMCommandHandler.class, "mockFetchPackHandler"); final Properties mockProperties = context.mock(Properties.class); checking(new Expectations(){{
one(mockUploadPackHandler).execute(filteredCommand, mockInputStream, mockOutputStream, mockErrorStream, mockExitCallback, mockProperties, AuthorizationLevel.AUTH_LEVEL_READ_WRITE);
gaffo/scumd
src/main/java/com/asolutions/scmsshd/converters/path/regexp/AMatchingGroupPathToProjectNameConverter.java
// Path: src/main/java/com/asolutions/scmsshd/converters/path/IPathToProjectNameConverter.java // public interface IPathToProjectNameConverter { // // public abstract String convert(String toParse) // throws UnparsableProjectException; // // } // // Path: src/main/java/com/asolutions/scmsshd/sshd/UnparsableProjectException.java // public class UnparsableProjectException extends Exception { // // private static final long serialVersionUID = 643951700141491862L; // // public UnparsableProjectException(String reason) { // super(reason); // } // // }
import java.util.regex.Matcher; import java.util.regex.Pattern; import com.asolutions.scmsshd.converters.path.IPathToProjectNameConverter; import com.asolutions.scmsshd.sshd.UnparsableProjectException;
package com.asolutions.scmsshd.converters.path.regexp; public abstract class AMatchingGroupPathToProjectNameConverter implements IPathToProjectNameConverter{ public AMatchingGroupPathToProjectNameConverter() { super(); }
// Path: src/main/java/com/asolutions/scmsshd/converters/path/IPathToProjectNameConverter.java // public interface IPathToProjectNameConverter { // // public abstract String convert(String toParse) // throws UnparsableProjectException; // // } // // Path: src/main/java/com/asolutions/scmsshd/sshd/UnparsableProjectException.java // public class UnparsableProjectException extends Exception { // // private static final long serialVersionUID = 643951700141491862L; // // public UnparsableProjectException(String reason) { // super(reason); // } // // } // Path: src/main/java/com/asolutions/scmsshd/converters/path/regexp/AMatchingGroupPathToProjectNameConverter.java import java.util.regex.Matcher; import java.util.regex.Pattern; import com.asolutions.scmsshd.converters.path.IPathToProjectNameConverter; import com.asolutions.scmsshd.sshd.UnparsableProjectException; package com.asolutions.scmsshd.converters.path.regexp; public abstract class AMatchingGroupPathToProjectNameConverter implements IPathToProjectNameConverter{ public AMatchingGroupPathToProjectNameConverter() { super(); }
public String convert(String toParse) throws UnparsableProjectException {
gaffo/scumd
src/test/java/com/asolutions/scmsshd/authenticators/LDAPBindingProviderTest.java
// Path: src/main/java/com/asolutions/scmsshd/ldap/LDAPBindingProvider.java // public class LDAPBindingProvider { // private String lookupUserDN; // private String lookupUserPassword; // private String url; // private boolean promiscuous; // // public LDAPBindingProvider(String lookupUserDN, String lookupUserPassword, // String url, boolean promiscuous) { // this.lookupUserDN = lookupUserDN; // this.lookupUserPassword = lookupUserPassword; // this.url = url; // this.promiscuous = promiscuous; // } // // // public InitialDirContext getBinding() throws NamingException { // return new InitialDirContext(getProperties(url, lookupUserDN, lookupUserPassword, promiscuous)); // } // // public InitialDirContext getBinding(String lookupUserDN, String lookupUserPassword) throws NamingException { // return new InitialDirContext(getProperties(url, lookupUserDN, lookupUserPassword, promiscuous)); // } // // // public Properties getProperties(String url, String username, String password, boolean promiscuous) // { // Properties properties = new Properties(); // properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); // properties.setProperty(Context.PROVIDER_URL, url); // properties.setProperty(Context.SECURITY_PRINCIPAL, username); // properties.setProperty(Context.SECURITY_CREDENTIALS, password); // if (promiscuous){ // properties.setProperty("java.naming.ldap.factory.socket", PromiscuousSSLSocketFactory.class.getName()); // } // return properties; // } // } // // Path: src/main/java/com/asolutions/scmsshd/ssl/PromiscuousSSLSocketFactory.java // public class PromiscuousSSLSocketFactory extends SocketFactory { // protected final Logger log = LoggerFactory.getLogger(getClass()); // private static SocketFactory blindFactory = null; // // /** // * // * Builds an all trusting "blind" ssl socket factory. // * // */ // // static { // // create a trust manager that will purposefully fall down on the // // job // TrustManager[] blindTrustMan = new TrustManager[] { new X509TrustManager() { // public X509Certificate[] getAcceptedIssuers() { // return null; // } // public void checkClientTrusted(X509Certificate[] c, String a) { // } // public void checkServerTrusted(X509Certificate[] c, String a) { // } // } }; // // // create our "blind" ssl socket factory with our lazy trust manager // try { // SSLContext sc = SSLContext.getInstance("SSL"); // sc.init(null, blindTrustMan, new java.security.SecureRandom()); // blindFactory = sc.getSocketFactory(); // } catch (GeneralSecurityException e) { // LoggerFactory.getLogger(PromiscuousSSLSocketFactory.class).error("Error taking security promiscuous" , e); // } // } // // /** // * // * @see javax.net.SocketFactory#getDefault() // * // */ // // public static SocketFactory getDefault() { // return new PromiscuousSSLSocketFactory(); // } // // /** // * // * @see javax.net.SocketFactory#createSocket(java.lang.String, int) // * // */ // // @Override // public Socket createSocket(String arg0, int arg1) throws IOException, // UnknownHostException { // return blindFactory.createSocket(arg0, arg1); // } // // /** // * // * @see javax.net.SocketFactory#createSocket(java.net.InetAddress, int) // * // */ // // @Override // public Socket createSocket(InetAddress arg0, int arg1) throws IOException { // return blindFactory.createSocket(arg0, arg1); // } // // /** // * // * @see javax.net.SocketFactory#createSocket(java.lang.String, int, // * // * java.net.InetAddress, int) // * // */ // // @Override // public Socket createSocket(String arg0, int arg1, InetAddress arg2, int arg3) // throws IOException, UnknownHostException { // return blindFactory.createSocket(arg0, arg1, arg2, arg3); // // } // // /** // * // * @see javax.net.SocketFactory#createSocket(java.net.InetAddress, int, // * // * java.net.InetAddress, int) // * // */ // // @Override // public Socket createSocket(InetAddress arg0, int arg1, InetAddress arg2, int arg3) throws IOException { // return blindFactory.createSocket(arg0, arg1, arg2, arg3); // } // // }
import static org.junit.Assert.assertEquals; import java.util.Properties; import javax.naming.Context; import org.junit.Test; import com.asolutions.scmsshd.ldap.LDAPBindingProvider; import com.asolutions.scmsshd.ssl.PromiscuousSSLSocketFactory;
package com.asolutions.scmsshd.authenticators; public class LDAPBindingProviderTest { private static final String PASSWORD = "password"; private static final String USERNAME = "username"; private static final String URL = "ldaps://server.lan"; @Test public void testGettingPropertiesNonPromiscuous() throws Exception {
// Path: src/main/java/com/asolutions/scmsshd/ldap/LDAPBindingProvider.java // public class LDAPBindingProvider { // private String lookupUserDN; // private String lookupUserPassword; // private String url; // private boolean promiscuous; // // public LDAPBindingProvider(String lookupUserDN, String lookupUserPassword, // String url, boolean promiscuous) { // this.lookupUserDN = lookupUserDN; // this.lookupUserPassword = lookupUserPassword; // this.url = url; // this.promiscuous = promiscuous; // } // // // public InitialDirContext getBinding() throws NamingException { // return new InitialDirContext(getProperties(url, lookupUserDN, lookupUserPassword, promiscuous)); // } // // public InitialDirContext getBinding(String lookupUserDN, String lookupUserPassword) throws NamingException { // return new InitialDirContext(getProperties(url, lookupUserDN, lookupUserPassword, promiscuous)); // } // // // public Properties getProperties(String url, String username, String password, boolean promiscuous) // { // Properties properties = new Properties(); // properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); // properties.setProperty(Context.PROVIDER_URL, url); // properties.setProperty(Context.SECURITY_PRINCIPAL, username); // properties.setProperty(Context.SECURITY_CREDENTIALS, password); // if (promiscuous){ // properties.setProperty("java.naming.ldap.factory.socket", PromiscuousSSLSocketFactory.class.getName()); // } // return properties; // } // } // // Path: src/main/java/com/asolutions/scmsshd/ssl/PromiscuousSSLSocketFactory.java // public class PromiscuousSSLSocketFactory extends SocketFactory { // protected final Logger log = LoggerFactory.getLogger(getClass()); // private static SocketFactory blindFactory = null; // // /** // * // * Builds an all trusting "blind" ssl socket factory. // * // */ // // static { // // create a trust manager that will purposefully fall down on the // // job // TrustManager[] blindTrustMan = new TrustManager[] { new X509TrustManager() { // public X509Certificate[] getAcceptedIssuers() { // return null; // } // public void checkClientTrusted(X509Certificate[] c, String a) { // } // public void checkServerTrusted(X509Certificate[] c, String a) { // } // } }; // // // create our "blind" ssl socket factory with our lazy trust manager // try { // SSLContext sc = SSLContext.getInstance("SSL"); // sc.init(null, blindTrustMan, new java.security.SecureRandom()); // blindFactory = sc.getSocketFactory(); // } catch (GeneralSecurityException e) { // LoggerFactory.getLogger(PromiscuousSSLSocketFactory.class).error("Error taking security promiscuous" , e); // } // } // // /** // * // * @see javax.net.SocketFactory#getDefault() // * // */ // // public static SocketFactory getDefault() { // return new PromiscuousSSLSocketFactory(); // } // // /** // * // * @see javax.net.SocketFactory#createSocket(java.lang.String, int) // * // */ // // @Override // public Socket createSocket(String arg0, int arg1) throws IOException, // UnknownHostException { // return blindFactory.createSocket(arg0, arg1); // } // // /** // * // * @see javax.net.SocketFactory#createSocket(java.net.InetAddress, int) // * // */ // // @Override // public Socket createSocket(InetAddress arg0, int arg1) throws IOException { // return blindFactory.createSocket(arg0, arg1); // } // // /** // * // * @see javax.net.SocketFactory#createSocket(java.lang.String, int, // * // * java.net.InetAddress, int) // * // */ // // @Override // public Socket createSocket(String arg0, int arg1, InetAddress arg2, int arg3) // throws IOException, UnknownHostException { // return blindFactory.createSocket(arg0, arg1, arg2, arg3); // // } // // /** // * // * @see javax.net.SocketFactory#createSocket(java.net.InetAddress, int, // * // * java.net.InetAddress, int) // * // */ // // @Override // public Socket createSocket(InetAddress arg0, int arg1, InetAddress arg2, int arg3) throws IOException { // return blindFactory.createSocket(arg0, arg1, arg2, arg3); // } // // } // Path: src/test/java/com/asolutions/scmsshd/authenticators/LDAPBindingProviderTest.java import static org.junit.Assert.assertEquals; import java.util.Properties; import javax.naming.Context; import org.junit.Test; import com.asolutions.scmsshd.ldap.LDAPBindingProvider; import com.asolutions.scmsshd.ssl.PromiscuousSSLSocketFactory; package com.asolutions.scmsshd.authenticators; public class LDAPBindingProviderTest { private static final String PASSWORD = "password"; private static final String USERNAME = "username"; private static final String URL = "ldaps://server.lan"; @Test public void testGettingPropertiesNonPromiscuous() throws Exception {
LDAPBindingProvider provider = new LDAPBindingProvider(USERNAME, PASSWORD, URL, false);
gaffo/scumd
src/test/java/com/asolutions/asynchrony/customizations/AsynchronyPathToProjectNameConverterTest.java
// Path: src/main/java/com/asolutions/scmsshd/sshd/UnparsableProjectException.java // public class UnparsableProjectException extends Exception { // // private static final long serialVersionUID = 643951700141491862L; // // public UnparsableProjectException(String reason) { // super(reason); // } // // }
import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; import org.junit.Test; import com.asolutions.scmsshd.sshd.UnparsableProjectException;
package com.asolutions.asynchrony.customizations; public class AsynchronyPathToProjectNameConverterTest { @Test public void testProjectGetter() throws Exception { assertEquals("proj-2", new AsynchronyPathToProjectNameConverter().convert("'/proj-2/git.git'")); } @Test public void testGetterThrowsUnparsableExceptionOnBadUrl() throws Exception { try{ new AsynchronyPathToProjectNameConverter().convert("blork"); fail("Didn't Throw"); }
// Path: src/main/java/com/asolutions/scmsshd/sshd/UnparsableProjectException.java // public class UnparsableProjectException extends Exception { // // private static final long serialVersionUID = 643951700141491862L; // // public UnparsableProjectException(String reason) { // super(reason); // } // // } // Path: src/test/java/com/asolutions/asynchrony/customizations/AsynchronyPathToProjectNameConverterTest.java import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; import org.junit.Test; import com.asolutions.scmsshd.sshd.UnparsableProjectException; package com.asolutions.asynchrony.customizations; public class AsynchronyPathToProjectNameConverterTest { @Test public void testProjectGetter() throws Exception { assertEquals("proj-2", new AsynchronyPathToProjectNameConverter().convert("'/proj-2/git.git'")); } @Test public void testGetterThrowsUnparsableExceptionOnBadUrl() throws Exception { try{ new AsynchronyPathToProjectNameConverter().convert("blork"); fail("Didn't Throw"); }
catch (UnparsableProjectException e){
gaffo/scumd
src/test/java/com/asolutions/scmsshd/commands/factories/GitCommandFactoryTest.java
// Path: src/main/java/com/asolutions/scmsshd/commands/filters/git/GitBadCommandFilter.java // public class GitBadCommandFilter implements IBadCommandFilter { // // // private static final Pattern commandFilter = Pattern.compile("^'/*(?P<path>[a-zA-Z0-9][a-zA-Z0-9@._-]*(/[a-zA-Z0-9][a-zA-Z0-9@._-]*)*)'$"); // private static final String commandFilter = "^'.+'$"; // private static final String[] validCommands = {"git-upload-pack", "git-receive-pack"}; // private String[] parts; // // public GitBadCommandFilter() { // } // // public FilteredCommand filterOrThrow(String command) throws BadCommandException { // command = new GitCommandSeamer(command).toString(); // checkForNewlines(command); // parts = checkForOneArgument(command); // throwIfContains(parts[1], ".."); // throwIfContains(parts[1], "!"); // checkAgainstPattern(parts[1]); // checkValidCommands(parts[0]); // parts[1] = parts[1].replaceAll("^'", ""); // parts[1] = parts[1].replaceAll("'$", ""); // return new FilteredCommand(parts[0], parts[1]); // } // // private void checkValidCommands(String commandToCheck) throws BadCommandException { // for (String validCommand : validCommands) { // if (validCommand.equals(commandToCheck)){ // return; // } // } // throw new BadCommandException("Unknown Command: " + commandToCheck); // } // // private void checkAgainstPattern(String command) throws BadCommandException { // if (!Pattern.matches(commandFilter, command)) // { // throw new BadCommandException(); // } // } // // private String[] checkForOneArgument(String command) throws BadCommandException { // String[] parts = command.split(" "); // int count = parts.length; // if (count == 1 || count > 2) // { // throw new BadCommandException("Invalid Number Of Arguments (must be 1): " + count); // } // return parts; // } // // private void checkForNewlines(String command) throws BadCommandException { // throwIfContains(command, "\n"); // throwIfContains(command, "\r"); // } // // private void throwIfContains(String command, String toCheckFor) throws BadCommandException { // if (command.contains(toCheckFor)){ // throw new BadCommandException("Cant Contain: " + toCheckFor); // } // } // // public String getCommand() // { // return parts[0]; // } // // public String getArgument() // { // return parts[1]; // } // // }
import static org.junit.Assert.assertEquals; import org.junit.Test; import com.asolutions.scmsshd.commands.filters.git.GitBadCommandFilter;
package com.asolutions.scmsshd.commands.factories; public class GitCommandFactoryTest { @Test public void testUsesCorrectFilterAndFactory() throws Exception { CommandFactoryBase factory = new GitCommandFactory();
// Path: src/main/java/com/asolutions/scmsshd/commands/filters/git/GitBadCommandFilter.java // public class GitBadCommandFilter implements IBadCommandFilter { // // // private static final Pattern commandFilter = Pattern.compile("^'/*(?P<path>[a-zA-Z0-9][a-zA-Z0-9@._-]*(/[a-zA-Z0-9][a-zA-Z0-9@._-]*)*)'$"); // private static final String commandFilter = "^'.+'$"; // private static final String[] validCommands = {"git-upload-pack", "git-receive-pack"}; // private String[] parts; // // public GitBadCommandFilter() { // } // // public FilteredCommand filterOrThrow(String command) throws BadCommandException { // command = new GitCommandSeamer(command).toString(); // checkForNewlines(command); // parts = checkForOneArgument(command); // throwIfContains(parts[1], ".."); // throwIfContains(parts[1], "!"); // checkAgainstPattern(parts[1]); // checkValidCommands(parts[0]); // parts[1] = parts[1].replaceAll("^'", ""); // parts[1] = parts[1].replaceAll("'$", ""); // return new FilteredCommand(parts[0], parts[1]); // } // // private void checkValidCommands(String commandToCheck) throws BadCommandException { // for (String validCommand : validCommands) { // if (validCommand.equals(commandToCheck)){ // return; // } // } // throw new BadCommandException("Unknown Command: " + commandToCheck); // } // // private void checkAgainstPattern(String command) throws BadCommandException { // if (!Pattern.matches(commandFilter, command)) // { // throw new BadCommandException(); // } // } // // private String[] checkForOneArgument(String command) throws BadCommandException { // String[] parts = command.split(" "); // int count = parts.length; // if (count == 1 || count > 2) // { // throw new BadCommandException("Invalid Number Of Arguments (must be 1): " + count); // } // return parts; // } // // private void checkForNewlines(String command) throws BadCommandException { // throwIfContains(command, "\n"); // throwIfContains(command, "\r"); // } // // private void throwIfContains(String command, String toCheckFor) throws BadCommandException { // if (command.contains(toCheckFor)){ // throw new BadCommandException("Cant Contain: " + toCheckFor); // } // } // // public String getCommand() // { // return parts[0]; // } // // public String getArgument() // { // return parts[1]; // } // // } // Path: src/test/java/com/asolutions/scmsshd/commands/factories/GitCommandFactoryTest.java import static org.junit.Assert.assertEquals; import org.junit.Test; import com.asolutions.scmsshd.commands.filters.git.GitBadCommandFilter; package com.asolutions.scmsshd.commands.factories; public class GitCommandFactoryTest { @Test public void testUsesCorrectFilterAndFactory() throws Exception { CommandFactoryBase factory = new GitCommandFactory();
assertEquals(GitBadCommandFilter.class, factory.getBadCommandFilter().getClass());
gaffo/scumd
src/main/java/com/asolutions/scmsshd/authenticators/JavaxNamingLDAPAuthLookupProvider.java
// Path: src/main/java/com/asolutions/scmsshd/ldap/ILDAPAuthLookupProvider.java // public interface ILDAPAuthLookupProvider { // // Object provide(String url, String username, String password, boolean promiscuous) throws NamingException; // // } // // Path: src/main/java/com/asolutions/scmsshd/ssl/PromiscuousSSLSocketFactory.java // public class PromiscuousSSLSocketFactory extends SocketFactory { // protected final Logger log = LoggerFactory.getLogger(getClass()); // private static SocketFactory blindFactory = null; // // /** // * // * Builds an all trusting "blind" ssl socket factory. // * // */ // // static { // // create a trust manager that will purposefully fall down on the // // job // TrustManager[] blindTrustMan = new TrustManager[] { new X509TrustManager() { // public X509Certificate[] getAcceptedIssuers() { // return null; // } // public void checkClientTrusted(X509Certificate[] c, String a) { // } // public void checkServerTrusted(X509Certificate[] c, String a) { // } // } }; // // // create our "blind" ssl socket factory with our lazy trust manager // try { // SSLContext sc = SSLContext.getInstance("SSL"); // sc.init(null, blindTrustMan, new java.security.SecureRandom()); // blindFactory = sc.getSocketFactory(); // } catch (GeneralSecurityException e) { // LoggerFactory.getLogger(PromiscuousSSLSocketFactory.class).error("Error taking security promiscuous" , e); // } // } // // /** // * // * @see javax.net.SocketFactory#getDefault() // * // */ // // public static SocketFactory getDefault() { // return new PromiscuousSSLSocketFactory(); // } // // /** // * // * @see javax.net.SocketFactory#createSocket(java.lang.String, int) // * // */ // // @Override // public Socket createSocket(String arg0, int arg1) throws IOException, // UnknownHostException { // return blindFactory.createSocket(arg0, arg1); // } // // /** // * // * @see javax.net.SocketFactory#createSocket(java.net.InetAddress, int) // * // */ // // @Override // public Socket createSocket(InetAddress arg0, int arg1) throws IOException { // return blindFactory.createSocket(arg0, arg1); // } // // /** // * // * @see javax.net.SocketFactory#createSocket(java.lang.String, int, // * // * java.net.InetAddress, int) // * // */ // // @Override // public Socket createSocket(String arg0, int arg1, InetAddress arg2, int arg3) // throws IOException, UnknownHostException { // return blindFactory.createSocket(arg0, arg1, arg2, arg3); // // } // // /** // * // * @see javax.net.SocketFactory#createSocket(java.net.InetAddress, int, // * // * java.net.InetAddress, int) // * // */ // // @Override // public Socket createSocket(InetAddress arg0, int arg1, InetAddress arg2, int arg3) throws IOException { // return blindFactory.createSocket(arg0, arg1, arg2, arg3); // } // // }
import java.util.Properties; import javax.naming.Context; import javax.naming.NamingEnumeration; import javax.naming.NamingException; import javax.naming.directory.InitialDirContext; import javax.naming.directory.SearchControls; import javax.naming.directory.SearchResult; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.asolutions.scmsshd.ldap.ILDAPAuthLookupProvider; import com.asolutions.scmsshd.ssl.PromiscuousSSLSocketFactory;
package com.asolutions.scmsshd.authenticators; public class JavaxNamingLDAPAuthLookupProvider implements ILDAPAuthLookupProvider { protected final Logger log = LoggerFactory.getLogger(getClass()); public Object provide(String url, String username, String password, boolean promiscuous) throws NamingException { InitialDirContext context = new InitialDirContext(getProperties(url, username, password, promiscuous)); SearchControls searchCtls = new SearchControls(); //Specify the search scope searchCtls.setSearchScope(SearchControls.SUBTREE_SCOPE); //specify the LDAP search filter String searchFilter = "(objectClass=user)"; //initialize counter to total the results // Search for objects using the filter NamingEnumeration<SearchResult> answer = context.search(username, searchFilter, searchCtls); return (answer.next()); } public Properties getProperties(String url, String username, String password, boolean promiscuous) { Properties properties = new Properties(); properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); properties.setProperty(Context.PROVIDER_URL, url); properties.setProperty(Context.SECURITY_PRINCIPAL, username); properties.setProperty(Context.SECURITY_CREDENTIALS, password); if (promiscuous){
// Path: src/main/java/com/asolutions/scmsshd/ldap/ILDAPAuthLookupProvider.java // public interface ILDAPAuthLookupProvider { // // Object provide(String url, String username, String password, boolean promiscuous) throws NamingException; // // } // // Path: src/main/java/com/asolutions/scmsshd/ssl/PromiscuousSSLSocketFactory.java // public class PromiscuousSSLSocketFactory extends SocketFactory { // protected final Logger log = LoggerFactory.getLogger(getClass()); // private static SocketFactory blindFactory = null; // // /** // * // * Builds an all trusting "blind" ssl socket factory. // * // */ // // static { // // create a trust manager that will purposefully fall down on the // // job // TrustManager[] blindTrustMan = new TrustManager[] { new X509TrustManager() { // public X509Certificate[] getAcceptedIssuers() { // return null; // } // public void checkClientTrusted(X509Certificate[] c, String a) { // } // public void checkServerTrusted(X509Certificate[] c, String a) { // } // } }; // // // create our "blind" ssl socket factory with our lazy trust manager // try { // SSLContext sc = SSLContext.getInstance("SSL"); // sc.init(null, blindTrustMan, new java.security.SecureRandom()); // blindFactory = sc.getSocketFactory(); // } catch (GeneralSecurityException e) { // LoggerFactory.getLogger(PromiscuousSSLSocketFactory.class).error("Error taking security promiscuous" , e); // } // } // // /** // * // * @see javax.net.SocketFactory#getDefault() // * // */ // // public static SocketFactory getDefault() { // return new PromiscuousSSLSocketFactory(); // } // // /** // * // * @see javax.net.SocketFactory#createSocket(java.lang.String, int) // * // */ // // @Override // public Socket createSocket(String arg0, int arg1) throws IOException, // UnknownHostException { // return blindFactory.createSocket(arg0, arg1); // } // // /** // * // * @see javax.net.SocketFactory#createSocket(java.net.InetAddress, int) // * // */ // // @Override // public Socket createSocket(InetAddress arg0, int arg1) throws IOException { // return blindFactory.createSocket(arg0, arg1); // } // // /** // * // * @see javax.net.SocketFactory#createSocket(java.lang.String, int, // * // * java.net.InetAddress, int) // * // */ // // @Override // public Socket createSocket(String arg0, int arg1, InetAddress arg2, int arg3) // throws IOException, UnknownHostException { // return blindFactory.createSocket(arg0, arg1, arg2, arg3); // // } // // /** // * // * @see javax.net.SocketFactory#createSocket(java.net.InetAddress, int, // * // * java.net.InetAddress, int) // * // */ // // @Override // public Socket createSocket(InetAddress arg0, int arg1, InetAddress arg2, int arg3) throws IOException { // return blindFactory.createSocket(arg0, arg1, arg2, arg3); // } // // } // Path: src/main/java/com/asolutions/scmsshd/authenticators/JavaxNamingLDAPAuthLookupProvider.java import java.util.Properties; import javax.naming.Context; import javax.naming.NamingEnumeration; import javax.naming.NamingException; import javax.naming.directory.InitialDirContext; import javax.naming.directory.SearchControls; import javax.naming.directory.SearchResult; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.asolutions.scmsshd.ldap.ILDAPAuthLookupProvider; import com.asolutions.scmsshd.ssl.PromiscuousSSLSocketFactory; package com.asolutions.scmsshd.authenticators; public class JavaxNamingLDAPAuthLookupProvider implements ILDAPAuthLookupProvider { protected final Logger log = LoggerFactory.getLogger(getClass()); public Object provide(String url, String username, String password, boolean promiscuous) throws NamingException { InitialDirContext context = new InitialDirContext(getProperties(url, username, password, promiscuous)); SearchControls searchCtls = new SearchControls(); //Specify the search scope searchCtls.setSearchScope(SearchControls.SUBTREE_SCOPE); //specify the LDAP search filter String searchFilter = "(objectClass=user)"; //initialize counter to total the results // Search for objects using the filter NamingEnumeration<SearchResult> answer = context.search(username, searchFilter, searchCtls); return (answer.next()); } public Properties getProperties(String url, String username, String password, boolean promiscuous) { Properties properties = new Properties(); properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); properties.setProperty(Context.PROVIDER_URL, url); properties.setProperty(Context.SECURITY_PRINCIPAL, username); properties.setProperty(Context.SECURITY_CREDENTIALS, password); if (promiscuous){
properties.setProperty("java.naming.ldap.factory.socket", PromiscuousSSLSocketFactory.class.getName());
gaffo/scumd
src/main/java/com/asolutions/scmsshd/commands/AllowedCommandChecker.java
// Path: src/main/java/com/asolutions/scmsshd/commands/filters/BadCommandException.java // public class BadCommandException extends Exception { // // private static final long serialVersionUID = 4904880805323643780L; // // public BadCommandException(String reason) { // super(reason); // } // // public BadCommandException() { // } // // } // // Path: src/main/java/com/asolutions/scmsshd/commands/filters/git/GitCommandSeamer.java // public class GitCommandSeamer { // // private String command; // // public GitCommandSeamer(String command) { // this.command = command; // this.command = this.command.replaceFirst("^git (\\w)", "git-$1"); // } // // @Override // public String toString() { // return command; // } // // }
import com.asolutions.scmsshd.commands.filters.BadCommandException; import com.asolutions.scmsshd.commands.filters.git.GitCommandSeamer;
package com.asolutions.scmsshd.commands; public class AllowedCommandChecker { private static String commands[] = {"git-upload-pack", "git-receive-pack", };
// Path: src/main/java/com/asolutions/scmsshd/commands/filters/BadCommandException.java // public class BadCommandException extends Exception { // // private static final long serialVersionUID = 4904880805323643780L; // // public BadCommandException(String reason) { // super(reason); // } // // public BadCommandException() { // } // // } // // Path: src/main/java/com/asolutions/scmsshd/commands/filters/git/GitCommandSeamer.java // public class GitCommandSeamer { // // private String command; // // public GitCommandSeamer(String command) { // this.command = command; // this.command = this.command.replaceFirst("^git (\\w)", "git-$1"); // } // // @Override // public String toString() { // return command; // } // // } // Path: src/main/java/com/asolutions/scmsshd/commands/AllowedCommandChecker.java import com.asolutions.scmsshd.commands.filters.BadCommandException; import com.asolutions.scmsshd.commands.filters.git.GitCommandSeamer; package com.asolutions.scmsshd.commands; public class AllowedCommandChecker { private static String commands[] = {"git-upload-pack", "git-receive-pack", };
public AllowedCommandChecker(String cmd) throws BadCommandException {
gaffo/scumd
src/main/java/com/asolutions/scmsshd/commands/AllowedCommandChecker.java
// Path: src/main/java/com/asolutions/scmsshd/commands/filters/BadCommandException.java // public class BadCommandException extends Exception { // // private static final long serialVersionUID = 4904880805323643780L; // // public BadCommandException(String reason) { // super(reason); // } // // public BadCommandException() { // } // // } // // Path: src/main/java/com/asolutions/scmsshd/commands/filters/git/GitCommandSeamer.java // public class GitCommandSeamer { // // private String command; // // public GitCommandSeamer(String command) { // this.command = command; // this.command = this.command.replaceFirst("^git (\\w)", "git-$1"); // } // // @Override // public String toString() { // return command; // } // // }
import com.asolutions.scmsshd.commands.filters.BadCommandException; import com.asolutions.scmsshd.commands.filters.git.GitCommandSeamer;
package com.asolutions.scmsshd.commands; public class AllowedCommandChecker { private static String commands[] = {"git-upload-pack", "git-receive-pack", }; public AllowedCommandChecker(String cmd) throws BadCommandException {
// Path: src/main/java/com/asolutions/scmsshd/commands/filters/BadCommandException.java // public class BadCommandException extends Exception { // // private static final long serialVersionUID = 4904880805323643780L; // // public BadCommandException(String reason) { // super(reason); // } // // public BadCommandException() { // } // // } // // Path: src/main/java/com/asolutions/scmsshd/commands/filters/git/GitCommandSeamer.java // public class GitCommandSeamer { // // private String command; // // public GitCommandSeamer(String command) { // this.command = command; // this.command = this.command.replaceFirst("^git (\\w)", "git-$1"); // } // // @Override // public String toString() { // return command; // } // // } // Path: src/main/java/com/asolutions/scmsshd/commands/AllowedCommandChecker.java import com.asolutions.scmsshd.commands.filters.BadCommandException; import com.asolutions.scmsshd.commands.filters.git.GitCommandSeamer; package com.asolutions.scmsshd.commands; public class AllowedCommandChecker { private static String commands[] = {"git-upload-pack", "git-receive-pack", }; public AllowedCommandChecker(String cmd) throws BadCommandException {
cmd = new GitCommandSeamer(cmd).toString();
gaffo/scumd
src/test/java/com/asolutions/scmsshd/commands/git/GitUploadPackSCMCommandHandlerTest.java
// Path: src/test/java/com/asolutions/MockTestCase.java // public class MockTestCase { // // protected Mockery context = new JUnit4Mockery(); // // @Before // public void setupMockery() { // context.setImposteriser(ClassImposteriser.INSTANCE); // } // // @After // public void mockeryAssertIsSatisfied(){ // context.assertIsSatisfied(); // } // // protected void checking(Expectations expectations) { // context.checking(expectations); // } // // } // // Path: src/main/java/com/asolutions/scmsshd/authorizors/AuthorizationLevel.java // public enum AuthorizationLevel { // AUTH_LEVEL_READ_ONLY, // AUTH_LEVEL_READ_WRITE; // } // // Path: src/main/java/com/asolutions/scmsshd/commands/FilteredCommand.java // public class FilteredCommand { // // private String command; // private String argument; // // public FilteredCommand() { // } // // public FilteredCommand(String command, String argument) { // this.command = command; // this.argument = argument; // } // // public void setArgument(String argument) { // this.argument = argument; // } // // public void setCommand(String command) { // this.command = command; // } // // public String getCommand() { // return this.command; // } // // public String getArgument() { // return this.argument; // } // // @Override // public String toString() // { // return "Filtered Command: " + getCommand() + ", " + getArgument(); // } // // } // // Path: src/main/java/com/asolutions/scmsshd/commands/factories/GitSCMCommandFactory.java // public class GitSCMCommandFactory implements ISCMCommandFactory { // // public static final String REPOSITORY_BASE = "repositoryBase"; // // public Command create(FilteredCommand filteredCommand, // IProjectAuthorizer projectAuthorizer, // IPathToProjectNameConverter pathToProjectNameConverter, // Properties configuration) { // SCMCommand retVal = new SCMCommand(filteredCommand, projectAuthorizer, new GitSCMCommandHandler(), pathToProjectNameConverter, configuration); // return retVal; // } // // }
import java.io.File; import java.io.InputStream; import java.io.OutputStream; import java.util.Properties; import org.apache.sshd.server.CommandFactory.ExitCallback; import org.jmock.Expectations; import org.junit.Test; import org.spearce.jgit.lib.Repository; import org.spearce.jgit.transport.UploadPack; import com.asolutions.MockTestCase; import com.asolutions.scmsshd.authorizors.AuthorizationLevel; import com.asolutions.scmsshd.commands.FilteredCommand; import com.asolutions.scmsshd.commands.factories.GitSCMCommandFactory;
package com.asolutions.scmsshd.commands.git; public class GitUploadPackSCMCommandHandlerTest extends MockTestCase { @Test public void testUploadPackPassesCorrectStuffToJGIT() throws Exception { final String pathtobasedir = "pathtobasedir";
// Path: src/test/java/com/asolutions/MockTestCase.java // public class MockTestCase { // // protected Mockery context = new JUnit4Mockery(); // // @Before // public void setupMockery() { // context.setImposteriser(ClassImposteriser.INSTANCE); // } // // @After // public void mockeryAssertIsSatisfied(){ // context.assertIsSatisfied(); // } // // protected void checking(Expectations expectations) { // context.checking(expectations); // } // // } // // Path: src/main/java/com/asolutions/scmsshd/authorizors/AuthorizationLevel.java // public enum AuthorizationLevel { // AUTH_LEVEL_READ_ONLY, // AUTH_LEVEL_READ_WRITE; // } // // Path: src/main/java/com/asolutions/scmsshd/commands/FilteredCommand.java // public class FilteredCommand { // // private String command; // private String argument; // // public FilteredCommand() { // } // // public FilteredCommand(String command, String argument) { // this.command = command; // this.argument = argument; // } // // public void setArgument(String argument) { // this.argument = argument; // } // // public void setCommand(String command) { // this.command = command; // } // // public String getCommand() { // return this.command; // } // // public String getArgument() { // return this.argument; // } // // @Override // public String toString() // { // return "Filtered Command: " + getCommand() + ", " + getArgument(); // } // // } // // Path: src/main/java/com/asolutions/scmsshd/commands/factories/GitSCMCommandFactory.java // public class GitSCMCommandFactory implements ISCMCommandFactory { // // public static final String REPOSITORY_BASE = "repositoryBase"; // // public Command create(FilteredCommand filteredCommand, // IProjectAuthorizer projectAuthorizer, // IPathToProjectNameConverter pathToProjectNameConverter, // Properties configuration) { // SCMCommand retVal = new SCMCommand(filteredCommand, projectAuthorizer, new GitSCMCommandHandler(), pathToProjectNameConverter, configuration); // return retVal; // } // // } // Path: src/test/java/com/asolutions/scmsshd/commands/git/GitUploadPackSCMCommandHandlerTest.java import java.io.File; import java.io.InputStream; import java.io.OutputStream; import java.util.Properties; import org.apache.sshd.server.CommandFactory.ExitCallback; import org.jmock.Expectations; import org.junit.Test; import org.spearce.jgit.lib.Repository; import org.spearce.jgit.transport.UploadPack; import com.asolutions.MockTestCase; import com.asolutions.scmsshd.authorizors.AuthorizationLevel; import com.asolutions.scmsshd.commands.FilteredCommand; import com.asolutions.scmsshd.commands.factories.GitSCMCommandFactory; package com.asolutions.scmsshd.commands.git; public class GitUploadPackSCMCommandHandlerTest extends MockTestCase { @Test public void testUploadPackPassesCorrectStuffToJGIT() throws Exception { final String pathtobasedir = "pathtobasedir";
final FilteredCommand filteredCommand = new FilteredCommand(
gaffo/scumd
src/test/java/com/asolutions/scmsshd/commands/git/GitUploadPackSCMCommandHandlerTest.java
// Path: src/test/java/com/asolutions/MockTestCase.java // public class MockTestCase { // // protected Mockery context = new JUnit4Mockery(); // // @Before // public void setupMockery() { // context.setImposteriser(ClassImposteriser.INSTANCE); // } // // @After // public void mockeryAssertIsSatisfied(){ // context.assertIsSatisfied(); // } // // protected void checking(Expectations expectations) { // context.checking(expectations); // } // // } // // Path: src/main/java/com/asolutions/scmsshd/authorizors/AuthorizationLevel.java // public enum AuthorizationLevel { // AUTH_LEVEL_READ_ONLY, // AUTH_LEVEL_READ_WRITE; // } // // Path: src/main/java/com/asolutions/scmsshd/commands/FilteredCommand.java // public class FilteredCommand { // // private String command; // private String argument; // // public FilteredCommand() { // } // // public FilteredCommand(String command, String argument) { // this.command = command; // this.argument = argument; // } // // public void setArgument(String argument) { // this.argument = argument; // } // // public void setCommand(String command) { // this.command = command; // } // // public String getCommand() { // return this.command; // } // // public String getArgument() { // return this.argument; // } // // @Override // public String toString() // { // return "Filtered Command: " + getCommand() + ", " + getArgument(); // } // // } // // Path: src/main/java/com/asolutions/scmsshd/commands/factories/GitSCMCommandFactory.java // public class GitSCMCommandFactory implements ISCMCommandFactory { // // public static final String REPOSITORY_BASE = "repositoryBase"; // // public Command create(FilteredCommand filteredCommand, // IProjectAuthorizer projectAuthorizer, // IPathToProjectNameConverter pathToProjectNameConverter, // Properties configuration) { // SCMCommand retVal = new SCMCommand(filteredCommand, projectAuthorizer, new GitSCMCommandHandler(), pathToProjectNameConverter, configuration); // return retVal; // } // // }
import java.io.File; import java.io.InputStream; import java.io.OutputStream; import java.util.Properties; import org.apache.sshd.server.CommandFactory.ExitCallback; import org.jmock.Expectations; import org.junit.Test; import org.spearce.jgit.lib.Repository; import org.spearce.jgit.transport.UploadPack; import com.asolutions.MockTestCase; import com.asolutions.scmsshd.authorizors.AuthorizationLevel; import com.asolutions.scmsshd.commands.FilteredCommand; import com.asolutions.scmsshd.commands.factories.GitSCMCommandFactory;
final InputStream mockInputStream = context.mock(InputStream.class); final OutputStream mockOutputStream = context.mock(OutputStream.class, "mockOutputStream"); final OutputStream mockErrorStream = context.mock(OutputStream.class, "mockErrorStream"); final ExitCallback mockExitCallback = context.mock(ExitCallback.class); final GitSCMRepositoryProvider mockRepoProvider = context .mock(GitSCMRepositoryProvider.class); final Repository mockRepoistory = context.mock(Repository.class); final File base = new File(pathtobasedir); final GitUploadPackProvider mockUploadPackProvider = context .mock(GitUploadPackProvider.class); final UploadPack mockUploadPack = context.mock(UploadPack.class); final Properties mockConfig = context.mock(Properties.class); checking(new Expectations() { { one(mockRepoProvider).provide(base, filteredCommand.getArgument()); will(returnValue(mockRepoistory)); one(mockUploadPackProvider).provide(mockRepoistory); will(returnValue(mockUploadPack)); one(mockUploadPack).upload(mockInputStream, mockOutputStream, mockErrorStream); // one(mockExitCallback).onExit(0); // one(mockOutputStream).flush(); // one(mockErrorStream).flush(); one(mockConfig).getProperty(
// Path: src/test/java/com/asolutions/MockTestCase.java // public class MockTestCase { // // protected Mockery context = new JUnit4Mockery(); // // @Before // public void setupMockery() { // context.setImposteriser(ClassImposteriser.INSTANCE); // } // // @After // public void mockeryAssertIsSatisfied(){ // context.assertIsSatisfied(); // } // // protected void checking(Expectations expectations) { // context.checking(expectations); // } // // } // // Path: src/main/java/com/asolutions/scmsshd/authorizors/AuthorizationLevel.java // public enum AuthorizationLevel { // AUTH_LEVEL_READ_ONLY, // AUTH_LEVEL_READ_WRITE; // } // // Path: src/main/java/com/asolutions/scmsshd/commands/FilteredCommand.java // public class FilteredCommand { // // private String command; // private String argument; // // public FilteredCommand() { // } // // public FilteredCommand(String command, String argument) { // this.command = command; // this.argument = argument; // } // // public void setArgument(String argument) { // this.argument = argument; // } // // public void setCommand(String command) { // this.command = command; // } // // public String getCommand() { // return this.command; // } // // public String getArgument() { // return this.argument; // } // // @Override // public String toString() // { // return "Filtered Command: " + getCommand() + ", " + getArgument(); // } // // } // // Path: src/main/java/com/asolutions/scmsshd/commands/factories/GitSCMCommandFactory.java // public class GitSCMCommandFactory implements ISCMCommandFactory { // // public static final String REPOSITORY_BASE = "repositoryBase"; // // public Command create(FilteredCommand filteredCommand, // IProjectAuthorizer projectAuthorizer, // IPathToProjectNameConverter pathToProjectNameConverter, // Properties configuration) { // SCMCommand retVal = new SCMCommand(filteredCommand, projectAuthorizer, new GitSCMCommandHandler(), pathToProjectNameConverter, configuration); // return retVal; // } // // } // Path: src/test/java/com/asolutions/scmsshd/commands/git/GitUploadPackSCMCommandHandlerTest.java import java.io.File; import java.io.InputStream; import java.io.OutputStream; import java.util.Properties; import org.apache.sshd.server.CommandFactory.ExitCallback; import org.jmock.Expectations; import org.junit.Test; import org.spearce.jgit.lib.Repository; import org.spearce.jgit.transport.UploadPack; import com.asolutions.MockTestCase; import com.asolutions.scmsshd.authorizors.AuthorizationLevel; import com.asolutions.scmsshd.commands.FilteredCommand; import com.asolutions.scmsshd.commands.factories.GitSCMCommandFactory; final InputStream mockInputStream = context.mock(InputStream.class); final OutputStream mockOutputStream = context.mock(OutputStream.class, "mockOutputStream"); final OutputStream mockErrorStream = context.mock(OutputStream.class, "mockErrorStream"); final ExitCallback mockExitCallback = context.mock(ExitCallback.class); final GitSCMRepositoryProvider mockRepoProvider = context .mock(GitSCMRepositoryProvider.class); final Repository mockRepoistory = context.mock(Repository.class); final File base = new File(pathtobasedir); final GitUploadPackProvider mockUploadPackProvider = context .mock(GitUploadPackProvider.class); final UploadPack mockUploadPack = context.mock(UploadPack.class); final Properties mockConfig = context.mock(Properties.class); checking(new Expectations() { { one(mockRepoProvider).provide(base, filteredCommand.getArgument()); will(returnValue(mockRepoistory)); one(mockUploadPackProvider).provide(mockRepoistory); will(returnValue(mockUploadPack)); one(mockUploadPack).upload(mockInputStream, mockOutputStream, mockErrorStream); // one(mockExitCallback).onExit(0); // one(mockOutputStream).flush(); // one(mockErrorStream).flush(); one(mockConfig).getProperty(
GitSCMCommandFactory.REPOSITORY_BASE);
gaffo/scumd
src/test/java/com/asolutions/scmsshd/commands/git/GitUploadPackSCMCommandHandlerTest.java
// Path: src/test/java/com/asolutions/MockTestCase.java // public class MockTestCase { // // protected Mockery context = new JUnit4Mockery(); // // @Before // public void setupMockery() { // context.setImposteriser(ClassImposteriser.INSTANCE); // } // // @After // public void mockeryAssertIsSatisfied(){ // context.assertIsSatisfied(); // } // // protected void checking(Expectations expectations) { // context.checking(expectations); // } // // } // // Path: src/main/java/com/asolutions/scmsshd/authorizors/AuthorizationLevel.java // public enum AuthorizationLevel { // AUTH_LEVEL_READ_ONLY, // AUTH_LEVEL_READ_WRITE; // } // // Path: src/main/java/com/asolutions/scmsshd/commands/FilteredCommand.java // public class FilteredCommand { // // private String command; // private String argument; // // public FilteredCommand() { // } // // public FilteredCommand(String command, String argument) { // this.command = command; // this.argument = argument; // } // // public void setArgument(String argument) { // this.argument = argument; // } // // public void setCommand(String command) { // this.command = command; // } // // public String getCommand() { // return this.command; // } // // public String getArgument() { // return this.argument; // } // // @Override // public String toString() // { // return "Filtered Command: " + getCommand() + ", " + getArgument(); // } // // } // // Path: src/main/java/com/asolutions/scmsshd/commands/factories/GitSCMCommandFactory.java // public class GitSCMCommandFactory implements ISCMCommandFactory { // // public static final String REPOSITORY_BASE = "repositoryBase"; // // public Command create(FilteredCommand filteredCommand, // IProjectAuthorizer projectAuthorizer, // IPathToProjectNameConverter pathToProjectNameConverter, // Properties configuration) { // SCMCommand retVal = new SCMCommand(filteredCommand, projectAuthorizer, new GitSCMCommandHandler(), pathToProjectNameConverter, configuration); // return retVal; // } // // }
import java.io.File; import java.io.InputStream; import java.io.OutputStream; import java.util.Properties; import org.apache.sshd.server.CommandFactory.ExitCallback; import org.jmock.Expectations; import org.junit.Test; import org.spearce.jgit.lib.Repository; import org.spearce.jgit.transport.UploadPack; import com.asolutions.MockTestCase; import com.asolutions.scmsshd.authorizors.AuthorizationLevel; import com.asolutions.scmsshd.commands.FilteredCommand; import com.asolutions.scmsshd.commands.factories.GitSCMCommandFactory;
final Repository mockRepoistory = context.mock(Repository.class); final File base = new File(pathtobasedir); final GitUploadPackProvider mockUploadPackProvider = context .mock(GitUploadPackProvider.class); final UploadPack mockUploadPack = context.mock(UploadPack.class); final Properties mockConfig = context.mock(Properties.class); checking(new Expectations() { { one(mockRepoProvider).provide(base, filteredCommand.getArgument()); will(returnValue(mockRepoistory)); one(mockUploadPackProvider).provide(mockRepoistory); will(returnValue(mockUploadPack)); one(mockUploadPack).upload(mockInputStream, mockOutputStream, mockErrorStream); // one(mockExitCallback).onExit(0); // one(mockOutputStream).flush(); // one(mockErrorStream).flush(); one(mockConfig).getProperty( GitSCMCommandFactory.REPOSITORY_BASE); will(returnValue(pathtobasedir)); } }); GitSCMCommandImpl handler = new GitUploadPackSCMCommandHandler( mockRepoProvider, mockUploadPackProvider); handler.runCommand(filteredCommand, mockInputStream, mockOutputStream, mockErrorStream, mockExitCallback, mockConfig,
// Path: src/test/java/com/asolutions/MockTestCase.java // public class MockTestCase { // // protected Mockery context = new JUnit4Mockery(); // // @Before // public void setupMockery() { // context.setImposteriser(ClassImposteriser.INSTANCE); // } // // @After // public void mockeryAssertIsSatisfied(){ // context.assertIsSatisfied(); // } // // protected void checking(Expectations expectations) { // context.checking(expectations); // } // // } // // Path: src/main/java/com/asolutions/scmsshd/authorizors/AuthorizationLevel.java // public enum AuthorizationLevel { // AUTH_LEVEL_READ_ONLY, // AUTH_LEVEL_READ_WRITE; // } // // Path: src/main/java/com/asolutions/scmsshd/commands/FilteredCommand.java // public class FilteredCommand { // // private String command; // private String argument; // // public FilteredCommand() { // } // // public FilteredCommand(String command, String argument) { // this.command = command; // this.argument = argument; // } // // public void setArgument(String argument) { // this.argument = argument; // } // // public void setCommand(String command) { // this.command = command; // } // // public String getCommand() { // return this.command; // } // // public String getArgument() { // return this.argument; // } // // @Override // public String toString() // { // return "Filtered Command: " + getCommand() + ", " + getArgument(); // } // // } // // Path: src/main/java/com/asolutions/scmsshd/commands/factories/GitSCMCommandFactory.java // public class GitSCMCommandFactory implements ISCMCommandFactory { // // public static final String REPOSITORY_BASE = "repositoryBase"; // // public Command create(FilteredCommand filteredCommand, // IProjectAuthorizer projectAuthorizer, // IPathToProjectNameConverter pathToProjectNameConverter, // Properties configuration) { // SCMCommand retVal = new SCMCommand(filteredCommand, projectAuthorizer, new GitSCMCommandHandler(), pathToProjectNameConverter, configuration); // return retVal; // } // // } // Path: src/test/java/com/asolutions/scmsshd/commands/git/GitUploadPackSCMCommandHandlerTest.java import java.io.File; import java.io.InputStream; import java.io.OutputStream; import java.util.Properties; import org.apache.sshd.server.CommandFactory.ExitCallback; import org.jmock.Expectations; import org.junit.Test; import org.spearce.jgit.lib.Repository; import org.spearce.jgit.transport.UploadPack; import com.asolutions.MockTestCase; import com.asolutions.scmsshd.authorizors.AuthorizationLevel; import com.asolutions.scmsshd.commands.FilteredCommand; import com.asolutions.scmsshd.commands.factories.GitSCMCommandFactory; final Repository mockRepoistory = context.mock(Repository.class); final File base = new File(pathtobasedir); final GitUploadPackProvider mockUploadPackProvider = context .mock(GitUploadPackProvider.class); final UploadPack mockUploadPack = context.mock(UploadPack.class); final Properties mockConfig = context.mock(Properties.class); checking(new Expectations() { { one(mockRepoProvider).provide(base, filteredCommand.getArgument()); will(returnValue(mockRepoistory)); one(mockUploadPackProvider).provide(mockRepoistory); will(returnValue(mockUploadPack)); one(mockUploadPack).upload(mockInputStream, mockOutputStream, mockErrorStream); // one(mockExitCallback).onExit(0); // one(mockOutputStream).flush(); // one(mockErrorStream).flush(); one(mockConfig).getProperty( GitSCMCommandFactory.REPOSITORY_BASE); will(returnValue(pathtobasedir)); } }); GitSCMCommandImpl handler = new GitUploadPackSCMCommandHandler( mockRepoProvider, mockUploadPackProvider); handler.runCommand(filteredCommand, mockInputStream, mockOutputStream, mockErrorStream, mockExitCallback, mockConfig,
AuthorizationLevel.AUTH_LEVEL_READ_ONLY);
gaffo/scumd
src/main/java/com/asolutions/scmsshd/commands/factories/GitCommandFactory.java
// Path: src/main/java/com/asolutions/scmsshd/commands/filters/git/GitBadCommandFilter.java // public class GitBadCommandFilter implements IBadCommandFilter { // // // private static final Pattern commandFilter = Pattern.compile("^'/*(?P<path>[a-zA-Z0-9][a-zA-Z0-9@._-]*(/[a-zA-Z0-9][a-zA-Z0-9@._-]*)*)'$"); // private static final String commandFilter = "^'.+'$"; // private static final String[] validCommands = {"git-upload-pack", "git-receive-pack"}; // private String[] parts; // // public GitBadCommandFilter() { // } // // public FilteredCommand filterOrThrow(String command) throws BadCommandException { // command = new GitCommandSeamer(command).toString(); // checkForNewlines(command); // parts = checkForOneArgument(command); // throwIfContains(parts[1], ".."); // throwIfContains(parts[1], "!"); // checkAgainstPattern(parts[1]); // checkValidCommands(parts[0]); // parts[1] = parts[1].replaceAll("^'", ""); // parts[1] = parts[1].replaceAll("'$", ""); // return new FilteredCommand(parts[0], parts[1]); // } // // private void checkValidCommands(String commandToCheck) throws BadCommandException { // for (String validCommand : validCommands) { // if (validCommand.equals(commandToCheck)){ // return; // } // } // throw new BadCommandException("Unknown Command: " + commandToCheck); // } // // private void checkAgainstPattern(String command) throws BadCommandException { // if (!Pattern.matches(commandFilter, command)) // { // throw new BadCommandException(); // } // } // // private String[] checkForOneArgument(String command) throws BadCommandException { // String[] parts = command.split(" "); // int count = parts.length; // if (count == 1 || count > 2) // { // throw new BadCommandException("Invalid Number Of Arguments (must be 1): " + count); // } // return parts; // } // // private void checkForNewlines(String command) throws BadCommandException { // throwIfContains(command, "\n"); // throwIfContains(command, "\r"); // } // // private void throwIfContains(String command, String toCheckFor) throws BadCommandException { // if (command.contains(toCheckFor)){ // throw new BadCommandException("Cant Contain: " + toCheckFor); // } // } // // public String getCommand() // { // return parts[0]; // } // // public String getArgument() // { // return parts[1]; // } // // }
import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.asolutions.scmsshd.commands.filters.git.GitBadCommandFilter;
package com.asolutions.scmsshd.commands.factories; public class GitCommandFactory extends CommandFactoryBase { protected final Logger log = LoggerFactory.getLogger(getClass()); public GitCommandFactory() {
// Path: src/main/java/com/asolutions/scmsshd/commands/filters/git/GitBadCommandFilter.java // public class GitBadCommandFilter implements IBadCommandFilter { // // // private static final Pattern commandFilter = Pattern.compile("^'/*(?P<path>[a-zA-Z0-9][a-zA-Z0-9@._-]*(/[a-zA-Z0-9][a-zA-Z0-9@._-]*)*)'$"); // private static final String commandFilter = "^'.+'$"; // private static final String[] validCommands = {"git-upload-pack", "git-receive-pack"}; // private String[] parts; // // public GitBadCommandFilter() { // } // // public FilteredCommand filterOrThrow(String command) throws BadCommandException { // command = new GitCommandSeamer(command).toString(); // checkForNewlines(command); // parts = checkForOneArgument(command); // throwIfContains(parts[1], ".."); // throwIfContains(parts[1], "!"); // checkAgainstPattern(parts[1]); // checkValidCommands(parts[0]); // parts[1] = parts[1].replaceAll("^'", ""); // parts[1] = parts[1].replaceAll("'$", ""); // return new FilteredCommand(parts[0], parts[1]); // } // // private void checkValidCommands(String commandToCheck) throws BadCommandException { // for (String validCommand : validCommands) { // if (validCommand.equals(commandToCheck)){ // return; // } // } // throw new BadCommandException("Unknown Command: " + commandToCheck); // } // // private void checkAgainstPattern(String command) throws BadCommandException { // if (!Pattern.matches(commandFilter, command)) // { // throw new BadCommandException(); // } // } // // private String[] checkForOneArgument(String command) throws BadCommandException { // String[] parts = command.split(" "); // int count = parts.length; // if (count == 1 || count > 2) // { // throw new BadCommandException("Invalid Number Of Arguments (must be 1): " + count); // } // return parts; // } // // private void checkForNewlines(String command) throws BadCommandException { // throwIfContains(command, "\n"); // throwIfContains(command, "\r"); // } // // private void throwIfContains(String command, String toCheckFor) throws BadCommandException { // if (command.contains(toCheckFor)){ // throw new BadCommandException("Cant Contain: " + toCheckFor); // } // } // // public String getCommand() // { // return parts[0]; // } // // public String getArgument() // { // return parts[1]; // } // // } // Path: src/main/java/com/asolutions/scmsshd/commands/factories/GitCommandFactory.java import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.asolutions.scmsshd.commands.filters.git.GitBadCommandFilter; package com.asolutions.scmsshd.commands.factories; public class GitCommandFactory extends CommandFactoryBase { protected final Logger log = LoggerFactory.getLogger(getClass()); public GitCommandFactory() {
setBadCommandFilter(new GitBadCommandFilter());
gaffo/scumd
src/main/java/com/asolutions/scmsshd/commands/handlers/ISCMCommandHandler.java
// Path: src/main/java/com/asolutions/scmsshd/authorizors/AuthorizationLevel.java // public enum AuthorizationLevel { // AUTH_LEVEL_READ_ONLY, // AUTH_LEVEL_READ_WRITE; // } // // Path: src/main/java/com/asolutions/scmsshd/commands/FilteredCommand.java // public class FilteredCommand { // // private String command; // private String argument; // // public FilteredCommand() { // } // // public FilteredCommand(String command, String argument) { // this.command = command; // this.argument = argument; // } // // public void setArgument(String argument) { // this.argument = argument; // } // // public void setCommand(String command) { // this.command = command; // } // // public String getCommand() { // return this.command; // } // // public String getArgument() { // return this.argument; // } // // @Override // public String toString() // { // return "Filtered Command: " + getCommand() + ", " + getArgument(); // } // // }
import java.io.InputStream; import java.io.OutputStream; import java.util.Properties; import org.apache.sshd.server.CommandFactory.ExitCallback; import com.asolutions.scmsshd.authorizors.AuthorizationLevel; import com.asolutions.scmsshd.commands.FilteredCommand;
package com.asolutions.scmsshd.commands.handlers; public interface ISCMCommandHandler { void execute(FilteredCommand filteredCommand, InputStream inputStream, OutputStream outputStream, OutputStream errorStream,
// Path: src/main/java/com/asolutions/scmsshd/authorizors/AuthorizationLevel.java // public enum AuthorizationLevel { // AUTH_LEVEL_READ_ONLY, // AUTH_LEVEL_READ_WRITE; // } // // Path: src/main/java/com/asolutions/scmsshd/commands/FilteredCommand.java // public class FilteredCommand { // // private String command; // private String argument; // // public FilteredCommand() { // } // // public FilteredCommand(String command, String argument) { // this.command = command; // this.argument = argument; // } // // public void setArgument(String argument) { // this.argument = argument; // } // // public void setCommand(String command) { // this.command = command; // } // // public String getCommand() { // return this.command; // } // // public String getArgument() { // return this.argument; // } // // @Override // public String toString() // { // return "Filtered Command: " + getCommand() + ", " + getArgument(); // } // // } // Path: src/main/java/com/asolutions/scmsshd/commands/handlers/ISCMCommandHandler.java import java.io.InputStream; import java.io.OutputStream; import java.util.Properties; import org.apache.sshd.server.CommandFactory.ExitCallback; import com.asolutions.scmsshd.authorizors.AuthorizationLevel; import com.asolutions.scmsshd.commands.FilteredCommand; package com.asolutions.scmsshd.commands.handlers; public interface ISCMCommandHandler { void execute(FilteredCommand filteredCommand, InputStream inputStream, OutputStream outputStream, OutputStream errorStream,
ExitCallback exitCallback, Properties configuration, AuthorizationLevel authorizationLevel);
gaffo/scumd
src/main/java/com/asolutions/scmsshd/commands/filters/git/GitBadCommandFilter.java
// Path: src/main/java/com/asolutions/scmsshd/commands/FilteredCommand.java // public class FilteredCommand { // // private String command; // private String argument; // // public FilteredCommand() { // } // // public FilteredCommand(String command, String argument) { // this.command = command; // this.argument = argument; // } // // public void setArgument(String argument) { // this.argument = argument; // } // // public void setCommand(String command) { // this.command = command; // } // // public String getCommand() { // return this.command; // } // // public String getArgument() { // return this.argument; // } // // @Override // public String toString() // { // return "Filtered Command: " + getCommand() + ", " + getArgument(); // } // // } // // Path: src/main/java/com/asolutions/scmsshd/commands/filters/BadCommandException.java // public class BadCommandException extends Exception { // // private static final long serialVersionUID = 4904880805323643780L; // // public BadCommandException(String reason) { // super(reason); // } // // public BadCommandException() { // } // // } // // Path: src/main/java/com/asolutions/scmsshd/commands/filters/IBadCommandFilter.java // public interface IBadCommandFilter { // // FilteredCommand filterOrThrow(String command) throws BadCommandException; // // }
import java.util.regex.Pattern; import com.asolutions.scmsshd.commands.FilteredCommand; import com.asolutions.scmsshd.commands.filters.BadCommandException; import com.asolutions.scmsshd.commands.filters.IBadCommandFilter;
package com.asolutions.scmsshd.commands.filters.git; public class GitBadCommandFilter implements IBadCommandFilter { // private static final Pattern commandFilter = Pattern.compile("^'/*(?P<path>[a-zA-Z0-9][a-zA-Z0-9@._-]*(/[a-zA-Z0-9][a-zA-Z0-9@._-]*)*)'$"); private static final String commandFilter = "^'.+'$"; private static final String[] validCommands = {"git-upload-pack", "git-receive-pack"}; private String[] parts; public GitBadCommandFilter() { }
// Path: src/main/java/com/asolutions/scmsshd/commands/FilteredCommand.java // public class FilteredCommand { // // private String command; // private String argument; // // public FilteredCommand() { // } // // public FilteredCommand(String command, String argument) { // this.command = command; // this.argument = argument; // } // // public void setArgument(String argument) { // this.argument = argument; // } // // public void setCommand(String command) { // this.command = command; // } // // public String getCommand() { // return this.command; // } // // public String getArgument() { // return this.argument; // } // // @Override // public String toString() // { // return "Filtered Command: " + getCommand() + ", " + getArgument(); // } // // } // // Path: src/main/java/com/asolutions/scmsshd/commands/filters/BadCommandException.java // public class BadCommandException extends Exception { // // private static final long serialVersionUID = 4904880805323643780L; // // public BadCommandException(String reason) { // super(reason); // } // // public BadCommandException() { // } // // } // // Path: src/main/java/com/asolutions/scmsshd/commands/filters/IBadCommandFilter.java // public interface IBadCommandFilter { // // FilteredCommand filterOrThrow(String command) throws BadCommandException; // // } // Path: src/main/java/com/asolutions/scmsshd/commands/filters/git/GitBadCommandFilter.java import java.util.regex.Pattern; import com.asolutions.scmsshd.commands.FilteredCommand; import com.asolutions.scmsshd.commands.filters.BadCommandException; import com.asolutions.scmsshd.commands.filters.IBadCommandFilter; package com.asolutions.scmsshd.commands.filters.git; public class GitBadCommandFilter implements IBadCommandFilter { // private static final Pattern commandFilter = Pattern.compile("^'/*(?P<path>[a-zA-Z0-9][a-zA-Z0-9@._-]*(/[a-zA-Z0-9][a-zA-Z0-9@._-]*)*)'$"); private static final String commandFilter = "^'.+'$"; private static final String[] validCommands = {"git-upload-pack", "git-receive-pack"}; private String[] parts; public GitBadCommandFilter() { }
public FilteredCommand filterOrThrow(String command) throws BadCommandException {
gaffo/scumd
src/main/java/com/asolutions/scmsshd/commands/filters/git/GitBadCommandFilter.java
// Path: src/main/java/com/asolutions/scmsshd/commands/FilteredCommand.java // public class FilteredCommand { // // private String command; // private String argument; // // public FilteredCommand() { // } // // public FilteredCommand(String command, String argument) { // this.command = command; // this.argument = argument; // } // // public void setArgument(String argument) { // this.argument = argument; // } // // public void setCommand(String command) { // this.command = command; // } // // public String getCommand() { // return this.command; // } // // public String getArgument() { // return this.argument; // } // // @Override // public String toString() // { // return "Filtered Command: " + getCommand() + ", " + getArgument(); // } // // } // // Path: src/main/java/com/asolutions/scmsshd/commands/filters/BadCommandException.java // public class BadCommandException extends Exception { // // private static final long serialVersionUID = 4904880805323643780L; // // public BadCommandException(String reason) { // super(reason); // } // // public BadCommandException() { // } // // } // // Path: src/main/java/com/asolutions/scmsshd/commands/filters/IBadCommandFilter.java // public interface IBadCommandFilter { // // FilteredCommand filterOrThrow(String command) throws BadCommandException; // // }
import java.util.regex.Pattern; import com.asolutions.scmsshd.commands.FilteredCommand; import com.asolutions.scmsshd.commands.filters.BadCommandException; import com.asolutions.scmsshd.commands.filters.IBadCommandFilter;
package com.asolutions.scmsshd.commands.filters.git; public class GitBadCommandFilter implements IBadCommandFilter { // private static final Pattern commandFilter = Pattern.compile("^'/*(?P<path>[a-zA-Z0-9][a-zA-Z0-9@._-]*(/[a-zA-Z0-9][a-zA-Z0-9@._-]*)*)'$"); private static final String commandFilter = "^'.+'$"; private static final String[] validCommands = {"git-upload-pack", "git-receive-pack"}; private String[] parts; public GitBadCommandFilter() { }
// Path: src/main/java/com/asolutions/scmsshd/commands/FilteredCommand.java // public class FilteredCommand { // // private String command; // private String argument; // // public FilteredCommand() { // } // // public FilteredCommand(String command, String argument) { // this.command = command; // this.argument = argument; // } // // public void setArgument(String argument) { // this.argument = argument; // } // // public void setCommand(String command) { // this.command = command; // } // // public String getCommand() { // return this.command; // } // // public String getArgument() { // return this.argument; // } // // @Override // public String toString() // { // return "Filtered Command: " + getCommand() + ", " + getArgument(); // } // // } // // Path: src/main/java/com/asolutions/scmsshd/commands/filters/BadCommandException.java // public class BadCommandException extends Exception { // // private static final long serialVersionUID = 4904880805323643780L; // // public BadCommandException(String reason) { // super(reason); // } // // public BadCommandException() { // } // // } // // Path: src/main/java/com/asolutions/scmsshd/commands/filters/IBadCommandFilter.java // public interface IBadCommandFilter { // // FilteredCommand filterOrThrow(String command) throws BadCommandException; // // } // Path: src/main/java/com/asolutions/scmsshd/commands/filters/git/GitBadCommandFilter.java import java.util.regex.Pattern; import com.asolutions.scmsshd.commands.FilteredCommand; import com.asolutions.scmsshd.commands.filters.BadCommandException; import com.asolutions.scmsshd.commands.filters.IBadCommandFilter; package com.asolutions.scmsshd.commands.filters.git; public class GitBadCommandFilter implements IBadCommandFilter { // private static final Pattern commandFilter = Pattern.compile("^'/*(?P<path>[a-zA-Z0-9][a-zA-Z0-9@._-]*(/[a-zA-Z0-9][a-zA-Z0-9@._-]*)*)'$"); private static final String commandFilter = "^'.+'$"; private static final String[] validCommands = {"git-upload-pack", "git-receive-pack"}; private String[] parts; public GitBadCommandFilter() { }
public FilteredCommand filterOrThrow(String command) throws BadCommandException {
gaffo/scumd
src/test/java/com/asolutions/scmsshd/ldap/LDAPProjectAuthorizerTest.java
// Path: src/test/java/com/asolutions/MockTestCase.java // public class MockTestCase { // // protected Mockery context = new JUnit4Mockery(); // // @Before // public void setupMockery() { // context.setImposteriser(ClassImposteriser.INSTANCE); // } // // @After // public void mockeryAssertIsSatisfied(){ // context.assertIsSatisfied(); // } // // protected void checking(Expectations expectations) { // context.checking(expectations); // } // // } // // Path: src/main/java/com/asolutions/scmsshd/authenticators/LDAPUsernameResolver.java // public class LDAPUsernameResolver { // LDAPBindingProvider provider; // private String userBase; // private String matchingElement; // public LDAPUsernameResolver(LDAPBindingProvider provider, String userBase) { // this(provider, userBase, "cn="); // } // public LDAPUsernameResolver(LDAPBindingProvider provider, String userBase, String matchingElement) { // this.provider = provider; // this.userBase = userBase; // this.matchingElement = matchingElement; // } // // public String resolveUserName(String username) throws NamingException{ // InitialDirContext InitialDirectoryContext = provider.getBinding(); // SearchControls searchCtls = new SearchControls(); // //Specify the search scope // searchCtls.setSearchScope(SearchControls.SUBTREE_SCOPE); // // //specify the LDAP search filter // String searchFilter = "("+matchingElement+username+")"; // // //initialize counter to total the results // // // Search for objects using the filter // NamingEnumeration<SearchResult> answer = InitialDirectoryContext.search(userBase, searchFilter, searchCtls); // SearchResult next = answer.next(); // return next.getNameInNamespace(); // } // } // // Path: src/main/java/com/asolutions/scmsshd/authorizors/AuthorizationLevel.java // public enum AuthorizationLevel { // AUTH_LEVEL_READ_ONLY, // AUTH_LEVEL_READ_WRITE; // }
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import javax.naming.NamingEnumeration; import javax.naming.directory.Attribute; import javax.naming.directory.Attributes; import javax.naming.directory.InitialDirContext; import org.jmock.Expectations; import org.junit.Before; import org.junit.Test; import com.asolutions.MockTestCase; import com.asolutions.scmsshd.authenticators.LDAPUsernameResolver; import com.asolutions.scmsshd.authorizors.AuthorizationLevel;
package com.asolutions.scmsshd.ldap; public class LDAPProjectAuthorizerTest extends MockTestCase { final private String groupBaseDN = "cn=Groups,DC=ldapserver,DC=lan"; final private String userBaseDN = "cn=User,DC=ldapserver,DC=lan"; private LDAPBindingProvider ldapBinding; private String usernameToCheck = "mike.gaffney"; private String userToCheckDN = "cn=" + usernameToCheck + "," + userBaseDN;
// Path: src/test/java/com/asolutions/MockTestCase.java // public class MockTestCase { // // protected Mockery context = new JUnit4Mockery(); // // @Before // public void setupMockery() { // context.setImposteriser(ClassImposteriser.INSTANCE); // } // // @After // public void mockeryAssertIsSatisfied(){ // context.assertIsSatisfied(); // } // // protected void checking(Expectations expectations) { // context.checking(expectations); // } // // } // // Path: src/main/java/com/asolutions/scmsshd/authenticators/LDAPUsernameResolver.java // public class LDAPUsernameResolver { // LDAPBindingProvider provider; // private String userBase; // private String matchingElement; // public LDAPUsernameResolver(LDAPBindingProvider provider, String userBase) { // this(provider, userBase, "cn="); // } // public LDAPUsernameResolver(LDAPBindingProvider provider, String userBase, String matchingElement) { // this.provider = provider; // this.userBase = userBase; // this.matchingElement = matchingElement; // } // // public String resolveUserName(String username) throws NamingException{ // InitialDirContext InitialDirectoryContext = provider.getBinding(); // SearchControls searchCtls = new SearchControls(); // //Specify the search scope // searchCtls.setSearchScope(SearchControls.SUBTREE_SCOPE); // // //specify the LDAP search filter // String searchFilter = "("+matchingElement+username+")"; // // //initialize counter to total the results // // // Search for objects using the filter // NamingEnumeration<SearchResult> answer = InitialDirectoryContext.search(userBase, searchFilter, searchCtls); // SearchResult next = answer.next(); // return next.getNameInNamespace(); // } // } // // Path: src/main/java/com/asolutions/scmsshd/authorizors/AuthorizationLevel.java // public enum AuthorizationLevel { // AUTH_LEVEL_READ_ONLY, // AUTH_LEVEL_READ_WRITE; // } // Path: src/test/java/com/asolutions/scmsshd/ldap/LDAPProjectAuthorizerTest.java import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import javax.naming.NamingEnumeration; import javax.naming.directory.Attribute; import javax.naming.directory.Attributes; import javax.naming.directory.InitialDirContext; import org.jmock.Expectations; import org.junit.Before; import org.junit.Test; import com.asolutions.MockTestCase; import com.asolutions.scmsshd.authenticators.LDAPUsernameResolver; import com.asolutions.scmsshd.authorizors.AuthorizationLevel; package com.asolutions.scmsshd.ldap; public class LDAPProjectAuthorizerTest extends MockTestCase { final private String groupBaseDN = "cn=Groups,DC=ldapserver,DC=lan"; final private String userBaseDN = "cn=User,DC=ldapserver,DC=lan"; private LDAPBindingProvider ldapBinding; private String usernameToCheck = "mike.gaffney"; private String userToCheckDN = "cn=" + usernameToCheck + "," + userBaseDN;
private LDAPUsernameResolver ldapUsernameResolver;
gaffo/scumd
src/test/java/com/asolutions/scmsshd/ldap/LDAPProjectAuthorizerTest.java
// Path: src/test/java/com/asolutions/MockTestCase.java // public class MockTestCase { // // protected Mockery context = new JUnit4Mockery(); // // @Before // public void setupMockery() { // context.setImposteriser(ClassImposteriser.INSTANCE); // } // // @After // public void mockeryAssertIsSatisfied(){ // context.assertIsSatisfied(); // } // // protected void checking(Expectations expectations) { // context.checking(expectations); // } // // } // // Path: src/main/java/com/asolutions/scmsshd/authenticators/LDAPUsernameResolver.java // public class LDAPUsernameResolver { // LDAPBindingProvider provider; // private String userBase; // private String matchingElement; // public LDAPUsernameResolver(LDAPBindingProvider provider, String userBase) { // this(provider, userBase, "cn="); // } // public LDAPUsernameResolver(LDAPBindingProvider provider, String userBase, String matchingElement) { // this.provider = provider; // this.userBase = userBase; // this.matchingElement = matchingElement; // } // // public String resolveUserName(String username) throws NamingException{ // InitialDirContext InitialDirectoryContext = provider.getBinding(); // SearchControls searchCtls = new SearchControls(); // //Specify the search scope // searchCtls.setSearchScope(SearchControls.SUBTREE_SCOPE); // // //specify the LDAP search filter // String searchFilter = "("+matchingElement+username+")"; // // //initialize counter to total the results // // // Search for objects using the filter // NamingEnumeration<SearchResult> answer = InitialDirectoryContext.search(userBase, searchFilter, searchCtls); // SearchResult next = answer.next(); // return next.getNameInNamespace(); // } // } // // Path: src/main/java/com/asolutions/scmsshd/authorizors/AuthorizationLevel.java // public enum AuthorizationLevel { // AUTH_LEVEL_READ_ONLY, // AUTH_LEVEL_READ_WRITE; // }
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import javax.naming.NamingEnumeration; import javax.naming.directory.Attribute; import javax.naming.directory.Attributes; import javax.naming.directory.InitialDirContext; import org.jmock.Expectations; import org.junit.Before; import org.junit.Test; import com.asolutions.MockTestCase; import com.asolutions.scmsshd.authenticators.LDAPUsernameResolver; import com.asolutions.scmsshd.authorizors.AuthorizationLevel;
final Attributes mockAttrs = context.mock(Attributes.class); final Attribute mockAttribute = context.mock(Attribute.class); final NamingEnumeration<?> mockEnum = context.mock(NamingEnumeration.class); checking(new Expectations(){{ one(ldapUsernameResolver).resolveUserName(usernameToCheck); will(returnValue(userToCheckDN)); one(mockBinding).getAttributes("cn=proj-2-git,cn=Groups,DC=ldapserver,DC=lan"); will(returnValue(mockAttrs)); one(mockAttrs).get("member"); will(returnValue(mockAttribute)); one(mockAttribute).getAll(); will(returnValue(mockEnum)); one(mockEnum).hasMoreElements(); will(returnValue(true)); one(mockEnum).nextElement(); will(returnValue(userToCheckDN)); one(ldapBinding).getBinding(); will(returnValue(mockBinding)); }}); LDAPProjectAuthorizer auth = new LDAPProjectAuthorizer(groupBaseDN, "git",
// Path: src/test/java/com/asolutions/MockTestCase.java // public class MockTestCase { // // protected Mockery context = new JUnit4Mockery(); // // @Before // public void setupMockery() { // context.setImposteriser(ClassImposteriser.INSTANCE); // } // // @After // public void mockeryAssertIsSatisfied(){ // context.assertIsSatisfied(); // } // // protected void checking(Expectations expectations) { // context.checking(expectations); // } // // } // // Path: src/main/java/com/asolutions/scmsshd/authenticators/LDAPUsernameResolver.java // public class LDAPUsernameResolver { // LDAPBindingProvider provider; // private String userBase; // private String matchingElement; // public LDAPUsernameResolver(LDAPBindingProvider provider, String userBase) { // this(provider, userBase, "cn="); // } // public LDAPUsernameResolver(LDAPBindingProvider provider, String userBase, String matchingElement) { // this.provider = provider; // this.userBase = userBase; // this.matchingElement = matchingElement; // } // // public String resolveUserName(String username) throws NamingException{ // InitialDirContext InitialDirectoryContext = provider.getBinding(); // SearchControls searchCtls = new SearchControls(); // //Specify the search scope // searchCtls.setSearchScope(SearchControls.SUBTREE_SCOPE); // // //specify the LDAP search filter // String searchFilter = "("+matchingElement+username+")"; // // //initialize counter to total the results // // // Search for objects using the filter // NamingEnumeration<SearchResult> answer = InitialDirectoryContext.search(userBase, searchFilter, searchCtls); // SearchResult next = answer.next(); // return next.getNameInNamespace(); // } // } // // Path: src/main/java/com/asolutions/scmsshd/authorizors/AuthorizationLevel.java // public enum AuthorizationLevel { // AUTH_LEVEL_READ_ONLY, // AUTH_LEVEL_READ_WRITE; // } // Path: src/test/java/com/asolutions/scmsshd/ldap/LDAPProjectAuthorizerTest.java import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import javax.naming.NamingEnumeration; import javax.naming.directory.Attribute; import javax.naming.directory.Attributes; import javax.naming.directory.InitialDirContext; import org.jmock.Expectations; import org.junit.Before; import org.junit.Test; import com.asolutions.MockTestCase; import com.asolutions.scmsshd.authenticators.LDAPUsernameResolver; import com.asolutions.scmsshd.authorizors.AuthorizationLevel; final Attributes mockAttrs = context.mock(Attributes.class); final Attribute mockAttribute = context.mock(Attribute.class); final NamingEnumeration<?> mockEnum = context.mock(NamingEnumeration.class); checking(new Expectations(){{ one(ldapUsernameResolver).resolveUserName(usernameToCheck); will(returnValue(userToCheckDN)); one(mockBinding).getAttributes("cn=proj-2-git,cn=Groups,DC=ldapserver,DC=lan"); will(returnValue(mockAttrs)); one(mockAttrs).get("member"); will(returnValue(mockAttribute)); one(mockAttribute).getAll(); will(returnValue(mockEnum)); one(mockEnum).hasMoreElements(); will(returnValue(true)); one(mockEnum).nextElement(); will(returnValue(userToCheckDN)); one(ldapBinding).getBinding(); will(returnValue(mockBinding)); }}); LDAPProjectAuthorizer auth = new LDAPProjectAuthorizer(groupBaseDN, "git",
AuthorizationLevel.AUTH_LEVEL_READ_ONLY,
threerings/nexus
server/src/main/java/com/threerings/nexus/server/GlobalMap.java
// Path: core/src/main/java/com/threerings/nexus/distrib/DistribUtil.java // public class DistribUtil // { // public static void init (NexusObject object, int id, EventSink sink) { // object.init(id, sink); // } // // public static void clear (NexusObject object) { // object.clear(); // } // // public static <R> void dispatchCall (NexusObject object, int attrIdx, short methId, // Object[] args, Slot<? super Try<R>> slot) { // DService.Dispatcher<?> disp = null; // try { // @SuppressWarnings("unchecked") RFuture<R> result = (RFuture<R>) // object.<DService.Dispatcher<?>>getAttribute(attrIdx).dispatchCall(methId, args); // if (result != null) result.onComplete(slot); // // } catch (NexusException ne) { // if (slot != null) slot.onEmit(Try.<R>failure(ne)); // else log.warning("Service call failed", "obj", object, "attr", disp, // "methId", methId, ne); // // } catch (Throwable t) { // log.warning("Service call failed", "obj", object, "attr", disp, "methId", methId, t); // if (slot != null) slot.onEmit(Try.<R>failure(new NexusException("Internal error"))); // } // } // // /** // * Returns a sentinel value for use by events in tracking unset values. // */ // public static <T> T sentinelValue () { // @SuppressWarnings("unchecked") T value = (T)SENTINEL_VALUE; // return value; // } // // private DistribUtil () {} // no constructsky // // /** Used by {@link #sentinelValue}. */ // private static final Object SENTINEL_VALUE = new Object(); // }
import com.threerings.nexus.distrib.DistribUtil; import com.google.common.collect.Maps;
// // Nexus Server - server-side support for Nexus distributed application framework // http://github.com/threerings/nexus/blob/master/LICENSE package com.threerings.nexus.server; /** * A map whose contents are mirrored across all servers in the network. */ class GlobalMap<K,V> extends react.RMap<K,V> { public GlobalMap (String id, ObjectManager omgr) { super(Maps.<K,V>newConcurrentMap()); _id = id; _omgr = omgr; } public void applyPut (K key, V value, V oldValue) {
// Path: core/src/main/java/com/threerings/nexus/distrib/DistribUtil.java // public class DistribUtil // { // public static void init (NexusObject object, int id, EventSink sink) { // object.init(id, sink); // } // // public static void clear (NexusObject object) { // object.clear(); // } // // public static <R> void dispatchCall (NexusObject object, int attrIdx, short methId, // Object[] args, Slot<? super Try<R>> slot) { // DService.Dispatcher<?> disp = null; // try { // @SuppressWarnings("unchecked") RFuture<R> result = (RFuture<R>) // object.<DService.Dispatcher<?>>getAttribute(attrIdx).dispatchCall(methId, args); // if (result != null) result.onComplete(slot); // // } catch (NexusException ne) { // if (slot != null) slot.onEmit(Try.<R>failure(ne)); // else log.warning("Service call failed", "obj", object, "attr", disp, // "methId", methId, ne); // // } catch (Throwable t) { // log.warning("Service call failed", "obj", object, "attr", disp, "methId", methId, t); // if (slot != null) slot.onEmit(Try.<R>failure(new NexusException("Internal error"))); // } // } // // /** // * Returns a sentinel value for use by events in tracking unset values. // */ // public static <T> T sentinelValue () { // @SuppressWarnings("unchecked") T value = (T)SENTINEL_VALUE; // return value; // } // // private DistribUtil () {} // no constructsky // // /** Used by {@link #sentinelValue}. */ // private static final Object SENTINEL_VALUE = new Object(); // } // Path: server/src/main/java/com/threerings/nexus/server/GlobalMap.java import com.threerings.nexus.distrib.DistribUtil; import com.google.common.collect.Maps; // // Nexus Server - server-side support for Nexus distributed application framework // http://github.com/threerings/nexus/blob/master/LICENSE package com.threerings.nexus.server; /** * A map whose contents are mirrored across all servers in the network. */ class GlobalMap<K,V> extends react.RMap<K,V> { public GlobalMap (String id, ObjectManager omgr) { super(Maps.<K,V>newConcurrentMap()); _id = id; _omgr = omgr; } public void applyPut (K key, V value, V oldValue) {
if (oldValue == DistribUtil.<V>sentinelValue()) {
threerings/nexus
gwt-server/src/main/java/com/threerings/nexus/server/GWTConnectionManager.java
// Path: gwt-io/src/main/java/com/threerings/nexus/client/GWTClient.java // public class GWTClient extends NexusClient // { // /** The default (root-relative) path at which we will make our WebSocket connections. */ // public static final String DEFAULT_WS_PATH = "/nexusws"; // // /** // * Creates a Nexus client which will use WebSockets to connect to hosts. // * @param port the port on which to make WebSocket connections. // * @param path the path to the GWTIO WebSockets servlet. Must start with '/'. // * @param szer the serializer that knows about all types that will cross the wire. // */ // public static NexusClient create (int port, String path, Serializer szer) { // if (!path.startsWith("/")) throw new IllegalArgumentException("Path must start with '/'."); // Log.log = GWT_LOGGER; // configure the logger to use GWT // return new GWTClient(port, path, szer); // } // // /** // * Creates a Nexus client which will use WebSockets to connect to hosts. Uses the default // * servlet path (i.e. {@link #DEFAULT_WS_PATH}). // * @param port the port on which to make WebSocket connections. // * @param szer the serializer that knows about all types that will cross the wire. // */ // public static NexusClient create (int port, Serializer szer) { // return create(port, DEFAULT_WS_PATH, szer); // } // // protected GWTClient (int port, String path, Serializer szer) { // _port = port; // _path = path; // _szer = szer; // } // // @Override protected int port () { // return _port; // } // // @Override protected void connect (String host, RPromise<Connection> callback) { // new GWTConnection(host, _port, _path, _szer, callback); // } // // protected final int _port; // protected final String _path; // protected final Serializer _szer; // // protected static final Log.Logger GWT_LOGGER = new Log.Logger() { // @Override public void temp (String message, Object... args) { // format(null, message, args); // } // @Override public void info (String message, Object... args) { // if (!_warnOnly) { // format(null, message, args); // } // } // @Override public void warning (String message, Object... args) { // format(null, message, args); // } // @Override public void log (Object level, String message, Throwable cause) { // if (GWT.isScript()) { // sendToBrowserConsole(message, cause); // } else { // GWT.log(message, cause); // } // } // @Override public void setWarnOnly (boolean warnOnly) { // _warnOnly = warnOnly; // } // protected boolean _warnOnly; // }; // // protected static native void sendToBrowserConsole(String msg, Throwable e) /*-{ // if ($wnd.console && $wnd.console.info) { // if (e != null) { // $wnd.console.info(msg, e); // } else { // $wnd.console.info(msg); // } // } // }-*/; // } // // Path: core/src/main/java/com/threerings/nexus/distrib/NexusException.java // public class NexusException extends RuntimeException // implements Streamable // { // /** // * Throws a NexusException with the supplied error message if {@code condition} is not true. // */ // public static void require (boolean condition, String errmsg, Object... args) { // if (!condition) throw new NexusException(Log.format(errmsg, args)); // } // // public NexusException (String message) { // super(message); // } // // public NexusException (String message, Throwable cause) { // super(message, cause); // } // // public NexusException (Throwable cause) { // super(cause); // } // } // // Path: core/src/main/java/com/threerings/nexus/io/Serializer.java // public interface Serializer // { // /** Returns the class assigned the supplied code. // * @throws NexusException if no class is registered for the supplied code. */ // Class<?> getClass (short code); // // /** Returns the streamer for the class assigned the supplied code. // * @throws NexusException if no streamer is registered for the supplied code. */ // Streamer<?> getStreamer (short code); // // /** Returns the service factory for the class assigned the supplied code. // * @throws NexusException if no service is registered for the supplied code. */ // DService.Factory<?> getServiceFactory (short code); // // /** Returns the code assigned to the supplied class. // * @throws NexusException if the class in question is not registered. */ // short getCode (Class<?> clazz); // // /** Returns the code assigned to the supplied service class. // * @throws NexusException if the class in question is not registered. */ // short getServiceCode (Class<? extends NexusService> clazz); // // /** Writes the class code for the supplied value, and returns the streamer for same. // * @throws NexusException if the class for the value in question is not registered. */ // <T> Streamer<T> writeStreamer (Streamable.Output out, T value); // }
import java.io.File; import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.handler.HandlerList; import org.eclipse.jetty.server.handler.ResourceHandler; import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.servlet.ServletHolder; import com.threerings.nexus.client.GWTClient; import com.threerings.nexus.distrib.NexusException; import com.threerings.nexus.io.Serializer;
// // Nexus GWTServer - server-side support for Nexus GWT/WebSockets services // http://github.com/threerings/nexus/blob/master/LICENSE package com.threerings.nexus.server; /** * Handles starting a Jetty server and configuring it to listen for GWTIO WebSocket requests on a * specified port. For systems that don't otherwise make use of Jetty, this simplifies things. * Systems that do make use of Jetty can simply wire up the {@link GWTIOJettyServlet} themselves. */ public class GWTConnectionManager { /** * Creates a Jetty server that listens on the specified hostname and port and binds the * WebSocket servlet to the {@link GWTClient#DEFAULT_WS_PATH}. */
// Path: gwt-io/src/main/java/com/threerings/nexus/client/GWTClient.java // public class GWTClient extends NexusClient // { // /** The default (root-relative) path at which we will make our WebSocket connections. */ // public static final String DEFAULT_WS_PATH = "/nexusws"; // // /** // * Creates a Nexus client which will use WebSockets to connect to hosts. // * @param port the port on which to make WebSocket connections. // * @param path the path to the GWTIO WebSockets servlet. Must start with '/'. // * @param szer the serializer that knows about all types that will cross the wire. // */ // public static NexusClient create (int port, String path, Serializer szer) { // if (!path.startsWith("/")) throw new IllegalArgumentException("Path must start with '/'."); // Log.log = GWT_LOGGER; // configure the logger to use GWT // return new GWTClient(port, path, szer); // } // // /** // * Creates a Nexus client which will use WebSockets to connect to hosts. Uses the default // * servlet path (i.e. {@link #DEFAULT_WS_PATH}). // * @param port the port on which to make WebSocket connections. // * @param szer the serializer that knows about all types that will cross the wire. // */ // public static NexusClient create (int port, Serializer szer) { // return create(port, DEFAULT_WS_PATH, szer); // } // // protected GWTClient (int port, String path, Serializer szer) { // _port = port; // _path = path; // _szer = szer; // } // // @Override protected int port () { // return _port; // } // // @Override protected void connect (String host, RPromise<Connection> callback) { // new GWTConnection(host, _port, _path, _szer, callback); // } // // protected final int _port; // protected final String _path; // protected final Serializer _szer; // // protected static final Log.Logger GWT_LOGGER = new Log.Logger() { // @Override public void temp (String message, Object... args) { // format(null, message, args); // } // @Override public void info (String message, Object... args) { // if (!_warnOnly) { // format(null, message, args); // } // } // @Override public void warning (String message, Object... args) { // format(null, message, args); // } // @Override public void log (Object level, String message, Throwable cause) { // if (GWT.isScript()) { // sendToBrowserConsole(message, cause); // } else { // GWT.log(message, cause); // } // } // @Override public void setWarnOnly (boolean warnOnly) { // _warnOnly = warnOnly; // } // protected boolean _warnOnly; // }; // // protected static native void sendToBrowserConsole(String msg, Throwable e) /*-{ // if ($wnd.console && $wnd.console.info) { // if (e != null) { // $wnd.console.info(msg, e); // } else { // $wnd.console.info(msg); // } // } // }-*/; // } // // Path: core/src/main/java/com/threerings/nexus/distrib/NexusException.java // public class NexusException extends RuntimeException // implements Streamable // { // /** // * Throws a NexusException with the supplied error message if {@code condition} is not true. // */ // public static void require (boolean condition, String errmsg, Object... args) { // if (!condition) throw new NexusException(Log.format(errmsg, args)); // } // // public NexusException (String message) { // super(message); // } // // public NexusException (String message, Throwable cause) { // super(message, cause); // } // // public NexusException (Throwable cause) { // super(cause); // } // } // // Path: core/src/main/java/com/threerings/nexus/io/Serializer.java // public interface Serializer // { // /** Returns the class assigned the supplied code. // * @throws NexusException if no class is registered for the supplied code. */ // Class<?> getClass (short code); // // /** Returns the streamer for the class assigned the supplied code. // * @throws NexusException if no streamer is registered for the supplied code. */ // Streamer<?> getStreamer (short code); // // /** Returns the service factory for the class assigned the supplied code. // * @throws NexusException if no service is registered for the supplied code. */ // DService.Factory<?> getServiceFactory (short code); // // /** Returns the code assigned to the supplied class. // * @throws NexusException if the class in question is not registered. */ // short getCode (Class<?> clazz); // // /** Returns the code assigned to the supplied service class. // * @throws NexusException if the class in question is not registered. */ // short getServiceCode (Class<? extends NexusService> clazz); // // /** Writes the class code for the supplied value, and returns the streamer for same. // * @throws NexusException if the class for the value in question is not registered. */ // <T> Streamer<T> writeStreamer (Streamable.Output out, T value); // } // Path: gwt-server/src/main/java/com/threerings/nexus/server/GWTConnectionManager.java import java.io.File; import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.handler.HandlerList; import org.eclipse.jetty.server.handler.ResourceHandler; import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.servlet.ServletHolder; import com.threerings.nexus.client.GWTClient; import com.threerings.nexus.distrib.NexusException; import com.threerings.nexus.io.Serializer; // // Nexus GWTServer - server-side support for Nexus GWT/WebSockets services // http://github.com/threerings/nexus/blob/master/LICENSE package com.threerings.nexus.server; /** * Handles starting a Jetty server and configuring it to listen for GWTIO WebSocket requests on a * specified port. For systems that don't otherwise make use of Jetty, this simplifies things. * Systems that do make use of Jetty can simply wire up the {@link GWTIOJettyServlet} themselves. */ public class GWTConnectionManager { /** * Creates a Jetty server that listens on the specified hostname and port and binds the * WebSocket servlet to the {@link GWTClient#DEFAULT_WS_PATH}. */
public GWTConnectionManager (SessionManager smgr, Serializer szer, String hostname, int port) {
threerings/nexus
gwt-server/src/main/java/com/threerings/nexus/server/GWTConnectionManager.java
// Path: gwt-io/src/main/java/com/threerings/nexus/client/GWTClient.java // public class GWTClient extends NexusClient // { // /** The default (root-relative) path at which we will make our WebSocket connections. */ // public static final String DEFAULT_WS_PATH = "/nexusws"; // // /** // * Creates a Nexus client which will use WebSockets to connect to hosts. // * @param port the port on which to make WebSocket connections. // * @param path the path to the GWTIO WebSockets servlet. Must start with '/'. // * @param szer the serializer that knows about all types that will cross the wire. // */ // public static NexusClient create (int port, String path, Serializer szer) { // if (!path.startsWith("/")) throw new IllegalArgumentException("Path must start with '/'."); // Log.log = GWT_LOGGER; // configure the logger to use GWT // return new GWTClient(port, path, szer); // } // // /** // * Creates a Nexus client which will use WebSockets to connect to hosts. Uses the default // * servlet path (i.e. {@link #DEFAULT_WS_PATH}). // * @param port the port on which to make WebSocket connections. // * @param szer the serializer that knows about all types that will cross the wire. // */ // public static NexusClient create (int port, Serializer szer) { // return create(port, DEFAULT_WS_PATH, szer); // } // // protected GWTClient (int port, String path, Serializer szer) { // _port = port; // _path = path; // _szer = szer; // } // // @Override protected int port () { // return _port; // } // // @Override protected void connect (String host, RPromise<Connection> callback) { // new GWTConnection(host, _port, _path, _szer, callback); // } // // protected final int _port; // protected final String _path; // protected final Serializer _szer; // // protected static final Log.Logger GWT_LOGGER = new Log.Logger() { // @Override public void temp (String message, Object... args) { // format(null, message, args); // } // @Override public void info (String message, Object... args) { // if (!_warnOnly) { // format(null, message, args); // } // } // @Override public void warning (String message, Object... args) { // format(null, message, args); // } // @Override public void log (Object level, String message, Throwable cause) { // if (GWT.isScript()) { // sendToBrowserConsole(message, cause); // } else { // GWT.log(message, cause); // } // } // @Override public void setWarnOnly (boolean warnOnly) { // _warnOnly = warnOnly; // } // protected boolean _warnOnly; // }; // // protected static native void sendToBrowserConsole(String msg, Throwable e) /*-{ // if ($wnd.console && $wnd.console.info) { // if (e != null) { // $wnd.console.info(msg, e); // } else { // $wnd.console.info(msg); // } // } // }-*/; // } // // Path: core/src/main/java/com/threerings/nexus/distrib/NexusException.java // public class NexusException extends RuntimeException // implements Streamable // { // /** // * Throws a NexusException with the supplied error message if {@code condition} is not true. // */ // public static void require (boolean condition, String errmsg, Object... args) { // if (!condition) throw new NexusException(Log.format(errmsg, args)); // } // // public NexusException (String message) { // super(message); // } // // public NexusException (String message, Throwable cause) { // super(message, cause); // } // // public NexusException (Throwable cause) { // super(cause); // } // } // // Path: core/src/main/java/com/threerings/nexus/io/Serializer.java // public interface Serializer // { // /** Returns the class assigned the supplied code. // * @throws NexusException if no class is registered for the supplied code. */ // Class<?> getClass (short code); // // /** Returns the streamer for the class assigned the supplied code. // * @throws NexusException if no streamer is registered for the supplied code. */ // Streamer<?> getStreamer (short code); // // /** Returns the service factory for the class assigned the supplied code. // * @throws NexusException if no service is registered for the supplied code. */ // DService.Factory<?> getServiceFactory (short code); // // /** Returns the code assigned to the supplied class. // * @throws NexusException if the class in question is not registered. */ // short getCode (Class<?> clazz); // // /** Returns the code assigned to the supplied service class. // * @throws NexusException if the class in question is not registered. */ // short getServiceCode (Class<? extends NexusService> clazz); // // /** Writes the class code for the supplied value, and returns the streamer for same. // * @throws NexusException if the class for the value in question is not registered. */ // <T> Streamer<T> writeStreamer (Streamable.Output out, T value); // }
import java.io.File; import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.handler.HandlerList; import org.eclipse.jetty.server.handler.ResourceHandler; import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.servlet.ServletHolder; import com.threerings.nexus.client.GWTClient; import com.threerings.nexus.distrib.NexusException; import com.threerings.nexus.io.Serializer;
// // Nexus GWTServer - server-side support for Nexus GWT/WebSockets services // http://github.com/threerings/nexus/blob/master/LICENSE package com.threerings.nexus.server; /** * Handles starting a Jetty server and configuring it to listen for GWTIO WebSocket requests on a * specified port. For systems that don't otherwise make use of Jetty, this simplifies things. * Systems that do make use of Jetty can simply wire up the {@link GWTIOJettyServlet} themselves. */ public class GWTConnectionManager { /** * Creates a Jetty server that listens on the specified hostname and port and binds the * WebSocket servlet to the {@link GWTClient#DEFAULT_WS_PATH}. */ public GWTConnectionManager (SessionManager smgr, Serializer szer, String hostname, int port) {
// Path: gwt-io/src/main/java/com/threerings/nexus/client/GWTClient.java // public class GWTClient extends NexusClient // { // /** The default (root-relative) path at which we will make our WebSocket connections. */ // public static final String DEFAULT_WS_PATH = "/nexusws"; // // /** // * Creates a Nexus client which will use WebSockets to connect to hosts. // * @param port the port on which to make WebSocket connections. // * @param path the path to the GWTIO WebSockets servlet. Must start with '/'. // * @param szer the serializer that knows about all types that will cross the wire. // */ // public static NexusClient create (int port, String path, Serializer szer) { // if (!path.startsWith("/")) throw new IllegalArgumentException("Path must start with '/'."); // Log.log = GWT_LOGGER; // configure the logger to use GWT // return new GWTClient(port, path, szer); // } // // /** // * Creates a Nexus client which will use WebSockets to connect to hosts. Uses the default // * servlet path (i.e. {@link #DEFAULT_WS_PATH}). // * @param port the port on which to make WebSocket connections. // * @param szer the serializer that knows about all types that will cross the wire. // */ // public static NexusClient create (int port, Serializer szer) { // return create(port, DEFAULT_WS_PATH, szer); // } // // protected GWTClient (int port, String path, Serializer szer) { // _port = port; // _path = path; // _szer = szer; // } // // @Override protected int port () { // return _port; // } // // @Override protected void connect (String host, RPromise<Connection> callback) { // new GWTConnection(host, _port, _path, _szer, callback); // } // // protected final int _port; // protected final String _path; // protected final Serializer _szer; // // protected static final Log.Logger GWT_LOGGER = new Log.Logger() { // @Override public void temp (String message, Object... args) { // format(null, message, args); // } // @Override public void info (String message, Object... args) { // if (!_warnOnly) { // format(null, message, args); // } // } // @Override public void warning (String message, Object... args) { // format(null, message, args); // } // @Override public void log (Object level, String message, Throwable cause) { // if (GWT.isScript()) { // sendToBrowserConsole(message, cause); // } else { // GWT.log(message, cause); // } // } // @Override public void setWarnOnly (boolean warnOnly) { // _warnOnly = warnOnly; // } // protected boolean _warnOnly; // }; // // protected static native void sendToBrowserConsole(String msg, Throwable e) /*-{ // if ($wnd.console && $wnd.console.info) { // if (e != null) { // $wnd.console.info(msg, e); // } else { // $wnd.console.info(msg); // } // } // }-*/; // } // // Path: core/src/main/java/com/threerings/nexus/distrib/NexusException.java // public class NexusException extends RuntimeException // implements Streamable // { // /** // * Throws a NexusException with the supplied error message if {@code condition} is not true. // */ // public static void require (boolean condition, String errmsg, Object... args) { // if (!condition) throw new NexusException(Log.format(errmsg, args)); // } // // public NexusException (String message) { // super(message); // } // // public NexusException (String message, Throwable cause) { // super(message, cause); // } // // public NexusException (Throwable cause) { // super(cause); // } // } // // Path: core/src/main/java/com/threerings/nexus/io/Serializer.java // public interface Serializer // { // /** Returns the class assigned the supplied code. // * @throws NexusException if no class is registered for the supplied code. */ // Class<?> getClass (short code); // // /** Returns the streamer for the class assigned the supplied code. // * @throws NexusException if no streamer is registered for the supplied code. */ // Streamer<?> getStreamer (short code); // // /** Returns the service factory for the class assigned the supplied code. // * @throws NexusException if no service is registered for the supplied code. */ // DService.Factory<?> getServiceFactory (short code); // // /** Returns the code assigned to the supplied class. // * @throws NexusException if the class in question is not registered. */ // short getCode (Class<?> clazz); // // /** Returns the code assigned to the supplied service class. // * @throws NexusException if the class in question is not registered. */ // short getServiceCode (Class<? extends NexusService> clazz); // // /** Writes the class code for the supplied value, and returns the streamer for same. // * @throws NexusException if the class for the value in question is not registered. */ // <T> Streamer<T> writeStreamer (Streamable.Output out, T value); // } // Path: gwt-server/src/main/java/com/threerings/nexus/server/GWTConnectionManager.java import java.io.File; import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.handler.HandlerList; import org.eclipse.jetty.server.handler.ResourceHandler; import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.servlet.ServletHolder; import com.threerings.nexus.client.GWTClient; import com.threerings.nexus.distrib.NexusException; import com.threerings.nexus.io.Serializer; // // Nexus GWTServer - server-side support for Nexus GWT/WebSockets services // http://github.com/threerings/nexus/blob/master/LICENSE package com.threerings.nexus.server; /** * Handles starting a Jetty server and configuring it to listen for GWTIO WebSocket requests on a * specified port. For systems that don't otherwise make use of Jetty, this simplifies things. * Systems that do make use of Jetty can simply wire up the {@link GWTIOJettyServlet} themselves. */ public class GWTConnectionManager { /** * Creates a Jetty server that listens on the specified hostname and port and binds the * WebSocket servlet to the {@link GWTClient#DEFAULT_WS_PATH}. */ public GWTConnectionManager (SessionManager smgr, Serializer szer, String hostname, int port) {
this(smgr, szer, hostname, port, GWTClient.DEFAULT_WS_PATH);
threerings/nexus
server/src/main/java/com/threerings/nexus/server/EntityContext.java
// Path: core/src/main/java/com/threerings/nexus/util/Log.java // public static Logger log = new JavaLogger("nexus");
import java.util.concurrent.Executor; import static com.threerings.nexus.util.Log.log; import java.util.ArrayDeque; import java.util.Queue;
// // Nexus Server - server-side support for Nexus distributed application framework // http://github.com/threerings/nexus/blob/master/LICENSE package com.threerings.nexus.server; /** * Contains an execution queue for one or more Nexus entities. Distributed events, actions and * requests are all executed in order, one at a time, by no more than a single thread (for a given * context) for all entities registered with a particular context. In general, there is a one * entity to one context relationship, meaning that everything is run in parallel. However, if an * object is registered as a child of another entity, that object will share the entity's context. */ public class EntityContext { /** Contains a reference to the currently executing entity context. */ public static final ThreadLocal<EntityContext> current = new ThreadLocal<EntityContext>(); /** * Creates an entity context that will use the supplied executor for executions. */ public EntityContext (Executor exec) { _exec = exec; } /** * Queues the supplied operation for execution on this context. If the context is currently * being executed, the operation will simply be added to its queue. If it is not being * executed, it will additionally be queued up on the supplied executor, so that its pending * operations will be executed. */ public synchronized void postOp (final Runnable op) { _ops.offer(new Runnable() { public void run () { try { current.set(EntityContext.this); op.run(); } catch (Throwable t) {
// Path: core/src/main/java/com/threerings/nexus/util/Log.java // public static Logger log = new JavaLogger("nexus"); // Path: server/src/main/java/com/threerings/nexus/server/EntityContext.java import java.util.concurrent.Executor; import static com.threerings.nexus.util.Log.log; import java.util.ArrayDeque; import java.util.Queue; // // Nexus Server - server-side support for Nexus distributed application framework // http://github.com/threerings/nexus/blob/master/LICENSE package com.threerings.nexus.server; /** * Contains an execution queue for one or more Nexus entities. Distributed events, actions and * requests are all executed in order, one at a time, by no more than a single thread (for a given * context) for all entities registered with a particular context. In general, there is a one * entity to one context relationship, meaning that everything is run in parallel. However, if an * object is registered as a child of another entity, that object will share the entity's context. */ public class EntityContext { /** Contains a reference to the currently executing entity context. */ public static final ThreadLocal<EntityContext> current = new ThreadLocal<EntityContext>(); /** * Creates an entity context that will use the supplied executor for executions. */ public EntityContext (Executor exec) { _exec = exec; } /** * Queues the supplied operation for execution on this context. If the context is currently * being executed, the operation will simply be added to its queue. If it is not being * executed, it will additionally be queued up on the supplied executor, so that its pending * operations will be executed. */ public synchronized void postOp (final Runnable op) { _ops.offer(new Runnable() { public void run () { try { current.set(EntityContext.this); op.run(); } catch (Throwable t) {
log.warning("Entity operation failed: " + op, t);
threerings/nexus
gwt-io/src/main/java/com/threerings/nexus/io/ClientInput.java
// Path: core/src/main/java/com/threerings/nexus/distrib/DService.java // public abstract class DService<T extends NexusService> implements DAttribute // { // /** Used to create service attributes. */ // public interface Factory<T extends NexusService> // { // /** Creates a service attribute with the supplied owner. */ // DService<T> createService (NexusObject owner); // } // // /** An implementation detail used by service dispatchers. */ // public static abstract class Dispatcher<T extends NexusService> extends DService<T> { // /** Dispatches a service call that came in over the network. */ // public RFuture<?> dispatchCall (short methodId, Object[] args) { // throw new IllegalArgumentException("Unknown service method [id=" + methodId + // ", obj=" + _owner.getClass().getName() + // ", attrIdx=" + _index + "]"); // } // // protected Dispatcher (NexusObject owner) { // super(owner); // } // // /** Used to concisely, and without warning, cast arguments of generic type. */ // @SuppressWarnings("unchecked") // protected final <C> C cast (Object obj) { // return (C)obj; // } // } // // /** Returns the service encapsulated by this attribute. */ // public abstract T get (); // // /** Returns the class for the service encapsulated by this attribute. */ // public abstract Class<T> getServiceClass (); // // @Override public void readContents (Streamable.Input in) { // // NOOP // } // // @Override public void writeContents (Streamable.Output out) { // // NOOP // } // // protected DService (NexusObject owner) { // _owner = owner; // _index = owner.registerAttr(this); // } // // /** Used by marshallers to dispatch calls over the network. */ // protected <R> RFuture<R> postCall (short methodId, Object... args) { // RPromise<R> result = RPromise.create(); // _owner.postCall(_index, methodId, args, result); // return result; // } // // /** Used by marshallers to dispatch calls over the network. */ // protected void postVoidCall (short methodId, Object... args) { // _owner.postCall(_index, methodId, args, null); // } // // /** The object that owns this attribute. */ // protected final NexusObject _owner; // // /** The index of this attribute in its containing object. */ // protected final short _index; // } // // Path: core/src/main/java/com/threerings/nexus/distrib/NexusService.java // public interface NexusService // { // }
import com.threerings.nexus.distrib.DService; import com.threerings.nexus.distrib.NexusService; import com.google.gwt.core.client.JavaScriptObject; import com.google.gwt.core.client.UnsafeNativeLong;
// // Nexus GWTIO - I/O and network services for Nexus built on GWT and WebSockets // http://github.com/threerings/nexus/blob/master/LICENSE package com.threerings.nexus.io; /** * Handles the decoding of an input payload (from the server) into proper values. */ class ClientInput extends Streamable.Input { public ClientInput (Serializer szer, String data) { _szer = szer; _values = decode(data); } @Override public native boolean readBoolean () /*-{ return !!this.@com.threerings.nexus.io.ClientInput::_values[ this.@com.threerings.nexus.io.ClientInput::_nextValIdx++]; }-*/; @Override public native byte readByte () /*-{ return this.@com.threerings.nexus.io.ClientInput::_values[ this.@com.threerings.nexus.io.ClientInput::_nextValIdx++]; }-*/; @Override public native short readShort () /*-{ return this.@com.threerings.nexus.io.ClientInput::_values[ this.@com.threerings.nexus.io.ClientInput::_nextValIdx++]; }-*/; @Override public native char readChar () /*-{ return this.@com.threerings.nexus.io.ClientInput::_values[ this.@com.threerings.nexus.io.ClientInput::_nextValIdx++]; }-*/; @Override public native int readInt () /*-{ return this.@com.threerings.nexus.io.ClientInput::_values[ this.@com.threerings.nexus.io.ClientInput::_nextValIdx++]; }-*/; @Override @UnsafeNativeLong public native long readLong () /*-{ var data = this.@com.threerings.nexus.io.ClientInput::_values[ this.@com.threerings.nexus.io.ClientInput::_nextValIdx++]; return @com.google.gwt.lang.LongLib::longFromBase64(Ljava/lang/String;)(data); }-*/; @Override public native float readFloat () /*-{ return this.@com.threerings.nexus.io.ClientInput::_values[ this.@com.threerings.nexus.io.ClientInput::_nextValIdx++]; }-*/; @Override public native double readDouble () /*-{ return this.@com.threerings.nexus.io.ClientInput::_values[ this.@com.threerings.nexus.io.ClientInput::_nextValIdx++]; }-*/; @Override public native String readString () /*-{ return this.@com.threerings.nexus.io.ClientInput::_values[ this.@com.threerings.nexus.io.ClientInput::_nextValIdx++]; }-*/; @Override public <T extends Streamable> Class<T> readClass () { @SuppressWarnings("unchecked") Class<T> clazz = (Class<T>)_szer.getClass(readShort()); return clazz; }
// Path: core/src/main/java/com/threerings/nexus/distrib/DService.java // public abstract class DService<T extends NexusService> implements DAttribute // { // /** Used to create service attributes. */ // public interface Factory<T extends NexusService> // { // /** Creates a service attribute with the supplied owner. */ // DService<T> createService (NexusObject owner); // } // // /** An implementation detail used by service dispatchers. */ // public static abstract class Dispatcher<T extends NexusService> extends DService<T> { // /** Dispatches a service call that came in over the network. */ // public RFuture<?> dispatchCall (short methodId, Object[] args) { // throw new IllegalArgumentException("Unknown service method [id=" + methodId + // ", obj=" + _owner.getClass().getName() + // ", attrIdx=" + _index + "]"); // } // // protected Dispatcher (NexusObject owner) { // super(owner); // } // // /** Used to concisely, and without warning, cast arguments of generic type. */ // @SuppressWarnings("unchecked") // protected final <C> C cast (Object obj) { // return (C)obj; // } // } // // /** Returns the service encapsulated by this attribute. */ // public abstract T get (); // // /** Returns the class for the service encapsulated by this attribute. */ // public abstract Class<T> getServiceClass (); // // @Override public void readContents (Streamable.Input in) { // // NOOP // } // // @Override public void writeContents (Streamable.Output out) { // // NOOP // } // // protected DService (NexusObject owner) { // _owner = owner; // _index = owner.registerAttr(this); // } // // /** Used by marshallers to dispatch calls over the network. */ // protected <R> RFuture<R> postCall (short methodId, Object... args) { // RPromise<R> result = RPromise.create(); // _owner.postCall(_index, methodId, args, result); // return result; // } // // /** Used by marshallers to dispatch calls over the network. */ // protected void postVoidCall (short methodId, Object... args) { // _owner.postCall(_index, methodId, args, null); // } // // /** The object that owns this attribute. */ // protected final NexusObject _owner; // // /** The index of this attribute in its containing object. */ // protected final short _index; // } // // Path: core/src/main/java/com/threerings/nexus/distrib/NexusService.java // public interface NexusService // { // } // Path: gwt-io/src/main/java/com/threerings/nexus/io/ClientInput.java import com.threerings.nexus.distrib.DService; import com.threerings.nexus.distrib.NexusService; import com.google.gwt.core.client.JavaScriptObject; import com.google.gwt.core.client.UnsafeNativeLong; // // Nexus GWTIO - I/O and network services for Nexus built on GWT and WebSockets // http://github.com/threerings/nexus/blob/master/LICENSE package com.threerings.nexus.io; /** * Handles the decoding of an input payload (from the server) into proper values. */ class ClientInput extends Streamable.Input { public ClientInput (Serializer szer, String data) { _szer = szer; _values = decode(data); } @Override public native boolean readBoolean () /*-{ return !!this.@com.threerings.nexus.io.ClientInput::_values[ this.@com.threerings.nexus.io.ClientInput::_nextValIdx++]; }-*/; @Override public native byte readByte () /*-{ return this.@com.threerings.nexus.io.ClientInput::_values[ this.@com.threerings.nexus.io.ClientInput::_nextValIdx++]; }-*/; @Override public native short readShort () /*-{ return this.@com.threerings.nexus.io.ClientInput::_values[ this.@com.threerings.nexus.io.ClientInput::_nextValIdx++]; }-*/; @Override public native char readChar () /*-{ return this.@com.threerings.nexus.io.ClientInput::_values[ this.@com.threerings.nexus.io.ClientInput::_nextValIdx++]; }-*/; @Override public native int readInt () /*-{ return this.@com.threerings.nexus.io.ClientInput::_values[ this.@com.threerings.nexus.io.ClientInput::_nextValIdx++]; }-*/; @Override @UnsafeNativeLong public native long readLong () /*-{ var data = this.@com.threerings.nexus.io.ClientInput::_values[ this.@com.threerings.nexus.io.ClientInput::_nextValIdx++]; return @com.google.gwt.lang.LongLib::longFromBase64(Ljava/lang/String;)(data); }-*/; @Override public native float readFloat () /*-{ return this.@com.threerings.nexus.io.ClientInput::_values[ this.@com.threerings.nexus.io.ClientInput::_nextValIdx++]; }-*/; @Override public native double readDouble () /*-{ return this.@com.threerings.nexus.io.ClientInput::_values[ this.@com.threerings.nexus.io.ClientInput::_nextValIdx++]; }-*/; @Override public native String readString () /*-{ return this.@com.threerings.nexus.io.ClientInput::_values[ this.@com.threerings.nexus.io.ClientInput::_nextValIdx++]; }-*/; @Override public <T extends Streamable> Class<T> readClass () { @SuppressWarnings("unchecked") Class<T> clazz = (Class<T>)_szer.getClass(readShort()); return clazz; }
@Override public <T extends NexusService> DService.Factory<T> readService () {
threerings/nexus
gwt-io/src/main/java/com/threerings/nexus/io/ClientInput.java
// Path: core/src/main/java/com/threerings/nexus/distrib/DService.java // public abstract class DService<T extends NexusService> implements DAttribute // { // /** Used to create service attributes. */ // public interface Factory<T extends NexusService> // { // /** Creates a service attribute with the supplied owner. */ // DService<T> createService (NexusObject owner); // } // // /** An implementation detail used by service dispatchers. */ // public static abstract class Dispatcher<T extends NexusService> extends DService<T> { // /** Dispatches a service call that came in over the network. */ // public RFuture<?> dispatchCall (short methodId, Object[] args) { // throw new IllegalArgumentException("Unknown service method [id=" + methodId + // ", obj=" + _owner.getClass().getName() + // ", attrIdx=" + _index + "]"); // } // // protected Dispatcher (NexusObject owner) { // super(owner); // } // // /** Used to concisely, and without warning, cast arguments of generic type. */ // @SuppressWarnings("unchecked") // protected final <C> C cast (Object obj) { // return (C)obj; // } // } // // /** Returns the service encapsulated by this attribute. */ // public abstract T get (); // // /** Returns the class for the service encapsulated by this attribute. */ // public abstract Class<T> getServiceClass (); // // @Override public void readContents (Streamable.Input in) { // // NOOP // } // // @Override public void writeContents (Streamable.Output out) { // // NOOP // } // // protected DService (NexusObject owner) { // _owner = owner; // _index = owner.registerAttr(this); // } // // /** Used by marshallers to dispatch calls over the network. */ // protected <R> RFuture<R> postCall (short methodId, Object... args) { // RPromise<R> result = RPromise.create(); // _owner.postCall(_index, methodId, args, result); // return result; // } // // /** Used by marshallers to dispatch calls over the network. */ // protected void postVoidCall (short methodId, Object... args) { // _owner.postCall(_index, methodId, args, null); // } // // /** The object that owns this attribute. */ // protected final NexusObject _owner; // // /** The index of this attribute in its containing object. */ // protected final short _index; // } // // Path: core/src/main/java/com/threerings/nexus/distrib/NexusService.java // public interface NexusService // { // }
import com.threerings.nexus.distrib.DService; import com.threerings.nexus.distrib.NexusService; import com.google.gwt.core.client.JavaScriptObject; import com.google.gwt.core.client.UnsafeNativeLong;
// // Nexus GWTIO - I/O and network services for Nexus built on GWT and WebSockets // http://github.com/threerings/nexus/blob/master/LICENSE package com.threerings.nexus.io; /** * Handles the decoding of an input payload (from the server) into proper values. */ class ClientInput extends Streamable.Input { public ClientInput (Serializer szer, String data) { _szer = szer; _values = decode(data); } @Override public native boolean readBoolean () /*-{ return !!this.@com.threerings.nexus.io.ClientInput::_values[ this.@com.threerings.nexus.io.ClientInput::_nextValIdx++]; }-*/; @Override public native byte readByte () /*-{ return this.@com.threerings.nexus.io.ClientInput::_values[ this.@com.threerings.nexus.io.ClientInput::_nextValIdx++]; }-*/; @Override public native short readShort () /*-{ return this.@com.threerings.nexus.io.ClientInput::_values[ this.@com.threerings.nexus.io.ClientInput::_nextValIdx++]; }-*/; @Override public native char readChar () /*-{ return this.@com.threerings.nexus.io.ClientInput::_values[ this.@com.threerings.nexus.io.ClientInput::_nextValIdx++]; }-*/; @Override public native int readInt () /*-{ return this.@com.threerings.nexus.io.ClientInput::_values[ this.@com.threerings.nexus.io.ClientInput::_nextValIdx++]; }-*/; @Override @UnsafeNativeLong public native long readLong () /*-{ var data = this.@com.threerings.nexus.io.ClientInput::_values[ this.@com.threerings.nexus.io.ClientInput::_nextValIdx++]; return @com.google.gwt.lang.LongLib::longFromBase64(Ljava/lang/String;)(data); }-*/; @Override public native float readFloat () /*-{ return this.@com.threerings.nexus.io.ClientInput::_values[ this.@com.threerings.nexus.io.ClientInput::_nextValIdx++]; }-*/; @Override public native double readDouble () /*-{ return this.@com.threerings.nexus.io.ClientInput::_values[ this.@com.threerings.nexus.io.ClientInput::_nextValIdx++]; }-*/; @Override public native String readString () /*-{ return this.@com.threerings.nexus.io.ClientInput::_values[ this.@com.threerings.nexus.io.ClientInput::_nextValIdx++]; }-*/; @Override public <T extends Streamable> Class<T> readClass () { @SuppressWarnings("unchecked") Class<T> clazz = (Class<T>)_szer.getClass(readShort()); return clazz; }
// Path: core/src/main/java/com/threerings/nexus/distrib/DService.java // public abstract class DService<T extends NexusService> implements DAttribute // { // /** Used to create service attributes. */ // public interface Factory<T extends NexusService> // { // /** Creates a service attribute with the supplied owner. */ // DService<T> createService (NexusObject owner); // } // // /** An implementation detail used by service dispatchers. */ // public static abstract class Dispatcher<T extends NexusService> extends DService<T> { // /** Dispatches a service call that came in over the network. */ // public RFuture<?> dispatchCall (short methodId, Object[] args) { // throw new IllegalArgumentException("Unknown service method [id=" + methodId + // ", obj=" + _owner.getClass().getName() + // ", attrIdx=" + _index + "]"); // } // // protected Dispatcher (NexusObject owner) { // super(owner); // } // // /** Used to concisely, and without warning, cast arguments of generic type. */ // @SuppressWarnings("unchecked") // protected final <C> C cast (Object obj) { // return (C)obj; // } // } // // /** Returns the service encapsulated by this attribute. */ // public abstract T get (); // // /** Returns the class for the service encapsulated by this attribute. */ // public abstract Class<T> getServiceClass (); // // @Override public void readContents (Streamable.Input in) { // // NOOP // } // // @Override public void writeContents (Streamable.Output out) { // // NOOP // } // // protected DService (NexusObject owner) { // _owner = owner; // _index = owner.registerAttr(this); // } // // /** Used by marshallers to dispatch calls over the network. */ // protected <R> RFuture<R> postCall (short methodId, Object... args) { // RPromise<R> result = RPromise.create(); // _owner.postCall(_index, methodId, args, result); // return result; // } // // /** Used by marshallers to dispatch calls over the network. */ // protected void postVoidCall (short methodId, Object... args) { // _owner.postCall(_index, methodId, args, null); // } // // /** The object that owns this attribute. */ // protected final NexusObject _owner; // // /** The index of this attribute in its containing object. */ // protected final short _index; // } // // Path: core/src/main/java/com/threerings/nexus/distrib/NexusService.java // public interface NexusService // { // } // Path: gwt-io/src/main/java/com/threerings/nexus/io/ClientInput.java import com.threerings.nexus.distrib.DService; import com.threerings.nexus.distrib.NexusService; import com.google.gwt.core.client.JavaScriptObject; import com.google.gwt.core.client.UnsafeNativeLong; // // Nexus GWTIO - I/O and network services for Nexus built on GWT and WebSockets // http://github.com/threerings/nexus/blob/master/LICENSE package com.threerings.nexus.io; /** * Handles the decoding of an input payload (from the server) into proper values. */ class ClientInput extends Streamable.Input { public ClientInput (Serializer szer, String data) { _szer = szer; _values = decode(data); } @Override public native boolean readBoolean () /*-{ return !!this.@com.threerings.nexus.io.ClientInput::_values[ this.@com.threerings.nexus.io.ClientInput::_nextValIdx++]; }-*/; @Override public native byte readByte () /*-{ return this.@com.threerings.nexus.io.ClientInput::_values[ this.@com.threerings.nexus.io.ClientInput::_nextValIdx++]; }-*/; @Override public native short readShort () /*-{ return this.@com.threerings.nexus.io.ClientInput::_values[ this.@com.threerings.nexus.io.ClientInput::_nextValIdx++]; }-*/; @Override public native char readChar () /*-{ return this.@com.threerings.nexus.io.ClientInput::_values[ this.@com.threerings.nexus.io.ClientInput::_nextValIdx++]; }-*/; @Override public native int readInt () /*-{ return this.@com.threerings.nexus.io.ClientInput::_values[ this.@com.threerings.nexus.io.ClientInput::_nextValIdx++]; }-*/; @Override @UnsafeNativeLong public native long readLong () /*-{ var data = this.@com.threerings.nexus.io.ClientInput::_values[ this.@com.threerings.nexus.io.ClientInput::_nextValIdx++]; return @com.google.gwt.lang.LongLib::longFromBase64(Ljava/lang/String;)(data); }-*/; @Override public native float readFloat () /*-{ return this.@com.threerings.nexus.io.ClientInput::_values[ this.@com.threerings.nexus.io.ClientInput::_nextValIdx++]; }-*/; @Override public native double readDouble () /*-{ return this.@com.threerings.nexus.io.ClientInput::_values[ this.@com.threerings.nexus.io.ClientInput::_nextValIdx++]; }-*/; @Override public native String readString () /*-{ return this.@com.threerings.nexus.io.ClientInput::_values[ this.@com.threerings.nexus.io.ClientInput::_nextValIdx++]; }-*/; @Override public <T extends Streamable> Class<T> readClass () { @SuppressWarnings("unchecked") Class<T> clazz = (Class<T>)_szer.getClass(readShort()); return clazz; }
@Override public <T extends NexusService> DService.Factory<T> readService () {
threerings/nexus
gwt-io/src/main/java/com/threerings/nexus/io/ClientOutput.java
// Path: core/src/main/java/com/threerings/nexus/distrib/DService.java // public abstract class DService<T extends NexusService> implements DAttribute // { // /** Used to create service attributes. */ // public interface Factory<T extends NexusService> // { // /** Creates a service attribute with the supplied owner. */ // DService<T> createService (NexusObject owner); // } // // /** An implementation detail used by service dispatchers. */ // public static abstract class Dispatcher<T extends NexusService> extends DService<T> { // /** Dispatches a service call that came in over the network. */ // public RFuture<?> dispatchCall (short methodId, Object[] args) { // throw new IllegalArgumentException("Unknown service method [id=" + methodId + // ", obj=" + _owner.getClass().getName() + // ", attrIdx=" + _index + "]"); // } // // protected Dispatcher (NexusObject owner) { // super(owner); // } // // /** Used to concisely, and without warning, cast arguments of generic type. */ // @SuppressWarnings("unchecked") // protected final <C> C cast (Object obj) { // return (C)obj; // } // } // // /** Returns the service encapsulated by this attribute. */ // public abstract T get (); // // /** Returns the class for the service encapsulated by this attribute. */ // public abstract Class<T> getServiceClass (); // // @Override public void readContents (Streamable.Input in) { // // NOOP // } // // @Override public void writeContents (Streamable.Output out) { // // NOOP // } // // protected DService (NexusObject owner) { // _owner = owner; // _index = owner.registerAttr(this); // } // // /** Used by marshallers to dispatch calls over the network. */ // protected <R> RFuture<R> postCall (short methodId, Object... args) { // RPromise<R> result = RPromise.create(); // _owner.postCall(_index, methodId, args, result); // return result; // } // // /** Used by marshallers to dispatch calls over the network. */ // protected void postVoidCall (short methodId, Object... args) { // _owner.postCall(_index, methodId, args, null); // } // // /** The object that owns this attribute. */ // protected final NexusObject _owner; // // /** The index of this attribute in its containing object. */ // protected final short _index; // }
import com.threerings.nexus.distrib.DService; import com.google.gwt.lang.LongLib;
// // Nexus GWTIO - I/O and network services for Nexus built on GWT and WebSockets // http://github.com/threerings/nexus/blob/master/LICENSE package com.threerings.nexus.io; /** * Handles the encoding of streamable data into a string payload (for delivery to the server). */ class ClientOutput extends Streamable.Output { /** The character used to separate values in an encoded payload. */ public static final char SEPARATOR = '|'; public ClientOutput (Serializer szer, StringBuffer output) { _szer = szer; _output = output; } @Override public void writeBoolean (boolean value) { append(value ? "1" : "0"); } @Override public void writeByte (byte value) { append(String.valueOf(value)); } @Override public void writeShort (short value) { append(String.valueOf(value)); } @Override public void writeChar (char value) { // use an int, to avoid having to cope with escaping things writeInt((int)value); } @Override public void writeInt (int value) { append(String.valueOf(value)); } @Override public void writeLong (long value) { append(LongLib.toBase64(value)); } @Override public void writeFloat (float value) { writeDouble(value); } @Override public void writeDouble (double value) { append(String.valueOf(value)); } @Override public void writeString (String value) { if (value == null) { writeBoolean(false); } else { writeBoolean(true); append(quoteString(value)); } } @Override public void writeClass (Class<? extends Streamable> clazz) { writeShort(_szer.getCode(clazz)); }
// Path: core/src/main/java/com/threerings/nexus/distrib/DService.java // public abstract class DService<T extends NexusService> implements DAttribute // { // /** Used to create service attributes. */ // public interface Factory<T extends NexusService> // { // /** Creates a service attribute with the supplied owner. */ // DService<T> createService (NexusObject owner); // } // // /** An implementation detail used by service dispatchers. */ // public static abstract class Dispatcher<T extends NexusService> extends DService<T> { // /** Dispatches a service call that came in over the network. */ // public RFuture<?> dispatchCall (short methodId, Object[] args) { // throw new IllegalArgumentException("Unknown service method [id=" + methodId + // ", obj=" + _owner.getClass().getName() + // ", attrIdx=" + _index + "]"); // } // // protected Dispatcher (NexusObject owner) { // super(owner); // } // // /** Used to concisely, and without warning, cast arguments of generic type. */ // @SuppressWarnings("unchecked") // protected final <C> C cast (Object obj) { // return (C)obj; // } // } // // /** Returns the service encapsulated by this attribute. */ // public abstract T get (); // // /** Returns the class for the service encapsulated by this attribute. */ // public abstract Class<T> getServiceClass (); // // @Override public void readContents (Streamable.Input in) { // // NOOP // } // // @Override public void writeContents (Streamable.Output out) { // // NOOP // } // // protected DService (NexusObject owner) { // _owner = owner; // _index = owner.registerAttr(this); // } // // /** Used by marshallers to dispatch calls over the network. */ // protected <R> RFuture<R> postCall (short methodId, Object... args) { // RPromise<R> result = RPromise.create(); // _owner.postCall(_index, methodId, args, result); // return result; // } // // /** Used by marshallers to dispatch calls over the network. */ // protected void postVoidCall (short methodId, Object... args) { // _owner.postCall(_index, methodId, args, null); // } // // /** The object that owns this attribute. */ // protected final NexusObject _owner; // // /** The index of this attribute in its containing object. */ // protected final short _index; // } // Path: gwt-io/src/main/java/com/threerings/nexus/io/ClientOutput.java import com.threerings.nexus.distrib.DService; import com.google.gwt.lang.LongLib; // // Nexus GWTIO - I/O and network services for Nexus built on GWT and WebSockets // http://github.com/threerings/nexus/blob/master/LICENSE package com.threerings.nexus.io; /** * Handles the encoding of streamable data into a string payload (for delivery to the server). */ class ClientOutput extends Streamable.Output { /** The character used to separate values in an encoded payload. */ public static final char SEPARATOR = '|'; public ClientOutput (Serializer szer, StringBuffer output) { _szer = szer; _output = output; } @Override public void writeBoolean (boolean value) { append(value ? "1" : "0"); } @Override public void writeByte (byte value) { append(String.valueOf(value)); } @Override public void writeShort (short value) { append(String.valueOf(value)); } @Override public void writeChar (char value) { // use an int, to avoid having to cope with escaping things writeInt((int)value); } @Override public void writeInt (int value) { append(String.valueOf(value)); } @Override public void writeLong (long value) { append(LongLib.toBase64(value)); } @Override public void writeFloat (float value) { writeDouble(value); } @Override public void writeDouble (double value) { append(String.valueOf(value)); } @Override public void writeString (String value) { if (value == null) { writeBoolean(false); } else { writeBoolean(true); append(quoteString(value)); } } @Override public void writeClass (Class<? extends Streamable> clazz) { writeShort(_szer.getCode(clazz)); }
@Override public void writeService (DService<?> service) {
threerings/nexus
core/src/main/java/com/threerings/nexus/distrib/DistribUtil.java
// Path: core/src/main/java/com/threerings/nexus/util/Log.java // public static Logger log = new JavaLogger("nexus");
import react.Try; import static com.threerings.nexus.util.Log.log; import react.RFuture; import react.Slot;
// // Nexus Core - a framework for developing distributed applications // http://github.com/threerings/nexus/blob/master/LICENSE package com.threerings.nexus.distrib; /** * Provides access to interfaces that should not be called by normal clients, but which must be * accessible to the Nexus implementation code, which may reside in a different package. */ public class DistribUtil { public static void init (NexusObject object, int id, EventSink sink) { object.init(id, sink); } public static void clear (NexusObject object) { object.clear(); } public static <R> void dispatchCall (NexusObject object, int attrIdx, short methId, Object[] args, Slot<? super Try<R>> slot) { DService.Dispatcher<?> disp = null; try { @SuppressWarnings("unchecked") RFuture<R> result = (RFuture<R>) object.<DService.Dispatcher<?>>getAttribute(attrIdx).dispatchCall(methId, args); if (result != null) result.onComplete(slot); } catch (NexusException ne) { if (slot != null) slot.onEmit(Try.<R>failure(ne));
// Path: core/src/main/java/com/threerings/nexus/util/Log.java // public static Logger log = new JavaLogger("nexus"); // Path: core/src/main/java/com/threerings/nexus/distrib/DistribUtil.java import react.Try; import static com.threerings.nexus.util.Log.log; import react.RFuture; import react.Slot; // // Nexus Core - a framework for developing distributed applications // http://github.com/threerings/nexus/blob/master/LICENSE package com.threerings.nexus.distrib; /** * Provides access to interfaces that should not be called by normal clients, but which must be * accessible to the Nexus implementation code, which may reside in a different package. */ public class DistribUtil { public static void init (NexusObject object, int id, EventSink sink) { object.init(id, sink); } public static void clear (NexusObject object) { object.clear(); } public static <R> void dispatchCall (NexusObject object, int attrIdx, short methId, Object[] args, Slot<? super Try<R>> slot) { DService.Dispatcher<?> disp = null; try { @SuppressWarnings("unchecked") RFuture<R> result = (RFuture<R>) object.<DService.Dispatcher<?>>getAttribute(attrIdx).dispatchCall(methId, args); if (result != null) result.onComplete(slot); } catch (NexusException ne) { if (slot != null) slot.onEmit(Try.<R>failure(ne));
else log.warning("Service call failed", "obj", object, "attr", disp,
threerings/nexus
server/src/test/java/com/threerings/nexus/server/NexusJavaTest.java
// Path: server/src/main/java/com/threerings/nexus/distrib/Action.java // public abstract class Action<E> // { // /** A variant of {@link Action} that can be used when you know that the action will not cross // * server boundaries. This allows things to be referenced from the enclosing scope <em>when // * that is known to be thread safe</em>. Remember that actions likely execute in a different // * thread context than the one from which they were initiated, so one must be careful not to // * use things from an enclosing scope that will cause race conditions. */ // public static abstract class Local<E> extends Action<E> { // } // // /** // * Called with the requested entity on the thread appropriate for said entity. // */ // public abstract void invoke (E entity); // // /** // * Called if the action could not be processed due to the target entity being not found. Note: // * this only occurs for keyed entities, not singleton entities. Note also that this method will // * be called in no execution context, which means that one must either perform only thread-safe // * operations in the body of this method, or one must dispatch a new action to process the // * failure. The default implementation simply logs a warning. // * // * @param nexus a reference to the nexus for convenient dispatch of a new action. // * @param eclass the class of the entity that could not be found. // * @param key the key of the entity that could not be found. // */ // public void onDropped (Nexus nexus, Class<?> eclass, Comparable<?> key) { // log.warning("Dropping action on unknown entity", "eclass", eclass.getName(), "key", key, // "action", this); // } // } // // Path: core/src/main/java/com/threerings/nexus/distrib/Singleton.java // public interface Singleton // { // }
import java.util.Properties; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import org.junit.*; import static org.junit.Assert.*; import com.threerings.nexus.distrib.Action; import com.threerings.nexus.distrib.Singleton;
// // Nexus Server - server-side support for Nexus distributed application framework // http://github.com/threerings/nexus/blob/master/LICENSE package com.threerings.nexus.server; public class NexusJavaTest { @Before public void createServer () { System.setProperty("nexus.safety_checks", "true"); _exec = Executors.newFixedThreadPool(3); Properties props = new Properties(); props.setProperty("nexus.node", "test"); props.setProperty("nexus.hostname", "localhost"); props.setProperty("nexus.rpc_timeout", "1000"); _server = new NexusServer(new NexusConfig(props), _exec); } @After public void shutdownServer () throws Exception { _server.shutdown(); _exec.shutdown(); if (!_exec.awaitTermination(2, TimeUnit.SECONDS)) { fail("Executor failed to terminate after 2 seconds."); } System.setProperty("nexus.safety_checks", ""); } @Test public void testRuntimeChecksOnAction () { final boolean[] printed = new boolean[] { false };
// Path: server/src/main/java/com/threerings/nexus/distrib/Action.java // public abstract class Action<E> // { // /** A variant of {@link Action} that can be used when you know that the action will not cross // * server boundaries. This allows things to be referenced from the enclosing scope <em>when // * that is known to be thread safe</em>. Remember that actions likely execute in a different // * thread context than the one from which they were initiated, so one must be careful not to // * use things from an enclosing scope that will cause race conditions. */ // public static abstract class Local<E> extends Action<E> { // } // // /** // * Called with the requested entity on the thread appropriate for said entity. // */ // public abstract void invoke (E entity); // // /** // * Called if the action could not be processed due to the target entity being not found. Note: // * this only occurs for keyed entities, not singleton entities. Note also that this method will // * be called in no execution context, which means that one must either perform only thread-safe // * operations in the body of this method, or one must dispatch a new action to process the // * failure. The default implementation simply logs a warning. // * // * @param nexus a reference to the nexus for convenient dispatch of a new action. // * @param eclass the class of the entity that could not be found. // * @param key the key of the entity that could not be found. // */ // public void onDropped (Nexus nexus, Class<?> eclass, Comparable<?> key) { // log.warning("Dropping action on unknown entity", "eclass", eclass.getName(), "key", key, // "action", this); // } // } // // Path: core/src/main/java/com/threerings/nexus/distrib/Singleton.java // public interface Singleton // { // } // Path: server/src/test/java/com/threerings/nexus/server/NexusJavaTest.java import java.util.Properties; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import org.junit.*; import static org.junit.Assert.*; import com.threerings.nexus.distrib.Action; import com.threerings.nexus.distrib.Singleton; // // Nexus Server - server-side support for Nexus distributed application framework // http://github.com/threerings/nexus/blob/master/LICENSE package com.threerings.nexus.server; public class NexusJavaTest { @Before public void createServer () { System.setProperty("nexus.safety_checks", "true"); _exec = Executors.newFixedThreadPool(3); Properties props = new Properties(); props.setProperty("nexus.node", "test"); props.setProperty("nexus.hostname", "localhost"); props.setProperty("nexus.rpc_timeout", "1000"); _server = new NexusServer(new NexusConfig(props), _exec); } @After public void shutdownServer () throws Exception { _server.shutdown(); _exec.shutdown(); if (!_exec.awaitTermination(2, TimeUnit.SECONDS)) { fail("Executor failed to terminate after 2 seconds."); } System.setProperty("nexus.safety_checks", ""); } @Test public void testRuntimeChecksOnAction () { final boolean[] printed = new boolean[] { false };
class EntityA implements Singleton {
threerings/nexus
server/src/test/java/com/threerings/nexus/server/NexusJavaTest.java
// Path: server/src/main/java/com/threerings/nexus/distrib/Action.java // public abstract class Action<E> // { // /** A variant of {@link Action} that can be used when you know that the action will not cross // * server boundaries. This allows things to be referenced from the enclosing scope <em>when // * that is known to be thread safe</em>. Remember that actions likely execute in a different // * thread context than the one from which they were initiated, so one must be careful not to // * use things from an enclosing scope that will cause race conditions. */ // public static abstract class Local<E> extends Action<E> { // } // // /** // * Called with the requested entity on the thread appropriate for said entity. // */ // public abstract void invoke (E entity); // // /** // * Called if the action could not be processed due to the target entity being not found. Note: // * this only occurs for keyed entities, not singleton entities. Note also that this method will // * be called in no execution context, which means that one must either perform only thread-safe // * operations in the body of this method, or one must dispatch a new action to process the // * failure. The default implementation simply logs a warning. // * // * @param nexus a reference to the nexus for convenient dispatch of a new action. // * @param eclass the class of the entity that could not be found. // * @param key the key of the entity that could not be found. // */ // public void onDropped (Nexus nexus, Class<?> eclass, Comparable<?> key) { // log.warning("Dropping action on unknown entity", "eclass", eclass.getName(), "key", key, // "action", this); // } // } // // Path: core/src/main/java/com/threerings/nexus/distrib/Singleton.java // public interface Singleton // { // }
import java.util.Properties; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import org.junit.*; import static org.junit.Assert.*; import com.threerings.nexus.distrib.Action; import com.threerings.nexus.distrib.Singleton;
// // Nexus Server - server-side support for Nexus distributed application framework // http://github.com/threerings/nexus/blob/master/LICENSE package com.threerings.nexus.server; public class NexusJavaTest { @Before public void createServer () { System.setProperty("nexus.safety_checks", "true"); _exec = Executors.newFixedThreadPool(3); Properties props = new Properties(); props.setProperty("nexus.node", "test"); props.setProperty("nexus.hostname", "localhost"); props.setProperty("nexus.rpc_timeout", "1000"); _server = new NexusServer(new NexusConfig(props), _exec); } @After public void shutdownServer () throws Exception { _server.shutdown(); _exec.shutdown(); if (!_exec.awaitTermination(2, TimeUnit.SECONDS)) { fail("Executor failed to terminate after 2 seconds."); } System.setProperty("nexus.safety_checks", ""); } @Test public void testRuntimeChecksOnAction () { final boolean[] printed = new boolean[] { false }; class EntityA implements Singleton { public int incr (int value) { return value + 1; } } class EntityB implements Singleton { public void incrAndDoubleAndPrint (final int value) {
// Path: server/src/main/java/com/threerings/nexus/distrib/Action.java // public abstract class Action<E> // { // /** A variant of {@link Action} that can be used when you know that the action will not cross // * server boundaries. This allows things to be referenced from the enclosing scope <em>when // * that is known to be thread safe</em>. Remember that actions likely execute in a different // * thread context than the one from which they were initiated, so one must be careful not to // * use things from an enclosing scope that will cause race conditions. */ // public static abstract class Local<E> extends Action<E> { // } // // /** // * Called with the requested entity on the thread appropriate for said entity. // */ // public abstract void invoke (E entity); // // /** // * Called if the action could not be processed due to the target entity being not found. Note: // * this only occurs for keyed entities, not singleton entities. Note also that this method will // * be called in no execution context, which means that one must either perform only thread-safe // * operations in the body of this method, or one must dispatch a new action to process the // * failure. The default implementation simply logs a warning. // * // * @param nexus a reference to the nexus for convenient dispatch of a new action. // * @param eclass the class of the entity that could not be found. // * @param key the key of the entity that could not be found. // */ // public void onDropped (Nexus nexus, Class<?> eclass, Comparable<?> key) { // log.warning("Dropping action on unknown entity", "eclass", eclass.getName(), "key", key, // "action", this); // } // } // // Path: core/src/main/java/com/threerings/nexus/distrib/Singleton.java // public interface Singleton // { // } // Path: server/src/test/java/com/threerings/nexus/server/NexusJavaTest.java import java.util.Properties; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import org.junit.*; import static org.junit.Assert.*; import com.threerings.nexus.distrib.Action; import com.threerings.nexus.distrib.Singleton; // // Nexus Server - server-side support for Nexus distributed application framework // http://github.com/threerings/nexus/blob/master/LICENSE package com.threerings.nexus.server; public class NexusJavaTest { @Before public void createServer () { System.setProperty("nexus.safety_checks", "true"); _exec = Executors.newFixedThreadPool(3); Properties props = new Properties(); props.setProperty("nexus.node", "test"); props.setProperty("nexus.hostname", "localhost"); props.setProperty("nexus.rpc_timeout", "1000"); _server = new NexusServer(new NexusConfig(props), _exec); } @After public void shutdownServer () throws Exception { _server.shutdown(); _exec.shutdown(); if (!_exec.awaitTermination(2, TimeUnit.SECONDS)) { fail("Executor failed to terminate after 2 seconds."); } System.setProperty("nexus.safety_checks", ""); } @Test public void testRuntimeChecksOnAction () { final boolean[] printed = new boolean[] { false }; class EntityA implements Singleton { public int incr (int value) { return value + 1; } } class EntityB implements Singleton { public void incrAndDoubleAndPrint (final int value) {
_server.invoke(EntityA.class, new Action<EntityA>() {
threerings/nexus
core/src/main/java/com/threerings/nexus/io/Streamable.java
// Path: core/src/main/java/com/threerings/nexus/distrib/DService.java // public abstract class DService<T extends NexusService> implements DAttribute // { // /** Used to create service attributes. */ // public interface Factory<T extends NexusService> // { // /** Creates a service attribute with the supplied owner. */ // DService<T> createService (NexusObject owner); // } // // /** An implementation detail used by service dispatchers. */ // public static abstract class Dispatcher<T extends NexusService> extends DService<T> { // /** Dispatches a service call that came in over the network. */ // public RFuture<?> dispatchCall (short methodId, Object[] args) { // throw new IllegalArgumentException("Unknown service method [id=" + methodId + // ", obj=" + _owner.getClass().getName() + // ", attrIdx=" + _index + "]"); // } // // protected Dispatcher (NexusObject owner) { // super(owner); // } // // /** Used to concisely, and without warning, cast arguments of generic type. */ // @SuppressWarnings("unchecked") // protected final <C> C cast (Object obj) { // return (C)obj; // } // } // // /** Returns the service encapsulated by this attribute. */ // public abstract T get (); // // /** Returns the class for the service encapsulated by this attribute. */ // public abstract Class<T> getServiceClass (); // // @Override public void readContents (Streamable.Input in) { // // NOOP // } // // @Override public void writeContents (Streamable.Output out) { // // NOOP // } // // protected DService (NexusObject owner) { // _owner = owner; // _index = owner.registerAttr(this); // } // // /** Used by marshallers to dispatch calls over the network. */ // protected <R> RFuture<R> postCall (short methodId, Object... args) { // RPromise<R> result = RPromise.create(); // _owner.postCall(_index, methodId, args, result); // return result; // } // // /** Used by marshallers to dispatch calls over the network. */ // protected void postVoidCall (short methodId, Object... args) { // _owner.postCall(_index, methodId, args, null); // } // // /** The object that owns this attribute. */ // protected final NexusObject _owner; // // /** The index of this attribute in its containing object. */ // protected final short _index; // } // // Path: core/src/main/java/com/threerings/nexus/distrib/NexusService.java // public interface NexusService // { // }
import com.threerings.nexus.distrib.DService; import com.threerings.nexus.distrib.NexusService; import java.util.Collection; import java.util.Iterator;
} return data; } /** * Reads a single value from the input (which must have been written via a call to {@link * Output#writeValue}). */ public <T> T readValue () { return this.<T>readStreamer().readObject(this); } /** * Reads a series of same-typed values from the input, storing them into {@code into} using * the {@link Collection#add} method. The values must have been written via a call to * {@link Output#writeValues}. */ public <T> void readValues (Collection<T> into) { int count = readShort(); if (count > 0) { Streamer<T> s = this.<T>readStreamer(); for (; count > 0; --count) { into.add(s.readObject(this)); } } } /** * Reads a service factory, which can be used to create Nexus service attributes. */
// Path: core/src/main/java/com/threerings/nexus/distrib/DService.java // public abstract class DService<T extends NexusService> implements DAttribute // { // /** Used to create service attributes. */ // public interface Factory<T extends NexusService> // { // /** Creates a service attribute with the supplied owner. */ // DService<T> createService (NexusObject owner); // } // // /** An implementation detail used by service dispatchers. */ // public static abstract class Dispatcher<T extends NexusService> extends DService<T> { // /** Dispatches a service call that came in over the network. */ // public RFuture<?> dispatchCall (short methodId, Object[] args) { // throw new IllegalArgumentException("Unknown service method [id=" + methodId + // ", obj=" + _owner.getClass().getName() + // ", attrIdx=" + _index + "]"); // } // // protected Dispatcher (NexusObject owner) { // super(owner); // } // // /** Used to concisely, and without warning, cast arguments of generic type. */ // @SuppressWarnings("unchecked") // protected final <C> C cast (Object obj) { // return (C)obj; // } // } // // /** Returns the service encapsulated by this attribute. */ // public abstract T get (); // // /** Returns the class for the service encapsulated by this attribute. */ // public abstract Class<T> getServiceClass (); // // @Override public void readContents (Streamable.Input in) { // // NOOP // } // // @Override public void writeContents (Streamable.Output out) { // // NOOP // } // // protected DService (NexusObject owner) { // _owner = owner; // _index = owner.registerAttr(this); // } // // /** Used by marshallers to dispatch calls over the network. */ // protected <R> RFuture<R> postCall (short methodId, Object... args) { // RPromise<R> result = RPromise.create(); // _owner.postCall(_index, methodId, args, result); // return result; // } // // /** Used by marshallers to dispatch calls over the network. */ // protected void postVoidCall (short methodId, Object... args) { // _owner.postCall(_index, methodId, args, null); // } // // /** The object that owns this attribute. */ // protected final NexusObject _owner; // // /** The index of this attribute in its containing object. */ // protected final short _index; // } // // Path: core/src/main/java/com/threerings/nexus/distrib/NexusService.java // public interface NexusService // { // } // Path: core/src/main/java/com/threerings/nexus/io/Streamable.java import com.threerings.nexus.distrib.DService; import com.threerings.nexus.distrib.NexusService; import java.util.Collection; import java.util.Iterator; } return data; } /** * Reads a single value from the input (which must have been written via a call to {@link * Output#writeValue}). */ public <T> T readValue () { return this.<T>readStreamer().readObject(this); } /** * Reads a series of same-typed values from the input, storing them into {@code into} using * the {@link Collection#add} method. The values must have been written via a call to * {@link Output#writeValues}. */ public <T> void readValues (Collection<T> into) { int count = readShort(); if (count > 0) { Streamer<T> s = this.<T>readStreamer(); for (; count > 0; --count) { into.add(s.readObject(this)); } } } /** * Reads a service factory, which can be used to create Nexus service attributes. */
public abstract <T extends NexusService> DService.Factory<T> readService ();
threerings/nexus
core/src/main/java/com/threerings/nexus/io/Streamable.java
// Path: core/src/main/java/com/threerings/nexus/distrib/DService.java // public abstract class DService<T extends NexusService> implements DAttribute // { // /** Used to create service attributes. */ // public interface Factory<T extends NexusService> // { // /** Creates a service attribute with the supplied owner. */ // DService<T> createService (NexusObject owner); // } // // /** An implementation detail used by service dispatchers. */ // public static abstract class Dispatcher<T extends NexusService> extends DService<T> { // /** Dispatches a service call that came in over the network. */ // public RFuture<?> dispatchCall (short methodId, Object[] args) { // throw new IllegalArgumentException("Unknown service method [id=" + methodId + // ", obj=" + _owner.getClass().getName() + // ", attrIdx=" + _index + "]"); // } // // protected Dispatcher (NexusObject owner) { // super(owner); // } // // /** Used to concisely, and without warning, cast arguments of generic type. */ // @SuppressWarnings("unchecked") // protected final <C> C cast (Object obj) { // return (C)obj; // } // } // // /** Returns the service encapsulated by this attribute. */ // public abstract T get (); // // /** Returns the class for the service encapsulated by this attribute. */ // public abstract Class<T> getServiceClass (); // // @Override public void readContents (Streamable.Input in) { // // NOOP // } // // @Override public void writeContents (Streamable.Output out) { // // NOOP // } // // protected DService (NexusObject owner) { // _owner = owner; // _index = owner.registerAttr(this); // } // // /** Used by marshallers to dispatch calls over the network. */ // protected <R> RFuture<R> postCall (short methodId, Object... args) { // RPromise<R> result = RPromise.create(); // _owner.postCall(_index, methodId, args, result); // return result; // } // // /** Used by marshallers to dispatch calls over the network. */ // protected void postVoidCall (short methodId, Object... args) { // _owner.postCall(_index, methodId, args, null); // } // // /** The object that owns this attribute. */ // protected final NexusObject _owner; // // /** The index of this attribute in its containing object. */ // protected final short _index; // } // // Path: core/src/main/java/com/threerings/nexus/distrib/NexusService.java // public interface NexusService // { // }
import com.threerings.nexus.distrib.DService; import com.threerings.nexus.distrib.NexusService; import java.util.Collection; import java.util.Iterator;
} return data; } /** * Reads a single value from the input (which must have been written via a call to {@link * Output#writeValue}). */ public <T> T readValue () { return this.<T>readStreamer().readObject(this); } /** * Reads a series of same-typed values from the input, storing them into {@code into} using * the {@link Collection#add} method. The values must have been written via a call to * {@link Output#writeValues}. */ public <T> void readValues (Collection<T> into) { int count = readShort(); if (count > 0) { Streamer<T> s = this.<T>readStreamer(); for (; count > 0; --count) { into.add(s.readObject(this)); } } } /** * Reads a service factory, which can be used to create Nexus service attributes. */
// Path: core/src/main/java/com/threerings/nexus/distrib/DService.java // public abstract class DService<T extends NexusService> implements DAttribute // { // /** Used to create service attributes. */ // public interface Factory<T extends NexusService> // { // /** Creates a service attribute with the supplied owner. */ // DService<T> createService (NexusObject owner); // } // // /** An implementation detail used by service dispatchers. */ // public static abstract class Dispatcher<T extends NexusService> extends DService<T> { // /** Dispatches a service call that came in over the network. */ // public RFuture<?> dispatchCall (short methodId, Object[] args) { // throw new IllegalArgumentException("Unknown service method [id=" + methodId + // ", obj=" + _owner.getClass().getName() + // ", attrIdx=" + _index + "]"); // } // // protected Dispatcher (NexusObject owner) { // super(owner); // } // // /** Used to concisely, and without warning, cast arguments of generic type. */ // @SuppressWarnings("unchecked") // protected final <C> C cast (Object obj) { // return (C)obj; // } // } // // /** Returns the service encapsulated by this attribute. */ // public abstract T get (); // // /** Returns the class for the service encapsulated by this attribute. */ // public abstract Class<T> getServiceClass (); // // @Override public void readContents (Streamable.Input in) { // // NOOP // } // // @Override public void writeContents (Streamable.Output out) { // // NOOP // } // // protected DService (NexusObject owner) { // _owner = owner; // _index = owner.registerAttr(this); // } // // /** Used by marshallers to dispatch calls over the network. */ // protected <R> RFuture<R> postCall (short methodId, Object... args) { // RPromise<R> result = RPromise.create(); // _owner.postCall(_index, methodId, args, result); // return result; // } // // /** Used by marshallers to dispatch calls over the network. */ // protected void postVoidCall (short methodId, Object... args) { // _owner.postCall(_index, methodId, args, null); // } // // /** The object that owns this attribute. */ // protected final NexusObject _owner; // // /** The index of this attribute in its containing object. */ // protected final short _index; // } // // Path: core/src/main/java/com/threerings/nexus/distrib/NexusService.java // public interface NexusService // { // } // Path: core/src/main/java/com/threerings/nexus/io/Streamable.java import com.threerings.nexus.distrib.DService; import com.threerings.nexus.distrib.NexusService; import java.util.Collection; import java.util.Iterator; } return data; } /** * Reads a single value from the input (which must have been written via a call to {@link * Output#writeValue}). */ public <T> T readValue () { return this.<T>readStreamer().readObject(this); } /** * Reads a series of same-typed values from the input, storing them into {@code into} using * the {@link Collection#add} method. The values must have been written via a call to * {@link Output#writeValues}. */ public <T> void readValues (Collection<T> into) { int count = readShort(); if (count > 0) { Streamer<T> s = this.<T>readStreamer(); for (; count > 0; --count) { into.add(s.readObject(this)); } } } /** * Reads a service factory, which can be used to create Nexus service attributes. */
public abstract <T extends NexusService> DService.Factory<T> readService ();
threerings/nexus
jvm-server/src/test/java/com/threerings/nexus/server/SimpleServerTest.java
// Path: server/src/main/java/com/threerings/nexus/distrib/Action.java // public abstract class Action<E> // { // /** A variant of {@link Action} that can be used when you know that the action will not cross // * server boundaries. This allows things to be referenced from the enclosing scope <em>when // * that is known to be thread safe</em>. Remember that actions likely execute in a different // * thread context than the one from which they were initiated, so one must be careful not to // * use things from an enclosing scope that will cause race conditions. */ // public static abstract class Local<E> extends Action<E> { // } // // /** // * Called with the requested entity on the thread appropriate for said entity. // */ // public abstract void invoke (E entity); // // /** // * Called if the action could not be processed due to the target entity being not found. Note: // * this only occurs for keyed entities, not singleton entities. Note also that this method will // * be called in no execution context, which means that one must either perform only thread-safe // * operations in the body of this method, or one must dispatch a new action to process the // * failure. The default implementation simply logs a warning. // * // * @param nexus a reference to the nexus for convenient dispatch of a new action. // * @param eclass the class of the entity that could not be found. // * @param key the key of the entity that could not be found. // */ // public void onDropped (Nexus nexus, Class<?> eclass, Comparable<?> key) { // log.warning("Dropping action on unknown entity", "eclass", eclass.getName(), "key", key, // "action", this); // } // } // // Path: core/src/main/java/com/threerings/nexus/distrib/DValue.java // public class DValue<T> extends react.Value<T> implements DAttribute // { // /** // * Creates a new attribute with the specified owner and initial value. // */ // public static <T> DValue<T> create (NexusObject owner, T value) { // return new DValue<T>(owner, value); // } // // @Override public void readContents (Streamable.Input in) { // _value = in.<T>readValue(); // } // // @Override public void writeContents (Streamable.Output out) { // out.writeValue(_value); // } // // protected DValue (NexusObject owner, T value) { // super(value); // _owner = owner; // _index = owner.registerAttr(this); // } // // @Override protected void emitChange (T value, T oldValue) { // // we don't call super as we defer notification until the event is dispatched // ChangeEvent<T> event = new ChangeEvent<T>(_owner.getId(), _index, value); // event.oldValue = oldValue; // _owner.postEvent(event); // } // // protected void applyChange (T value, T oldValue) { // if (oldValue == DistribUtil.<T>sentinelValue()) { // // we came in over the network: read our old value and update _value // oldValue = updateLocal(value); // } // else: we were initiated in this JVM: _value was already updated // notifyChange(value, oldValue); // } // // /** An event emitted when a value changes. */ // protected static class ChangeEvent<T> extends DAttribute.Event { // public T oldValue = DistribUtil.<T>sentinelValue(); // // public ChangeEvent (int targetId, short index, T value) { // super(targetId, index); // _value = value; // } // // @Override public void applyTo (NexusObject target) { // target.<DValue<T>>getAttribute(this.index).applyChange(_value, oldValue); // } // // @Override protected void toString (StringBuilder buf) { // super.toString(buf); // buf.append(", value=").append(_value); // } // // protected final T _value; // } // // /** The object that owns this attribute. */ // protected final NexusObject _owner; // // /** The index of this attribute in its containing object. */ // protected final short _index; // } // // Path: test-support/src/main/java/com/threerings/nexus/distrib/TestObject.java // public class TestObject extends NexusObject // implements Singleton // { // public final DValue<String> value = DValue.create(this, "test"); // // public final DService<TestService> testsvc; // // public TestObject (DService.Factory<TestService> testsvc) { // this.testsvc = testsvc.createService(this); // } // } // // Path: core/src/main/java/com/threerings/nexus/util/Log.java // public static Logger log = new JavaLogger("nexus");
import java.io.IOException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import com.threerings.nexus.distrib.Action; import com.threerings.nexus.distrib.DValue; import com.threerings.nexus.distrib.TestObject; import org.junit.*; import static org.junit.Assert.*; import static com.threerings.nexus.util.Log.log;
// // Nexus JVMServer - server-side support for Nexus java.nio-based services // http://github.com/threerings/nexus/blob/master/LICENSE package com.threerings.nexus.server; /** * Tests basic Nexus server functionality. */ public class SimpleServerTest { @Before public void suppressLogging () {
// Path: server/src/main/java/com/threerings/nexus/distrib/Action.java // public abstract class Action<E> // { // /** A variant of {@link Action} that can be used when you know that the action will not cross // * server boundaries. This allows things to be referenced from the enclosing scope <em>when // * that is known to be thread safe</em>. Remember that actions likely execute in a different // * thread context than the one from which they were initiated, so one must be careful not to // * use things from an enclosing scope that will cause race conditions. */ // public static abstract class Local<E> extends Action<E> { // } // // /** // * Called with the requested entity on the thread appropriate for said entity. // */ // public abstract void invoke (E entity); // // /** // * Called if the action could not be processed due to the target entity being not found. Note: // * this only occurs for keyed entities, not singleton entities. Note also that this method will // * be called in no execution context, which means that one must either perform only thread-safe // * operations in the body of this method, or one must dispatch a new action to process the // * failure. The default implementation simply logs a warning. // * // * @param nexus a reference to the nexus for convenient dispatch of a new action. // * @param eclass the class of the entity that could not be found. // * @param key the key of the entity that could not be found. // */ // public void onDropped (Nexus nexus, Class<?> eclass, Comparable<?> key) { // log.warning("Dropping action on unknown entity", "eclass", eclass.getName(), "key", key, // "action", this); // } // } // // Path: core/src/main/java/com/threerings/nexus/distrib/DValue.java // public class DValue<T> extends react.Value<T> implements DAttribute // { // /** // * Creates a new attribute with the specified owner and initial value. // */ // public static <T> DValue<T> create (NexusObject owner, T value) { // return new DValue<T>(owner, value); // } // // @Override public void readContents (Streamable.Input in) { // _value = in.<T>readValue(); // } // // @Override public void writeContents (Streamable.Output out) { // out.writeValue(_value); // } // // protected DValue (NexusObject owner, T value) { // super(value); // _owner = owner; // _index = owner.registerAttr(this); // } // // @Override protected void emitChange (T value, T oldValue) { // // we don't call super as we defer notification until the event is dispatched // ChangeEvent<T> event = new ChangeEvent<T>(_owner.getId(), _index, value); // event.oldValue = oldValue; // _owner.postEvent(event); // } // // protected void applyChange (T value, T oldValue) { // if (oldValue == DistribUtil.<T>sentinelValue()) { // // we came in over the network: read our old value and update _value // oldValue = updateLocal(value); // } // else: we were initiated in this JVM: _value was already updated // notifyChange(value, oldValue); // } // // /** An event emitted when a value changes. */ // protected static class ChangeEvent<T> extends DAttribute.Event { // public T oldValue = DistribUtil.<T>sentinelValue(); // // public ChangeEvent (int targetId, short index, T value) { // super(targetId, index); // _value = value; // } // // @Override public void applyTo (NexusObject target) { // target.<DValue<T>>getAttribute(this.index).applyChange(_value, oldValue); // } // // @Override protected void toString (StringBuilder buf) { // super.toString(buf); // buf.append(", value=").append(_value); // } // // protected final T _value; // } // // /** The object that owns this attribute. */ // protected final NexusObject _owner; // // /** The index of this attribute in its containing object. */ // protected final short _index; // } // // Path: test-support/src/main/java/com/threerings/nexus/distrib/TestObject.java // public class TestObject extends NexusObject // implements Singleton // { // public final DValue<String> value = DValue.create(this, "test"); // // public final DService<TestService> testsvc; // // public TestObject (DService.Factory<TestService> testsvc) { // this.testsvc = testsvc.createService(this); // } // } // // Path: core/src/main/java/com/threerings/nexus/util/Log.java // public static Logger log = new JavaLogger("nexus"); // Path: jvm-server/src/test/java/com/threerings/nexus/server/SimpleServerTest.java import java.io.IOException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import com.threerings.nexus.distrib.Action; import com.threerings.nexus.distrib.DValue; import com.threerings.nexus.distrib.TestObject; import org.junit.*; import static org.junit.Assert.*; import static com.threerings.nexus.util.Log.log; // // Nexus JVMServer - server-side support for Nexus java.nio-based services // http://github.com/threerings/nexus/blob/master/LICENSE package com.threerings.nexus.server; /** * Tests basic Nexus server functionality. */ public class SimpleServerTest { @Before public void suppressLogging () {
log.setWarnOnly(true);
threerings/nexus
jvm-server/src/test/java/com/threerings/nexus/server/SimpleServerTest.java
// Path: server/src/main/java/com/threerings/nexus/distrib/Action.java // public abstract class Action<E> // { // /** A variant of {@link Action} that can be used when you know that the action will not cross // * server boundaries. This allows things to be referenced from the enclosing scope <em>when // * that is known to be thread safe</em>. Remember that actions likely execute in a different // * thread context than the one from which they were initiated, so one must be careful not to // * use things from an enclosing scope that will cause race conditions. */ // public static abstract class Local<E> extends Action<E> { // } // // /** // * Called with the requested entity on the thread appropriate for said entity. // */ // public abstract void invoke (E entity); // // /** // * Called if the action could not be processed due to the target entity being not found. Note: // * this only occurs for keyed entities, not singleton entities. Note also that this method will // * be called in no execution context, which means that one must either perform only thread-safe // * operations in the body of this method, or one must dispatch a new action to process the // * failure. The default implementation simply logs a warning. // * // * @param nexus a reference to the nexus for convenient dispatch of a new action. // * @param eclass the class of the entity that could not be found. // * @param key the key of the entity that could not be found. // */ // public void onDropped (Nexus nexus, Class<?> eclass, Comparable<?> key) { // log.warning("Dropping action on unknown entity", "eclass", eclass.getName(), "key", key, // "action", this); // } // } // // Path: core/src/main/java/com/threerings/nexus/distrib/DValue.java // public class DValue<T> extends react.Value<T> implements DAttribute // { // /** // * Creates a new attribute with the specified owner and initial value. // */ // public static <T> DValue<T> create (NexusObject owner, T value) { // return new DValue<T>(owner, value); // } // // @Override public void readContents (Streamable.Input in) { // _value = in.<T>readValue(); // } // // @Override public void writeContents (Streamable.Output out) { // out.writeValue(_value); // } // // protected DValue (NexusObject owner, T value) { // super(value); // _owner = owner; // _index = owner.registerAttr(this); // } // // @Override protected void emitChange (T value, T oldValue) { // // we don't call super as we defer notification until the event is dispatched // ChangeEvent<T> event = new ChangeEvent<T>(_owner.getId(), _index, value); // event.oldValue = oldValue; // _owner.postEvent(event); // } // // protected void applyChange (T value, T oldValue) { // if (oldValue == DistribUtil.<T>sentinelValue()) { // // we came in over the network: read our old value and update _value // oldValue = updateLocal(value); // } // else: we were initiated in this JVM: _value was already updated // notifyChange(value, oldValue); // } // // /** An event emitted when a value changes. */ // protected static class ChangeEvent<T> extends DAttribute.Event { // public T oldValue = DistribUtil.<T>sentinelValue(); // // public ChangeEvent (int targetId, short index, T value) { // super(targetId, index); // _value = value; // } // // @Override public void applyTo (NexusObject target) { // target.<DValue<T>>getAttribute(this.index).applyChange(_value, oldValue); // } // // @Override protected void toString (StringBuilder buf) { // super.toString(buf); // buf.append(", value=").append(_value); // } // // protected final T _value; // } // // /** The object that owns this attribute. */ // protected final NexusObject _owner; // // /** The index of this attribute in its containing object. */ // protected final short _index; // } // // Path: test-support/src/main/java/com/threerings/nexus/distrib/TestObject.java // public class TestObject extends NexusObject // implements Singleton // { // public final DValue<String> value = DValue.create(this, "test"); // // public final DService<TestService> testsvc; // // public TestObject (DService.Factory<TestService> testsvc) { // this.testsvc = testsvc.createService(this); // } // } // // Path: core/src/main/java/com/threerings/nexus/util/Log.java // public static Logger log = new JavaLogger("nexus");
import java.io.IOException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import com.threerings.nexus.distrib.Action; import com.threerings.nexus.distrib.DValue; import com.threerings.nexus.distrib.TestObject; import org.junit.*; import static org.junit.Assert.*; import static com.threerings.nexus.util.Log.log;
public void testStartupShutdownWithConMgr () throws IOException { // create a server with a thread pool NexusConfig config = TestUtil.createTestConfig(); final ExecutorService exec = Executors.newFixedThreadPool(3); NexusServer server = new NexusServer(config, exec); // set up a connection manager and listen on a port final JVMConnectionManager conmgr = new JVMConnectionManager(server.getSessionManager()); conmgr.listen("localhost", 1234); conmgr.start(); // run a simple event dispatch through testEventDispatchAndShutdown(server, new Runnable() { public void run () { // since JUnit forcibly terminates the JVM on test completion, wait a few // milliseconds to give the reader and writer threads time to go away conmgr.disconnect(); try { Thread.sleep(100); } catch (Throwable t) {} conmgr.shutdown(); try { Thread.sleep(100); } catch (Throwable t) {} assert(conmgr.isTerminated()); exec.shutdown(); } }); // now wait for everything to run to completion TestUtil.awaitTermination(exec); } protected void testEventDispatchAndShutdown (NexusServer server, final Runnable onComplete) {
// Path: server/src/main/java/com/threerings/nexus/distrib/Action.java // public abstract class Action<E> // { // /** A variant of {@link Action} that can be used when you know that the action will not cross // * server boundaries. This allows things to be referenced from the enclosing scope <em>when // * that is known to be thread safe</em>. Remember that actions likely execute in a different // * thread context than the one from which they were initiated, so one must be careful not to // * use things from an enclosing scope that will cause race conditions. */ // public static abstract class Local<E> extends Action<E> { // } // // /** // * Called with the requested entity on the thread appropriate for said entity. // */ // public abstract void invoke (E entity); // // /** // * Called if the action could not be processed due to the target entity being not found. Note: // * this only occurs for keyed entities, not singleton entities. Note also that this method will // * be called in no execution context, which means that one must either perform only thread-safe // * operations in the body of this method, or one must dispatch a new action to process the // * failure. The default implementation simply logs a warning. // * // * @param nexus a reference to the nexus for convenient dispatch of a new action. // * @param eclass the class of the entity that could not be found. // * @param key the key of the entity that could not be found. // */ // public void onDropped (Nexus nexus, Class<?> eclass, Comparable<?> key) { // log.warning("Dropping action on unknown entity", "eclass", eclass.getName(), "key", key, // "action", this); // } // } // // Path: core/src/main/java/com/threerings/nexus/distrib/DValue.java // public class DValue<T> extends react.Value<T> implements DAttribute // { // /** // * Creates a new attribute with the specified owner and initial value. // */ // public static <T> DValue<T> create (NexusObject owner, T value) { // return new DValue<T>(owner, value); // } // // @Override public void readContents (Streamable.Input in) { // _value = in.<T>readValue(); // } // // @Override public void writeContents (Streamable.Output out) { // out.writeValue(_value); // } // // protected DValue (NexusObject owner, T value) { // super(value); // _owner = owner; // _index = owner.registerAttr(this); // } // // @Override protected void emitChange (T value, T oldValue) { // // we don't call super as we defer notification until the event is dispatched // ChangeEvent<T> event = new ChangeEvent<T>(_owner.getId(), _index, value); // event.oldValue = oldValue; // _owner.postEvent(event); // } // // protected void applyChange (T value, T oldValue) { // if (oldValue == DistribUtil.<T>sentinelValue()) { // // we came in over the network: read our old value and update _value // oldValue = updateLocal(value); // } // else: we were initiated in this JVM: _value was already updated // notifyChange(value, oldValue); // } // // /** An event emitted when a value changes. */ // protected static class ChangeEvent<T> extends DAttribute.Event { // public T oldValue = DistribUtil.<T>sentinelValue(); // // public ChangeEvent (int targetId, short index, T value) { // super(targetId, index); // _value = value; // } // // @Override public void applyTo (NexusObject target) { // target.<DValue<T>>getAttribute(this.index).applyChange(_value, oldValue); // } // // @Override protected void toString (StringBuilder buf) { // super.toString(buf); // buf.append(", value=").append(_value); // } // // protected final T _value; // } // // /** The object that owns this attribute. */ // protected final NexusObject _owner; // // /** The index of this attribute in its containing object. */ // protected final short _index; // } // // Path: test-support/src/main/java/com/threerings/nexus/distrib/TestObject.java // public class TestObject extends NexusObject // implements Singleton // { // public final DValue<String> value = DValue.create(this, "test"); // // public final DService<TestService> testsvc; // // public TestObject (DService.Factory<TestService> testsvc) { // this.testsvc = testsvc.createService(this); // } // } // // Path: core/src/main/java/com/threerings/nexus/util/Log.java // public static Logger log = new JavaLogger("nexus"); // Path: jvm-server/src/test/java/com/threerings/nexus/server/SimpleServerTest.java import java.io.IOException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import com.threerings.nexus.distrib.Action; import com.threerings.nexus.distrib.DValue; import com.threerings.nexus.distrib.TestObject; import org.junit.*; import static org.junit.Assert.*; import static com.threerings.nexus.util.Log.log; public void testStartupShutdownWithConMgr () throws IOException { // create a server with a thread pool NexusConfig config = TestUtil.createTestConfig(); final ExecutorService exec = Executors.newFixedThreadPool(3); NexusServer server = new NexusServer(config, exec); // set up a connection manager and listen on a port final JVMConnectionManager conmgr = new JVMConnectionManager(server.getSessionManager()); conmgr.listen("localhost", 1234); conmgr.start(); // run a simple event dispatch through testEventDispatchAndShutdown(server, new Runnable() { public void run () { // since JUnit forcibly terminates the JVM on test completion, wait a few // milliseconds to give the reader and writer threads time to go away conmgr.disconnect(); try { Thread.sleep(100); } catch (Throwable t) {} conmgr.shutdown(); try { Thread.sleep(100); } catch (Throwable t) {} assert(conmgr.isTerminated()); exec.shutdown(); } }); // now wait for everything to run to completion TestUtil.awaitTermination(exec); } protected void testEventDispatchAndShutdown (NexusServer server, final Runnable onComplete) {
TestObject test = new TestObject(TestUtil.createTestServiceAttr());
threerings/nexus
jvm-server/src/test/java/com/threerings/nexus/server/SimpleServerTest.java
// Path: server/src/main/java/com/threerings/nexus/distrib/Action.java // public abstract class Action<E> // { // /** A variant of {@link Action} that can be used when you know that the action will not cross // * server boundaries. This allows things to be referenced from the enclosing scope <em>when // * that is known to be thread safe</em>. Remember that actions likely execute in a different // * thread context than the one from which they were initiated, so one must be careful not to // * use things from an enclosing scope that will cause race conditions. */ // public static abstract class Local<E> extends Action<E> { // } // // /** // * Called with the requested entity on the thread appropriate for said entity. // */ // public abstract void invoke (E entity); // // /** // * Called if the action could not be processed due to the target entity being not found. Note: // * this only occurs for keyed entities, not singleton entities. Note also that this method will // * be called in no execution context, which means that one must either perform only thread-safe // * operations in the body of this method, or one must dispatch a new action to process the // * failure. The default implementation simply logs a warning. // * // * @param nexus a reference to the nexus for convenient dispatch of a new action. // * @param eclass the class of the entity that could not be found. // * @param key the key of the entity that could not be found. // */ // public void onDropped (Nexus nexus, Class<?> eclass, Comparable<?> key) { // log.warning("Dropping action on unknown entity", "eclass", eclass.getName(), "key", key, // "action", this); // } // } // // Path: core/src/main/java/com/threerings/nexus/distrib/DValue.java // public class DValue<T> extends react.Value<T> implements DAttribute // { // /** // * Creates a new attribute with the specified owner and initial value. // */ // public static <T> DValue<T> create (NexusObject owner, T value) { // return new DValue<T>(owner, value); // } // // @Override public void readContents (Streamable.Input in) { // _value = in.<T>readValue(); // } // // @Override public void writeContents (Streamable.Output out) { // out.writeValue(_value); // } // // protected DValue (NexusObject owner, T value) { // super(value); // _owner = owner; // _index = owner.registerAttr(this); // } // // @Override protected void emitChange (T value, T oldValue) { // // we don't call super as we defer notification until the event is dispatched // ChangeEvent<T> event = new ChangeEvent<T>(_owner.getId(), _index, value); // event.oldValue = oldValue; // _owner.postEvent(event); // } // // protected void applyChange (T value, T oldValue) { // if (oldValue == DistribUtil.<T>sentinelValue()) { // // we came in over the network: read our old value and update _value // oldValue = updateLocal(value); // } // else: we were initiated in this JVM: _value was already updated // notifyChange(value, oldValue); // } // // /** An event emitted when a value changes. */ // protected static class ChangeEvent<T> extends DAttribute.Event { // public T oldValue = DistribUtil.<T>sentinelValue(); // // public ChangeEvent (int targetId, short index, T value) { // super(targetId, index); // _value = value; // } // // @Override public void applyTo (NexusObject target) { // target.<DValue<T>>getAttribute(this.index).applyChange(_value, oldValue); // } // // @Override protected void toString (StringBuilder buf) { // super.toString(buf); // buf.append(", value=").append(_value); // } // // protected final T _value; // } // // /** The object that owns this attribute. */ // protected final NexusObject _owner; // // /** The index of this attribute in its containing object. */ // protected final short _index; // } // // Path: test-support/src/main/java/com/threerings/nexus/distrib/TestObject.java // public class TestObject extends NexusObject // implements Singleton // { // public final DValue<String> value = DValue.create(this, "test"); // // public final DService<TestService> testsvc; // // public TestObject (DService.Factory<TestService> testsvc) { // this.testsvc = testsvc.createService(this); // } // } // // Path: core/src/main/java/com/threerings/nexus/util/Log.java // public static Logger log = new JavaLogger("nexus");
import java.io.IOException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import com.threerings.nexus.distrib.Action; import com.threerings.nexus.distrib.DValue; import com.threerings.nexus.distrib.TestObject; import org.junit.*; import static org.junit.Assert.*; import static com.threerings.nexus.util.Log.log;
// run a simple event dispatch through testEventDispatchAndShutdown(server, new Runnable() { public void run () { // since JUnit forcibly terminates the JVM on test completion, wait a few // milliseconds to give the reader and writer threads time to go away conmgr.disconnect(); try { Thread.sleep(100); } catch (Throwable t) {} conmgr.shutdown(); try { Thread.sleep(100); } catch (Throwable t) {} assert(conmgr.isTerminated()); exec.shutdown(); } }); // now wait for everything to run to completion TestUtil.awaitTermination(exec); } protected void testEventDispatchAndShutdown (NexusServer server, final Runnable onComplete) { TestObject test = new TestObject(TestUtil.createTestServiceAttr()); server.register(TestObject.class, test); // ensure that we've been assigned an id assertTrue(test.getId() > 0); // ensure that event dispatch is wired up final String ovalue = test.value.get(); final String nvalue = "newValue"; final boolean[] triggered = new boolean[1];
// Path: server/src/main/java/com/threerings/nexus/distrib/Action.java // public abstract class Action<E> // { // /** A variant of {@link Action} that can be used when you know that the action will not cross // * server boundaries. This allows things to be referenced from the enclosing scope <em>when // * that is known to be thread safe</em>. Remember that actions likely execute in a different // * thread context than the one from which they were initiated, so one must be careful not to // * use things from an enclosing scope that will cause race conditions. */ // public static abstract class Local<E> extends Action<E> { // } // // /** // * Called with the requested entity on the thread appropriate for said entity. // */ // public abstract void invoke (E entity); // // /** // * Called if the action could not be processed due to the target entity being not found. Note: // * this only occurs for keyed entities, not singleton entities. Note also that this method will // * be called in no execution context, which means that one must either perform only thread-safe // * operations in the body of this method, or one must dispatch a new action to process the // * failure. The default implementation simply logs a warning. // * // * @param nexus a reference to the nexus for convenient dispatch of a new action. // * @param eclass the class of the entity that could not be found. // * @param key the key of the entity that could not be found. // */ // public void onDropped (Nexus nexus, Class<?> eclass, Comparable<?> key) { // log.warning("Dropping action on unknown entity", "eclass", eclass.getName(), "key", key, // "action", this); // } // } // // Path: core/src/main/java/com/threerings/nexus/distrib/DValue.java // public class DValue<T> extends react.Value<T> implements DAttribute // { // /** // * Creates a new attribute with the specified owner and initial value. // */ // public static <T> DValue<T> create (NexusObject owner, T value) { // return new DValue<T>(owner, value); // } // // @Override public void readContents (Streamable.Input in) { // _value = in.<T>readValue(); // } // // @Override public void writeContents (Streamable.Output out) { // out.writeValue(_value); // } // // protected DValue (NexusObject owner, T value) { // super(value); // _owner = owner; // _index = owner.registerAttr(this); // } // // @Override protected void emitChange (T value, T oldValue) { // // we don't call super as we defer notification until the event is dispatched // ChangeEvent<T> event = new ChangeEvent<T>(_owner.getId(), _index, value); // event.oldValue = oldValue; // _owner.postEvent(event); // } // // protected void applyChange (T value, T oldValue) { // if (oldValue == DistribUtil.<T>sentinelValue()) { // // we came in over the network: read our old value and update _value // oldValue = updateLocal(value); // } // else: we were initiated in this JVM: _value was already updated // notifyChange(value, oldValue); // } // // /** An event emitted when a value changes. */ // protected static class ChangeEvent<T> extends DAttribute.Event { // public T oldValue = DistribUtil.<T>sentinelValue(); // // public ChangeEvent (int targetId, short index, T value) { // super(targetId, index); // _value = value; // } // // @Override public void applyTo (NexusObject target) { // target.<DValue<T>>getAttribute(this.index).applyChange(_value, oldValue); // } // // @Override protected void toString (StringBuilder buf) { // super.toString(buf); // buf.append(", value=").append(_value); // } // // protected final T _value; // } // // /** The object that owns this attribute. */ // protected final NexusObject _owner; // // /** The index of this attribute in its containing object. */ // protected final short _index; // } // // Path: test-support/src/main/java/com/threerings/nexus/distrib/TestObject.java // public class TestObject extends NexusObject // implements Singleton // { // public final DValue<String> value = DValue.create(this, "test"); // // public final DService<TestService> testsvc; // // public TestObject (DService.Factory<TestService> testsvc) { // this.testsvc = testsvc.createService(this); // } // } // // Path: core/src/main/java/com/threerings/nexus/util/Log.java // public static Logger log = new JavaLogger("nexus"); // Path: jvm-server/src/test/java/com/threerings/nexus/server/SimpleServerTest.java import java.io.IOException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import com.threerings.nexus.distrib.Action; import com.threerings.nexus.distrib.DValue; import com.threerings.nexus.distrib.TestObject; import org.junit.*; import static org.junit.Assert.*; import static com.threerings.nexus.util.Log.log; // run a simple event dispatch through testEventDispatchAndShutdown(server, new Runnable() { public void run () { // since JUnit forcibly terminates the JVM on test completion, wait a few // milliseconds to give the reader and writer threads time to go away conmgr.disconnect(); try { Thread.sleep(100); } catch (Throwable t) {} conmgr.shutdown(); try { Thread.sleep(100); } catch (Throwable t) {} assert(conmgr.isTerminated()); exec.shutdown(); } }); // now wait for everything to run to completion TestUtil.awaitTermination(exec); } protected void testEventDispatchAndShutdown (NexusServer server, final Runnable onComplete) { TestObject test = new TestObject(TestUtil.createTestServiceAttr()); server.register(TestObject.class, test); // ensure that we've been assigned an id assertTrue(test.getId() > 0); // ensure that event dispatch is wired up final String ovalue = test.value.get(); final String nvalue = "newValue"; final boolean[] triggered = new boolean[1];
test.value.connect(new DValue.Listener<String>() {
threerings/nexus
jvm-server/src/test/java/com/threerings/nexus/server/SimpleServerTest.java
// Path: server/src/main/java/com/threerings/nexus/distrib/Action.java // public abstract class Action<E> // { // /** A variant of {@link Action} that can be used when you know that the action will not cross // * server boundaries. This allows things to be referenced from the enclosing scope <em>when // * that is known to be thread safe</em>. Remember that actions likely execute in a different // * thread context than the one from which they were initiated, so one must be careful not to // * use things from an enclosing scope that will cause race conditions. */ // public static abstract class Local<E> extends Action<E> { // } // // /** // * Called with the requested entity on the thread appropriate for said entity. // */ // public abstract void invoke (E entity); // // /** // * Called if the action could not be processed due to the target entity being not found. Note: // * this only occurs for keyed entities, not singleton entities. Note also that this method will // * be called in no execution context, which means that one must either perform only thread-safe // * operations in the body of this method, or one must dispatch a new action to process the // * failure. The default implementation simply logs a warning. // * // * @param nexus a reference to the nexus for convenient dispatch of a new action. // * @param eclass the class of the entity that could not be found. // * @param key the key of the entity that could not be found. // */ // public void onDropped (Nexus nexus, Class<?> eclass, Comparable<?> key) { // log.warning("Dropping action on unknown entity", "eclass", eclass.getName(), "key", key, // "action", this); // } // } // // Path: core/src/main/java/com/threerings/nexus/distrib/DValue.java // public class DValue<T> extends react.Value<T> implements DAttribute // { // /** // * Creates a new attribute with the specified owner and initial value. // */ // public static <T> DValue<T> create (NexusObject owner, T value) { // return new DValue<T>(owner, value); // } // // @Override public void readContents (Streamable.Input in) { // _value = in.<T>readValue(); // } // // @Override public void writeContents (Streamable.Output out) { // out.writeValue(_value); // } // // protected DValue (NexusObject owner, T value) { // super(value); // _owner = owner; // _index = owner.registerAttr(this); // } // // @Override protected void emitChange (T value, T oldValue) { // // we don't call super as we defer notification until the event is dispatched // ChangeEvent<T> event = new ChangeEvent<T>(_owner.getId(), _index, value); // event.oldValue = oldValue; // _owner.postEvent(event); // } // // protected void applyChange (T value, T oldValue) { // if (oldValue == DistribUtil.<T>sentinelValue()) { // // we came in over the network: read our old value and update _value // oldValue = updateLocal(value); // } // else: we were initiated in this JVM: _value was already updated // notifyChange(value, oldValue); // } // // /** An event emitted when a value changes. */ // protected static class ChangeEvent<T> extends DAttribute.Event { // public T oldValue = DistribUtil.<T>sentinelValue(); // // public ChangeEvent (int targetId, short index, T value) { // super(targetId, index); // _value = value; // } // // @Override public void applyTo (NexusObject target) { // target.<DValue<T>>getAttribute(this.index).applyChange(_value, oldValue); // } // // @Override protected void toString (StringBuilder buf) { // super.toString(buf); // buf.append(", value=").append(_value); // } // // protected final T _value; // } // // /** The object that owns this attribute. */ // protected final NexusObject _owner; // // /** The index of this attribute in its containing object. */ // protected final short _index; // } // // Path: test-support/src/main/java/com/threerings/nexus/distrib/TestObject.java // public class TestObject extends NexusObject // implements Singleton // { // public final DValue<String> value = DValue.create(this, "test"); // // public final DService<TestService> testsvc; // // public TestObject (DService.Factory<TestService> testsvc) { // this.testsvc = testsvc.createService(this); // } // } // // Path: core/src/main/java/com/threerings/nexus/util/Log.java // public static Logger log = new JavaLogger("nexus");
import java.io.IOException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import com.threerings.nexus.distrib.Action; import com.threerings.nexus.distrib.DValue; import com.threerings.nexus.distrib.TestObject; import org.junit.*; import static org.junit.Assert.*; import static com.threerings.nexus.util.Log.log;
}); // now wait for everything to run to completion TestUtil.awaitTermination(exec); } protected void testEventDispatchAndShutdown (NexusServer server, final Runnable onComplete) { TestObject test = new TestObject(TestUtil.createTestServiceAttr()); server.register(TestObject.class, test); // ensure that we've been assigned an id assertTrue(test.getId() > 0); // ensure that event dispatch is wired up final String ovalue = test.value.get(); final String nvalue = "newValue"; final boolean[] triggered = new boolean[1]; test.value.connect(new DValue.Listener<String>() { @Override public void onChange (String value, String oldValue) { assertEquals(ovalue, oldValue); assertEquals(nvalue, value); triggered[0] = true; } }); // update the value test.value.update(nvalue); // make sure the listener was triggered (we need to queue this check up on the object's // action queue so that we can be sure the attribute change goes through first)
// Path: server/src/main/java/com/threerings/nexus/distrib/Action.java // public abstract class Action<E> // { // /** A variant of {@link Action} that can be used when you know that the action will not cross // * server boundaries. This allows things to be referenced from the enclosing scope <em>when // * that is known to be thread safe</em>. Remember that actions likely execute in a different // * thread context than the one from which they were initiated, so one must be careful not to // * use things from an enclosing scope that will cause race conditions. */ // public static abstract class Local<E> extends Action<E> { // } // // /** // * Called with the requested entity on the thread appropriate for said entity. // */ // public abstract void invoke (E entity); // // /** // * Called if the action could not be processed due to the target entity being not found. Note: // * this only occurs for keyed entities, not singleton entities. Note also that this method will // * be called in no execution context, which means that one must either perform only thread-safe // * operations in the body of this method, or one must dispatch a new action to process the // * failure. The default implementation simply logs a warning. // * // * @param nexus a reference to the nexus for convenient dispatch of a new action. // * @param eclass the class of the entity that could not be found. // * @param key the key of the entity that could not be found. // */ // public void onDropped (Nexus nexus, Class<?> eclass, Comparable<?> key) { // log.warning("Dropping action on unknown entity", "eclass", eclass.getName(), "key", key, // "action", this); // } // } // // Path: core/src/main/java/com/threerings/nexus/distrib/DValue.java // public class DValue<T> extends react.Value<T> implements DAttribute // { // /** // * Creates a new attribute with the specified owner and initial value. // */ // public static <T> DValue<T> create (NexusObject owner, T value) { // return new DValue<T>(owner, value); // } // // @Override public void readContents (Streamable.Input in) { // _value = in.<T>readValue(); // } // // @Override public void writeContents (Streamable.Output out) { // out.writeValue(_value); // } // // protected DValue (NexusObject owner, T value) { // super(value); // _owner = owner; // _index = owner.registerAttr(this); // } // // @Override protected void emitChange (T value, T oldValue) { // // we don't call super as we defer notification until the event is dispatched // ChangeEvent<T> event = new ChangeEvent<T>(_owner.getId(), _index, value); // event.oldValue = oldValue; // _owner.postEvent(event); // } // // protected void applyChange (T value, T oldValue) { // if (oldValue == DistribUtil.<T>sentinelValue()) { // // we came in over the network: read our old value and update _value // oldValue = updateLocal(value); // } // else: we were initiated in this JVM: _value was already updated // notifyChange(value, oldValue); // } // // /** An event emitted when a value changes. */ // protected static class ChangeEvent<T> extends DAttribute.Event { // public T oldValue = DistribUtil.<T>sentinelValue(); // // public ChangeEvent (int targetId, short index, T value) { // super(targetId, index); // _value = value; // } // // @Override public void applyTo (NexusObject target) { // target.<DValue<T>>getAttribute(this.index).applyChange(_value, oldValue); // } // // @Override protected void toString (StringBuilder buf) { // super.toString(buf); // buf.append(", value=").append(_value); // } // // protected final T _value; // } // // /** The object that owns this attribute. */ // protected final NexusObject _owner; // // /** The index of this attribute in its containing object. */ // protected final short _index; // } // // Path: test-support/src/main/java/com/threerings/nexus/distrib/TestObject.java // public class TestObject extends NexusObject // implements Singleton // { // public final DValue<String> value = DValue.create(this, "test"); // // public final DService<TestService> testsvc; // // public TestObject (DService.Factory<TestService> testsvc) { // this.testsvc = testsvc.createService(this); // } // } // // Path: core/src/main/java/com/threerings/nexus/util/Log.java // public static Logger log = new JavaLogger("nexus"); // Path: jvm-server/src/test/java/com/threerings/nexus/server/SimpleServerTest.java import java.io.IOException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import com.threerings.nexus.distrib.Action; import com.threerings.nexus.distrib.DValue; import com.threerings.nexus.distrib.TestObject; import org.junit.*; import static org.junit.Assert.*; import static com.threerings.nexus.util.Log.log; }); // now wait for everything to run to completion TestUtil.awaitTermination(exec); } protected void testEventDispatchAndShutdown (NexusServer server, final Runnable onComplete) { TestObject test = new TestObject(TestUtil.createTestServiceAttr()); server.register(TestObject.class, test); // ensure that we've been assigned an id assertTrue(test.getId() > 0); // ensure that event dispatch is wired up final String ovalue = test.value.get(); final String nvalue = "newValue"; final boolean[] triggered = new boolean[1]; test.value.connect(new DValue.Listener<String>() { @Override public void onChange (String value, String oldValue) { assertEquals(ovalue, oldValue); assertEquals(nvalue, value); triggered[0] = true; } }); // update the value test.value.update(nvalue); // make sure the listener was triggered (we need to queue this check up on the object's // action queue so that we can be sure the attribute change goes through first)
server.invoke(TestObject.class, new Action<TestObject>() {
threerings/nexus
core/src/main/java/com/threerings/nexus/io/AbstractSerializer.java
// Path: core/src/main/java/com/threerings/nexus/distrib/DService.java // public abstract class DService<T extends NexusService> implements DAttribute // { // /** Used to create service attributes. */ // public interface Factory<T extends NexusService> // { // /** Creates a service attribute with the supplied owner. */ // DService<T> createService (NexusObject owner); // } // // /** An implementation detail used by service dispatchers. */ // public static abstract class Dispatcher<T extends NexusService> extends DService<T> { // /** Dispatches a service call that came in over the network. */ // public RFuture<?> dispatchCall (short methodId, Object[] args) { // throw new IllegalArgumentException("Unknown service method [id=" + methodId + // ", obj=" + _owner.getClass().getName() + // ", attrIdx=" + _index + "]"); // } // // protected Dispatcher (NexusObject owner) { // super(owner); // } // // /** Used to concisely, and without warning, cast arguments of generic type. */ // @SuppressWarnings("unchecked") // protected final <C> C cast (Object obj) { // return (C)obj; // } // } // // /** Returns the service encapsulated by this attribute. */ // public abstract T get (); // // /** Returns the class for the service encapsulated by this attribute. */ // public abstract Class<T> getServiceClass (); // // @Override public void readContents (Streamable.Input in) { // // NOOP // } // // @Override public void writeContents (Streamable.Output out) { // // NOOP // } // // protected DService (NexusObject owner) { // _owner = owner; // _index = owner.registerAttr(this); // } // // /** Used by marshallers to dispatch calls over the network. */ // protected <R> RFuture<R> postCall (short methodId, Object... args) { // RPromise<R> result = RPromise.create(); // _owner.postCall(_index, methodId, args, result); // return result; // } // // /** Used by marshallers to dispatch calls over the network. */ // protected void postVoidCall (short methodId, Object... args) { // _owner.postCall(_index, methodId, args, null); // } // // /** The object that owns this attribute. */ // protected final NexusObject _owner; // // /** The index of this attribute in its containing object. */ // protected final short _index; // } // // Path: core/src/main/java/com/threerings/nexus/distrib/NexusException.java // public class NexusException extends RuntimeException // implements Streamable // { // /** // * Throws a NexusException with the supplied error message if {@code condition} is not true. // */ // public static void require (boolean condition, String errmsg, Object... args) { // if (!condition) throw new NexusException(Log.format(errmsg, args)); // } // // public NexusException (String message) { // super(message); // } // // public NexusException (String message, Throwable cause) { // super(message, cause); // } // // public NexusException (Throwable cause) { // super(cause); // } // } // // Path: core/src/main/java/com/threerings/nexus/distrib/NexusService.java // public interface NexusService // { // }
import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import com.threerings.nexus.distrib.DService; import com.threerings.nexus.distrib.NexusException; import com.threerings.nexus.distrib.NexusService;
// // Nexus Core - a framework for developing distributed applications // http://github.com/threerings/nexus/blob/master/LICENSE package com.threerings.nexus.io; /** * A basic {@link Serializer} implementation that handles standard types. This is extended by * generated serializers to add support for project classes. */ public abstract class AbstractSerializer implements Serializer { // from interface Serializer public Class<?> getClass (short code) { return nonNull(_classes.get(code), "Unknown class code ", code); } // from interface Serializer public Streamer<?> getStreamer (short code) { return nonNull(_streamers.get(code), "Unknown class code ", code); } // from interface Serializer
// Path: core/src/main/java/com/threerings/nexus/distrib/DService.java // public abstract class DService<T extends NexusService> implements DAttribute // { // /** Used to create service attributes. */ // public interface Factory<T extends NexusService> // { // /** Creates a service attribute with the supplied owner. */ // DService<T> createService (NexusObject owner); // } // // /** An implementation detail used by service dispatchers. */ // public static abstract class Dispatcher<T extends NexusService> extends DService<T> { // /** Dispatches a service call that came in over the network. */ // public RFuture<?> dispatchCall (short methodId, Object[] args) { // throw new IllegalArgumentException("Unknown service method [id=" + methodId + // ", obj=" + _owner.getClass().getName() + // ", attrIdx=" + _index + "]"); // } // // protected Dispatcher (NexusObject owner) { // super(owner); // } // // /** Used to concisely, and without warning, cast arguments of generic type. */ // @SuppressWarnings("unchecked") // protected final <C> C cast (Object obj) { // return (C)obj; // } // } // // /** Returns the service encapsulated by this attribute. */ // public abstract T get (); // // /** Returns the class for the service encapsulated by this attribute. */ // public abstract Class<T> getServiceClass (); // // @Override public void readContents (Streamable.Input in) { // // NOOP // } // // @Override public void writeContents (Streamable.Output out) { // // NOOP // } // // protected DService (NexusObject owner) { // _owner = owner; // _index = owner.registerAttr(this); // } // // /** Used by marshallers to dispatch calls over the network. */ // protected <R> RFuture<R> postCall (short methodId, Object... args) { // RPromise<R> result = RPromise.create(); // _owner.postCall(_index, methodId, args, result); // return result; // } // // /** Used by marshallers to dispatch calls over the network. */ // protected void postVoidCall (short methodId, Object... args) { // _owner.postCall(_index, methodId, args, null); // } // // /** The object that owns this attribute. */ // protected final NexusObject _owner; // // /** The index of this attribute in its containing object. */ // protected final short _index; // } // // Path: core/src/main/java/com/threerings/nexus/distrib/NexusException.java // public class NexusException extends RuntimeException // implements Streamable // { // /** // * Throws a NexusException with the supplied error message if {@code condition} is not true. // */ // public static void require (boolean condition, String errmsg, Object... args) { // if (!condition) throw new NexusException(Log.format(errmsg, args)); // } // // public NexusException (String message) { // super(message); // } // // public NexusException (String message, Throwable cause) { // super(message, cause); // } // // public NexusException (Throwable cause) { // super(cause); // } // } // // Path: core/src/main/java/com/threerings/nexus/distrib/NexusService.java // public interface NexusService // { // } // Path: core/src/main/java/com/threerings/nexus/io/AbstractSerializer.java import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import com.threerings.nexus.distrib.DService; import com.threerings.nexus.distrib.NexusException; import com.threerings.nexus.distrib.NexusService; // // Nexus Core - a framework for developing distributed applications // http://github.com/threerings/nexus/blob/master/LICENSE package com.threerings.nexus.io; /** * A basic {@link Serializer} implementation that handles standard types. This is extended by * generated serializers to add support for project classes. */ public abstract class AbstractSerializer implements Serializer { // from interface Serializer public Class<?> getClass (short code) { return nonNull(_classes.get(code), "Unknown class code ", code); } // from interface Serializer public Streamer<?> getStreamer (short code) { return nonNull(_streamers.get(code), "Unknown class code ", code); } // from interface Serializer
public DService.Factory<?> getServiceFactory (short code) {
threerings/nexus
core/src/main/java/com/threerings/nexus/io/AbstractSerializer.java
// Path: core/src/main/java/com/threerings/nexus/distrib/DService.java // public abstract class DService<T extends NexusService> implements DAttribute // { // /** Used to create service attributes. */ // public interface Factory<T extends NexusService> // { // /** Creates a service attribute with the supplied owner. */ // DService<T> createService (NexusObject owner); // } // // /** An implementation detail used by service dispatchers. */ // public static abstract class Dispatcher<T extends NexusService> extends DService<T> { // /** Dispatches a service call that came in over the network. */ // public RFuture<?> dispatchCall (short methodId, Object[] args) { // throw new IllegalArgumentException("Unknown service method [id=" + methodId + // ", obj=" + _owner.getClass().getName() + // ", attrIdx=" + _index + "]"); // } // // protected Dispatcher (NexusObject owner) { // super(owner); // } // // /** Used to concisely, and without warning, cast arguments of generic type. */ // @SuppressWarnings("unchecked") // protected final <C> C cast (Object obj) { // return (C)obj; // } // } // // /** Returns the service encapsulated by this attribute. */ // public abstract T get (); // // /** Returns the class for the service encapsulated by this attribute. */ // public abstract Class<T> getServiceClass (); // // @Override public void readContents (Streamable.Input in) { // // NOOP // } // // @Override public void writeContents (Streamable.Output out) { // // NOOP // } // // protected DService (NexusObject owner) { // _owner = owner; // _index = owner.registerAttr(this); // } // // /** Used by marshallers to dispatch calls over the network. */ // protected <R> RFuture<R> postCall (short methodId, Object... args) { // RPromise<R> result = RPromise.create(); // _owner.postCall(_index, methodId, args, result); // return result; // } // // /** Used by marshallers to dispatch calls over the network. */ // protected void postVoidCall (short methodId, Object... args) { // _owner.postCall(_index, methodId, args, null); // } // // /** The object that owns this attribute. */ // protected final NexusObject _owner; // // /** The index of this attribute in its containing object. */ // protected final short _index; // } // // Path: core/src/main/java/com/threerings/nexus/distrib/NexusException.java // public class NexusException extends RuntimeException // implements Streamable // { // /** // * Throws a NexusException with the supplied error message if {@code condition} is not true. // */ // public static void require (boolean condition, String errmsg, Object... args) { // if (!condition) throw new NexusException(Log.format(errmsg, args)); // } // // public NexusException (String message) { // super(message); // } // // public NexusException (String message, Throwable cause) { // super(message, cause); // } // // public NexusException (Throwable cause) { // super(cause); // } // } // // Path: core/src/main/java/com/threerings/nexus/distrib/NexusService.java // public interface NexusService // { // }
import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import com.threerings.nexus.distrib.DService; import com.threerings.nexus.distrib.NexusException; import com.threerings.nexus.distrib.NexusService;
// // Nexus Core - a framework for developing distributed applications // http://github.com/threerings/nexus/blob/master/LICENSE package com.threerings.nexus.io; /** * A basic {@link Serializer} implementation that handles standard types. This is extended by * generated serializers to add support for project classes. */ public abstract class AbstractSerializer implements Serializer { // from interface Serializer public Class<?> getClass (short code) { return nonNull(_classes.get(code), "Unknown class code ", code); } // from interface Serializer public Streamer<?> getStreamer (short code) { return nonNull(_streamers.get(code), "Unknown class code ", code); } // from interface Serializer public DService.Factory<?> getServiceFactory (short code) { return nonNull(_services.get(code), "Unknown service code ", code); } // from interface Serializer public short getCode (Class<?> clazz) { return nonNull(_codes.get(clazz), "Unknown streamable class ", clazz); } // from interface Serializer
// Path: core/src/main/java/com/threerings/nexus/distrib/DService.java // public abstract class DService<T extends NexusService> implements DAttribute // { // /** Used to create service attributes. */ // public interface Factory<T extends NexusService> // { // /** Creates a service attribute with the supplied owner. */ // DService<T> createService (NexusObject owner); // } // // /** An implementation detail used by service dispatchers. */ // public static abstract class Dispatcher<T extends NexusService> extends DService<T> { // /** Dispatches a service call that came in over the network. */ // public RFuture<?> dispatchCall (short methodId, Object[] args) { // throw new IllegalArgumentException("Unknown service method [id=" + methodId + // ", obj=" + _owner.getClass().getName() + // ", attrIdx=" + _index + "]"); // } // // protected Dispatcher (NexusObject owner) { // super(owner); // } // // /** Used to concisely, and without warning, cast arguments of generic type. */ // @SuppressWarnings("unchecked") // protected final <C> C cast (Object obj) { // return (C)obj; // } // } // // /** Returns the service encapsulated by this attribute. */ // public abstract T get (); // // /** Returns the class for the service encapsulated by this attribute. */ // public abstract Class<T> getServiceClass (); // // @Override public void readContents (Streamable.Input in) { // // NOOP // } // // @Override public void writeContents (Streamable.Output out) { // // NOOP // } // // protected DService (NexusObject owner) { // _owner = owner; // _index = owner.registerAttr(this); // } // // /** Used by marshallers to dispatch calls over the network. */ // protected <R> RFuture<R> postCall (short methodId, Object... args) { // RPromise<R> result = RPromise.create(); // _owner.postCall(_index, methodId, args, result); // return result; // } // // /** Used by marshallers to dispatch calls over the network. */ // protected void postVoidCall (short methodId, Object... args) { // _owner.postCall(_index, methodId, args, null); // } // // /** The object that owns this attribute. */ // protected final NexusObject _owner; // // /** The index of this attribute in its containing object. */ // protected final short _index; // } // // Path: core/src/main/java/com/threerings/nexus/distrib/NexusException.java // public class NexusException extends RuntimeException // implements Streamable // { // /** // * Throws a NexusException with the supplied error message if {@code condition} is not true. // */ // public static void require (boolean condition, String errmsg, Object... args) { // if (!condition) throw new NexusException(Log.format(errmsg, args)); // } // // public NexusException (String message) { // super(message); // } // // public NexusException (String message, Throwable cause) { // super(message, cause); // } // // public NexusException (Throwable cause) { // super(cause); // } // } // // Path: core/src/main/java/com/threerings/nexus/distrib/NexusService.java // public interface NexusService // { // } // Path: core/src/main/java/com/threerings/nexus/io/AbstractSerializer.java import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import com.threerings.nexus.distrib.DService; import com.threerings.nexus.distrib.NexusException; import com.threerings.nexus.distrib.NexusService; // // Nexus Core - a framework for developing distributed applications // http://github.com/threerings/nexus/blob/master/LICENSE package com.threerings.nexus.io; /** * A basic {@link Serializer} implementation that handles standard types. This is extended by * generated serializers to add support for project classes. */ public abstract class AbstractSerializer implements Serializer { // from interface Serializer public Class<?> getClass (short code) { return nonNull(_classes.get(code), "Unknown class code ", code); } // from interface Serializer public Streamer<?> getStreamer (short code) { return nonNull(_streamers.get(code), "Unknown class code ", code); } // from interface Serializer public DService.Factory<?> getServiceFactory (short code) { return nonNull(_services.get(code), "Unknown service code ", code); } // from interface Serializer public short getCode (Class<?> clazz) { return nonNull(_codes.get(clazz), "Unknown streamable class ", clazz); } // from interface Serializer
public short getServiceCode (Class<? extends NexusService> clazz) {
threerings/nexus
core/src/main/java/com/threerings/nexus/io/AbstractSerializer.java
// Path: core/src/main/java/com/threerings/nexus/distrib/DService.java // public abstract class DService<T extends NexusService> implements DAttribute // { // /** Used to create service attributes. */ // public interface Factory<T extends NexusService> // { // /** Creates a service attribute with the supplied owner. */ // DService<T> createService (NexusObject owner); // } // // /** An implementation detail used by service dispatchers. */ // public static abstract class Dispatcher<T extends NexusService> extends DService<T> { // /** Dispatches a service call that came in over the network. */ // public RFuture<?> dispatchCall (short methodId, Object[] args) { // throw new IllegalArgumentException("Unknown service method [id=" + methodId + // ", obj=" + _owner.getClass().getName() + // ", attrIdx=" + _index + "]"); // } // // protected Dispatcher (NexusObject owner) { // super(owner); // } // // /** Used to concisely, and without warning, cast arguments of generic type. */ // @SuppressWarnings("unchecked") // protected final <C> C cast (Object obj) { // return (C)obj; // } // } // // /** Returns the service encapsulated by this attribute. */ // public abstract T get (); // // /** Returns the class for the service encapsulated by this attribute. */ // public abstract Class<T> getServiceClass (); // // @Override public void readContents (Streamable.Input in) { // // NOOP // } // // @Override public void writeContents (Streamable.Output out) { // // NOOP // } // // protected DService (NexusObject owner) { // _owner = owner; // _index = owner.registerAttr(this); // } // // /** Used by marshallers to dispatch calls over the network. */ // protected <R> RFuture<R> postCall (short methodId, Object... args) { // RPromise<R> result = RPromise.create(); // _owner.postCall(_index, methodId, args, result); // return result; // } // // /** Used by marshallers to dispatch calls over the network. */ // protected void postVoidCall (short methodId, Object... args) { // _owner.postCall(_index, methodId, args, null); // } // // /** The object that owns this attribute. */ // protected final NexusObject _owner; // // /** The index of this attribute in its containing object. */ // protected final short _index; // } // // Path: core/src/main/java/com/threerings/nexus/distrib/NexusException.java // public class NexusException extends RuntimeException // implements Streamable // { // /** // * Throws a NexusException with the supplied error message if {@code condition} is not true. // */ // public static void require (boolean condition, String errmsg, Object... args) { // if (!condition) throw new NexusException(Log.format(errmsg, args)); // } // // public NexusException (String message) { // super(message); // } // // public NexusException (String message, Throwable cause) { // super(message, cause); // } // // public NexusException (Throwable cause) { // super(cause); // } // } // // Path: core/src/main/java/com/threerings/nexus/distrib/NexusService.java // public interface NexusService // { // }
import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import com.threerings.nexus.distrib.DService; import com.threerings.nexus.distrib.NexusException; import com.threerings.nexus.distrib.NexusService;
return nonNull(_serviceCodes.get(clazz), "Unknown service class ", clazz); } // from interface Serializer public <T> Streamer<T> writeStreamer (Streamable.Output out, T value) { if (value == null) { return this.<T>writeClass(out, (short)0); // null streamer has code 0 } // if the class is known, just look up the code and write it Class<?> vclass = value.getClass(); Short code = _codes.get(vclass); if (code != null) { return this.<T>writeClass(out, code); } // if the class is some more obscure subtype of list/set/map, use the stock // streamer and cache this type with the same code if (value instanceof List) { _codes.put(vclass, code = _codes.get(ArrayList.class)); return this.<T>writeClass(out, code); } else if (value instanceof Set) { _codes.put(vclass, code = _codes.get(HashSet.class)); return this.<T>writeClass(out, code); } else if (value instanceof Map) { _codes.put(vclass, code = _codes.get(HashMap.class)); return this.<T>writeClass(out, code); } // otherwise: houston, we have a problem
// Path: core/src/main/java/com/threerings/nexus/distrib/DService.java // public abstract class DService<T extends NexusService> implements DAttribute // { // /** Used to create service attributes. */ // public interface Factory<T extends NexusService> // { // /** Creates a service attribute with the supplied owner. */ // DService<T> createService (NexusObject owner); // } // // /** An implementation detail used by service dispatchers. */ // public static abstract class Dispatcher<T extends NexusService> extends DService<T> { // /** Dispatches a service call that came in over the network. */ // public RFuture<?> dispatchCall (short methodId, Object[] args) { // throw new IllegalArgumentException("Unknown service method [id=" + methodId + // ", obj=" + _owner.getClass().getName() + // ", attrIdx=" + _index + "]"); // } // // protected Dispatcher (NexusObject owner) { // super(owner); // } // // /** Used to concisely, and without warning, cast arguments of generic type. */ // @SuppressWarnings("unchecked") // protected final <C> C cast (Object obj) { // return (C)obj; // } // } // // /** Returns the service encapsulated by this attribute. */ // public abstract T get (); // // /** Returns the class for the service encapsulated by this attribute. */ // public abstract Class<T> getServiceClass (); // // @Override public void readContents (Streamable.Input in) { // // NOOP // } // // @Override public void writeContents (Streamable.Output out) { // // NOOP // } // // protected DService (NexusObject owner) { // _owner = owner; // _index = owner.registerAttr(this); // } // // /** Used by marshallers to dispatch calls over the network. */ // protected <R> RFuture<R> postCall (short methodId, Object... args) { // RPromise<R> result = RPromise.create(); // _owner.postCall(_index, methodId, args, result); // return result; // } // // /** Used by marshallers to dispatch calls over the network. */ // protected void postVoidCall (short methodId, Object... args) { // _owner.postCall(_index, methodId, args, null); // } // // /** The object that owns this attribute. */ // protected final NexusObject _owner; // // /** The index of this attribute in its containing object. */ // protected final short _index; // } // // Path: core/src/main/java/com/threerings/nexus/distrib/NexusException.java // public class NexusException extends RuntimeException // implements Streamable // { // /** // * Throws a NexusException with the supplied error message if {@code condition} is not true. // */ // public static void require (boolean condition, String errmsg, Object... args) { // if (!condition) throw new NexusException(Log.format(errmsg, args)); // } // // public NexusException (String message) { // super(message); // } // // public NexusException (String message, Throwable cause) { // super(message, cause); // } // // public NexusException (Throwable cause) { // super(cause); // } // } // // Path: core/src/main/java/com/threerings/nexus/distrib/NexusService.java // public interface NexusService // { // } // Path: core/src/main/java/com/threerings/nexus/io/AbstractSerializer.java import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import com.threerings.nexus.distrib.DService; import com.threerings.nexus.distrib.NexusException; import com.threerings.nexus.distrib.NexusService; return nonNull(_serviceCodes.get(clazz), "Unknown service class ", clazz); } // from interface Serializer public <T> Streamer<T> writeStreamer (Streamable.Output out, T value) { if (value == null) { return this.<T>writeClass(out, (short)0); // null streamer has code 0 } // if the class is known, just look up the code and write it Class<?> vclass = value.getClass(); Short code = _codes.get(vclass); if (code != null) { return this.<T>writeClass(out, code); } // if the class is some more obscure subtype of list/set/map, use the stock // streamer and cache this type with the same code if (value instanceof List) { _codes.put(vclass, code = _codes.get(ArrayList.class)); return this.<T>writeClass(out, code); } else if (value instanceof Set) { _codes.put(vclass, code = _codes.get(HashSet.class)); return this.<T>writeClass(out, code); } else if (value instanceof Map) { _codes.put(vclass, code = _codes.get(HashMap.class)); return this.<T>writeClass(out, code); } // otherwise: houston, we have a problem
throw new NexusException("Requested to stream unknown type " + vclass);
threerings/nexus
server/src/main/java/com/threerings/nexus/distrib/Action.java
// Path: core/src/main/java/com/threerings/nexus/util/Log.java // public static Logger log = new JavaLogger("nexus");
import static com.threerings.nexus.util.Log.log;
// // Nexus Server - server-side support for Nexus distributed application framework // http://github.com/threerings/nexus/blob/master/LICENSE package com.threerings.nexus.distrib; /** * An action invoked in the context of a Nexus entity. The sender does not block awaiting a * response. TODO: this needs to become an interface with a default method when the time comes to * support Java 8 lambdas. */ // TODO: @FunctionalInterface public abstract class Action<E> { /** A variant of {@link Action} that can be used when you know that the action will not cross * server boundaries. This allows things to be referenced from the enclosing scope <em>when * that is known to be thread safe</em>. Remember that actions likely execute in a different * thread context than the one from which they were initiated, so one must be careful not to * use things from an enclosing scope that will cause race conditions. */ public static abstract class Local<E> extends Action<E> { } /** * Called with the requested entity on the thread appropriate for said entity. */ public abstract void invoke (E entity); /** * Called if the action could not be processed due to the target entity being not found. Note: * this only occurs for keyed entities, not singleton entities. Note also that this method will * be called in no execution context, which means that one must either perform only thread-safe * operations in the body of this method, or one must dispatch a new action to process the * failure. The default implementation simply logs a warning. * * @param nexus a reference to the nexus for convenient dispatch of a new action. * @param eclass the class of the entity that could not be found. * @param key the key of the entity that could not be found. */ public void onDropped (Nexus nexus, Class<?> eclass, Comparable<?> key) {
// Path: core/src/main/java/com/threerings/nexus/util/Log.java // public static Logger log = new JavaLogger("nexus"); // Path: server/src/main/java/com/threerings/nexus/distrib/Action.java import static com.threerings.nexus.util.Log.log; // // Nexus Server - server-side support for Nexus distributed application framework // http://github.com/threerings/nexus/blob/master/LICENSE package com.threerings.nexus.distrib; /** * An action invoked in the context of a Nexus entity. The sender does not block awaiting a * response. TODO: this needs to become an interface with a default method when the time comes to * support Java 8 lambdas. */ // TODO: @FunctionalInterface public abstract class Action<E> { /** A variant of {@link Action} that can be used when you know that the action will not cross * server boundaries. This allows things to be referenced from the enclosing scope <em>when * that is known to be thread safe</em>. Remember that actions likely execute in a different * thread context than the one from which they were initiated, so one must be careful not to * use things from an enclosing scope that will cause race conditions. */ public static abstract class Local<E> extends Action<E> { } /** * Called with the requested entity on the thread appropriate for said entity. */ public abstract void invoke (E entity); /** * Called if the action could not be processed due to the target entity being not found. Note: * this only occurs for keyed entities, not singleton entities. Note also that this method will * be called in no execution context, which means that one must either perform only thread-safe * operations in the body of this method, or one must dispatch a new action to process the * failure. The default implementation simply logs a warning. * * @param nexus a reference to the nexus for convenient dispatch of a new action. * @param eclass the class of the entity that could not be found. * @param key the key of the entity that could not be found. */ public void onDropped (Nexus nexus, Class<?> eclass, Comparable<?> key) {
log.warning("Dropping action on unknown entity", "eclass", eclass.getName(), "key", key,
threerings/nexus
jvm-server/src/main/java/com/threerings/nexus/server/JVMConnectionManager.java
// Path: core/src/main/java/com/threerings/nexus/util/Log.java // public static Logger log = new JavaLogger("nexus");
import java.io.IOException; import java.net.InetSocketAddress; import java.nio.channels.SelectionKey; import java.nio.channels.Selector; import java.nio.channels.ServerSocketChannel; import java.nio.channels.SocketChannel; import java.util.List; import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; import com.google.common.base.Preconditions; import com.google.common.base.Strings; import com.google.common.collect.Lists; import static com.threerings.nexus.util.Log.log;
// // Nexus JVMServer - server-side support for Nexus java.nio-based services // http://github.com/threerings/nexus/blob/master/LICENSE package com.threerings.nexus.server; /** * Handles listening for Nexus connections and reading and writing over the sockets. Interacts with * a {@link SessionManager} to source and sink messages. */ public class JVMConnectionManager { /** * Creates a connection manager that will listen for connections on the specified host/port * combination and establish sessions with the supplied session manager. */ public JVMConnectionManager (SessionManager smgr) throws IOException { _smgr = smgr; _selector = Selector.open(); } /** * Binds a listening socket on the specified host and port. * @param bindHost the address on which to listen, or null to listen on 0.0.0.0. * @param bindPort the port on which to listen. * @throws IOException if a failure occurs binding the socket. */ public void listen (String bindHost, int bindPort) throws IOException { final ServerSocketChannel ssocket = ServerSocketChannel.open(); ssocket.configureBlocking(false); InetSocketAddress addr = Strings.isNullOrEmpty(bindHost) ? new InetSocketAddress(bindPort) : new InetSocketAddress(bindHost, bindPort); ssocket.socket().bind(addr); SelectionKey key = ssocket.register(_selector, SelectionKey.OP_ACCEPT); key.attach(new IOHandler() { public void handleIO () { handleAccept(ssocket); } }); _ssocks.add(ssocket);
// Path: core/src/main/java/com/threerings/nexus/util/Log.java // public static Logger log = new JavaLogger("nexus"); // Path: jvm-server/src/main/java/com/threerings/nexus/server/JVMConnectionManager.java import java.io.IOException; import java.net.InetSocketAddress; import java.nio.channels.SelectionKey; import java.nio.channels.Selector; import java.nio.channels.ServerSocketChannel; import java.nio.channels.SocketChannel; import java.util.List; import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; import com.google.common.base.Preconditions; import com.google.common.base.Strings; import com.google.common.collect.Lists; import static com.threerings.nexus.util.Log.log; // // Nexus JVMServer - server-side support for Nexus java.nio-based services // http://github.com/threerings/nexus/blob/master/LICENSE package com.threerings.nexus.server; /** * Handles listening for Nexus connections and reading and writing over the sockets. Interacts with * a {@link SessionManager} to source and sink messages. */ public class JVMConnectionManager { /** * Creates a connection manager that will listen for connections on the specified host/port * combination and establish sessions with the supplied session manager. */ public JVMConnectionManager (SessionManager smgr) throws IOException { _smgr = smgr; _selector = Selector.open(); } /** * Binds a listening socket on the specified host and port. * @param bindHost the address on which to listen, or null to listen on 0.0.0.0. * @param bindPort the port on which to listen. * @throws IOException if a failure occurs binding the socket. */ public void listen (String bindHost, int bindPort) throws IOException { final ServerSocketChannel ssocket = ServerSocketChannel.open(); ssocket.configureBlocking(false); InetSocketAddress addr = Strings.isNullOrEmpty(bindHost) ? new InetSocketAddress(bindPort) : new InetSocketAddress(bindHost, bindPort); ssocket.socket().bind(addr); SelectionKey key = ssocket.register(_selector, SelectionKey.OP_ACCEPT); key.attach(new IOHandler() { public void handleIO () { handleAccept(ssocket); } }); _ssocks.add(ssocket);
log.info("Server listening on " + addr);
threerings/nexus
gwt-server/src/main/java/com/threerings/nexus/io/ServerOutput.java
// Path: core/src/main/java/com/threerings/nexus/distrib/DService.java // public abstract class DService<T extends NexusService> implements DAttribute // { // /** Used to create service attributes. */ // public interface Factory<T extends NexusService> // { // /** Creates a service attribute with the supplied owner. */ // DService<T> createService (NexusObject owner); // } // // /** An implementation detail used by service dispatchers. */ // public static abstract class Dispatcher<T extends NexusService> extends DService<T> { // /** Dispatches a service call that came in over the network. */ // public RFuture<?> dispatchCall (short methodId, Object[] args) { // throw new IllegalArgumentException("Unknown service method [id=" + methodId + // ", obj=" + _owner.getClass().getName() + // ", attrIdx=" + _index + "]"); // } // // protected Dispatcher (NexusObject owner) { // super(owner); // } // // /** Used to concisely, and without warning, cast arguments of generic type. */ // @SuppressWarnings("unchecked") // protected final <C> C cast (Object obj) { // return (C)obj; // } // } // // /** Returns the service encapsulated by this attribute. */ // public abstract T get (); // // /** Returns the class for the service encapsulated by this attribute. */ // public abstract Class<T> getServiceClass (); // // @Override public void readContents (Streamable.Input in) { // // NOOP // } // // @Override public void writeContents (Streamable.Output out) { // // NOOP // } // // protected DService (NexusObject owner) { // _owner = owner; // _index = owner.registerAttr(this); // } // // /** Used by marshallers to dispatch calls over the network. */ // protected <R> RFuture<R> postCall (short methodId, Object... args) { // RPromise<R> result = RPromise.create(); // _owner.postCall(_index, methodId, args, result); // return result; // } // // /** Used by marshallers to dispatch calls over the network. */ // protected void postVoidCall (short methodId, Object... args) { // _owner.postCall(_index, methodId, args, null); // } // // /** The object that owns this attribute. */ // protected final NexusObject _owner; // // /** The index of this attribute in its containing object. */ // protected final short _index; // }
import com.google.gwt.user.server.Base64Utils; import com.threerings.nexus.distrib.DService;
_output.appendSeparator(); } @Override public void writeLong (long value) { _output._buffer.append('\'').append(Base64Utils.toBase64(value)).append('\''); _output.appendSeparator(); } @Override public void writeFloat (float value) { writeDouble(value); } @Override public void writeDouble (double value) { _output._buffer.append(String.valueOf(value)); _output.appendSeparator(); } @Override public void writeString (String value) { if (value == null) { _output._buffer.append("null"); } else { _output._buffer.append('\"').append(escapeString(value)).append('\"'); } _output.appendSeparator(); } @Override public void writeClass (Class<? extends Streamable> clazz) { writeShort(_szer.getCode(clazz)); }
// Path: core/src/main/java/com/threerings/nexus/distrib/DService.java // public abstract class DService<T extends NexusService> implements DAttribute // { // /** Used to create service attributes. */ // public interface Factory<T extends NexusService> // { // /** Creates a service attribute with the supplied owner. */ // DService<T> createService (NexusObject owner); // } // // /** An implementation detail used by service dispatchers. */ // public static abstract class Dispatcher<T extends NexusService> extends DService<T> { // /** Dispatches a service call that came in over the network. */ // public RFuture<?> dispatchCall (short methodId, Object[] args) { // throw new IllegalArgumentException("Unknown service method [id=" + methodId + // ", obj=" + _owner.getClass().getName() + // ", attrIdx=" + _index + "]"); // } // // protected Dispatcher (NexusObject owner) { // super(owner); // } // // /** Used to concisely, and without warning, cast arguments of generic type. */ // @SuppressWarnings("unchecked") // protected final <C> C cast (Object obj) { // return (C)obj; // } // } // // /** Returns the service encapsulated by this attribute. */ // public abstract T get (); // // /** Returns the class for the service encapsulated by this attribute. */ // public abstract Class<T> getServiceClass (); // // @Override public void readContents (Streamable.Input in) { // // NOOP // } // // @Override public void writeContents (Streamable.Output out) { // // NOOP // } // // protected DService (NexusObject owner) { // _owner = owner; // _index = owner.registerAttr(this); // } // // /** Used by marshallers to dispatch calls over the network. */ // protected <R> RFuture<R> postCall (short methodId, Object... args) { // RPromise<R> result = RPromise.create(); // _owner.postCall(_index, methodId, args, result); // return result; // } // // /** Used by marshallers to dispatch calls over the network. */ // protected void postVoidCall (short methodId, Object... args) { // _owner.postCall(_index, methodId, args, null); // } // // /** The object that owns this attribute. */ // protected final NexusObject _owner; // // /** The index of this attribute in its containing object. */ // protected final short _index; // } // Path: gwt-server/src/main/java/com/threerings/nexus/io/ServerOutput.java import com.google.gwt.user.server.Base64Utils; import com.threerings.nexus.distrib.DService; _output.appendSeparator(); } @Override public void writeLong (long value) { _output._buffer.append('\'').append(Base64Utils.toBase64(value)).append('\''); _output.appendSeparator(); } @Override public void writeFloat (float value) { writeDouble(value); } @Override public void writeDouble (double value) { _output._buffer.append(String.valueOf(value)); _output.appendSeparator(); } @Override public void writeString (String value) { if (value == null) { _output._buffer.append("null"); } else { _output._buffer.append('\"').append(escapeString(value)).append('\"'); } _output.appendSeparator(); } @Override public void writeClass (Class<? extends Streamable> clazz) { writeShort(_szer.getCode(clazz)); }
@Override public void writeService (DService<?> service) {
threerings/nexus
core/src/main/java/com/threerings/nexus/io/Serializer.java
// Path: core/src/main/java/com/threerings/nexus/distrib/DService.java // public abstract class DService<T extends NexusService> implements DAttribute // { // /** Used to create service attributes. */ // public interface Factory<T extends NexusService> // { // /** Creates a service attribute with the supplied owner. */ // DService<T> createService (NexusObject owner); // } // // /** An implementation detail used by service dispatchers. */ // public static abstract class Dispatcher<T extends NexusService> extends DService<T> { // /** Dispatches a service call that came in over the network. */ // public RFuture<?> dispatchCall (short methodId, Object[] args) { // throw new IllegalArgumentException("Unknown service method [id=" + methodId + // ", obj=" + _owner.getClass().getName() + // ", attrIdx=" + _index + "]"); // } // // protected Dispatcher (NexusObject owner) { // super(owner); // } // // /** Used to concisely, and without warning, cast arguments of generic type. */ // @SuppressWarnings("unchecked") // protected final <C> C cast (Object obj) { // return (C)obj; // } // } // // /** Returns the service encapsulated by this attribute. */ // public abstract T get (); // // /** Returns the class for the service encapsulated by this attribute. */ // public abstract Class<T> getServiceClass (); // // @Override public void readContents (Streamable.Input in) { // // NOOP // } // // @Override public void writeContents (Streamable.Output out) { // // NOOP // } // // protected DService (NexusObject owner) { // _owner = owner; // _index = owner.registerAttr(this); // } // // /** Used by marshallers to dispatch calls over the network. */ // protected <R> RFuture<R> postCall (short methodId, Object... args) { // RPromise<R> result = RPromise.create(); // _owner.postCall(_index, methodId, args, result); // return result; // } // // /** Used by marshallers to dispatch calls over the network. */ // protected void postVoidCall (short methodId, Object... args) { // _owner.postCall(_index, methodId, args, null); // } // // /** The object that owns this attribute. */ // protected final NexusObject _owner; // // /** The index of this attribute in its containing object. */ // protected final short _index; // } // // Path: core/src/main/java/com/threerings/nexus/distrib/NexusService.java // public interface NexusService // { // }
import com.threerings.nexus.distrib.DService; import com.threerings.nexus.distrib.NexusService;
// // Nexus Core - a framework for developing distributed applications // http://github.com/threerings/nexus/blob/master/LICENSE package com.threerings.nexus.io; /** * An automatically generated class that knows about all {@link Streamable} and * {@link NexusService} classes that will be used by a client. This is used on platforms that lack * reflection capabilities. */ public interface Serializer { /** Returns the class assigned the supplied code. * @throws NexusException if no class is registered for the supplied code. */ Class<?> getClass (short code); /** Returns the streamer for the class assigned the supplied code. * @throws NexusException if no streamer is registered for the supplied code. */ Streamer<?> getStreamer (short code); /** Returns the service factory for the class assigned the supplied code. * @throws NexusException if no service is registered for the supplied code. */
// Path: core/src/main/java/com/threerings/nexus/distrib/DService.java // public abstract class DService<T extends NexusService> implements DAttribute // { // /** Used to create service attributes. */ // public interface Factory<T extends NexusService> // { // /** Creates a service attribute with the supplied owner. */ // DService<T> createService (NexusObject owner); // } // // /** An implementation detail used by service dispatchers. */ // public static abstract class Dispatcher<T extends NexusService> extends DService<T> { // /** Dispatches a service call that came in over the network. */ // public RFuture<?> dispatchCall (short methodId, Object[] args) { // throw new IllegalArgumentException("Unknown service method [id=" + methodId + // ", obj=" + _owner.getClass().getName() + // ", attrIdx=" + _index + "]"); // } // // protected Dispatcher (NexusObject owner) { // super(owner); // } // // /** Used to concisely, and without warning, cast arguments of generic type. */ // @SuppressWarnings("unchecked") // protected final <C> C cast (Object obj) { // return (C)obj; // } // } // // /** Returns the service encapsulated by this attribute. */ // public abstract T get (); // // /** Returns the class for the service encapsulated by this attribute. */ // public abstract Class<T> getServiceClass (); // // @Override public void readContents (Streamable.Input in) { // // NOOP // } // // @Override public void writeContents (Streamable.Output out) { // // NOOP // } // // protected DService (NexusObject owner) { // _owner = owner; // _index = owner.registerAttr(this); // } // // /** Used by marshallers to dispatch calls over the network. */ // protected <R> RFuture<R> postCall (short methodId, Object... args) { // RPromise<R> result = RPromise.create(); // _owner.postCall(_index, methodId, args, result); // return result; // } // // /** Used by marshallers to dispatch calls over the network. */ // protected void postVoidCall (short methodId, Object... args) { // _owner.postCall(_index, methodId, args, null); // } // // /** The object that owns this attribute. */ // protected final NexusObject _owner; // // /** The index of this attribute in its containing object. */ // protected final short _index; // } // // Path: core/src/main/java/com/threerings/nexus/distrib/NexusService.java // public interface NexusService // { // } // Path: core/src/main/java/com/threerings/nexus/io/Serializer.java import com.threerings.nexus.distrib.DService; import com.threerings.nexus.distrib.NexusService; // // Nexus Core - a framework for developing distributed applications // http://github.com/threerings/nexus/blob/master/LICENSE package com.threerings.nexus.io; /** * An automatically generated class that knows about all {@link Streamable} and * {@link NexusService} classes that will be used by a client. This is used on platforms that lack * reflection capabilities. */ public interface Serializer { /** Returns the class assigned the supplied code. * @throws NexusException if no class is registered for the supplied code. */ Class<?> getClass (short code); /** Returns the streamer for the class assigned the supplied code. * @throws NexusException if no streamer is registered for the supplied code. */ Streamer<?> getStreamer (short code); /** Returns the service factory for the class assigned the supplied code. * @throws NexusException if no service is registered for the supplied code. */
DService.Factory<?> getServiceFactory (short code);
threerings/nexus
core/src/main/java/com/threerings/nexus/io/Serializer.java
// Path: core/src/main/java/com/threerings/nexus/distrib/DService.java // public abstract class DService<T extends NexusService> implements DAttribute // { // /** Used to create service attributes. */ // public interface Factory<T extends NexusService> // { // /** Creates a service attribute with the supplied owner. */ // DService<T> createService (NexusObject owner); // } // // /** An implementation detail used by service dispatchers. */ // public static abstract class Dispatcher<T extends NexusService> extends DService<T> { // /** Dispatches a service call that came in over the network. */ // public RFuture<?> dispatchCall (short methodId, Object[] args) { // throw new IllegalArgumentException("Unknown service method [id=" + methodId + // ", obj=" + _owner.getClass().getName() + // ", attrIdx=" + _index + "]"); // } // // protected Dispatcher (NexusObject owner) { // super(owner); // } // // /** Used to concisely, and without warning, cast arguments of generic type. */ // @SuppressWarnings("unchecked") // protected final <C> C cast (Object obj) { // return (C)obj; // } // } // // /** Returns the service encapsulated by this attribute. */ // public abstract T get (); // // /** Returns the class for the service encapsulated by this attribute. */ // public abstract Class<T> getServiceClass (); // // @Override public void readContents (Streamable.Input in) { // // NOOP // } // // @Override public void writeContents (Streamable.Output out) { // // NOOP // } // // protected DService (NexusObject owner) { // _owner = owner; // _index = owner.registerAttr(this); // } // // /** Used by marshallers to dispatch calls over the network. */ // protected <R> RFuture<R> postCall (short methodId, Object... args) { // RPromise<R> result = RPromise.create(); // _owner.postCall(_index, methodId, args, result); // return result; // } // // /** Used by marshallers to dispatch calls over the network. */ // protected void postVoidCall (short methodId, Object... args) { // _owner.postCall(_index, methodId, args, null); // } // // /** The object that owns this attribute. */ // protected final NexusObject _owner; // // /** The index of this attribute in its containing object. */ // protected final short _index; // } // // Path: core/src/main/java/com/threerings/nexus/distrib/NexusService.java // public interface NexusService // { // }
import com.threerings.nexus.distrib.DService; import com.threerings.nexus.distrib.NexusService;
// // Nexus Core - a framework for developing distributed applications // http://github.com/threerings/nexus/blob/master/LICENSE package com.threerings.nexus.io; /** * An automatically generated class that knows about all {@link Streamable} and * {@link NexusService} classes that will be used by a client. This is used on platforms that lack * reflection capabilities. */ public interface Serializer { /** Returns the class assigned the supplied code. * @throws NexusException if no class is registered for the supplied code. */ Class<?> getClass (short code); /** Returns the streamer for the class assigned the supplied code. * @throws NexusException if no streamer is registered for the supplied code. */ Streamer<?> getStreamer (short code); /** Returns the service factory for the class assigned the supplied code. * @throws NexusException if no service is registered for the supplied code. */ DService.Factory<?> getServiceFactory (short code); /** Returns the code assigned to the supplied class. * @throws NexusException if the class in question is not registered. */ short getCode (Class<?> clazz); /** Returns the code assigned to the supplied service class. * @throws NexusException if the class in question is not registered. */
// Path: core/src/main/java/com/threerings/nexus/distrib/DService.java // public abstract class DService<T extends NexusService> implements DAttribute // { // /** Used to create service attributes. */ // public interface Factory<T extends NexusService> // { // /** Creates a service attribute with the supplied owner. */ // DService<T> createService (NexusObject owner); // } // // /** An implementation detail used by service dispatchers. */ // public static abstract class Dispatcher<T extends NexusService> extends DService<T> { // /** Dispatches a service call that came in over the network. */ // public RFuture<?> dispatchCall (short methodId, Object[] args) { // throw new IllegalArgumentException("Unknown service method [id=" + methodId + // ", obj=" + _owner.getClass().getName() + // ", attrIdx=" + _index + "]"); // } // // protected Dispatcher (NexusObject owner) { // super(owner); // } // // /** Used to concisely, and without warning, cast arguments of generic type. */ // @SuppressWarnings("unchecked") // protected final <C> C cast (Object obj) { // return (C)obj; // } // } // // /** Returns the service encapsulated by this attribute. */ // public abstract T get (); // // /** Returns the class for the service encapsulated by this attribute. */ // public abstract Class<T> getServiceClass (); // // @Override public void readContents (Streamable.Input in) { // // NOOP // } // // @Override public void writeContents (Streamable.Output out) { // // NOOP // } // // protected DService (NexusObject owner) { // _owner = owner; // _index = owner.registerAttr(this); // } // // /** Used by marshallers to dispatch calls over the network. */ // protected <R> RFuture<R> postCall (short methodId, Object... args) { // RPromise<R> result = RPromise.create(); // _owner.postCall(_index, methodId, args, result); // return result; // } // // /** Used by marshallers to dispatch calls over the network. */ // protected void postVoidCall (short methodId, Object... args) { // _owner.postCall(_index, methodId, args, null); // } // // /** The object that owns this attribute. */ // protected final NexusObject _owner; // // /** The index of this attribute in its containing object. */ // protected final short _index; // } // // Path: core/src/main/java/com/threerings/nexus/distrib/NexusService.java // public interface NexusService // { // } // Path: core/src/main/java/com/threerings/nexus/io/Serializer.java import com.threerings.nexus.distrib.DService; import com.threerings.nexus.distrib.NexusService; // // Nexus Core - a framework for developing distributed applications // http://github.com/threerings/nexus/blob/master/LICENSE package com.threerings.nexus.io; /** * An automatically generated class that knows about all {@link Streamable} and * {@link NexusService} classes that will be used by a client. This is used on platforms that lack * reflection capabilities. */ public interface Serializer { /** Returns the class assigned the supplied code. * @throws NexusException if no class is registered for the supplied code. */ Class<?> getClass (short code); /** Returns the streamer for the class assigned the supplied code. * @throws NexusException if no streamer is registered for the supplied code. */ Streamer<?> getStreamer (short code); /** Returns the service factory for the class assigned the supplied code. * @throws NexusException if no service is registered for the supplied code. */ DService.Factory<?> getServiceFactory (short code); /** Returns the code assigned to the supplied class. * @throws NexusException if the class in question is not registered. */ short getCode (Class<?> clazz); /** Returns the code assigned to the supplied service class. * @throws NexusException if the class in question is not registered. */
short getServiceCode (Class<? extends NexusService> clazz);
threerings/nexus
gwt-server/src/main/java/com/threerings/nexus/io/ServerInput.java
// Path: core/src/main/java/com/threerings/nexus/distrib/DService.java // public abstract class DService<T extends NexusService> implements DAttribute // { // /** Used to create service attributes. */ // public interface Factory<T extends NexusService> // { // /** Creates a service attribute with the supplied owner. */ // DService<T> createService (NexusObject owner); // } // // /** An implementation detail used by service dispatchers. */ // public static abstract class Dispatcher<T extends NexusService> extends DService<T> { // /** Dispatches a service call that came in over the network. */ // public RFuture<?> dispatchCall (short methodId, Object[] args) { // throw new IllegalArgumentException("Unknown service method [id=" + methodId + // ", obj=" + _owner.getClass().getName() + // ", attrIdx=" + _index + "]"); // } // // protected Dispatcher (NexusObject owner) { // super(owner); // } // // /** Used to concisely, and without warning, cast arguments of generic type. */ // @SuppressWarnings("unchecked") // protected final <C> C cast (Object obj) { // return (C)obj; // } // } // // /** Returns the service encapsulated by this attribute. */ // public abstract T get (); // // /** Returns the class for the service encapsulated by this attribute. */ // public abstract Class<T> getServiceClass (); // // @Override public void readContents (Streamable.Input in) { // // NOOP // } // // @Override public void writeContents (Streamable.Output out) { // // NOOP // } // // protected DService (NexusObject owner) { // _owner = owner; // _index = owner.registerAttr(this); // } // // /** Used by marshallers to dispatch calls over the network. */ // protected <R> RFuture<R> postCall (short methodId, Object... args) { // RPromise<R> result = RPromise.create(); // _owner.postCall(_index, methodId, args, result); // return result; // } // // /** Used by marshallers to dispatch calls over the network. */ // protected void postVoidCall (short methodId, Object... args) { // _owner.postCall(_index, methodId, args, null); // } // // /** The object that owns this attribute. */ // protected final NexusObject _owner; // // /** The index of this attribute in its containing object. */ // protected final short _index; // } // // Path: core/src/main/java/com/threerings/nexus/distrib/NexusService.java // public interface NexusService // { // }
import java.util.Iterator; import java.util.NoSuchElementException; import com.google.gwt.user.server.Base64Utils; import com.threerings.nexus.distrib.DService; import com.threerings.nexus.distrib.NexusService;
@Override public char readChar () { return (char)readInt(); } @Override public int readInt () { return Integer.parseInt(_valiter.next()); } @Override public long readLong () { return Base64Utils.longFromBase64(_valiter.next()); } @Override public float readFloat () { return (float)readDouble(); } @Override public double readDouble () { return Double.parseDouble(_valiter.next()); } @Override public String readString () { return readBoolean() ? _valiter.next() : null; // TODO: is wrong? } @Override public <T extends Streamable> Class<T> readClass () { @SuppressWarnings("unchecked") Class<T> c = (Class<T>)_szer.getClass(readShort()); return c; }
// Path: core/src/main/java/com/threerings/nexus/distrib/DService.java // public abstract class DService<T extends NexusService> implements DAttribute // { // /** Used to create service attributes. */ // public interface Factory<T extends NexusService> // { // /** Creates a service attribute with the supplied owner. */ // DService<T> createService (NexusObject owner); // } // // /** An implementation detail used by service dispatchers. */ // public static abstract class Dispatcher<T extends NexusService> extends DService<T> { // /** Dispatches a service call that came in over the network. */ // public RFuture<?> dispatchCall (short methodId, Object[] args) { // throw new IllegalArgumentException("Unknown service method [id=" + methodId + // ", obj=" + _owner.getClass().getName() + // ", attrIdx=" + _index + "]"); // } // // protected Dispatcher (NexusObject owner) { // super(owner); // } // // /** Used to concisely, and without warning, cast arguments of generic type. */ // @SuppressWarnings("unchecked") // protected final <C> C cast (Object obj) { // return (C)obj; // } // } // // /** Returns the service encapsulated by this attribute. */ // public abstract T get (); // // /** Returns the class for the service encapsulated by this attribute. */ // public abstract Class<T> getServiceClass (); // // @Override public void readContents (Streamable.Input in) { // // NOOP // } // // @Override public void writeContents (Streamable.Output out) { // // NOOP // } // // protected DService (NexusObject owner) { // _owner = owner; // _index = owner.registerAttr(this); // } // // /** Used by marshallers to dispatch calls over the network. */ // protected <R> RFuture<R> postCall (short methodId, Object... args) { // RPromise<R> result = RPromise.create(); // _owner.postCall(_index, methodId, args, result); // return result; // } // // /** Used by marshallers to dispatch calls over the network. */ // protected void postVoidCall (short methodId, Object... args) { // _owner.postCall(_index, methodId, args, null); // } // // /** The object that owns this attribute. */ // protected final NexusObject _owner; // // /** The index of this attribute in its containing object. */ // protected final short _index; // } // // Path: core/src/main/java/com/threerings/nexus/distrib/NexusService.java // public interface NexusService // { // } // Path: gwt-server/src/main/java/com/threerings/nexus/io/ServerInput.java import java.util.Iterator; import java.util.NoSuchElementException; import com.google.gwt.user.server.Base64Utils; import com.threerings.nexus.distrib.DService; import com.threerings.nexus.distrib.NexusService; @Override public char readChar () { return (char)readInt(); } @Override public int readInt () { return Integer.parseInt(_valiter.next()); } @Override public long readLong () { return Base64Utils.longFromBase64(_valiter.next()); } @Override public float readFloat () { return (float)readDouble(); } @Override public double readDouble () { return Double.parseDouble(_valiter.next()); } @Override public String readString () { return readBoolean() ? _valiter.next() : null; // TODO: is wrong? } @Override public <T extends Streamable> Class<T> readClass () { @SuppressWarnings("unchecked") Class<T> c = (Class<T>)_szer.getClass(readShort()); return c; }
@Override public <T extends NexusService> DService.Factory<T> readService () {
threerings/nexus
gwt-server/src/main/java/com/threerings/nexus/io/ServerInput.java
// Path: core/src/main/java/com/threerings/nexus/distrib/DService.java // public abstract class DService<T extends NexusService> implements DAttribute // { // /** Used to create service attributes. */ // public interface Factory<T extends NexusService> // { // /** Creates a service attribute with the supplied owner. */ // DService<T> createService (NexusObject owner); // } // // /** An implementation detail used by service dispatchers. */ // public static abstract class Dispatcher<T extends NexusService> extends DService<T> { // /** Dispatches a service call that came in over the network. */ // public RFuture<?> dispatchCall (short methodId, Object[] args) { // throw new IllegalArgumentException("Unknown service method [id=" + methodId + // ", obj=" + _owner.getClass().getName() + // ", attrIdx=" + _index + "]"); // } // // protected Dispatcher (NexusObject owner) { // super(owner); // } // // /** Used to concisely, and without warning, cast arguments of generic type. */ // @SuppressWarnings("unchecked") // protected final <C> C cast (Object obj) { // return (C)obj; // } // } // // /** Returns the service encapsulated by this attribute. */ // public abstract T get (); // // /** Returns the class for the service encapsulated by this attribute. */ // public abstract Class<T> getServiceClass (); // // @Override public void readContents (Streamable.Input in) { // // NOOP // } // // @Override public void writeContents (Streamable.Output out) { // // NOOP // } // // protected DService (NexusObject owner) { // _owner = owner; // _index = owner.registerAttr(this); // } // // /** Used by marshallers to dispatch calls over the network. */ // protected <R> RFuture<R> postCall (short methodId, Object... args) { // RPromise<R> result = RPromise.create(); // _owner.postCall(_index, methodId, args, result); // return result; // } // // /** Used by marshallers to dispatch calls over the network. */ // protected void postVoidCall (short methodId, Object... args) { // _owner.postCall(_index, methodId, args, null); // } // // /** The object that owns this attribute. */ // protected final NexusObject _owner; // // /** The index of this attribute in its containing object. */ // protected final short _index; // } // // Path: core/src/main/java/com/threerings/nexus/distrib/NexusService.java // public interface NexusService // { // }
import java.util.Iterator; import java.util.NoSuchElementException; import com.google.gwt.user.server.Base64Utils; import com.threerings.nexus.distrib.DService; import com.threerings.nexus.distrib.NexusService;
@Override public char readChar () { return (char)readInt(); } @Override public int readInt () { return Integer.parseInt(_valiter.next()); } @Override public long readLong () { return Base64Utils.longFromBase64(_valiter.next()); } @Override public float readFloat () { return (float)readDouble(); } @Override public double readDouble () { return Double.parseDouble(_valiter.next()); } @Override public String readString () { return readBoolean() ? _valiter.next() : null; // TODO: is wrong? } @Override public <T extends Streamable> Class<T> readClass () { @SuppressWarnings("unchecked") Class<T> c = (Class<T>)_szer.getClass(readShort()); return c; }
// Path: core/src/main/java/com/threerings/nexus/distrib/DService.java // public abstract class DService<T extends NexusService> implements DAttribute // { // /** Used to create service attributes. */ // public interface Factory<T extends NexusService> // { // /** Creates a service attribute with the supplied owner. */ // DService<T> createService (NexusObject owner); // } // // /** An implementation detail used by service dispatchers. */ // public static abstract class Dispatcher<T extends NexusService> extends DService<T> { // /** Dispatches a service call that came in over the network. */ // public RFuture<?> dispatchCall (short methodId, Object[] args) { // throw new IllegalArgumentException("Unknown service method [id=" + methodId + // ", obj=" + _owner.getClass().getName() + // ", attrIdx=" + _index + "]"); // } // // protected Dispatcher (NexusObject owner) { // super(owner); // } // // /** Used to concisely, and without warning, cast arguments of generic type. */ // @SuppressWarnings("unchecked") // protected final <C> C cast (Object obj) { // return (C)obj; // } // } // // /** Returns the service encapsulated by this attribute. */ // public abstract T get (); // // /** Returns the class for the service encapsulated by this attribute. */ // public abstract Class<T> getServiceClass (); // // @Override public void readContents (Streamable.Input in) { // // NOOP // } // // @Override public void writeContents (Streamable.Output out) { // // NOOP // } // // protected DService (NexusObject owner) { // _owner = owner; // _index = owner.registerAttr(this); // } // // /** Used by marshallers to dispatch calls over the network. */ // protected <R> RFuture<R> postCall (short methodId, Object... args) { // RPromise<R> result = RPromise.create(); // _owner.postCall(_index, methodId, args, result); // return result; // } // // /** Used by marshallers to dispatch calls over the network. */ // protected void postVoidCall (short methodId, Object... args) { // _owner.postCall(_index, methodId, args, null); // } // // /** The object that owns this attribute. */ // protected final NexusObject _owner; // // /** The index of this attribute in its containing object. */ // protected final short _index; // } // // Path: core/src/main/java/com/threerings/nexus/distrib/NexusService.java // public interface NexusService // { // } // Path: gwt-server/src/main/java/com/threerings/nexus/io/ServerInput.java import java.util.Iterator; import java.util.NoSuchElementException; import com.google.gwt.user.server.Base64Utils; import com.threerings.nexus.distrib.DService; import com.threerings.nexus.distrib.NexusService; @Override public char readChar () { return (char)readInt(); } @Override public int readInt () { return Integer.parseInt(_valiter.next()); } @Override public long readLong () { return Base64Utils.longFromBase64(_valiter.next()); } @Override public float readFloat () { return (float)readDouble(); } @Override public double readDouble () { return Double.parseDouble(_valiter.next()); } @Override public String readString () { return readBoolean() ? _valiter.next() : null; // TODO: is wrong? } @Override public <T extends Streamable> Class<T> readClass () { @SuppressWarnings("unchecked") Class<T> c = (Class<T>)_szer.getClass(readShort()); return c; }
@Override public <T extends NexusService> DService.Factory<T> readService () {
threerings/nexus
gwt-server/src/main/java/com/threerings/nexus/server/GWTIOJettyServlet.java
// Path: core/src/main/java/com/threerings/nexus/io/Serializer.java // public interface Serializer // { // /** Returns the class assigned the supplied code. // * @throws NexusException if no class is registered for the supplied code. */ // Class<?> getClass (short code); // // /** Returns the streamer for the class assigned the supplied code. // * @throws NexusException if no streamer is registered for the supplied code. */ // Streamer<?> getStreamer (short code); // // /** Returns the service factory for the class assigned the supplied code. // * @throws NexusException if no service is registered for the supplied code. */ // DService.Factory<?> getServiceFactory (short code); // // /** Returns the code assigned to the supplied class. // * @throws NexusException if the class in question is not registered. */ // short getCode (Class<?> clazz); // // /** Returns the code assigned to the supplied service class. // * @throws NexusException if the class in question is not registered. */ // short getServiceCode (Class<? extends NexusService> clazz); // // /** Writes the class code for the supplied value, and returns the streamer for same. // * @throws NexusException if the class for the value in question is not registered. */ // <T> Streamer<T> writeStreamer (Streamable.Output out, T value); // }
import org.eclipse.jetty.websocket.api.UpgradeRequest; import org.eclipse.jetty.websocket.api.UpgradeResponse; import org.eclipse.jetty.websocket.servlet.WebSocketCreator; import org.eclipse.jetty.websocket.servlet.WebSocketServlet; import org.eclipse.jetty.websocket.servlet.WebSocketServletFactory; import com.threerings.nexus.io.Serializer;
// // Nexus GWTServer - server-side support for Nexus GWT/WebSockets services // http://github.com/threerings/nexus/blob/master/LICENSE package com.threerings.nexus.server; /** * Wires our GWT/IO into Jetty WebSockets. */ public class GWTIOJettyServlet extends WebSocketServlet {
// Path: core/src/main/java/com/threerings/nexus/io/Serializer.java // public interface Serializer // { // /** Returns the class assigned the supplied code. // * @throws NexusException if no class is registered for the supplied code. */ // Class<?> getClass (short code); // // /** Returns the streamer for the class assigned the supplied code. // * @throws NexusException if no streamer is registered for the supplied code. */ // Streamer<?> getStreamer (short code); // // /** Returns the service factory for the class assigned the supplied code. // * @throws NexusException if no service is registered for the supplied code. */ // DService.Factory<?> getServiceFactory (short code); // // /** Returns the code assigned to the supplied class. // * @throws NexusException if the class in question is not registered. */ // short getCode (Class<?> clazz); // // /** Returns the code assigned to the supplied service class. // * @throws NexusException if the class in question is not registered. */ // short getServiceCode (Class<? extends NexusService> clazz); // // /** Writes the class code for the supplied value, and returns the streamer for same. // * @throws NexusException if the class for the value in question is not registered. */ // <T> Streamer<T> writeStreamer (Streamable.Output out, T value); // } // Path: gwt-server/src/main/java/com/threerings/nexus/server/GWTIOJettyServlet.java import org.eclipse.jetty.websocket.api.UpgradeRequest; import org.eclipse.jetty.websocket.api.UpgradeResponse; import org.eclipse.jetty.websocket.servlet.WebSocketCreator; import org.eclipse.jetty.websocket.servlet.WebSocketServlet; import org.eclipse.jetty.websocket.servlet.WebSocketServletFactory; import com.threerings.nexus.io.Serializer; // // Nexus GWTServer - server-side support for Nexus GWT/WebSockets services // http://github.com/threerings/nexus/blob/master/LICENSE package com.threerings.nexus.server; /** * Wires our GWT/IO into Jetty WebSockets. */ public class GWTIOJettyServlet extends WebSocketServlet {
public GWTIOJettyServlet (SessionManager smgr, Serializer szer) {
threerings/nexus
jvm-server/src/test/java/com/threerings/nexus/server/TestUtil.java
// Path: core/src/main/java/com/threerings/nexus/distrib/DService.java // public abstract class DService<T extends NexusService> implements DAttribute // { // /** Used to create service attributes. */ // public interface Factory<T extends NexusService> // { // /** Creates a service attribute with the supplied owner. */ // DService<T> createService (NexusObject owner); // } // // /** An implementation detail used by service dispatchers. */ // public static abstract class Dispatcher<T extends NexusService> extends DService<T> { // /** Dispatches a service call that came in over the network. */ // public RFuture<?> dispatchCall (short methodId, Object[] args) { // throw new IllegalArgumentException("Unknown service method [id=" + methodId + // ", obj=" + _owner.getClass().getName() + // ", attrIdx=" + _index + "]"); // } // // protected Dispatcher (NexusObject owner) { // super(owner); // } // // /** Used to concisely, and without warning, cast arguments of generic type. */ // @SuppressWarnings("unchecked") // protected final <C> C cast (Object obj) { // return (C)obj; // } // } // // /** Returns the service encapsulated by this attribute. */ // public abstract T get (); // // /** Returns the class for the service encapsulated by this attribute. */ // public abstract Class<T> getServiceClass (); // // @Override public void readContents (Streamable.Input in) { // // NOOP // } // // @Override public void writeContents (Streamable.Output out) { // // NOOP // } // // protected DService (NexusObject owner) { // _owner = owner; // _index = owner.registerAttr(this); // } // // /** Used by marshallers to dispatch calls over the network. */ // protected <R> RFuture<R> postCall (short methodId, Object... args) { // RPromise<R> result = RPromise.create(); // _owner.postCall(_index, methodId, args, result); // return result; // } // // /** Used by marshallers to dispatch calls over the network. */ // protected void postVoidCall (short methodId, Object... args) { // _owner.postCall(_index, methodId, args, null); // } // // /** The object that owns this attribute. */ // protected final NexusObject _owner; // // /** The index of this attribute in its containing object. */ // protected final short _index; // } // // Path: test-support/src/main/java/com/threerings/nexus/distrib/Factory_TestService.java // public class Factory_TestService implements DService.Factory<TestService> // { // @Override // public DService<TestService> createService (NexusObject owner) // { // return new Marshaller(owner); // } // // public static DService.Factory<TestService> createDispatcher (final TestService service) // { // return new DService.Factory<TestService>() { // public DService<TestService> createService (NexusObject owner) { // return new DService.Dispatcher<TestService>(owner) { // @Override public TestService get () { // return service; // } // // @Override public Class<TestService> getServiceClass () { // return TestService.class; // } // // @Override public RFuture<?> dispatchCall (short methodId, Object[] args) { // RFuture<?> result = null; // switch (methodId) { // case 1: // result = service.addOne( // this.<Integer>cast(args[0])); // break; // case 2: // service.launchMissiles(); // break; // default: // result = super.dispatchCall(methodId, args); // break; // } // return result; // } // }; // } // }; // } // // protected static class Marshaller extends DService<TestService> implements TestService // { // public Marshaller (NexusObject owner) { // super(owner); // } // @Override public TestService get () { // return this; // } // @Override public Class<TestService> getServiceClass () { // return TestService.class; // } // @Override public RFuture<Integer> addOne (int value) { // return this.<Integer>postCall((short)1, value); // } // @Override public void launchMissiles () { // postCall((short)2); // } // } // } // // Path: test-support/src/main/java/com/threerings/nexus/distrib/TestService.java // public interface TestService extends NexusService // { // /** Adds one to the supplied value. */ // RFuture<Integer> addOne (int value); // // /** Launches the missiles. Who needs confirmation for that? Pah! */ // void launchMissiles (); // }
import java.util.Properties; import java.util.concurrent.ExecutorService; import java.util.concurrent.TimeUnit; import react.RFuture; import com.threerings.nexus.distrib.DService; import com.threerings.nexus.distrib.Factory_TestService; import com.threerings.nexus.distrib.TestService; import org.junit.Assert;
// // Nexus JVMServer - server-side support for Nexus java.nio-based services // http://github.com/threerings/nexus/blob/master/LICENSE package com.threerings.nexus.server; /** * Test-related utility methods. */ public class TestUtil { public static NexusConfig createTestConfig () { Properties props = new Properties(); props.setProperty("nexus.node", "test"); props.setProperty("nexus.hostname", "localhost"); props.setProperty("nexus.rpc_timeout", "1000"); return new NexusConfig(props); } public static void awaitTermination (ExecutorService exec) { try { if (!exec.awaitTermination(2, TimeUnit.SECONDS)) { // TODO: change back to 10 Assert.fail("Executor failed to terminate after 10 seconds."); } } catch (InterruptedException ie) { Assert.fail("Executor interrupted?"); } }
// Path: core/src/main/java/com/threerings/nexus/distrib/DService.java // public abstract class DService<T extends NexusService> implements DAttribute // { // /** Used to create service attributes. */ // public interface Factory<T extends NexusService> // { // /** Creates a service attribute with the supplied owner. */ // DService<T> createService (NexusObject owner); // } // // /** An implementation detail used by service dispatchers. */ // public static abstract class Dispatcher<T extends NexusService> extends DService<T> { // /** Dispatches a service call that came in over the network. */ // public RFuture<?> dispatchCall (short methodId, Object[] args) { // throw new IllegalArgumentException("Unknown service method [id=" + methodId + // ", obj=" + _owner.getClass().getName() + // ", attrIdx=" + _index + "]"); // } // // protected Dispatcher (NexusObject owner) { // super(owner); // } // // /** Used to concisely, and without warning, cast arguments of generic type. */ // @SuppressWarnings("unchecked") // protected final <C> C cast (Object obj) { // return (C)obj; // } // } // // /** Returns the service encapsulated by this attribute. */ // public abstract T get (); // // /** Returns the class for the service encapsulated by this attribute. */ // public abstract Class<T> getServiceClass (); // // @Override public void readContents (Streamable.Input in) { // // NOOP // } // // @Override public void writeContents (Streamable.Output out) { // // NOOP // } // // protected DService (NexusObject owner) { // _owner = owner; // _index = owner.registerAttr(this); // } // // /** Used by marshallers to dispatch calls over the network. */ // protected <R> RFuture<R> postCall (short methodId, Object... args) { // RPromise<R> result = RPromise.create(); // _owner.postCall(_index, methodId, args, result); // return result; // } // // /** Used by marshallers to dispatch calls over the network. */ // protected void postVoidCall (short methodId, Object... args) { // _owner.postCall(_index, methodId, args, null); // } // // /** The object that owns this attribute. */ // protected final NexusObject _owner; // // /** The index of this attribute in its containing object. */ // protected final short _index; // } // // Path: test-support/src/main/java/com/threerings/nexus/distrib/Factory_TestService.java // public class Factory_TestService implements DService.Factory<TestService> // { // @Override // public DService<TestService> createService (NexusObject owner) // { // return new Marshaller(owner); // } // // public static DService.Factory<TestService> createDispatcher (final TestService service) // { // return new DService.Factory<TestService>() { // public DService<TestService> createService (NexusObject owner) { // return new DService.Dispatcher<TestService>(owner) { // @Override public TestService get () { // return service; // } // // @Override public Class<TestService> getServiceClass () { // return TestService.class; // } // // @Override public RFuture<?> dispatchCall (short methodId, Object[] args) { // RFuture<?> result = null; // switch (methodId) { // case 1: // result = service.addOne( // this.<Integer>cast(args[0])); // break; // case 2: // service.launchMissiles(); // break; // default: // result = super.dispatchCall(methodId, args); // break; // } // return result; // } // }; // } // }; // } // // protected static class Marshaller extends DService<TestService> implements TestService // { // public Marshaller (NexusObject owner) { // super(owner); // } // @Override public TestService get () { // return this; // } // @Override public Class<TestService> getServiceClass () { // return TestService.class; // } // @Override public RFuture<Integer> addOne (int value) { // return this.<Integer>postCall((short)1, value); // } // @Override public void launchMissiles () { // postCall((short)2); // } // } // } // // Path: test-support/src/main/java/com/threerings/nexus/distrib/TestService.java // public interface TestService extends NexusService // { // /** Adds one to the supplied value. */ // RFuture<Integer> addOne (int value); // // /** Launches the missiles. Who needs confirmation for that? Pah! */ // void launchMissiles (); // } // Path: jvm-server/src/test/java/com/threerings/nexus/server/TestUtil.java import java.util.Properties; import java.util.concurrent.ExecutorService; import java.util.concurrent.TimeUnit; import react.RFuture; import com.threerings.nexus.distrib.DService; import com.threerings.nexus.distrib.Factory_TestService; import com.threerings.nexus.distrib.TestService; import org.junit.Assert; // // Nexus JVMServer - server-side support for Nexus java.nio-based services // http://github.com/threerings/nexus/blob/master/LICENSE package com.threerings.nexus.server; /** * Test-related utility methods. */ public class TestUtil { public static NexusConfig createTestConfig () { Properties props = new Properties(); props.setProperty("nexus.node", "test"); props.setProperty("nexus.hostname", "localhost"); props.setProperty("nexus.rpc_timeout", "1000"); return new NexusConfig(props); } public static void awaitTermination (ExecutorService exec) { try { if (!exec.awaitTermination(2, TimeUnit.SECONDS)) { // TODO: change back to 10 Assert.fail("Executor failed to terminate after 10 seconds."); } } catch (InterruptedException ie) { Assert.fail("Executor interrupted?"); } }
public static DService.Factory<TestService> createTestServiceAttr () {
threerings/nexus
jvm-server/src/test/java/com/threerings/nexus/server/TestUtil.java
// Path: core/src/main/java/com/threerings/nexus/distrib/DService.java // public abstract class DService<T extends NexusService> implements DAttribute // { // /** Used to create service attributes. */ // public interface Factory<T extends NexusService> // { // /** Creates a service attribute with the supplied owner. */ // DService<T> createService (NexusObject owner); // } // // /** An implementation detail used by service dispatchers. */ // public static abstract class Dispatcher<T extends NexusService> extends DService<T> { // /** Dispatches a service call that came in over the network. */ // public RFuture<?> dispatchCall (short methodId, Object[] args) { // throw new IllegalArgumentException("Unknown service method [id=" + methodId + // ", obj=" + _owner.getClass().getName() + // ", attrIdx=" + _index + "]"); // } // // protected Dispatcher (NexusObject owner) { // super(owner); // } // // /** Used to concisely, and without warning, cast arguments of generic type. */ // @SuppressWarnings("unchecked") // protected final <C> C cast (Object obj) { // return (C)obj; // } // } // // /** Returns the service encapsulated by this attribute. */ // public abstract T get (); // // /** Returns the class for the service encapsulated by this attribute. */ // public abstract Class<T> getServiceClass (); // // @Override public void readContents (Streamable.Input in) { // // NOOP // } // // @Override public void writeContents (Streamable.Output out) { // // NOOP // } // // protected DService (NexusObject owner) { // _owner = owner; // _index = owner.registerAttr(this); // } // // /** Used by marshallers to dispatch calls over the network. */ // protected <R> RFuture<R> postCall (short methodId, Object... args) { // RPromise<R> result = RPromise.create(); // _owner.postCall(_index, methodId, args, result); // return result; // } // // /** Used by marshallers to dispatch calls over the network. */ // protected void postVoidCall (short methodId, Object... args) { // _owner.postCall(_index, methodId, args, null); // } // // /** The object that owns this attribute. */ // protected final NexusObject _owner; // // /** The index of this attribute in its containing object. */ // protected final short _index; // } // // Path: test-support/src/main/java/com/threerings/nexus/distrib/Factory_TestService.java // public class Factory_TestService implements DService.Factory<TestService> // { // @Override // public DService<TestService> createService (NexusObject owner) // { // return new Marshaller(owner); // } // // public static DService.Factory<TestService> createDispatcher (final TestService service) // { // return new DService.Factory<TestService>() { // public DService<TestService> createService (NexusObject owner) { // return new DService.Dispatcher<TestService>(owner) { // @Override public TestService get () { // return service; // } // // @Override public Class<TestService> getServiceClass () { // return TestService.class; // } // // @Override public RFuture<?> dispatchCall (short methodId, Object[] args) { // RFuture<?> result = null; // switch (methodId) { // case 1: // result = service.addOne( // this.<Integer>cast(args[0])); // break; // case 2: // service.launchMissiles(); // break; // default: // result = super.dispatchCall(methodId, args); // break; // } // return result; // } // }; // } // }; // } // // protected static class Marshaller extends DService<TestService> implements TestService // { // public Marshaller (NexusObject owner) { // super(owner); // } // @Override public TestService get () { // return this; // } // @Override public Class<TestService> getServiceClass () { // return TestService.class; // } // @Override public RFuture<Integer> addOne (int value) { // return this.<Integer>postCall((short)1, value); // } // @Override public void launchMissiles () { // postCall((short)2); // } // } // } // // Path: test-support/src/main/java/com/threerings/nexus/distrib/TestService.java // public interface TestService extends NexusService // { // /** Adds one to the supplied value. */ // RFuture<Integer> addOne (int value); // // /** Launches the missiles. Who needs confirmation for that? Pah! */ // void launchMissiles (); // }
import java.util.Properties; import java.util.concurrent.ExecutorService; import java.util.concurrent.TimeUnit; import react.RFuture; import com.threerings.nexus.distrib.DService; import com.threerings.nexus.distrib.Factory_TestService; import com.threerings.nexus.distrib.TestService; import org.junit.Assert;
// // Nexus JVMServer - server-side support for Nexus java.nio-based services // http://github.com/threerings/nexus/blob/master/LICENSE package com.threerings.nexus.server; /** * Test-related utility methods. */ public class TestUtil { public static NexusConfig createTestConfig () { Properties props = new Properties(); props.setProperty("nexus.node", "test"); props.setProperty("nexus.hostname", "localhost"); props.setProperty("nexus.rpc_timeout", "1000"); return new NexusConfig(props); } public static void awaitTermination (ExecutorService exec) { try { if (!exec.awaitTermination(2, TimeUnit.SECONDS)) { // TODO: change back to 10 Assert.fail("Executor failed to terminate after 10 seconds."); } } catch (InterruptedException ie) { Assert.fail("Executor interrupted?"); } }
// Path: core/src/main/java/com/threerings/nexus/distrib/DService.java // public abstract class DService<T extends NexusService> implements DAttribute // { // /** Used to create service attributes. */ // public interface Factory<T extends NexusService> // { // /** Creates a service attribute with the supplied owner. */ // DService<T> createService (NexusObject owner); // } // // /** An implementation detail used by service dispatchers. */ // public static abstract class Dispatcher<T extends NexusService> extends DService<T> { // /** Dispatches a service call that came in over the network. */ // public RFuture<?> dispatchCall (short methodId, Object[] args) { // throw new IllegalArgumentException("Unknown service method [id=" + methodId + // ", obj=" + _owner.getClass().getName() + // ", attrIdx=" + _index + "]"); // } // // protected Dispatcher (NexusObject owner) { // super(owner); // } // // /** Used to concisely, and without warning, cast arguments of generic type. */ // @SuppressWarnings("unchecked") // protected final <C> C cast (Object obj) { // return (C)obj; // } // } // // /** Returns the service encapsulated by this attribute. */ // public abstract T get (); // // /** Returns the class for the service encapsulated by this attribute. */ // public abstract Class<T> getServiceClass (); // // @Override public void readContents (Streamable.Input in) { // // NOOP // } // // @Override public void writeContents (Streamable.Output out) { // // NOOP // } // // protected DService (NexusObject owner) { // _owner = owner; // _index = owner.registerAttr(this); // } // // /** Used by marshallers to dispatch calls over the network. */ // protected <R> RFuture<R> postCall (short methodId, Object... args) { // RPromise<R> result = RPromise.create(); // _owner.postCall(_index, methodId, args, result); // return result; // } // // /** Used by marshallers to dispatch calls over the network. */ // protected void postVoidCall (short methodId, Object... args) { // _owner.postCall(_index, methodId, args, null); // } // // /** The object that owns this attribute. */ // protected final NexusObject _owner; // // /** The index of this attribute in its containing object. */ // protected final short _index; // } // // Path: test-support/src/main/java/com/threerings/nexus/distrib/Factory_TestService.java // public class Factory_TestService implements DService.Factory<TestService> // { // @Override // public DService<TestService> createService (NexusObject owner) // { // return new Marshaller(owner); // } // // public static DService.Factory<TestService> createDispatcher (final TestService service) // { // return new DService.Factory<TestService>() { // public DService<TestService> createService (NexusObject owner) { // return new DService.Dispatcher<TestService>(owner) { // @Override public TestService get () { // return service; // } // // @Override public Class<TestService> getServiceClass () { // return TestService.class; // } // // @Override public RFuture<?> dispatchCall (short methodId, Object[] args) { // RFuture<?> result = null; // switch (methodId) { // case 1: // result = service.addOne( // this.<Integer>cast(args[0])); // break; // case 2: // service.launchMissiles(); // break; // default: // result = super.dispatchCall(methodId, args); // break; // } // return result; // } // }; // } // }; // } // // protected static class Marshaller extends DService<TestService> implements TestService // { // public Marshaller (NexusObject owner) { // super(owner); // } // @Override public TestService get () { // return this; // } // @Override public Class<TestService> getServiceClass () { // return TestService.class; // } // @Override public RFuture<Integer> addOne (int value) { // return this.<Integer>postCall((short)1, value); // } // @Override public void launchMissiles () { // postCall((short)2); // } // } // } // // Path: test-support/src/main/java/com/threerings/nexus/distrib/TestService.java // public interface TestService extends NexusService // { // /** Adds one to the supplied value. */ // RFuture<Integer> addOne (int value); // // /** Launches the missiles. Who needs confirmation for that? Pah! */ // void launchMissiles (); // } // Path: jvm-server/src/test/java/com/threerings/nexus/server/TestUtil.java import java.util.Properties; import java.util.concurrent.ExecutorService; import java.util.concurrent.TimeUnit; import react.RFuture; import com.threerings.nexus.distrib.DService; import com.threerings.nexus.distrib.Factory_TestService; import com.threerings.nexus.distrib.TestService; import org.junit.Assert; // // Nexus JVMServer - server-side support for Nexus java.nio-based services // http://github.com/threerings/nexus/blob/master/LICENSE package com.threerings.nexus.server; /** * Test-related utility methods. */ public class TestUtil { public static NexusConfig createTestConfig () { Properties props = new Properties(); props.setProperty("nexus.node", "test"); props.setProperty("nexus.hostname", "localhost"); props.setProperty("nexus.rpc_timeout", "1000"); return new NexusConfig(props); } public static void awaitTermination (ExecutorService exec) { try { if (!exec.awaitTermination(2, TimeUnit.SECONDS)) { // TODO: change back to 10 Assert.fail("Executor failed to terminate after 10 seconds."); } } catch (InterruptedException ie) { Assert.fail("Executor interrupted?"); } }
public static DService.Factory<TestService> createTestServiceAttr () {
threerings/nexus
jvm-server/src/test/java/com/threerings/nexus/server/TestUtil.java
// Path: core/src/main/java/com/threerings/nexus/distrib/DService.java // public abstract class DService<T extends NexusService> implements DAttribute // { // /** Used to create service attributes. */ // public interface Factory<T extends NexusService> // { // /** Creates a service attribute with the supplied owner. */ // DService<T> createService (NexusObject owner); // } // // /** An implementation detail used by service dispatchers. */ // public static abstract class Dispatcher<T extends NexusService> extends DService<T> { // /** Dispatches a service call that came in over the network. */ // public RFuture<?> dispatchCall (short methodId, Object[] args) { // throw new IllegalArgumentException("Unknown service method [id=" + methodId + // ", obj=" + _owner.getClass().getName() + // ", attrIdx=" + _index + "]"); // } // // protected Dispatcher (NexusObject owner) { // super(owner); // } // // /** Used to concisely, and without warning, cast arguments of generic type. */ // @SuppressWarnings("unchecked") // protected final <C> C cast (Object obj) { // return (C)obj; // } // } // // /** Returns the service encapsulated by this attribute. */ // public abstract T get (); // // /** Returns the class for the service encapsulated by this attribute. */ // public abstract Class<T> getServiceClass (); // // @Override public void readContents (Streamable.Input in) { // // NOOP // } // // @Override public void writeContents (Streamable.Output out) { // // NOOP // } // // protected DService (NexusObject owner) { // _owner = owner; // _index = owner.registerAttr(this); // } // // /** Used by marshallers to dispatch calls over the network. */ // protected <R> RFuture<R> postCall (short methodId, Object... args) { // RPromise<R> result = RPromise.create(); // _owner.postCall(_index, methodId, args, result); // return result; // } // // /** Used by marshallers to dispatch calls over the network. */ // protected void postVoidCall (short methodId, Object... args) { // _owner.postCall(_index, methodId, args, null); // } // // /** The object that owns this attribute. */ // protected final NexusObject _owner; // // /** The index of this attribute in its containing object. */ // protected final short _index; // } // // Path: test-support/src/main/java/com/threerings/nexus/distrib/Factory_TestService.java // public class Factory_TestService implements DService.Factory<TestService> // { // @Override // public DService<TestService> createService (NexusObject owner) // { // return new Marshaller(owner); // } // // public static DService.Factory<TestService> createDispatcher (final TestService service) // { // return new DService.Factory<TestService>() { // public DService<TestService> createService (NexusObject owner) { // return new DService.Dispatcher<TestService>(owner) { // @Override public TestService get () { // return service; // } // // @Override public Class<TestService> getServiceClass () { // return TestService.class; // } // // @Override public RFuture<?> dispatchCall (short methodId, Object[] args) { // RFuture<?> result = null; // switch (methodId) { // case 1: // result = service.addOne( // this.<Integer>cast(args[0])); // break; // case 2: // service.launchMissiles(); // break; // default: // result = super.dispatchCall(methodId, args); // break; // } // return result; // } // }; // } // }; // } // // protected static class Marshaller extends DService<TestService> implements TestService // { // public Marshaller (NexusObject owner) { // super(owner); // } // @Override public TestService get () { // return this; // } // @Override public Class<TestService> getServiceClass () { // return TestService.class; // } // @Override public RFuture<Integer> addOne (int value) { // return this.<Integer>postCall((short)1, value); // } // @Override public void launchMissiles () { // postCall((short)2); // } // } // } // // Path: test-support/src/main/java/com/threerings/nexus/distrib/TestService.java // public interface TestService extends NexusService // { // /** Adds one to the supplied value. */ // RFuture<Integer> addOne (int value); // // /** Launches the missiles. Who needs confirmation for that? Pah! */ // void launchMissiles (); // }
import java.util.Properties; import java.util.concurrent.ExecutorService; import java.util.concurrent.TimeUnit; import react.RFuture; import com.threerings.nexus.distrib.DService; import com.threerings.nexus.distrib.Factory_TestService; import com.threerings.nexus.distrib.TestService; import org.junit.Assert;
// // Nexus JVMServer - server-side support for Nexus java.nio-based services // http://github.com/threerings/nexus/blob/master/LICENSE package com.threerings.nexus.server; /** * Test-related utility methods. */ public class TestUtil { public static NexusConfig createTestConfig () { Properties props = new Properties(); props.setProperty("nexus.node", "test"); props.setProperty("nexus.hostname", "localhost"); props.setProperty("nexus.rpc_timeout", "1000"); return new NexusConfig(props); } public static void awaitTermination (ExecutorService exec) { try { if (!exec.awaitTermination(2, TimeUnit.SECONDS)) { // TODO: change back to 10 Assert.fail("Executor failed to terminate after 10 seconds."); } } catch (InterruptedException ie) { Assert.fail("Executor interrupted?"); } } public static DService.Factory<TestService> createTestServiceAttr () {
// Path: core/src/main/java/com/threerings/nexus/distrib/DService.java // public abstract class DService<T extends NexusService> implements DAttribute // { // /** Used to create service attributes. */ // public interface Factory<T extends NexusService> // { // /** Creates a service attribute with the supplied owner. */ // DService<T> createService (NexusObject owner); // } // // /** An implementation detail used by service dispatchers. */ // public static abstract class Dispatcher<T extends NexusService> extends DService<T> { // /** Dispatches a service call that came in over the network. */ // public RFuture<?> dispatchCall (short methodId, Object[] args) { // throw new IllegalArgumentException("Unknown service method [id=" + methodId + // ", obj=" + _owner.getClass().getName() + // ", attrIdx=" + _index + "]"); // } // // protected Dispatcher (NexusObject owner) { // super(owner); // } // // /** Used to concisely, and without warning, cast arguments of generic type. */ // @SuppressWarnings("unchecked") // protected final <C> C cast (Object obj) { // return (C)obj; // } // } // // /** Returns the service encapsulated by this attribute. */ // public abstract T get (); // // /** Returns the class for the service encapsulated by this attribute. */ // public abstract Class<T> getServiceClass (); // // @Override public void readContents (Streamable.Input in) { // // NOOP // } // // @Override public void writeContents (Streamable.Output out) { // // NOOP // } // // protected DService (NexusObject owner) { // _owner = owner; // _index = owner.registerAttr(this); // } // // /** Used by marshallers to dispatch calls over the network. */ // protected <R> RFuture<R> postCall (short methodId, Object... args) { // RPromise<R> result = RPromise.create(); // _owner.postCall(_index, methodId, args, result); // return result; // } // // /** Used by marshallers to dispatch calls over the network. */ // protected void postVoidCall (short methodId, Object... args) { // _owner.postCall(_index, methodId, args, null); // } // // /** The object that owns this attribute. */ // protected final NexusObject _owner; // // /** The index of this attribute in its containing object. */ // protected final short _index; // } // // Path: test-support/src/main/java/com/threerings/nexus/distrib/Factory_TestService.java // public class Factory_TestService implements DService.Factory<TestService> // { // @Override // public DService<TestService> createService (NexusObject owner) // { // return new Marshaller(owner); // } // // public static DService.Factory<TestService> createDispatcher (final TestService service) // { // return new DService.Factory<TestService>() { // public DService<TestService> createService (NexusObject owner) { // return new DService.Dispatcher<TestService>(owner) { // @Override public TestService get () { // return service; // } // // @Override public Class<TestService> getServiceClass () { // return TestService.class; // } // // @Override public RFuture<?> dispatchCall (short methodId, Object[] args) { // RFuture<?> result = null; // switch (methodId) { // case 1: // result = service.addOne( // this.<Integer>cast(args[0])); // break; // case 2: // service.launchMissiles(); // break; // default: // result = super.dispatchCall(methodId, args); // break; // } // return result; // } // }; // } // }; // } // // protected static class Marshaller extends DService<TestService> implements TestService // { // public Marshaller (NexusObject owner) { // super(owner); // } // @Override public TestService get () { // return this; // } // @Override public Class<TestService> getServiceClass () { // return TestService.class; // } // @Override public RFuture<Integer> addOne (int value) { // return this.<Integer>postCall((short)1, value); // } // @Override public void launchMissiles () { // postCall((short)2); // } // } // } // // Path: test-support/src/main/java/com/threerings/nexus/distrib/TestService.java // public interface TestService extends NexusService // { // /** Adds one to the supplied value. */ // RFuture<Integer> addOne (int value); // // /** Launches the missiles. Who needs confirmation for that? Pah! */ // void launchMissiles (); // } // Path: jvm-server/src/test/java/com/threerings/nexus/server/TestUtil.java import java.util.Properties; import java.util.concurrent.ExecutorService; import java.util.concurrent.TimeUnit; import react.RFuture; import com.threerings.nexus.distrib.DService; import com.threerings.nexus.distrib.Factory_TestService; import com.threerings.nexus.distrib.TestService; import org.junit.Assert; // // Nexus JVMServer - server-side support for Nexus java.nio-based services // http://github.com/threerings/nexus/blob/master/LICENSE package com.threerings.nexus.server; /** * Test-related utility methods. */ public class TestUtil { public static NexusConfig createTestConfig () { Properties props = new Properties(); props.setProperty("nexus.node", "test"); props.setProperty("nexus.hostname", "localhost"); props.setProperty("nexus.rpc_timeout", "1000"); return new NexusConfig(props); } public static void awaitTermination (ExecutorService exec) { try { if (!exec.awaitTermination(2, TimeUnit.SECONDS)) { // TODO: change back to 10 Assert.fail("Executor failed to terminate after 10 seconds."); } } catch (InterruptedException ie) { Assert.fail("Executor interrupted?"); } } public static DService.Factory<TestService> createTestServiceAttr () {
return Factory_TestService.createDispatcher(new TestService () {
jmcampanini/gexf4j-core
src/main/java/com/ojn/gexf4j/core/impl/data/AttributeValueListImpl.java
// Path: src/main/java/com/ojn/gexf4j/core/data/Attribute.java // public interface Attribute { // // String getId(); // // String getTitle(); // Attribute setTitle(String title); // // AttributeType getAttributeType(); // // boolean hasDefaultValue(); // Attribute clearDefaultValue(); // String getDefaultValue(); // Attribute setDefaultValue(String defaultValue); // // List<String> getOptions(); // // AttributeValue createValue(String value); // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeValue.java // public interface AttributeValue extends Dynamic<AttributeValue> { // // Attribute getAttribute(); // // String getValue(); // AttributeValue setValue(String value); // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeValueList.java // public interface AttributeValueList extends List<AttributeValue> { // // AttributeValueList addValue(Attribute attribute, String value); // // AttributeValue createValue(Attribute attribute, String value); // }
import static com.google.common.base.Preconditions.checkArgument; import java.util.ArrayList; import com.ojn.gexf4j.core.data.Attribute; import com.ojn.gexf4j.core.data.AttributeValue; import com.ojn.gexf4j.core.data.AttributeValueList;
package com.ojn.gexf4j.core.impl.data; public class AttributeValueListImpl extends ArrayList<AttributeValue> implements AttributeValueList { private static final long serialVersionUID = 7730475001078826140L; public AttributeValueListImpl() { // do nothing } @Override
// Path: src/main/java/com/ojn/gexf4j/core/data/Attribute.java // public interface Attribute { // // String getId(); // // String getTitle(); // Attribute setTitle(String title); // // AttributeType getAttributeType(); // // boolean hasDefaultValue(); // Attribute clearDefaultValue(); // String getDefaultValue(); // Attribute setDefaultValue(String defaultValue); // // List<String> getOptions(); // // AttributeValue createValue(String value); // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeValue.java // public interface AttributeValue extends Dynamic<AttributeValue> { // // Attribute getAttribute(); // // String getValue(); // AttributeValue setValue(String value); // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeValueList.java // public interface AttributeValueList extends List<AttributeValue> { // // AttributeValueList addValue(Attribute attribute, String value); // // AttributeValue createValue(Attribute attribute, String value); // } // Path: src/main/java/com/ojn/gexf4j/core/impl/data/AttributeValueListImpl.java import static com.google.common.base.Preconditions.checkArgument; import java.util.ArrayList; import com.ojn.gexf4j.core.data.Attribute; import com.ojn.gexf4j.core.data.AttributeValue; import com.ojn.gexf4j.core.data.AttributeValueList; package com.ojn.gexf4j.core.impl.data; public class AttributeValueListImpl extends ArrayList<AttributeValue> implements AttributeValueList { private static final long serialVersionUID = 7730475001078826140L; public AttributeValueListImpl() { // do nothing } @Override
public AttributeValueList addValue(Attribute attribute, String value) {
jmcampanini/gexf4j-core
src/main/java/com/ojn/gexf4j/core/Edge.java
// Path: src/main/java/com/ojn/gexf4j/core/viz/Color.java // public interface Color { // // int getR(); // Color setR(int r); // // int getG(); // Color setG(int g); // // int getB(); // Color setB(int b); // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/EdgeShape.java // public enum EdgeShape { // // SOLID, // DOTTED, // DASHED, // DOUBLE, // NOTSET, // }
import com.ojn.gexf4j.core.viz.Color; import com.ojn.gexf4j.core.viz.EdgeShape;
package com.ojn.gexf4j.core; public interface Edge extends SlicableDatum<Edge> { String getId(); Node getSource(); Node getTarget(); Edge setTarget(Node target); boolean hasLabel(); Edge clearLabel(); String getLabel(); Edge setLabel(String label); boolean hasWeight(); Edge clearWeight(); float getWeight(); Edge setWeight(float weight); EdgeType getEdgeType(); Edge setEdgeType(EdgeType edgeType); boolean hasColor(); Edge clearColor();
// Path: src/main/java/com/ojn/gexf4j/core/viz/Color.java // public interface Color { // // int getR(); // Color setR(int r); // // int getG(); // Color setG(int g); // // int getB(); // Color setB(int b); // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/EdgeShape.java // public enum EdgeShape { // // SOLID, // DOTTED, // DASHED, // DOUBLE, // NOTSET, // } // Path: src/main/java/com/ojn/gexf4j/core/Edge.java import com.ojn.gexf4j.core.viz.Color; import com.ojn.gexf4j.core.viz.EdgeShape; package com.ojn.gexf4j.core; public interface Edge extends SlicableDatum<Edge> { String getId(); Node getSource(); Node getTarget(); Edge setTarget(Node target); boolean hasLabel(); Edge clearLabel(); String getLabel(); Edge setLabel(String label); boolean hasWeight(); Edge clearWeight(); float getWeight(); Edge setWeight(float weight); EdgeType getEdgeType(); Edge setEdgeType(EdgeType edgeType); boolean hasColor(); Edge clearColor();
Color getColor();
jmcampanini/gexf4j-core
src/main/java/com/ojn/gexf4j/core/Edge.java
// Path: src/main/java/com/ojn/gexf4j/core/viz/Color.java // public interface Color { // // int getR(); // Color setR(int r); // // int getG(); // Color setG(int g); // // int getB(); // Color setB(int b); // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/EdgeShape.java // public enum EdgeShape { // // SOLID, // DOTTED, // DASHED, // DOUBLE, // NOTSET, // }
import com.ojn.gexf4j.core.viz.Color; import com.ojn.gexf4j.core.viz.EdgeShape;
package com.ojn.gexf4j.core; public interface Edge extends SlicableDatum<Edge> { String getId(); Node getSource(); Node getTarget(); Edge setTarget(Node target); boolean hasLabel(); Edge clearLabel(); String getLabel(); Edge setLabel(String label); boolean hasWeight(); Edge clearWeight(); float getWeight(); Edge setWeight(float weight); EdgeType getEdgeType(); Edge setEdgeType(EdgeType edgeType); boolean hasColor(); Edge clearColor(); Color getColor(); Edge setColor(Color color); boolean hasThickness(); Edge clearThickness(); float getThickness(); Edge setThickness(float thickness);
// Path: src/main/java/com/ojn/gexf4j/core/viz/Color.java // public interface Color { // // int getR(); // Color setR(int r); // // int getG(); // Color setG(int g); // // int getB(); // Color setB(int b); // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/EdgeShape.java // public enum EdgeShape { // // SOLID, // DOTTED, // DASHED, // DOUBLE, // NOTSET, // } // Path: src/main/java/com/ojn/gexf4j/core/Edge.java import com.ojn.gexf4j.core.viz.Color; import com.ojn.gexf4j.core.viz.EdgeShape; package com.ojn.gexf4j.core; public interface Edge extends SlicableDatum<Edge> { String getId(); Node getSource(); Node getTarget(); Edge setTarget(Node target); boolean hasLabel(); Edge clearLabel(); String getLabel(); Edge setLabel(String label); boolean hasWeight(); Edge clearWeight(); float getWeight(); Edge setWeight(float weight); EdgeType getEdgeType(); Edge setEdgeType(EdgeType edgeType); boolean hasColor(); Edge clearColor(); Color getColor(); Edge setColor(Color color); boolean hasThickness(); Edge clearThickness(); float getThickness(); Edge setThickness(float thickness);
EdgeShape getShape();
jmcampanini/gexf4j-core
src/test/java/com/ojn/gexf4j/core/testgraphs/HierarchyPIDBuilder.java
// Path: src/main/java/com/ojn/gexf4j/core/EdgeType.java // public enum EdgeType { // // DIRECTED, // UNDIRECTED, // MUTUAL, // } // // Path: src/main/java/com/ojn/gexf4j/core/Gexf.java // public interface Gexf { // // String getVersion(); // // boolean hasVariant(); // Gexf clearVariant(); // String getVariant(); // Gexf setVariant(String variant); // // Metadata getMetadata(); // // Graph getGraph(); // // boolean hasVisualization(); // Gexf setVisualization(boolean viz); // } // // Path: src/main/java/com/ojn/gexf4j/core/Mode.java // public enum Mode { // // STATIC, // DYNAMIC, // } // // Path: src/main/java/com/ojn/gexf4j/core/Node.java // public interface Node extends SlicableDatum<Node>, HasNodes { // // String getId(); // // String getLabel(); // Node setLabel(String label); // // List<Edge> getEdges(); // // Edge connectTo(Node target); // Edge connectTo(String id, Node target); // // boolean hasEdgeTo(String id); // // boolean hasColor(); // Node clearColor(); // Color getColor(); // Node setColor(Color color); // // boolean hasPosition(); // Node clearPosition(); // Position getPosition(); // Node setPosition(Position position); // // boolean hasSize(); // Node clearSize(); // float getSize(); // Node setSize(float size); // // boolean hasShape(); // Node clearShape(); // NodeShapeEntity getShapeEntity(); // // List<Node> getParentForList(); // // boolean hasPID(); // Node clearPID(); // String getPID(); // Node setPID(String pid); // } // // Path: src/main/java/com/ojn/gexf4j/core/impl/GexfImpl.java // public class GexfImpl implements Gexf { // private static final String VERSION = "1.1"; // // private String variant = null; // private Graph graph = null; // private Metadata meta = null; // private boolean viz = false; // // public GexfImpl() { // graph = new GraphImpl(); // meta = new MetadataImpl(); // } // // @Override // public Graph getGraph() { // return graph; // } // // @Override // public Metadata getMetadata() { // return meta; // } // // @Override // public String getVersion() { // return VERSION; // } // // @Override // public boolean hasVariant() { // return (variant != null); // } // // @Override // public Gexf clearVariant() { // variant = null; // return this; // } // // @Override // public String getVariant() { // checkState(hasVariant(), "Variant has not been set."); // return variant; // } // // @Override // public Gexf setVariant(String variant) { // checkArgument(variant != null, "Variant cannot be null."); // checkArgument(!variant.trim().isEmpty(), "Variant cannot be empty or blank."); // this.variant = variant; // return this; // } // // @Override // public boolean hasVisualization() { // return viz; // } // // @Override // public Gexf setVisualization(boolean viz) { // this.viz = viz; // return this; // } // }
import com.ojn.gexf4j.core.EdgeType; import com.ojn.gexf4j.core.Gexf; import com.ojn.gexf4j.core.Mode; import com.ojn.gexf4j.core.Node; import com.ojn.gexf4j.core.impl.GexfImpl;
package com.ojn.gexf4j.core.testgraphs; public class HierarchyPIDBuilder extends GexfBuilder { @Override public String getSuffix() { return "hierarchyPID"; } @Override
// Path: src/main/java/com/ojn/gexf4j/core/EdgeType.java // public enum EdgeType { // // DIRECTED, // UNDIRECTED, // MUTUAL, // } // // Path: src/main/java/com/ojn/gexf4j/core/Gexf.java // public interface Gexf { // // String getVersion(); // // boolean hasVariant(); // Gexf clearVariant(); // String getVariant(); // Gexf setVariant(String variant); // // Metadata getMetadata(); // // Graph getGraph(); // // boolean hasVisualization(); // Gexf setVisualization(boolean viz); // } // // Path: src/main/java/com/ojn/gexf4j/core/Mode.java // public enum Mode { // // STATIC, // DYNAMIC, // } // // Path: src/main/java/com/ojn/gexf4j/core/Node.java // public interface Node extends SlicableDatum<Node>, HasNodes { // // String getId(); // // String getLabel(); // Node setLabel(String label); // // List<Edge> getEdges(); // // Edge connectTo(Node target); // Edge connectTo(String id, Node target); // // boolean hasEdgeTo(String id); // // boolean hasColor(); // Node clearColor(); // Color getColor(); // Node setColor(Color color); // // boolean hasPosition(); // Node clearPosition(); // Position getPosition(); // Node setPosition(Position position); // // boolean hasSize(); // Node clearSize(); // float getSize(); // Node setSize(float size); // // boolean hasShape(); // Node clearShape(); // NodeShapeEntity getShapeEntity(); // // List<Node> getParentForList(); // // boolean hasPID(); // Node clearPID(); // String getPID(); // Node setPID(String pid); // } // // Path: src/main/java/com/ojn/gexf4j/core/impl/GexfImpl.java // public class GexfImpl implements Gexf { // private static final String VERSION = "1.1"; // // private String variant = null; // private Graph graph = null; // private Metadata meta = null; // private boolean viz = false; // // public GexfImpl() { // graph = new GraphImpl(); // meta = new MetadataImpl(); // } // // @Override // public Graph getGraph() { // return graph; // } // // @Override // public Metadata getMetadata() { // return meta; // } // // @Override // public String getVersion() { // return VERSION; // } // // @Override // public boolean hasVariant() { // return (variant != null); // } // // @Override // public Gexf clearVariant() { // variant = null; // return this; // } // // @Override // public String getVariant() { // checkState(hasVariant(), "Variant has not been set."); // return variant; // } // // @Override // public Gexf setVariant(String variant) { // checkArgument(variant != null, "Variant cannot be null."); // checkArgument(!variant.trim().isEmpty(), "Variant cannot be empty or blank."); // this.variant = variant; // return this; // } // // @Override // public boolean hasVisualization() { // return viz; // } // // @Override // public Gexf setVisualization(boolean viz) { // this.viz = viz; // return this; // } // } // Path: src/test/java/com/ojn/gexf4j/core/testgraphs/HierarchyPIDBuilder.java import com.ojn.gexf4j.core.EdgeType; import com.ojn.gexf4j.core.Gexf; import com.ojn.gexf4j.core.Mode; import com.ojn.gexf4j.core.Node; import com.ojn.gexf4j.core.impl.GexfImpl; package com.ojn.gexf4j.core.testgraphs; public class HierarchyPIDBuilder extends GexfBuilder { @Override public String getSuffix() { return "hierarchyPID"; } @Override
public Gexf buildGexf() {
jmcampanini/gexf4j-core
src/test/java/com/ojn/gexf4j/core/testgraphs/HierarchyPIDBuilder.java
// Path: src/main/java/com/ojn/gexf4j/core/EdgeType.java // public enum EdgeType { // // DIRECTED, // UNDIRECTED, // MUTUAL, // } // // Path: src/main/java/com/ojn/gexf4j/core/Gexf.java // public interface Gexf { // // String getVersion(); // // boolean hasVariant(); // Gexf clearVariant(); // String getVariant(); // Gexf setVariant(String variant); // // Metadata getMetadata(); // // Graph getGraph(); // // boolean hasVisualization(); // Gexf setVisualization(boolean viz); // } // // Path: src/main/java/com/ojn/gexf4j/core/Mode.java // public enum Mode { // // STATIC, // DYNAMIC, // } // // Path: src/main/java/com/ojn/gexf4j/core/Node.java // public interface Node extends SlicableDatum<Node>, HasNodes { // // String getId(); // // String getLabel(); // Node setLabel(String label); // // List<Edge> getEdges(); // // Edge connectTo(Node target); // Edge connectTo(String id, Node target); // // boolean hasEdgeTo(String id); // // boolean hasColor(); // Node clearColor(); // Color getColor(); // Node setColor(Color color); // // boolean hasPosition(); // Node clearPosition(); // Position getPosition(); // Node setPosition(Position position); // // boolean hasSize(); // Node clearSize(); // float getSize(); // Node setSize(float size); // // boolean hasShape(); // Node clearShape(); // NodeShapeEntity getShapeEntity(); // // List<Node> getParentForList(); // // boolean hasPID(); // Node clearPID(); // String getPID(); // Node setPID(String pid); // } // // Path: src/main/java/com/ojn/gexf4j/core/impl/GexfImpl.java // public class GexfImpl implements Gexf { // private static final String VERSION = "1.1"; // // private String variant = null; // private Graph graph = null; // private Metadata meta = null; // private boolean viz = false; // // public GexfImpl() { // graph = new GraphImpl(); // meta = new MetadataImpl(); // } // // @Override // public Graph getGraph() { // return graph; // } // // @Override // public Metadata getMetadata() { // return meta; // } // // @Override // public String getVersion() { // return VERSION; // } // // @Override // public boolean hasVariant() { // return (variant != null); // } // // @Override // public Gexf clearVariant() { // variant = null; // return this; // } // // @Override // public String getVariant() { // checkState(hasVariant(), "Variant has not been set."); // return variant; // } // // @Override // public Gexf setVariant(String variant) { // checkArgument(variant != null, "Variant cannot be null."); // checkArgument(!variant.trim().isEmpty(), "Variant cannot be empty or blank."); // this.variant = variant; // return this; // } // // @Override // public boolean hasVisualization() { // return viz; // } // // @Override // public Gexf setVisualization(boolean viz) { // this.viz = viz; // return this; // } // }
import com.ojn.gexf4j.core.EdgeType; import com.ojn.gexf4j.core.Gexf; import com.ojn.gexf4j.core.Mode; import com.ojn.gexf4j.core.Node; import com.ojn.gexf4j.core.impl.GexfImpl;
package com.ojn.gexf4j.core.testgraphs; public class HierarchyPIDBuilder extends GexfBuilder { @Override public String getSuffix() { return "hierarchyPID"; } @Override public Gexf buildGexf() {
// Path: src/main/java/com/ojn/gexf4j/core/EdgeType.java // public enum EdgeType { // // DIRECTED, // UNDIRECTED, // MUTUAL, // } // // Path: src/main/java/com/ojn/gexf4j/core/Gexf.java // public interface Gexf { // // String getVersion(); // // boolean hasVariant(); // Gexf clearVariant(); // String getVariant(); // Gexf setVariant(String variant); // // Metadata getMetadata(); // // Graph getGraph(); // // boolean hasVisualization(); // Gexf setVisualization(boolean viz); // } // // Path: src/main/java/com/ojn/gexf4j/core/Mode.java // public enum Mode { // // STATIC, // DYNAMIC, // } // // Path: src/main/java/com/ojn/gexf4j/core/Node.java // public interface Node extends SlicableDatum<Node>, HasNodes { // // String getId(); // // String getLabel(); // Node setLabel(String label); // // List<Edge> getEdges(); // // Edge connectTo(Node target); // Edge connectTo(String id, Node target); // // boolean hasEdgeTo(String id); // // boolean hasColor(); // Node clearColor(); // Color getColor(); // Node setColor(Color color); // // boolean hasPosition(); // Node clearPosition(); // Position getPosition(); // Node setPosition(Position position); // // boolean hasSize(); // Node clearSize(); // float getSize(); // Node setSize(float size); // // boolean hasShape(); // Node clearShape(); // NodeShapeEntity getShapeEntity(); // // List<Node> getParentForList(); // // boolean hasPID(); // Node clearPID(); // String getPID(); // Node setPID(String pid); // } // // Path: src/main/java/com/ojn/gexf4j/core/impl/GexfImpl.java // public class GexfImpl implements Gexf { // private static final String VERSION = "1.1"; // // private String variant = null; // private Graph graph = null; // private Metadata meta = null; // private boolean viz = false; // // public GexfImpl() { // graph = new GraphImpl(); // meta = new MetadataImpl(); // } // // @Override // public Graph getGraph() { // return graph; // } // // @Override // public Metadata getMetadata() { // return meta; // } // // @Override // public String getVersion() { // return VERSION; // } // // @Override // public boolean hasVariant() { // return (variant != null); // } // // @Override // public Gexf clearVariant() { // variant = null; // return this; // } // // @Override // public String getVariant() { // checkState(hasVariant(), "Variant has not been set."); // return variant; // } // // @Override // public Gexf setVariant(String variant) { // checkArgument(variant != null, "Variant cannot be null."); // checkArgument(!variant.trim().isEmpty(), "Variant cannot be empty or blank."); // this.variant = variant; // return this; // } // // @Override // public boolean hasVisualization() { // return viz; // } // // @Override // public Gexf setVisualization(boolean viz) { // this.viz = viz; // return this; // } // } // Path: src/test/java/com/ojn/gexf4j/core/testgraphs/HierarchyPIDBuilder.java import com.ojn.gexf4j.core.EdgeType; import com.ojn.gexf4j.core.Gexf; import com.ojn.gexf4j.core.Mode; import com.ojn.gexf4j.core.Node; import com.ojn.gexf4j.core.impl.GexfImpl; package com.ojn.gexf4j.core.testgraphs; public class HierarchyPIDBuilder extends GexfBuilder { @Override public String getSuffix() { return "hierarchyPID"; } @Override public Gexf buildGexf() {
Gexf gexf = new GexfImpl();
jmcampanini/gexf4j-core
src/test/java/com/ojn/gexf4j/core/testgraphs/HierarchyPIDBuilder.java
// Path: src/main/java/com/ojn/gexf4j/core/EdgeType.java // public enum EdgeType { // // DIRECTED, // UNDIRECTED, // MUTUAL, // } // // Path: src/main/java/com/ojn/gexf4j/core/Gexf.java // public interface Gexf { // // String getVersion(); // // boolean hasVariant(); // Gexf clearVariant(); // String getVariant(); // Gexf setVariant(String variant); // // Metadata getMetadata(); // // Graph getGraph(); // // boolean hasVisualization(); // Gexf setVisualization(boolean viz); // } // // Path: src/main/java/com/ojn/gexf4j/core/Mode.java // public enum Mode { // // STATIC, // DYNAMIC, // } // // Path: src/main/java/com/ojn/gexf4j/core/Node.java // public interface Node extends SlicableDatum<Node>, HasNodes { // // String getId(); // // String getLabel(); // Node setLabel(String label); // // List<Edge> getEdges(); // // Edge connectTo(Node target); // Edge connectTo(String id, Node target); // // boolean hasEdgeTo(String id); // // boolean hasColor(); // Node clearColor(); // Color getColor(); // Node setColor(Color color); // // boolean hasPosition(); // Node clearPosition(); // Position getPosition(); // Node setPosition(Position position); // // boolean hasSize(); // Node clearSize(); // float getSize(); // Node setSize(float size); // // boolean hasShape(); // Node clearShape(); // NodeShapeEntity getShapeEntity(); // // List<Node> getParentForList(); // // boolean hasPID(); // Node clearPID(); // String getPID(); // Node setPID(String pid); // } // // Path: src/main/java/com/ojn/gexf4j/core/impl/GexfImpl.java // public class GexfImpl implements Gexf { // private static final String VERSION = "1.1"; // // private String variant = null; // private Graph graph = null; // private Metadata meta = null; // private boolean viz = false; // // public GexfImpl() { // graph = new GraphImpl(); // meta = new MetadataImpl(); // } // // @Override // public Graph getGraph() { // return graph; // } // // @Override // public Metadata getMetadata() { // return meta; // } // // @Override // public String getVersion() { // return VERSION; // } // // @Override // public boolean hasVariant() { // return (variant != null); // } // // @Override // public Gexf clearVariant() { // variant = null; // return this; // } // // @Override // public String getVariant() { // checkState(hasVariant(), "Variant has not been set."); // return variant; // } // // @Override // public Gexf setVariant(String variant) { // checkArgument(variant != null, "Variant cannot be null."); // checkArgument(!variant.trim().isEmpty(), "Variant cannot be empty or blank."); // this.variant = variant; // return this; // } // // @Override // public boolean hasVisualization() { // return viz; // } // // @Override // public Gexf setVisualization(boolean viz) { // this.viz = viz; // return this; // } // }
import com.ojn.gexf4j.core.EdgeType; import com.ojn.gexf4j.core.Gexf; import com.ojn.gexf4j.core.Mode; import com.ojn.gexf4j.core.Node; import com.ojn.gexf4j.core.impl.GexfImpl;
package com.ojn.gexf4j.core.testgraphs; public class HierarchyPIDBuilder extends GexfBuilder { @Override public String getSuffix() { return "hierarchyPID"; } @Override public Gexf buildGexf() { Gexf gexf = new GexfImpl(); gexf.getGraph()
// Path: src/main/java/com/ojn/gexf4j/core/EdgeType.java // public enum EdgeType { // // DIRECTED, // UNDIRECTED, // MUTUAL, // } // // Path: src/main/java/com/ojn/gexf4j/core/Gexf.java // public interface Gexf { // // String getVersion(); // // boolean hasVariant(); // Gexf clearVariant(); // String getVariant(); // Gexf setVariant(String variant); // // Metadata getMetadata(); // // Graph getGraph(); // // boolean hasVisualization(); // Gexf setVisualization(boolean viz); // } // // Path: src/main/java/com/ojn/gexf4j/core/Mode.java // public enum Mode { // // STATIC, // DYNAMIC, // } // // Path: src/main/java/com/ojn/gexf4j/core/Node.java // public interface Node extends SlicableDatum<Node>, HasNodes { // // String getId(); // // String getLabel(); // Node setLabel(String label); // // List<Edge> getEdges(); // // Edge connectTo(Node target); // Edge connectTo(String id, Node target); // // boolean hasEdgeTo(String id); // // boolean hasColor(); // Node clearColor(); // Color getColor(); // Node setColor(Color color); // // boolean hasPosition(); // Node clearPosition(); // Position getPosition(); // Node setPosition(Position position); // // boolean hasSize(); // Node clearSize(); // float getSize(); // Node setSize(float size); // // boolean hasShape(); // Node clearShape(); // NodeShapeEntity getShapeEntity(); // // List<Node> getParentForList(); // // boolean hasPID(); // Node clearPID(); // String getPID(); // Node setPID(String pid); // } // // Path: src/main/java/com/ojn/gexf4j/core/impl/GexfImpl.java // public class GexfImpl implements Gexf { // private static final String VERSION = "1.1"; // // private String variant = null; // private Graph graph = null; // private Metadata meta = null; // private boolean viz = false; // // public GexfImpl() { // graph = new GraphImpl(); // meta = new MetadataImpl(); // } // // @Override // public Graph getGraph() { // return graph; // } // // @Override // public Metadata getMetadata() { // return meta; // } // // @Override // public String getVersion() { // return VERSION; // } // // @Override // public boolean hasVariant() { // return (variant != null); // } // // @Override // public Gexf clearVariant() { // variant = null; // return this; // } // // @Override // public String getVariant() { // checkState(hasVariant(), "Variant has not been set."); // return variant; // } // // @Override // public Gexf setVariant(String variant) { // checkArgument(variant != null, "Variant cannot be null."); // checkArgument(!variant.trim().isEmpty(), "Variant cannot be empty or blank."); // this.variant = variant; // return this; // } // // @Override // public boolean hasVisualization() { // return viz; // } // // @Override // public Gexf setVisualization(boolean viz) { // this.viz = viz; // return this; // } // } // Path: src/test/java/com/ojn/gexf4j/core/testgraphs/HierarchyPIDBuilder.java import com.ojn.gexf4j.core.EdgeType; import com.ojn.gexf4j.core.Gexf; import com.ojn.gexf4j.core.Mode; import com.ojn.gexf4j.core.Node; import com.ojn.gexf4j.core.impl.GexfImpl; package com.ojn.gexf4j.core.testgraphs; public class HierarchyPIDBuilder extends GexfBuilder { @Override public String getSuffix() { return "hierarchyPID"; } @Override public Gexf buildGexf() { Gexf gexf = new GexfImpl(); gexf.getGraph()
.setMode(Mode.STATIC)
jmcampanini/gexf4j-core
src/test/java/com/ojn/gexf4j/core/testgraphs/HierarchyPIDBuilder.java
// Path: src/main/java/com/ojn/gexf4j/core/EdgeType.java // public enum EdgeType { // // DIRECTED, // UNDIRECTED, // MUTUAL, // } // // Path: src/main/java/com/ojn/gexf4j/core/Gexf.java // public interface Gexf { // // String getVersion(); // // boolean hasVariant(); // Gexf clearVariant(); // String getVariant(); // Gexf setVariant(String variant); // // Metadata getMetadata(); // // Graph getGraph(); // // boolean hasVisualization(); // Gexf setVisualization(boolean viz); // } // // Path: src/main/java/com/ojn/gexf4j/core/Mode.java // public enum Mode { // // STATIC, // DYNAMIC, // } // // Path: src/main/java/com/ojn/gexf4j/core/Node.java // public interface Node extends SlicableDatum<Node>, HasNodes { // // String getId(); // // String getLabel(); // Node setLabel(String label); // // List<Edge> getEdges(); // // Edge connectTo(Node target); // Edge connectTo(String id, Node target); // // boolean hasEdgeTo(String id); // // boolean hasColor(); // Node clearColor(); // Color getColor(); // Node setColor(Color color); // // boolean hasPosition(); // Node clearPosition(); // Position getPosition(); // Node setPosition(Position position); // // boolean hasSize(); // Node clearSize(); // float getSize(); // Node setSize(float size); // // boolean hasShape(); // Node clearShape(); // NodeShapeEntity getShapeEntity(); // // List<Node> getParentForList(); // // boolean hasPID(); // Node clearPID(); // String getPID(); // Node setPID(String pid); // } // // Path: src/main/java/com/ojn/gexf4j/core/impl/GexfImpl.java // public class GexfImpl implements Gexf { // private static final String VERSION = "1.1"; // // private String variant = null; // private Graph graph = null; // private Metadata meta = null; // private boolean viz = false; // // public GexfImpl() { // graph = new GraphImpl(); // meta = new MetadataImpl(); // } // // @Override // public Graph getGraph() { // return graph; // } // // @Override // public Metadata getMetadata() { // return meta; // } // // @Override // public String getVersion() { // return VERSION; // } // // @Override // public boolean hasVariant() { // return (variant != null); // } // // @Override // public Gexf clearVariant() { // variant = null; // return this; // } // // @Override // public String getVariant() { // checkState(hasVariant(), "Variant has not been set."); // return variant; // } // // @Override // public Gexf setVariant(String variant) { // checkArgument(variant != null, "Variant cannot be null."); // checkArgument(!variant.trim().isEmpty(), "Variant cannot be empty or blank."); // this.variant = variant; // return this; // } // // @Override // public boolean hasVisualization() { // return viz; // } // // @Override // public Gexf setVisualization(boolean viz) { // this.viz = viz; // return this; // } // }
import com.ojn.gexf4j.core.EdgeType; import com.ojn.gexf4j.core.Gexf; import com.ojn.gexf4j.core.Mode; import com.ojn.gexf4j.core.Node; import com.ojn.gexf4j.core.impl.GexfImpl;
package com.ojn.gexf4j.core.testgraphs; public class HierarchyPIDBuilder extends GexfBuilder { @Override public String getSuffix() { return "hierarchyPID"; } @Override public Gexf buildGexf() { Gexf gexf = new GexfImpl(); gexf.getGraph() .setMode(Mode.STATIC)
// Path: src/main/java/com/ojn/gexf4j/core/EdgeType.java // public enum EdgeType { // // DIRECTED, // UNDIRECTED, // MUTUAL, // } // // Path: src/main/java/com/ojn/gexf4j/core/Gexf.java // public interface Gexf { // // String getVersion(); // // boolean hasVariant(); // Gexf clearVariant(); // String getVariant(); // Gexf setVariant(String variant); // // Metadata getMetadata(); // // Graph getGraph(); // // boolean hasVisualization(); // Gexf setVisualization(boolean viz); // } // // Path: src/main/java/com/ojn/gexf4j/core/Mode.java // public enum Mode { // // STATIC, // DYNAMIC, // } // // Path: src/main/java/com/ojn/gexf4j/core/Node.java // public interface Node extends SlicableDatum<Node>, HasNodes { // // String getId(); // // String getLabel(); // Node setLabel(String label); // // List<Edge> getEdges(); // // Edge connectTo(Node target); // Edge connectTo(String id, Node target); // // boolean hasEdgeTo(String id); // // boolean hasColor(); // Node clearColor(); // Color getColor(); // Node setColor(Color color); // // boolean hasPosition(); // Node clearPosition(); // Position getPosition(); // Node setPosition(Position position); // // boolean hasSize(); // Node clearSize(); // float getSize(); // Node setSize(float size); // // boolean hasShape(); // Node clearShape(); // NodeShapeEntity getShapeEntity(); // // List<Node> getParentForList(); // // boolean hasPID(); // Node clearPID(); // String getPID(); // Node setPID(String pid); // } // // Path: src/main/java/com/ojn/gexf4j/core/impl/GexfImpl.java // public class GexfImpl implements Gexf { // private static final String VERSION = "1.1"; // // private String variant = null; // private Graph graph = null; // private Metadata meta = null; // private boolean viz = false; // // public GexfImpl() { // graph = new GraphImpl(); // meta = new MetadataImpl(); // } // // @Override // public Graph getGraph() { // return graph; // } // // @Override // public Metadata getMetadata() { // return meta; // } // // @Override // public String getVersion() { // return VERSION; // } // // @Override // public boolean hasVariant() { // return (variant != null); // } // // @Override // public Gexf clearVariant() { // variant = null; // return this; // } // // @Override // public String getVariant() { // checkState(hasVariant(), "Variant has not been set."); // return variant; // } // // @Override // public Gexf setVariant(String variant) { // checkArgument(variant != null, "Variant cannot be null."); // checkArgument(!variant.trim().isEmpty(), "Variant cannot be empty or blank."); // this.variant = variant; // return this; // } // // @Override // public boolean hasVisualization() { // return viz; // } // // @Override // public Gexf setVisualization(boolean viz) { // this.viz = viz; // return this; // } // } // Path: src/test/java/com/ojn/gexf4j/core/testgraphs/HierarchyPIDBuilder.java import com.ojn.gexf4j.core.EdgeType; import com.ojn.gexf4j.core.Gexf; import com.ojn.gexf4j.core.Mode; import com.ojn.gexf4j.core.Node; import com.ojn.gexf4j.core.impl.GexfImpl; package com.ojn.gexf4j.core.testgraphs; public class HierarchyPIDBuilder extends GexfBuilder { @Override public String getSuffix() { return "hierarchyPID"; } @Override public Gexf buildGexf() { Gexf gexf = new GexfImpl(); gexf.getGraph() .setMode(Mode.STATIC)
.setDefaultEdgeType(EdgeType.DIRECTED);
jmcampanini/gexf4j-core
src/test/java/com/ojn/gexf4j/core/testgraphs/HierarchyPIDBuilder.java
// Path: src/main/java/com/ojn/gexf4j/core/EdgeType.java // public enum EdgeType { // // DIRECTED, // UNDIRECTED, // MUTUAL, // } // // Path: src/main/java/com/ojn/gexf4j/core/Gexf.java // public interface Gexf { // // String getVersion(); // // boolean hasVariant(); // Gexf clearVariant(); // String getVariant(); // Gexf setVariant(String variant); // // Metadata getMetadata(); // // Graph getGraph(); // // boolean hasVisualization(); // Gexf setVisualization(boolean viz); // } // // Path: src/main/java/com/ojn/gexf4j/core/Mode.java // public enum Mode { // // STATIC, // DYNAMIC, // } // // Path: src/main/java/com/ojn/gexf4j/core/Node.java // public interface Node extends SlicableDatum<Node>, HasNodes { // // String getId(); // // String getLabel(); // Node setLabel(String label); // // List<Edge> getEdges(); // // Edge connectTo(Node target); // Edge connectTo(String id, Node target); // // boolean hasEdgeTo(String id); // // boolean hasColor(); // Node clearColor(); // Color getColor(); // Node setColor(Color color); // // boolean hasPosition(); // Node clearPosition(); // Position getPosition(); // Node setPosition(Position position); // // boolean hasSize(); // Node clearSize(); // float getSize(); // Node setSize(float size); // // boolean hasShape(); // Node clearShape(); // NodeShapeEntity getShapeEntity(); // // List<Node> getParentForList(); // // boolean hasPID(); // Node clearPID(); // String getPID(); // Node setPID(String pid); // } // // Path: src/main/java/com/ojn/gexf4j/core/impl/GexfImpl.java // public class GexfImpl implements Gexf { // private static final String VERSION = "1.1"; // // private String variant = null; // private Graph graph = null; // private Metadata meta = null; // private boolean viz = false; // // public GexfImpl() { // graph = new GraphImpl(); // meta = new MetadataImpl(); // } // // @Override // public Graph getGraph() { // return graph; // } // // @Override // public Metadata getMetadata() { // return meta; // } // // @Override // public String getVersion() { // return VERSION; // } // // @Override // public boolean hasVariant() { // return (variant != null); // } // // @Override // public Gexf clearVariant() { // variant = null; // return this; // } // // @Override // public String getVariant() { // checkState(hasVariant(), "Variant has not been set."); // return variant; // } // // @Override // public Gexf setVariant(String variant) { // checkArgument(variant != null, "Variant cannot be null."); // checkArgument(!variant.trim().isEmpty(), "Variant cannot be empty or blank."); // this.variant = variant; // return this; // } // // @Override // public boolean hasVisualization() { // return viz; // } // // @Override // public Gexf setVisualization(boolean viz) { // this.viz = viz; // return this; // } // }
import com.ojn.gexf4j.core.EdgeType; import com.ojn.gexf4j.core.Gexf; import com.ojn.gexf4j.core.Mode; import com.ojn.gexf4j.core.Node; import com.ojn.gexf4j.core.impl.GexfImpl;
package com.ojn.gexf4j.core.testgraphs; public class HierarchyPIDBuilder extends GexfBuilder { @Override public String getSuffix() { return "hierarchyPID"; } @Override public Gexf buildGexf() { Gexf gexf = new GexfImpl(); gexf.getGraph() .setMode(Mode.STATIC) .setDefaultEdgeType(EdgeType.DIRECTED);
// Path: src/main/java/com/ojn/gexf4j/core/EdgeType.java // public enum EdgeType { // // DIRECTED, // UNDIRECTED, // MUTUAL, // } // // Path: src/main/java/com/ojn/gexf4j/core/Gexf.java // public interface Gexf { // // String getVersion(); // // boolean hasVariant(); // Gexf clearVariant(); // String getVariant(); // Gexf setVariant(String variant); // // Metadata getMetadata(); // // Graph getGraph(); // // boolean hasVisualization(); // Gexf setVisualization(boolean viz); // } // // Path: src/main/java/com/ojn/gexf4j/core/Mode.java // public enum Mode { // // STATIC, // DYNAMIC, // } // // Path: src/main/java/com/ojn/gexf4j/core/Node.java // public interface Node extends SlicableDatum<Node>, HasNodes { // // String getId(); // // String getLabel(); // Node setLabel(String label); // // List<Edge> getEdges(); // // Edge connectTo(Node target); // Edge connectTo(String id, Node target); // // boolean hasEdgeTo(String id); // // boolean hasColor(); // Node clearColor(); // Color getColor(); // Node setColor(Color color); // // boolean hasPosition(); // Node clearPosition(); // Position getPosition(); // Node setPosition(Position position); // // boolean hasSize(); // Node clearSize(); // float getSize(); // Node setSize(float size); // // boolean hasShape(); // Node clearShape(); // NodeShapeEntity getShapeEntity(); // // List<Node> getParentForList(); // // boolean hasPID(); // Node clearPID(); // String getPID(); // Node setPID(String pid); // } // // Path: src/main/java/com/ojn/gexf4j/core/impl/GexfImpl.java // public class GexfImpl implements Gexf { // private static final String VERSION = "1.1"; // // private String variant = null; // private Graph graph = null; // private Metadata meta = null; // private boolean viz = false; // // public GexfImpl() { // graph = new GraphImpl(); // meta = new MetadataImpl(); // } // // @Override // public Graph getGraph() { // return graph; // } // // @Override // public Metadata getMetadata() { // return meta; // } // // @Override // public String getVersion() { // return VERSION; // } // // @Override // public boolean hasVariant() { // return (variant != null); // } // // @Override // public Gexf clearVariant() { // variant = null; // return this; // } // // @Override // public String getVariant() { // checkState(hasVariant(), "Variant has not been set."); // return variant; // } // // @Override // public Gexf setVariant(String variant) { // checkArgument(variant != null, "Variant cannot be null."); // checkArgument(!variant.trim().isEmpty(), "Variant cannot be empty or blank."); // this.variant = variant; // return this; // } // // @Override // public boolean hasVisualization() { // return viz; // } // // @Override // public Gexf setVisualization(boolean viz) { // this.viz = viz; // return this; // } // } // Path: src/test/java/com/ojn/gexf4j/core/testgraphs/HierarchyPIDBuilder.java import com.ojn.gexf4j.core.EdgeType; import com.ojn.gexf4j.core.Gexf; import com.ojn.gexf4j.core.Mode; import com.ojn.gexf4j.core.Node; import com.ojn.gexf4j.core.impl.GexfImpl; package com.ojn.gexf4j.core.testgraphs; public class HierarchyPIDBuilder extends GexfBuilder { @Override public String getSuffix() { return "hierarchyPID"; } @Override public Gexf buildGexf() { Gexf gexf = new GexfImpl(); gexf.getGraph() .setMode(Mode.STATIC) .setDefaultEdgeType(EdgeType.DIRECTED);
Node g = gexf.getGraph().createNode("g");
jmcampanini/gexf4j-core
src/test/java/com/ojn/gexf4j/core/impl/GraphImplTest.java
// Path: src/main/java/com/ojn/gexf4j/core/Graph.java // public interface Graph extends Dynamic<Graph>, HasNodes { // // EdgeType getDefaultEdgeType(); // Graph setDefaultEdgeType(EdgeType edgeType); // // IDType getIDType(); // Graph setIDType(IDType idType); // // Mode getMode(); // Graph setMode(Mode graphMode); // // TimeType getTimeType(); // Graph setTimeType(TimeType timeType); // // List<AttributeList> getAttributeLists(); // } // // Path: src/test/java/com/ojn/gexf4j/core/GraphTest.java // public abstract class GraphTest { // // protected abstract Graph newGraph(); // // @Test // public void defaultEdgeTypeValid() { // Graph g = newGraph(); // for (EdgeType edgeType : EdgeType.values()) { // g.setDefaultEdgeType(edgeType); // assertThat(g.getDefaultEdgeType(), is(equalTo(edgeType))); // } // } // // @Test // public void modeValid() { // Graph g = newGraph(); // for (Mode gm : Mode.values()) { // g.setMode(gm); // assertThat(g.getMode(), is(equalTo(gm))); // } // } // // @Test // public void createNode() { // Graph g = newGraph(); // g.createNode(); // } // // @Test // public void createNodeId() { // Graph g = newGraph(); // String id = UUID.randomUUID().toString(); // Node n = g.createNode(id); // // assertThat(n, is(notNullValue())); // assertThat(n.getId(), is(equalTo(id))); // assertThat(g.getNodeMap().containsKey(id), is(true)); // assertThat(g.getNodeMap().get(id), is(equalTo(n))); // } // // @Test(expected=IllegalArgumentException.class) // public void createNodeIdNull() { // Graph g = newGraph(); // g.createNode(null); // } // // @Test(expected=IllegalArgumentException.class) // public void createNodeIdBlank() { // Graph g = newGraph(); // g.createNode(" "); // } // // @Test(expected=IllegalArgumentException.class) // public void createNodeIdDuplicate() { // Graph g = newGraph(); // String id = UUID.randomUUID().toString(); // g.createNode(id); // g.createNode(id); // } // // @Test // public void getNodeMap() { // Graph g = newGraph(); // // String id1 = UUID.randomUUID().toString(); // String id2 = UUID.randomUUID().toString(); // // Node n1 = g.createNode(id1); // Node n2 = g.createNode(id2); // Node n3 = g.createNode(); // // Map<String, Node> map = g.getNodeMap(); // // assertThat(map.size(), is(equalTo(3))); // assertThat(map.containsKey(id1), is(true)); // assertThat(map.containsKey(id2), is(true)); // assertThat(map.containsValue(n1), is(true)); // assertThat(map.containsValue(n2), is(true)); // assertThat(map.containsValue(n3), is(true)); // assertThat(map.get(id1), is(equalTo(n1))); // assertThat(map.get(id2), is(equalTo(n2))); // } // }
import com.ojn.gexf4j.core.Graph; import com.ojn.gexf4j.core.GraphTest;
package com.ojn.gexf4j.core.impl; public class GraphImplTest extends GraphTest { @Override
// Path: src/main/java/com/ojn/gexf4j/core/Graph.java // public interface Graph extends Dynamic<Graph>, HasNodes { // // EdgeType getDefaultEdgeType(); // Graph setDefaultEdgeType(EdgeType edgeType); // // IDType getIDType(); // Graph setIDType(IDType idType); // // Mode getMode(); // Graph setMode(Mode graphMode); // // TimeType getTimeType(); // Graph setTimeType(TimeType timeType); // // List<AttributeList> getAttributeLists(); // } // // Path: src/test/java/com/ojn/gexf4j/core/GraphTest.java // public abstract class GraphTest { // // protected abstract Graph newGraph(); // // @Test // public void defaultEdgeTypeValid() { // Graph g = newGraph(); // for (EdgeType edgeType : EdgeType.values()) { // g.setDefaultEdgeType(edgeType); // assertThat(g.getDefaultEdgeType(), is(equalTo(edgeType))); // } // } // // @Test // public void modeValid() { // Graph g = newGraph(); // for (Mode gm : Mode.values()) { // g.setMode(gm); // assertThat(g.getMode(), is(equalTo(gm))); // } // } // // @Test // public void createNode() { // Graph g = newGraph(); // g.createNode(); // } // // @Test // public void createNodeId() { // Graph g = newGraph(); // String id = UUID.randomUUID().toString(); // Node n = g.createNode(id); // // assertThat(n, is(notNullValue())); // assertThat(n.getId(), is(equalTo(id))); // assertThat(g.getNodeMap().containsKey(id), is(true)); // assertThat(g.getNodeMap().get(id), is(equalTo(n))); // } // // @Test(expected=IllegalArgumentException.class) // public void createNodeIdNull() { // Graph g = newGraph(); // g.createNode(null); // } // // @Test(expected=IllegalArgumentException.class) // public void createNodeIdBlank() { // Graph g = newGraph(); // g.createNode(" "); // } // // @Test(expected=IllegalArgumentException.class) // public void createNodeIdDuplicate() { // Graph g = newGraph(); // String id = UUID.randomUUID().toString(); // g.createNode(id); // g.createNode(id); // } // // @Test // public void getNodeMap() { // Graph g = newGraph(); // // String id1 = UUID.randomUUID().toString(); // String id2 = UUID.randomUUID().toString(); // // Node n1 = g.createNode(id1); // Node n2 = g.createNode(id2); // Node n3 = g.createNode(); // // Map<String, Node> map = g.getNodeMap(); // // assertThat(map.size(), is(equalTo(3))); // assertThat(map.containsKey(id1), is(true)); // assertThat(map.containsKey(id2), is(true)); // assertThat(map.containsValue(n1), is(true)); // assertThat(map.containsValue(n2), is(true)); // assertThat(map.containsValue(n3), is(true)); // assertThat(map.get(id1), is(equalTo(n1))); // assertThat(map.get(id2), is(equalTo(n2))); // } // } // Path: src/test/java/com/ojn/gexf4j/core/impl/GraphImplTest.java import com.ojn.gexf4j.core.Graph; import com.ojn.gexf4j.core.GraphTest; package com.ojn.gexf4j.core.impl; public class GraphImplTest extends GraphTest { @Override
protected Graph newGraph() {
jmcampanini/gexf4j-core
src/test/java/com/ojn/gexf4j/core/testgraphs/VisualizationBuilder.java
// Path: src/main/java/com/ojn/gexf4j/core/Gexf.java // public interface Gexf { // // String getVersion(); // // boolean hasVariant(); // Gexf clearVariant(); // String getVariant(); // Gexf setVariant(String variant); // // Metadata getMetadata(); // // Graph getGraph(); // // boolean hasVisualization(); // Gexf setVisualization(boolean viz); // } // // Path: src/main/java/com/ojn/gexf4j/core/impl/GexfImpl.java // public class GexfImpl implements Gexf { // private static final String VERSION = "1.1"; // // private String variant = null; // private Graph graph = null; // private Metadata meta = null; // private boolean viz = false; // // public GexfImpl() { // graph = new GraphImpl(); // meta = new MetadataImpl(); // } // // @Override // public Graph getGraph() { // return graph; // } // // @Override // public Metadata getMetadata() { // return meta; // } // // @Override // public String getVersion() { // return VERSION; // } // // @Override // public boolean hasVariant() { // return (variant != null); // } // // @Override // public Gexf clearVariant() { // variant = null; // return this; // } // // @Override // public String getVariant() { // checkState(hasVariant(), "Variant has not been set."); // return variant; // } // // @Override // public Gexf setVariant(String variant) { // checkArgument(variant != null, "Variant cannot be null."); // checkArgument(!variant.trim().isEmpty(), "Variant cannot be empty or blank."); // this.variant = variant; // return this; // } // // @Override // public boolean hasVisualization() { // return viz; // } // // @Override // public Gexf setVisualization(boolean viz) { // this.viz = viz; // return this; // } // } // // Path: src/main/java/com/ojn/gexf4j/core/impl/viz/ColorImpl.java // public class ColorImpl implements Color { // // private int r = 0; // private int g = 0; // private int b = 0; // // public ColorImpl() { // // do nothing // } // // public ColorImpl(int r, int g, int b) { // setR(r); // setG(g); // setB(b); // } // // @Override // public int getR() { // return r; // } // // @Override // public Color setR(int r) { // checkArgument(r >= 0, "Color value cannot be less than 0."); // checkArgument(r <= 255, "Color value cannot be greater than 255."); // this.r = r; // return this; // } // // @Override // public int getG() { // return g; // } // // @Override // public Color setG(int g) { // checkArgument(g >= 0, "Color value cannot be less than 0."); // checkArgument(g <= 255, "Color value cannot be greater than 255."); // this.g = g; // return this; // } // // @Override // public int getB() { // return b; // } // // @Override // public Color setB(int b) { // checkArgument(b >= 0, "Color value cannot be less than 0."); // checkArgument(b <= 255, "Color value cannot be greater than 255."); // this.b = b; // return this; // } // } // // Path: src/main/java/com/ojn/gexf4j/core/impl/viz/PositionImpl.java // public class PositionImpl implements Position { // // private float x = 0.0f; // private float y = 0.0f; // private float z = 0.0f; // // public PositionImpl() { // // do nothing // } // // public PositionImpl(float x, float y, float z) { // setX(x); // setY(y); // setZ(z); // } // // public float getX() { // return x; // } // // public Position setX(float x) { // this.x = x; // return this; // } // // public float getY() { // return y; // } // // public Position setY(float y) { // this.y = y; // return this; // } // // public float getZ() { // return z; // } // // public Position setZ(float z) { // this.z = z; // return this; // } // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/NodeShape.java // public enum NodeShape { // // DISC, // SQUARE, // TRIANGLE, // DIAMOND, // IMAGE, // NOTSET, // }
import com.ojn.gexf4j.core.Gexf; import com.ojn.gexf4j.core.impl.GexfImpl; import com.ojn.gexf4j.core.impl.viz.ColorImpl; import com.ojn.gexf4j.core.impl.viz.PositionImpl; import com.ojn.gexf4j.core.viz.NodeShape;
package com.ojn.gexf4j.core.testgraphs; public class VisualizationBuilder extends GexfBuilder { @Override public String getSuffix() { return "viz"; } @Override
// Path: src/main/java/com/ojn/gexf4j/core/Gexf.java // public interface Gexf { // // String getVersion(); // // boolean hasVariant(); // Gexf clearVariant(); // String getVariant(); // Gexf setVariant(String variant); // // Metadata getMetadata(); // // Graph getGraph(); // // boolean hasVisualization(); // Gexf setVisualization(boolean viz); // } // // Path: src/main/java/com/ojn/gexf4j/core/impl/GexfImpl.java // public class GexfImpl implements Gexf { // private static final String VERSION = "1.1"; // // private String variant = null; // private Graph graph = null; // private Metadata meta = null; // private boolean viz = false; // // public GexfImpl() { // graph = new GraphImpl(); // meta = new MetadataImpl(); // } // // @Override // public Graph getGraph() { // return graph; // } // // @Override // public Metadata getMetadata() { // return meta; // } // // @Override // public String getVersion() { // return VERSION; // } // // @Override // public boolean hasVariant() { // return (variant != null); // } // // @Override // public Gexf clearVariant() { // variant = null; // return this; // } // // @Override // public String getVariant() { // checkState(hasVariant(), "Variant has not been set."); // return variant; // } // // @Override // public Gexf setVariant(String variant) { // checkArgument(variant != null, "Variant cannot be null."); // checkArgument(!variant.trim().isEmpty(), "Variant cannot be empty or blank."); // this.variant = variant; // return this; // } // // @Override // public boolean hasVisualization() { // return viz; // } // // @Override // public Gexf setVisualization(boolean viz) { // this.viz = viz; // return this; // } // } // // Path: src/main/java/com/ojn/gexf4j/core/impl/viz/ColorImpl.java // public class ColorImpl implements Color { // // private int r = 0; // private int g = 0; // private int b = 0; // // public ColorImpl() { // // do nothing // } // // public ColorImpl(int r, int g, int b) { // setR(r); // setG(g); // setB(b); // } // // @Override // public int getR() { // return r; // } // // @Override // public Color setR(int r) { // checkArgument(r >= 0, "Color value cannot be less than 0."); // checkArgument(r <= 255, "Color value cannot be greater than 255."); // this.r = r; // return this; // } // // @Override // public int getG() { // return g; // } // // @Override // public Color setG(int g) { // checkArgument(g >= 0, "Color value cannot be less than 0."); // checkArgument(g <= 255, "Color value cannot be greater than 255."); // this.g = g; // return this; // } // // @Override // public int getB() { // return b; // } // // @Override // public Color setB(int b) { // checkArgument(b >= 0, "Color value cannot be less than 0."); // checkArgument(b <= 255, "Color value cannot be greater than 255."); // this.b = b; // return this; // } // } // // Path: src/main/java/com/ojn/gexf4j/core/impl/viz/PositionImpl.java // public class PositionImpl implements Position { // // private float x = 0.0f; // private float y = 0.0f; // private float z = 0.0f; // // public PositionImpl() { // // do nothing // } // // public PositionImpl(float x, float y, float z) { // setX(x); // setY(y); // setZ(z); // } // // public float getX() { // return x; // } // // public Position setX(float x) { // this.x = x; // return this; // } // // public float getY() { // return y; // } // // public Position setY(float y) { // this.y = y; // return this; // } // // public float getZ() { // return z; // } // // public Position setZ(float z) { // this.z = z; // return this; // } // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/NodeShape.java // public enum NodeShape { // // DISC, // SQUARE, // TRIANGLE, // DIAMOND, // IMAGE, // NOTSET, // } // Path: src/test/java/com/ojn/gexf4j/core/testgraphs/VisualizationBuilder.java import com.ojn.gexf4j.core.Gexf; import com.ojn.gexf4j.core.impl.GexfImpl; import com.ojn.gexf4j.core.impl.viz.ColorImpl; import com.ojn.gexf4j.core.impl.viz.PositionImpl; import com.ojn.gexf4j.core.viz.NodeShape; package com.ojn.gexf4j.core.testgraphs; public class VisualizationBuilder extends GexfBuilder { @Override public String getSuffix() { return "viz"; } @Override
public Gexf buildGexf() {
jmcampanini/gexf4j-core
src/test/java/com/ojn/gexf4j/core/testgraphs/VisualizationBuilder.java
// Path: src/main/java/com/ojn/gexf4j/core/Gexf.java // public interface Gexf { // // String getVersion(); // // boolean hasVariant(); // Gexf clearVariant(); // String getVariant(); // Gexf setVariant(String variant); // // Metadata getMetadata(); // // Graph getGraph(); // // boolean hasVisualization(); // Gexf setVisualization(boolean viz); // } // // Path: src/main/java/com/ojn/gexf4j/core/impl/GexfImpl.java // public class GexfImpl implements Gexf { // private static final String VERSION = "1.1"; // // private String variant = null; // private Graph graph = null; // private Metadata meta = null; // private boolean viz = false; // // public GexfImpl() { // graph = new GraphImpl(); // meta = new MetadataImpl(); // } // // @Override // public Graph getGraph() { // return graph; // } // // @Override // public Metadata getMetadata() { // return meta; // } // // @Override // public String getVersion() { // return VERSION; // } // // @Override // public boolean hasVariant() { // return (variant != null); // } // // @Override // public Gexf clearVariant() { // variant = null; // return this; // } // // @Override // public String getVariant() { // checkState(hasVariant(), "Variant has not been set."); // return variant; // } // // @Override // public Gexf setVariant(String variant) { // checkArgument(variant != null, "Variant cannot be null."); // checkArgument(!variant.trim().isEmpty(), "Variant cannot be empty or blank."); // this.variant = variant; // return this; // } // // @Override // public boolean hasVisualization() { // return viz; // } // // @Override // public Gexf setVisualization(boolean viz) { // this.viz = viz; // return this; // } // } // // Path: src/main/java/com/ojn/gexf4j/core/impl/viz/ColorImpl.java // public class ColorImpl implements Color { // // private int r = 0; // private int g = 0; // private int b = 0; // // public ColorImpl() { // // do nothing // } // // public ColorImpl(int r, int g, int b) { // setR(r); // setG(g); // setB(b); // } // // @Override // public int getR() { // return r; // } // // @Override // public Color setR(int r) { // checkArgument(r >= 0, "Color value cannot be less than 0."); // checkArgument(r <= 255, "Color value cannot be greater than 255."); // this.r = r; // return this; // } // // @Override // public int getG() { // return g; // } // // @Override // public Color setG(int g) { // checkArgument(g >= 0, "Color value cannot be less than 0."); // checkArgument(g <= 255, "Color value cannot be greater than 255."); // this.g = g; // return this; // } // // @Override // public int getB() { // return b; // } // // @Override // public Color setB(int b) { // checkArgument(b >= 0, "Color value cannot be less than 0."); // checkArgument(b <= 255, "Color value cannot be greater than 255."); // this.b = b; // return this; // } // } // // Path: src/main/java/com/ojn/gexf4j/core/impl/viz/PositionImpl.java // public class PositionImpl implements Position { // // private float x = 0.0f; // private float y = 0.0f; // private float z = 0.0f; // // public PositionImpl() { // // do nothing // } // // public PositionImpl(float x, float y, float z) { // setX(x); // setY(y); // setZ(z); // } // // public float getX() { // return x; // } // // public Position setX(float x) { // this.x = x; // return this; // } // // public float getY() { // return y; // } // // public Position setY(float y) { // this.y = y; // return this; // } // // public float getZ() { // return z; // } // // public Position setZ(float z) { // this.z = z; // return this; // } // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/NodeShape.java // public enum NodeShape { // // DISC, // SQUARE, // TRIANGLE, // DIAMOND, // IMAGE, // NOTSET, // }
import com.ojn.gexf4j.core.Gexf; import com.ojn.gexf4j.core.impl.GexfImpl; import com.ojn.gexf4j.core.impl.viz.ColorImpl; import com.ojn.gexf4j.core.impl.viz.PositionImpl; import com.ojn.gexf4j.core.viz.NodeShape;
package com.ojn.gexf4j.core.testgraphs; public class VisualizationBuilder extends GexfBuilder { @Override public String getSuffix() { return "viz"; } @Override public Gexf buildGexf() {
// Path: src/main/java/com/ojn/gexf4j/core/Gexf.java // public interface Gexf { // // String getVersion(); // // boolean hasVariant(); // Gexf clearVariant(); // String getVariant(); // Gexf setVariant(String variant); // // Metadata getMetadata(); // // Graph getGraph(); // // boolean hasVisualization(); // Gexf setVisualization(boolean viz); // } // // Path: src/main/java/com/ojn/gexf4j/core/impl/GexfImpl.java // public class GexfImpl implements Gexf { // private static final String VERSION = "1.1"; // // private String variant = null; // private Graph graph = null; // private Metadata meta = null; // private boolean viz = false; // // public GexfImpl() { // graph = new GraphImpl(); // meta = new MetadataImpl(); // } // // @Override // public Graph getGraph() { // return graph; // } // // @Override // public Metadata getMetadata() { // return meta; // } // // @Override // public String getVersion() { // return VERSION; // } // // @Override // public boolean hasVariant() { // return (variant != null); // } // // @Override // public Gexf clearVariant() { // variant = null; // return this; // } // // @Override // public String getVariant() { // checkState(hasVariant(), "Variant has not been set."); // return variant; // } // // @Override // public Gexf setVariant(String variant) { // checkArgument(variant != null, "Variant cannot be null."); // checkArgument(!variant.trim().isEmpty(), "Variant cannot be empty or blank."); // this.variant = variant; // return this; // } // // @Override // public boolean hasVisualization() { // return viz; // } // // @Override // public Gexf setVisualization(boolean viz) { // this.viz = viz; // return this; // } // } // // Path: src/main/java/com/ojn/gexf4j/core/impl/viz/ColorImpl.java // public class ColorImpl implements Color { // // private int r = 0; // private int g = 0; // private int b = 0; // // public ColorImpl() { // // do nothing // } // // public ColorImpl(int r, int g, int b) { // setR(r); // setG(g); // setB(b); // } // // @Override // public int getR() { // return r; // } // // @Override // public Color setR(int r) { // checkArgument(r >= 0, "Color value cannot be less than 0."); // checkArgument(r <= 255, "Color value cannot be greater than 255."); // this.r = r; // return this; // } // // @Override // public int getG() { // return g; // } // // @Override // public Color setG(int g) { // checkArgument(g >= 0, "Color value cannot be less than 0."); // checkArgument(g <= 255, "Color value cannot be greater than 255."); // this.g = g; // return this; // } // // @Override // public int getB() { // return b; // } // // @Override // public Color setB(int b) { // checkArgument(b >= 0, "Color value cannot be less than 0."); // checkArgument(b <= 255, "Color value cannot be greater than 255."); // this.b = b; // return this; // } // } // // Path: src/main/java/com/ojn/gexf4j/core/impl/viz/PositionImpl.java // public class PositionImpl implements Position { // // private float x = 0.0f; // private float y = 0.0f; // private float z = 0.0f; // // public PositionImpl() { // // do nothing // } // // public PositionImpl(float x, float y, float z) { // setX(x); // setY(y); // setZ(z); // } // // public float getX() { // return x; // } // // public Position setX(float x) { // this.x = x; // return this; // } // // public float getY() { // return y; // } // // public Position setY(float y) { // this.y = y; // return this; // } // // public float getZ() { // return z; // } // // public Position setZ(float z) { // this.z = z; // return this; // } // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/NodeShape.java // public enum NodeShape { // // DISC, // SQUARE, // TRIANGLE, // DIAMOND, // IMAGE, // NOTSET, // } // Path: src/test/java/com/ojn/gexf4j/core/testgraphs/VisualizationBuilder.java import com.ojn.gexf4j.core.Gexf; import com.ojn.gexf4j.core.impl.GexfImpl; import com.ojn.gexf4j.core.impl.viz.ColorImpl; import com.ojn.gexf4j.core.impl.viz.PositionImpl; import com.ojn.gexf4j.core.viz.NodeShape; package com.ojn.gexf4j.core.testgraphs; public class VisualizationBuilder extends GexfBuilder { @Override public String getSuffix() { return "viz"; } @Override public Gexf buildGexf() {
Gexf gexf = new GexfImpl();
jmcampanini/gexf4j-core
src/test/java/com/ojn/gexf4j/core/impl/StaxGraphWriterTest.java
// Path: src/main/java/com/ojn/gexf4j/core/GexfWriter.java // public interface GexfWriter { // // void writeToStream(Gexf gexf, OutputStream out) throws IOException; // } // // Path: src/test/java/com/ojn/gexf4j/core/GraphWriterTest.java // @RunWith(Parameterized.class) // public abstract class GraphWriterTest { // // protected abstract String getFileNamePrefix(); // protected abstract GexfWriter newGraphWriter(); // // protected GexfBuilder builder = null; // // @Parameters // public static List<Object[]> getData() { // List<Object[]> rv = new ArrayList<Object[]>(); // // rv.add(new GexfBuilder[] { new BasicGraphBuilder() }); // rv.add(new GexfBuilder[] { new DataGraphBuilder() }); // rv.add(new GexfBuilder[] { new DynamicGraphBuilder() }); // rv.add(new GexfBuilder[] { new HierarchyInlineBuilder() }); // rv.add(new GexfBuilder[] { new HierarchyPIDBuilder() }); // rv.add(new GexfBuilder[] { new PhylogenyBuilder() }); // rv.add(new GexfBuilder[] { new VisualizationBuilder() }); // // return rv; // } // // public GraphWriterTest(GexfBuilder builder) { // this.builder = builder; // } // // @Test // public void writeToStream() throws SAXException, IOException { // Gexf gexf = builder.buildGexf(); // GexfWriter gw = newGraphWriter(); // String fileName = "target/" + getFileNamePrefix() + "_" + builder.getSuffix() + ".gexf"; // File f = new File(fileName); // FileOutputStream fos = new FileOutputStream(f); // // gw.writeToStream(gexf, fos); // // URL schemaFile = new URL(builder.getSchemaUrl()); // Source xmlFile = new StreamSource(f); // SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); // Schema schema = schemaFactory.newSchema(schemaFile); // Validator validator = schema.newValidator(); // // validator.validate(xmlFile); // } // } // // Path: src/test/java/com/ojn/gexf4j/core/testgraphs/GexfBuilder.java // public abstract class GexfBuilder { // private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); // // public abstract Gexf buildGexf(); // public abstract String getSuffix(); // // protected Date toDate(String s) { // try { // return sdf.parse(s); // } catch (ParseException e) { // return null; // } // } // // public String getSchemaUrl() { // return "http://gexf.net/1.1draft/gexf.xsd"; // } // }
import com.ojn.gexf4j.core.GexfWriter; import com.ojn.gexf4j.core.GraphWriterTest; import com.ojn.gexf4j.core.testgraphs.GexfBuilder;
package com.ojn.gexf4j.core.impl; public class StaxGraphWriterTest extends GraphWriterTest { public StaxGraphWriterTest(GexfBuilder builder) { super(builder); } @Override protected String getFileNamePrefix() { return "stax"; } @Override
// Path: src/main/java/com/ojn/gexf4j/core/GexfWriter.java // public interface GexfWriter { // // void writeToStream(Gexf gexf, OutputStream out) throws IOException; // } // // Path: src/test/java/com/ojn/gexf4j/core/GraphWriterTest.java // @RunWith(Parameterized.class) // public abstract class GraphWriterTest { // // protected abstract String getFileNamePrefix(); // protected abstract GexfWriter newGraphWriter(); // // protected GexfBuilder builder = null; // // @Parameters // public static List<Object[]> getData() { // List<Object[]> rv = new ArrayList<Object[]>(); // // rv.add(new GexfBuilder[] { new BasicGraphBuilder() }); // rv.add(new GexfBuilder[] { new DataGraphBuilder() }); // rv.add(new GexfBuilder[] { new DynamicGraphBuilder() }); // rv.add(new GexfBuilder[] { new HierarchyInlineBuilder() }); // rv.add(new GexfBuilder[] { new HierarchyPIDBuilder() }); // rv.add(new GexfBuilder[] { new PhylogenyBuilder() }); // rv.add(new GexfBuilder[] { new VisualizationBuilder() }); // // return rv; // } // // public GraphWriterTest(GexfBuilder builder) { // this.builder = builder; // } // // @Test // public void writeToStream() throws SAXException, IOException { // Gexf gexf = builder.buildGexf(); // GexfWriter gw = newGraphWriter(); // String fileName = "target/" + getFileNamePrefix() + "_" + builder.getSuffix() + ".gexf"; // File f = new File(fileName); // FileOutputStream fos = new FileOutputStream(f); // // gw.writeToStream(gexf, fos); // // URL schemaFile = new URL(builder.getSchemaUrl()); // Source xmlFile = new StreamSource(f); // SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); // Schema schema = schemaFactory.newSchema(schemaFile); // Validator validator = schema.newValidator(); // // validator.validate(xmlFile); // } // } // // Path: src/test/java/com/ojn/gexf4j/core/testgraphs/GexfBuilder.java // public abstract class GexfBuilder { // private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); // // public abstract Gexf buildGexf(); // public abstract String getSuffix(); // // protected Date toDate(String s) { // try { // return sdf.parse(s); // } catch (ParseException e) { // return null; // } // } // // public String getSchemaUrl() { // return "http://gexf.net/1.1draft/gexf.xsd"; // } // } // Path: src/test/java/com/ojn/gexf4j/core/impl/StaxGraphWriterTest.java import com.ojn.gexf4j.core.GexfWriter; import com.ojn.gexf4j.core.GraphWriterTest; import com.ojn.gexf4j.core.testgraphs.GexfBuilder; package com.ojn.gexf4j.core.impl; public class StaxGraphWriterTest extends GraphWriterTest { public StaxGraphWriterTest(GexfBuilder builder) { super(builder); } @Override protected String getFileNamePrefix() { return "stax"; } @Override
protected GexfWriter newGraphWriter() {
jmcampanini/gexf4j-core
src/main/java/com/ojn/gexf4j/core/impl/NodeImpl.java
// Path: src/main/java/com/ojn/gexf4j/core/Edge.java // public interface Edge extends SlicableDatum<Edge> { // // String getId(); // // Node getSource(); // // Node getTarget(); // Edge setTarget(Node target); // // boolean hasLabel(); // Edge clearLabel(); // String getLabel(); // Edge setLabel(String label); // // boolean hasWeight(); // Edge clearWeight(); // float getWeight(); // Edge setWeight(float weight); // // EdgeType getEdgeType(); // Edge setEdgeType(EdgeType edgeType); // // boolean hasColor(); // Edge clearColor(); // Color getColor(); // Edge setColor(Color color); // // boolean hasThickness(); // Edge clearThickness(); // float getThickness(); // Edge setThickness(float thickness); // // EdgeShape getShape(); // Edge setShape(EdgeShape shape); // } // // Path: src/main/java/com/ojn/gexf4j/core/Node.java // public interface Node extends SlicableDatum<Node>, HasNodes { // // String getId(); // // String getLabel(); // Node setLabel(String label); // // List<Edge> getEdges(); // // Edge connectTo(Node target); // Edge connectTo(String id, Node target); // // boolean hasEdgeTo(String id); // // boolean hasColor(); // Node clearColor(); // Color getColor(); // Node setColor(Color color); // // boolean hasPosition(); // Node clearPosition(); // Position getPosition(); // Node setPosition(Position position); // // boolean hasSize(); // Node clearSize(); // float getSize(); // Node setSize(float size); // // boolean hasShape(); // Node clearShape(); // NodeShapeEntity getShapeEntity(); // // List<Node> getParentForList(); // // boolean hasPID(); // Node clearPID(); // String getPID(); // Node setPID(String pid); // } // // Path: src/main/java/com/ojn/gexf4j/core/impl/viz/NodeShapeImpl.java // public class NodeShapeImpl implements NodeShapeEntity { // // private NodeShape shape = NodeShape.NOTSET; // private String uri = null; // // public NodeShapeImpl() { // // do nothing // } // // @Override // public NodeShapeEntity clearUri() { // uri = null; // return this; // } // // @Override // public NodeShape getNodeShape() { // return shape; // } // // @Override // public String getUri() { // checkState(hasUri(), "URI has not been set."); // return uri; // } // // @Override // public boolean hasUri() { // return (uri != null); // } // // @Override // public NodeShapeEntity setNodeShape(NodeShape shape) { // checkArgument(shape != NodeShape.NOTSET, "Node Shape cannot be NOTSET."); // this.shape = shape; // return this; // } // // @Override // public NodeShapeEntity setUri(String uri) { // checkArgument(uri != null, "URI cannot be set to null."); // return this; // } // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/Color.java // public interface Color { // // int getR(); // Color setR(int r); // // int getG(); // Color setG(int g); // // int getB(); // Color setB(int b); // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/NodeShape.java // public enum NodeShape { // // DISC, // SQUARE, // TRIANGLE, // DIAMOND, // IMAGE, // NOTSET, // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/NodeShapeEntity.java // public interface NodeShapeEntity { // // NodeShape getNodeShape(); // NodeShapeEntity setNodeShape(NodeShape shape); // // boolean hasUri(); // NodeShapeEntity clearUri(); // String getUri(); // NodeShapeEntity setUri(String uri); // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/Position.java // public interface Position { // // float getX(); // Position setX(float x); // // float getY(); // Position setY(float y); // // float getZ(); // Position setZ(float z); // }
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkState; import java.util.ArrayList; import java.util.List; import java.util.UUID; import com.ojn.gexf4j.core.Edge; import com.ojn.gexf4j.core.Node; import com.ojn.gexf4j.core.impl.viz.NodeShapeImpl; import com.ojn.gexf4j.core.viz.Color; import com.ojn.gexf4j.core.viz.NodeShape; import com.ojn.gexf4j.core.viz.NodeShapeEntity; import com.ojn.gexf4j.core.viz.Position;
package com.ojn.gexf4j.core.impl; public class NodeImpl extends SliceableDatumBase<Node> implements Node { private String id = ""; private String label = "";
// Path: src/main/java/com/ojn/gexf4j/core/Edge.java // public interface Edge extends SlicableDatum<Edge> { // // String getId(); // // Node getSource(); // // Node getTarget(); // Edge setTarget(Node target); // // boolean hasLabel(); // Edge clearLabel(); // String getLabel(); // Edge setLabel(String label); // // boolean hasWeight(); // Edge clearWeight(); // float getWeight(); // Edge setWeight(float weight); // // EdgeType getEdgeType(); // Edge setEdgeType(EdgeType edgeType); // // boolean hasColor(); // Edge clearColor(); // Color getColor(); // Edge setColor(Color color); // // boolean hasThickness(); // Edge clearThickness(); // float getThickness(); // Edge setThickness(float thickness); // // EdgeShape getShape(); // Edge setShape(EdgeShape shape); // } // // Path: src/main/java/com/ojn/gexf4j/core/Node.java // public interface Node extends SlicableDatum<Node>, HasNodes { // // String getId(); // // String getLabel(); // Node setLabel(String label); // // List<Edge> getEdges(); // // Edge connectTo(Node target); // Edge connectTo(String id, Node target); // // boolean hasEdgeTo(String id); // // boolean hasColor(); // Node clearColor(); // Color getColor(); // Node setColor(Color color); // // boolean hasPosition(); // Node clearPosition(); // Position getPosition(); // Node setPosition(Position position); // // boolean hasSize(); // Node clearSize(); // float getSize(); // Node setSize(float size); // // boolean hasShape(); // Node clearShape(); // NodeShapeEntity getShapeEntity(); // // List<Node> getParentForList(); // // boolean hasPID(); // Node clearPID(); // String getPID(); // Node setPID(String pid); // } // // Path: src/main/java/com/ojn/gexf4j/core/impl/viz/NodeShapeImpl.java // public class NodeShapeImpl implements NodeShapeEntity { // // private NodeShape shape = NodeShape.NOTSET; // private String uri = null; // // public NodeShapeImpl() { // // do nothing // } // // @Override // public NodeShapeEntity clearUri() { // uri = null; // return this; // } // // @Override // public NodeShape getNodeShape() { // return shape; // } // // @Override // public String getUri() { // checkState(hasUri(), "URI has not been set."); // return uri; // } // // @Override // public boolean hasUri() { // return (uri != null); // } // // @Override // public NodeShapeEntity setNodeShape(NodeShape shape) { // checkArgument(shape != NodeShape.NOTSET, "Node Shape cannot be NOTSET."); // this.shape = shape; // return this; // } // // @Override // public NodeShapeEntity setUri(String uri) { // checkArgument(uri != null, "URI cannot be set to null."); // return this; // } // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/Color.java // public interface Color { // // int getR(); // Color setR(int r); // // int getG(); // Color setG(int g); // // int getB(); // Color setB(int b); // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/NodeShape.java // public enum NodeShape { // // DISC, // SQUARE, // TRIANGLE, // DIAMOND, // IMAGE, // NOTSET, // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/NodeShapeEntity.java // public interface NodeShapeEntity { // // NodeShape getNodeShape(); // NodeShapeEntity setNodeShape(NodeShape shape); // // boolean hasUri(); // NodeShapeEntity clearUri(); // String getUri(); // NodeShapeEntity setUri(String uri); // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/Position.java // public interface Position { // // float getX(); // Position setX(float x); // // float getY(); // Position setY(float y); // // float getZ(); // Position setZ(float z); // } // Path: src/main/java/com/ojn/gexf4j/core/impl/NodeImpl.java import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkState; import java.util.ArrayList; import java.util.List; import java.util.UUID; import com.ojn.gexf4j.core.Edge; import com.ojn.gexf4j.core.Node; import com.ojn.gexf4j.core.impl.viz.NodeShapeImpl; import com.ojn.gexf4j.core.viz.Color; import com.ojn.gexf4j.core.viz.NodeShape; import com.ojn.gexf4j.core.viz.NodeShapeEntity; import com.ojn.gexf4j.core.viz.Position; package com.ojn.gexf4j.core.impl; public class NodeImpl extends SliceableDatumBase<Node> implements Node { private String id = ""; private String label = "";
private Color color = null;
jmcampanini/gexf4j-core
src/main/java/com/ojn/gexf4j/core/impl/NodeImpl.java
// Path: src/main/java/com/ojn/gexf4j/core/Edge.java // public interface Edge extends SlicableDatum<Edge> { // // String getId(); // // Node getSource(); // // Node getTarget(); // Edge setTarget(Node target); // // boolean hasLabel(); // Edge clearLabel(); // String getLabel(); // Edge setLabel(String label); // // boolean hasWeight(); // Edge clearWeight(); // float getWeight(); // Edge setWeight(float weight); // // EdgeType getEdgeType(); // Edge setEdgeType(EdgeType edgeType); // // boolean hasColor(); // Edge clearColor(); // Color getColor(); // Edge setColor(Color color); // // boolean hasThickness(); // Edge clearThickness(); // float getThickness(); // Edge setThickness(float thickness); // // EdgeShape getShape(); // Edge setShape(EdgeShape shape); // } // // Path: src/main/java/com/ojn/gexf4j/core/Node.java // public interface Node extends SlicableDatum<Node>, HasNodes { // // String getId(); // // String getLabel(); // Node setLabel(String label); // // List<Edge> getEdges(); // // Edge connectTo(Node target); // Edge connectTo(String id, Node target); // // boolean hasEdgeTo(String id); // // boolean hasColor(); // Node clearColor(); // Color getColor(); // Node setColor(Color color); // // boolean hasPosition(); // Node clearPosition(); // Position getPosition(); // Node setPosition(Position position); // // boolean hasSize(); // Node clearSize(); // float getSize(); // Node setSize(float size); // // boolean hasShape(); // Node clearShape(); // NodeShapeEntity getShapeEntity(); // // List<Node> getParentForList(); // // boolean hasPID(); // Node clearPID(); // String getPID(); // Node setPID(String pid); // } // // Path: src/main/java/com/ojn/gexf4j/core/impl/viz/NodeShapeImpl.java // public class NodeShapeImpl implements NodeShapeEntity { // // private NodeShape shape = NodeShape.NOTSET; // private String uri = null; // // public NodeShapeImpl() { // // do nothing // } // // @Override // public NodeShapeEntity clearUri() { // uri = null; // return this; // } // // @Override // public NodeShape getNodeShape() { // return shape; // } // // @Override // public String getUri() { // checkState(hasUri(), "URI has not been set."); // return uri; // } // // @Override // public boolean hasUri() { // return (uri != null); // } // // @Override // public NodeShapeEntity setNodeShape(NodeShape shape) { // checkArgument(shape != NodeShape.NOTSET, "Node Shape cannot be NOTSET."); // this.shape = shape; // return this; // } // // @Override // public NodeShapeEntity setUri(String uri) { // checkArgument(uri != null, "URI cannot be set to null."); // return this; // } // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/Color.java // public interface Color { // // int getR(); // Color setR(int r); // // int getG(); // Color setG(int g); // // int getB(); // Color setB(int b); // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/NodeShape.java // public enum NodeShape { // // DISC, // SQUARE, // TRIANGLE, // DIAMOND, // IMAGE, // NOTSET, // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/NodeShapeEntity.java // public interface NodeShapeEntity { // // NodeShape getNodeShape(); // NodeShapeEntity setNodeShape(NodeShape shape); // // boolean hasUri(); // NodeShapeEntity clearUri(); // String getUri(); // NodeShapeEntity setUri(String uri); // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/Position.java // public interface Position { // // float getX(); // Position setX(float x); // // float getY(); // Position setY(float y); // // float getZ(); // Position setZ(float z); // }
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkState; import java.util.ArrayList; import java.util.List; import java.util.UUID; import com.ojn.gexf4j.core.Edge; import com.ojn.gexf4j.core.Node; import com.ojn.gexf4j.core.impl.viz.NodeShapeImpl; import com.ojn.gexf4j.core.viz.Color; import com.ojn.gexf4j.core.viz.NodeShape; import com.ojn.gexf4j.core.viz.NodeShapeEntity; import com.ojn.gexf4j.core.viz.Position;
package com.ojn.gexf4j.core.impl; public class NodeImpl extends SliceableDatumBase<Node> implements Node { private String id = ""; private String label = ""; private Color color = null; private String pid = null;
// Path: src/main/java/com/ojn/gexf4j/core/Edge.java // public interface Edge extends SlicableDatum<Edge> { // // String getId(); // // Node getSource(); // // Node getTarget(); // Edge setTarget(Node target); // // boolean hasLabel(); // Edge clearLabel(); // String getLabel(); // Edge setLabel(String label); // // boolean hasWeight(); // Edge clearWeight(); // float getWeight(); // Edge setWeight(float weight); // // EdgeType getEdgeType(); // Edge setEdgeType(EdgeType edgeType); // // boolean hasColor(); // Edge clearColor(); // Color getColor(); // Edge setColor(Color color); // // boolean hasThickness(); // Edge clearThickness(); // float getThickness(); // Edge setThickness(float thickness); // // EdgeShape getShape(); // Edge setShape(EdgeShape shape); // } // // Path: src/main/java/com/ojn/gexf4j/core/Node.java // public interface Node extends SlicableDatum<Node>, HasNodes { // // String getId(); // // String getLabel(); // Node setLabel(String label); // // List<Edge> getEdges(); // // Edge connectTo(Node target); // Edge connectTo(String id, Node target); // // boolean hasEdgeTo(String id); // // boolean hasColor(); // Node clearColor(); // Color getColor(); // Node setColor(Color color); // // boolean hasPosition(); // Node clearPosition(); // Position getPosition(); // Node setPosition(Position position); // // boolean hasSize(); // Node clearSize(); // float getSize(); // Node setSize(float size); // // boolean hasShape(); // Node clearShape(); // NodeShapeEntity getShapeEntity(); // // List<Node> getParentForList(); // // boolean hasPID(); // Node clearPID(); // String getPID(); // Node setPID(String pid); // } // // Path: src/main/java/com/ojn/gexf4j/core/impl/viz/NodeShapeImpl.java // public class NodeShapeImpl implements NodeShapeEntity { // // private NodeShape shape = NodeShape.NOTSET; // private String uri = null; // // public NodeShapeImpl() { // // do nothing // } // // @Override // public NodeShapeEntity clearUri() { // uri = null; // return this; // } // // @Override // public NodeShape getNodeShape() { // return shape; // } // // @Override // public String getUri() { // checkState(hasUri(), "URI has not been set."); // return uri; // } // // @Override // public boolean hasUri() { // return (uri != null); // } // // @Override // public NodeShapeEntity setNodeShape(NodeShape shape) { // checkArgument(shape != NodeShape.NOTSET, "Node Shape cannot be NOTSET."); // this.shape = shape; // return this; // } // // @Override // public NodeShapeEntity setUri(String uri) { // checkArgument(uri != null, "URI cannot be set to null."); // return this; // } // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/Color.java // public interface Color { // // int getR(); // Color setR(int r); // // int getG(); // Color setG(int g); // // int getB(); // Color setB(int b); // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/NodeShape.java // public enum NodeShape { // // DISC, // SQUARE, // TRIANGLE, // DIAMOND, // IMAGE, // NOTSET, // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/NodeShapeEntity.java // public interface NodeShapeEntity { // // NodeShape getNodeShape(); // NodeShapeEntity setNodeShape(NodeShape shape); // // boolean hasUri(); // NodeShapeEntity clearUri(); // String getUri(); // NodeShapeEntity setUri(String uri); // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/Position.java // public interface Position { // // float getX(); // Position setX(float x); // // float getY(); // Position setY(float y); // // float getZ(); // Position setZ(float z); // } // Path: src/main/java/com/ojn/gexf4j/core/impl/NodeImpl.java import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkState; import java.util.ArrayList; import java.util.List; import java.util.UUID; import com.ojn.gexf4j.core.Edge; import com.ojn.gexf4j.core.Node; import com.ojn.gexf4j.core.impl.viz.NodeShapeImpl; import com.ojn.gexf4j.core.viz.Color; import com.ojn.gexf4j.core.viz.NodeShape; import com.ojn.gexf4j.core.viz.NodeShapeEntity; import com.ojn.gexf4j.core.viz.Position; package com.ojn.gexf4j.core.impl; public class NodeImpl extends SliceableDatumBase<Node> implements Node { private String id = ""; private String label = ""; private Color color = null; private String pid = null;
private Position position = null;
jmcampanini/gexf4j-core
src/main/java/com/ojn/gexf4j/core/impl/NodeImpl.java
// Path: src/main/java/com/ojn/gexf4j/core/Edge.java // public interface Edge extends SlicableDatum<Edge> { // // String getId(); // // Node getSource(); // // Node getTarget(); // Edge setTarget(Node target); // // boolean hasLabel(); // Edge clearLabel(); // String getLabel(); // Edge setLabel(String label); // // boolean hasWeight(); // Edge clearWeight(); // float getWeight(); // Edge setWeight(float weight); // // EdgeType getEdgeType(); // Edge setEdgeType(EdgeType edgeType); // // boolean hasColor(); // Edge clearColor(); // Color getColor(); // Edge setColor(Color color); // // boolean hasThickness(); // Edge clearThickness(); // float getThickness(); // Edge setThickness(float thickness); // // EdgeShape getShape(); // Edge setShape(EdgeShape shape); // } // // Path: src/main/java/com/ojn/gexf4j/core/Node.java // public interface Node extends SlicableDatum<Node>, HasNodes { // // String getId(); // // String getLabel(); // Node setLabel(String label); // // List<Edge> getEdges(); // // Edge connectTo(Node target); // Edge connectTo(String id, Node target); // // boolean hasEdgeTo(String id); // // boolean hasColor(); // Node clearColor(); // Color getColor(); // Node setColor(Color color); // // boolean hasPosition(); // Node clearPosition(); // Position getPosition(); // Node setPosition(Position position); // // boolean hasSize(); // Node clearSize(); // float getSize(); // Node setSize(float size); // // boolean hasShape(); // Node clearShape(); // NodeShapeEntity getShapeEntity(); // // List<Node> getParentForList(); // // boolean hasPID(); // Node clearPID(); // String getPID(); // Node setPID(String pid); // } // // Path: src/main/java/com/ojn/gexf4j/core/impl/viz/NodeShapeImpl.java // public class NodeShapeImpl implements NodeShapeEntity { // // private NodeShape shape = NodeShape.NOTSET; // private String uri = null; // // public NodeShapeImpl() { // // do nothing // } // // @Override // public NodeShapeEntity clearUri() { // uri = null; // return this; // } // // @Override // public NodeShape getNodeShape() { // return shape; // } // // @Override // public String getUri() { // checkState(hasUri(), "URI has not been set."); // return uri; // } // // @Override // public boolean hasUri() { // return (uri != null); // } // // @Override // public NodeShapeEntity setNodeShape(NodeShape shape) { // checkArgument(shape != NodeShape.NOTSET, "Node Shape cannot be NOTSET."); // this.shape = shape; // return this; // } // // @Override // public NodeShapeEntity setUri(String uri) { // checkArgument(uri != null, "URI cannot be set to null."); // return this; // } // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/Color.java // public interface Color { // // int getR(); // Color setR(int r); // // int getG(); // Color setG(int g); // // int getB(); // Color setB(int b); // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/NodeShape.java // public enum NodeShape { // // DISC, // SQUARE, // TRIANGLE, // DIAMOND, // IMAGE, // NOTSET, // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/NodeShapeEntity.java // public interface NodeShapeEntity { // // NodeShape getNodeShape(); // NodeShapeEntity setNodeShape(NodeShape shape); // // boolean hasUri(); // NodeShapeEntity clearUri(); // String getUri(); // NodeShapeEntity setUri(String uri); // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/Position.java // public interface Position { // // float getX(); // Position setX(float x); // // float getY(); // Position setY(float y); // // float getZ(); // Position setZ(float z); // }
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkState; import java.util.ArrayList; import java.util.List; import java.util.UUID; import com.ojn.gexf4j.core.Edge; import com.ojn.gexf4j.core.Node; import com.ojn.gexf4j.core.impl.viz.NodeShapeImpl; import com.ojn.gexf4j.core.viz.Color; import com.ojn.gexf4j.core.viz.NodeShape; import com.ojn.gexf4j.core.viz.NodeShapeEntity; import com.ojn.gexf4j.core.viz.Position;
package com.ojn.gexf4j.core.impl; public class NodeImpl extends SliceableDatumBase<Node> implements Node { private String id = ""; private String label = ""; private Color color = null; private String pid = null; private Position position = null;
// Path: src/main/java/com/ojn/gexf4j/core/Edge.java // public interface Edge extends SlicableDatum<Edge> { // // String getId(); // // Node getSource(); // // Node getTarget(); // Edge setTarget(Node target); // // boolean hasLabel(); // Edge clearLabel(); // String getLabel(); // Edge setLabel(String label); // // boolean hasWeight(); // Edge clearWeight(); // float getWeight(); // Edge setWeight(float weight); // // EdgeType getEdgeType(); // Edge setEdgeType(EdgeType edgeType); // // boolean hasColor(); // Edge clearColor(); // Color getColor(); // Edge setColor(Color color); // // boolean hasThickness(); // Edge clearThickness(); // float getThickness(); // Edge setThickness(float thickness); // // EdgeShape getShape(); // Edge setShape(EdgeShape shape); // } // // Path: src/main/java/com/ojn/gexf4j/core/Node.java // public interface Node extends SlicableDatum<Node>, HasNodes { // // String getId(); // // String getLabel(); // Node setLabel(String label); // // List<Edge> getEdges(); // // Edge connectTo(Node target); // Edge connectTo(String id, Node target); // // boolean hasEdgeTo(String id); // // boolean hasColor(); // Node clearColor(); // Color getColor(); // Node setColor(Color color); // // boolean hasPosition(); // Node clearPosition(); // Position getPosition(); // Node setPosition(Position position); // // boolean hasSize(); // Node clearSize(); // float getSize(); // Node setSize(float size); // // boolean hasShape(); // Node clearShape(); // NodeShapeEntity getShapeEntity(); // // List<Node> getParentForList(); // // boolean hasPID(); // Node clearPID(); // String getPID(); // Node setPID(String pid); // } // // Path: src/main/java/com/ojn/gexf4j/core/impl/viz/NodeShapeImpl.java // public class NodeShapeImpl implements NodeShapeEntity { // // private NodeShape shape = NodeShape.NOTSET; // private String uri = null; // // public NodeShapeImpl() { // // do nothing // } // // @Override // public NodeShapeEntity clearUri() { // uri = null; // return this; // } // // @Override // public NodeShape getNodeShape() { // return shape; // } // // @Override // public String getUri() { // checkState(hasUri(), "URI has not been set."); // return uri; // } // // @Override // public boolean hasUri() { // return (uri != null); // } // // @Override // public NodeShapeEntity setNodeShape(NodeShape shape) { // checkArgument(shape != NodeShape.NOTSET, "Node Shape cannot be NOTSET."); // this.shape = shape; // return this; // } // // @Override // public NodeShapeEntity setUri(String uri) { // checkArgument(uri != null, "URI cannot be set to null."); // return this; // } // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/Color.java // public interface Color { // // int getR(); // Color setR(int r); // // int getG(); // Color setG(int g); // // int getB(); // Color setB(int b); // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/NodeShape.java // public enum NodeShape { // // DISC, // SQUARE, // TRIANGLE, // DIAMOND, // IMAGE, // NOTSET, // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/NodeShapeEntity.java // public interface NodeShapeEntity { // // NodeShape getNodeShape(); // NodeShapeEntity setNodeShape(NodeShape shape); // // boolean hasUri(); // NodeShapeEntity clearUri(); // String getUri(); // NodeShapeEntity setUri(String uri); // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/Position.java // public interface Position { // // float getX(); // Position setX(float x); // // float getY(); // Position setY(float y); // // float getZ(); // Position setZ(float z); // } // Path: src/main/java/com/ojn/gexf4j/core/impl/NodeImpl.java import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkState; import java.util.ArrayList; import java.util.List; import java.util.UUID; import com.ojn.gexf4j.core.Edge; import com.ojn.gexf4j.core.Node; import com.ojn.gexf4j.core.impl.viz.NodeShapeImpl; import com.ojn.gexf4j.core.viz.Color; import com.ojn.gexf4j.core.viz.NodeShape; import com.ojn.gexf4j.core.viz.NodeShapeEntity; import com.ojn.gexf4j.core.viz.Position; package com.ojn.gexf4j.core.impl; public class NodeImpl extends SliceableDatumBase<Node> implements Node { private String id = ""; private String label = ""; private Color color = null; private String pid = null; private Position position = null;
private NodeShapeEntity shape = null;
jmcampanini/gexf4j-core
src/main/java/com/ojn/gexf4j/core/impl/NodeImpl.java
// Path: src/main/java/com/ojn/gexf4j/core/Edge.java // public interface Edge extends SlicableDatum<Edge> { // // String getId(); // // Node getSource(); // // Node getTarget(); // Edge setTarget(Node target); // // boolean hasLabel(); // Edge clearLabel(); // String getLabel(); // Edge setLabel(String label); // // boolean hasWeight(); // Edge clearWeight(); // float getWeight(); // Edge setWeight(float weight); // // EdgeType getEdgeType(); // Edge setEdgeType(EdgeType edgeType); // // boolean hasColor(); // Edge clearColor(); // Color getColor(); // Edge setColor(Color color); // // boolean hasThickness(); // Edge clearThickness(); // float getThickness(); // Edge setThickness(float thickness); // // EdgeShape getShape(); // Edge setShape(EdgeShape shape); // } // // Path: src/main/java/com/ojn/gexf4j/core/Node.java // public interface Node extends SlicableDatum<Node>, HasNodes { // // String getId(); // // String getLabel(); // Node setLabel(String label); // // List<Edge> getEdges(); // // Edge connectTo(Node target); // Edge connectTo(String id, Node target); // // boolean hasEdgeTo(String id); // // boolean hasColor(); // Node clearColor(); // Color getColor(); // Node setColor(Color color); // // boolean hasPosition(); // Node clearPosition(); // Position getPosition(); // Node setPosition(Position position); // // boolean hasSize(); // Node clearSize(); // float getSize(); // Node setSize(float size); // // boolean hasShape(); // Node clearShape(); // NodeShapeEntity getShapeEntity(); // // List<Node> getParentForList(); // // boolean hasPID(); // Node clearPID(); // String getPID(); // Node setPID(String pid); // } // // Path: src/main/java/com/ojn/gexf4j/core/impl/viz/NodeShapeImpl.java // public class NodeShapeImpl implements NodeShapeEntity { // // private NodeShape shape = NodeShape.NOTSET; // private String uri = null; // // public NodeShapeImpl() { // // do nothing // } // // @Override // public NodeShapeEntity clearUri() { // uri = null; // return this; // } // // @Override // public NodeShape getNodeShape() { // return shape; // } // // @Override // public String getUri() { // checkState(hasUri(), "URI has not been set."); // return uri; // } // // @Override // public boolean hasUri() { // return (uri != null); // } // // @Override // public NodeShapeEntity setNodeShape(NodeShape shape) { // checkArgument(shape != NodeShape.NOTSET, "Node Shape cannot be NOTSET."); // this.shape = shape; // return this; // } // // @Override // public NodeShapeEntity setUri(String uri) { // checkArgument(uri != null, "URI cannot be set to null."); // return this; // } // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/Color.java // public interface Color { // // int getR(); // Color setR(int r); // // int getG(); // Color setG(int g); // // int getB(); // Color setB(int b); // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/NodeShape.java // public enum NodeShape { // // DISC, // SQUARE, // TRIANGLE, // DIAMOND, // IMAGE, // NOTSET, // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/NodeShapeEntity.java // public interface NodeShapeEntity { // // NodeShape getNodeShape(); // NodeShapeEntity setNodeShape(NodeShape shape); // // boolean hasUri(); // NodeShapeEntity clearUri(); // String getUri(); // NodeShapeEntity setUri(String uri); // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/Position.java // public interface Position { // // float getX(); // Position setX(float x); // // float getY(); // Position setY(float y); // // float getZ(); // Position setZ(float z); // }
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkState; import java.util.ArrayList; import java.util.List; import java.util.UUID; import com.ojn.gexf4j.core.Edge; import com.ojn.gexf4j.core.Node; import com.ojn.gexf4j.core.impl.viz.NodeShapeImpl; import com.ojn.gexf4j.core.viz.Color; import com.ojn.gexf4j.core.viz.NodeShape; import com.ojn.gexf4j.core.viz.NodeShapeEntity; import com.ojn.gexf4j.core.viz.Position;
package com.ojn.gexf4j.core.impl; public class NodeImpl extends SliceableDatumBase<Node> implements Node { private String id = ""; private String label = ""; private Color color = null; private String pid = null; private Position position = null; private NodeShapeEntity shape = null; private float size = Float.MIN_VALUE; private List<Node> nodes = null;
// Path: src/main/java/com/ojn/gexf4j/core/Edge.java // public interface Edge extends SlicableDatum<Edge> { // // String getId(); // // Node getSource(); // // Node getTarget(); // Edge setTarget(Node target); // // boolean hasLabel(); // Edge clearLabel(); // String getLabel(); // Edge setLabel(String label); // // boolean hasWeight(); // Edge clearWeight(); // float getWeight(); // Edge setWeight(float weight); // // EdgeType getEdgeType(); // Edge setEdgeType(EdgeType edgeType); // // boolean hasColor(); // Edge clearColor(); // Color getColor(); // Edge setColor(Color color); // // boolean hasThickness(); // Edge clearThickness(); // float getThickness(); // Edge setThickness(float thickness); // // EdgeShape getShape(); // Edge setShape(EdgeShape shape); // } // // Path: src/main/java/com/ojn/gexf4j/core/Node.java // public interface Node extends SlicableDatum<Node>, HasNodes { // // String getId(); // // String getLabel(); // Node setLabel(String label); // // List<Edge> getEdges(); // // Edge connectTo(Node target); // Edge connectTo(String id, Node target); // // boolean hasEdgeTo(String id); // // boolean hasColor(); // Node clearColor(); // Color getColor(); // Node setColor(Color color); // // boolean hasPosition(); // Node clearPosition(); // Position getPosition(); // Node setPosition(Position position); // // boolean hasSize(); // Node clearSize(); // float getSize(); // Node setSize(float size); // // boolean hasShape(); // Node clearShape(); // NodeShapeEntity getShapeEntity(); // // List<Node> getParentForList(); // // boolean hasPID(); // Node clearPID(); // String getPID(); // Node setPID(String pid); // } // // Path: src/main/java/com/ojn/gexf4j/core/impl/viz/NodeShapeImpl.java // public class NodeShapeImpl implements NodeShapeEntity { // // private NodeShape shape = NodeShape.NOTSET; // private String uri = null; // // public NodeShapeImpl() { // // do nothing // } // // @Override // public NodeShapeEntity clearUri() { // uri = null; // return this; // } // // @Override // public NodeShape getNodeShape() { // return shape; // } // // @Override // public String getUri() { // checkState(hasUri(), "URI has not been set."); // return uri; // } // // @Override // public boolean hasUri() { // return (uri != null); // } // // @Override // public NodeShapeEntity setNodeShape(NodeShape shape) { // checkArgument(shape != NodeShape.NOTSET, "Node Shape cannot be NOTSET."); // this.shape = shape; // return this; // } // // @Override // public NodeShapeEntity setUri(String uri) { // checkArgument(uri != null, "URI cannot be set to null."); // return this; // } // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/Color.java // public interface Color { // // int getR(); // Color setR(int r); // // int getG(); // Color setG(int g); // // int getB(); // Color setB(int b); // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/NodeShape.java // public enum NodeShape { // // DISC, // SQUARE, // TRIANGLE, // DIAMOND, // IMAGE, // NOTSET, // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/NodeShapeEntity.java // public interface NodeShapeEntity { // // NodeShape getNodeShape(); // NodeShapeEntity setNodeShape(NodeShape shape); // // boolean hasUri(); // NodeShapeEntity clearUri(); // String getUri(); // NodeShapeEntity setUri(String uri); // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/Position.java // public interface Position { // // float getX(); // Position setX(float x); // // float getY(); // Position setY(float y); // // float getZ(); // Position setZ(float z); // } // Path: src/main/java/com/ojn/gexf4j/core/impl/NodeImpl.java import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkState; import java.util.ArrayList; import java.util.List; import java.util.UUID; import com.ojn.gexf4j.core.Edge; import com.ojn.gexf4j.core.Node; import com.ojn.gexf4j.core.impl.viz.NodeShapeImpl; import com.ojn.gexf4j.core.viz.Color; import com.ojn.gexf4j.core.viz.NodeShape; import com.ojn.gexf4j.core.viz.NodeShapeEntity; import com.ojn.gexf4j.core.viz.Position; package com.ojn.gexf4j.core.impl; public class NodeImpl extends SliceableDatumBase<Node> implements Node { private String id = ""; private String label = ""; private Color color = null; private String pid = null; private Position position = null; private NodeShapeEntity shape = null; private float size = Float.MIN_VALUE; private List<Node> nodes = null;
private List<Edge> edges = null;
jmcampanini/gexf4j-core
src/main/java/com/ojn/gexf4j/core/impl/NodeImpl.java
// Path: src/main/java/com/ojn/gexf4j/core/Edge.java // public interface Edge extends SlicableDatum<Edge> { // // String getId(); // // Node getSource(); // // Node getTarget(); // Edge setTarget(Node target); // // boolean hasLabel(); // Edge clearLabel(); // String getLabel(); // Edge setLabel(String label); // // boolean hasWeight(); // Edge clearWeight(); // float getWeight(); // Edge setWeight(float weight); // // EdgeType getEdgeType(); // Edge setEdgeType(EdgeType edgeType); // // boolean hasColor(); // Edge clearColor(); // Color getColor(); // Edge setColor(Color color); // // boolean hasThickness(); // Edge clearThickness(); // float getThickness(); // Edge setThickness(float thickness); // // EdgeShape getShape(); // Edge setShape(EdgeShape shape); // } // // Path: src/main/java/com/ojn/gexf4j/core/Node.java // public interface Node extends SlicableDatum<Node>, HasNodes { // // String getId(); // // String getLabel(); // Node setLabel(String label); // // List<Edge> getEdges(); // // Edge connectTo(Node target); // Edge connectTo(String id, Node target); // // boolean hasEdgeTo(String id); // // boolean hasColor(); // Node clearColor(); // Color getColor(); // Node setColor(Color color); // // boolean hasPosition(); // Node clearPosition(); // Position getPosition(); // Node setPosition(Position position); // // boolean hasSize(); // Node clearSize(); // float getSize(); // Node setSize(float size); // // boolean hasShape(); // Node clearShape(); // NodeShapeEntity getShapeEntity(); // // List<Node> getParentForList(); // // boolean hasPID(); // Node clearPID(); // String getPID(); // Node setPID(String pid); // } // // Path: src/main/java/com/ojn/gexf4j/core/impl/viz/NodeShapeImpl.java // public class NodeShapeImpl implements NodeShapeEntity { // // private NodeShape shape = NodeShape.NOTSET; // private String uri = null; // // public NodeShapeImpl() { // // do nothing // } // // @Override // public NodeShapeEntity clearUri() { // uri = null; // return this; // } // // @Override // public NodeShape getNodeShape() { // return shape; // } // // @Override // public String getUri() { // checkState(hasUri(), "URI has not been set."); // return uri; // } // // @Override // public boolean hasUri() { // return (uri != null); // } // // @Override // public NodeShapeEntity setNodeShape(NodeShape shape) { // checkArgument(shape != NodeShape.NOTSET, "Node Shape cannot be NOTSET."); // this.shape = shape; // return this; // } // // @Override // public NodeShapeEntity setUri(String uri) { // checkArgument(uri != null, "URI cannot be set to null."); // return this; // } // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/Color.java // public interface Color { // // int getR(); // Color setR(int r); // // int getG(); // Color setG(int g); // // int getB(); // Color setB(int b); // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/NodeShape.java // public enum NodeShape { // // DISC, // SQUARE, // TRIANGLE, // DIAMOND, // IMAGE, // NOTSET, // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/NodeShapeEntity.java // public interface NodeShapeEntity { // // NodeShape getNodeShape(); // NodeShapeEntity setNodeShape(NodeShape shape); // // boolean hasUri(); // NodeShapeEntity clearUri(); // String getUri(); // NodeShapeEntity setUri(String uri); // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/Position.java // public interface Position { // // float getX(); // Position setX(float x); // // float getY(); // Position setY(float y); // // float getZ(); // Position setZ(float z); // }
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkState; import java.util.ArrayList; import java.util.List; import java.util.UUID; import com.ojn.gexf4j.core.Edge; import com.ojn.gexf4j.core.Node; import com.ojn.gexf4j.core.impl.viz.NodeShapeImpl; import com.ojn.gexf4j.core.viz.Color; import com.ojn.gexf4j.core.viz.NodeShape; import com.ojn.gexf4j.core.viz.NodeShapeEntity; import com.ojn.gexf4j.core.viz.Position;
@Override public Position getPosition() { checkState(hasPosition(), "Position has not been set."); return position; } @Override public NodeShapeEntity getShapeEntity() { return shape; } @Override public float getSize() { checkState(hasSize(), "Size has not been set."); return size; } @Override public boolean hasPID() { return (pid != null); } @Override public boolean hasPosition() { return (position != null); } @Override public boolean hasShape() {
// Path: src/main/java/com/ojn/gexf4j/core/Edge.java // public interface Edge extends SlicableDatum<Edge> { // // String getId(); // // Node getSource(); // // Node getTarget(); // Edge setTarget(Node target); // // boolean hasLabel(); // Edge clearLabel(); // String getLabel(); // Edge setLabel(String label); // // boolean hasWeight(); // Edge clearWeight(); // float getWeight(); // Edge setWeight(float weight); // // EdgeType getEdgeType(); // Edge setEdgeType(EdgeType edgeType); // // boolean hasColor(); // Edge clearColor(); // Color getColor(); // Edge setColor(Color color); // // boolean hasThickness(); // Edge clearThickness(); // float getThickness(); // Edge setThickness(float thickness); // // EdgeShape getShape(); // Edge setShape(EdgeShape shape); // } // // Path: src/main/java/com/ojn/gexf4j/core/Node.java // public interface Node extends SlicableDatum<Node>, HasNodes { // // String getId(); // // String getLabel(); // Node setLabel(String label); // // List<Edge> getEdges(); // // Edge connectTo(Node target); // Edge connectTo(String id, Node target); // // boolean hasEdgeTo(String id); // // boolean hasColor(); // Node clearColor(); // Color getColor(); // Node setColor(Color color); // // boolean hasPosition(); // Node clearPosition(); // Position getPosition(); // Node setPosition(Position position); // // boolean hasSize(); // Node clearSize(); // float getSize(); // Node setSize(float size); // // boolean hasShape(); // Node clearShape(); // NodeShapeEntity getShapeEntity(); // // List<Node> getParentForList(); // // boolean hasPID(); // Node clearPID(); // String getPID(); // Node setPID(String pid); // } // // Path: src/main/java/com/ojn/gexf4j/core/impl/viz/NodeShapeImpl.java // public class NodeShapeImpl implements NodeShapeEntity { // // private NodeShape shape = NodeShape.NOTSET; // private String uri = null; // // public NodeShapeImpl() { // // do nothing // } // // @Override // public NodeShapeEntity clearUri() { // uri = null; // return this; // } // // @Override // public NodeShape getNodeShape() { // return shape; // } // // @Override // public String getUri() { // checkState(hasUri(), "URI has not been set."); // return uri; // } // // @Override // public boolean hasUri() { // return (uri != null); // } // // @Override // public NodeShapeEntity setNodeShape(NodeShape shape) { // checkArgument(shape != NodeShape.NOTSET, "Node Shape cannot be NOTSET."); // this.shape = shape; // return this; // } // // @Override // public NodeShapeEntity setUri(String uri) { // checkArgument(uri != null, "URI cannot be set to null."); // return this; // } // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/Color.java // public interface Color { // // int getR(); // Color setR(int r); // // int getG(); // Color setG(int g); // // int getB(); // Color setB(int b); // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/NodeShape.java // public enum NodeShape { // // DISC, // SQUARE, // TRIANGLE, // DIAMOND, // IMAGE, // NOTSET, // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/NodeShapeEntity.java // public interface NodeShapeEntity { // // NodeShape getNodeShape(); // NodeShapeEntity setNodeShape(NodeShape shape); // // boolean hasUri(); // NodeShapeEntity clearUri(); // String getUri(); // NodeShapeEntity setUri(String uri); // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/Position.java // public interface Position { // // float getX(); // Position setX(float x); // // float getY(); // Position setY(float y); // // float getZ(); // Position setZ(float z); // } // Path: src/main/java/com/ojn/gexf4j/core/impl/NodeImpl.java import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkState; import java.util.ArrayList; import java.util.List; import java.util.UUID; import com.ojn.gexf4j.core.Edge; import com.ojn.gexf4j.core.Node; import com.ojn.gexf4j.core.impl.viz.NodeShapeImpl; import com.ojn.gexf4j.core.viz.Color; import com.ojn.gexf4j.core.viz.NodeShape; import com.ojn.gexf4j.core.viz.NodeShapeEntity; import com.ojn.gexf4j.core.viz.Position; @Override public Position getPosition() { checkState(hasPosition(), "Position has not been set."); return position; } @Override public NodeShapeEntity getShapeEntity() { return shape; } @Override public float getSize() { checkState(hasSize(), "Size has not been set."); return size; } @Override public boolean hasPID() { return (pid != null); } @Override public boolean hasPosition() { return (position != null); } @Override public boolean hasShape() {
return (shape.getNodeShape() != NodeShape.NOTSET);
jmcampanini/gexf4j-core
src/main/java/com/ojn/gexf4j/core/impl/GexfImpl.java
// Path: src/main/java/com/ojn/gexf4j/core/Gexf.java // public interface Gexf { // // String getVersion(); // // boolean hasVariant(); // Gexf clearVariant(); // String getVariant(); // Gexf setVariant(String variant); // // Metadata getMetadata(); // // Graph getGraph(); // // boolean hasVisualization(); // Gexf setVisualization(boolean viz); // } // // Path: src/main/java/com/ojn/gexf4j/core/Graph.java // public interface Graph extends Dynamic<Graph>, HasNodes { // // EdgeType getDefaultEdgeType(); // Graph setDefaultEdgeType(EdgeType edgeType); // // IDType getIDType(); // Graph setIDType(IDType idType); // // Mode getMode(); // Graph setMode(Mode graphMode); // // TimeType getTimeType(); // Graph setTimeType(TimeType timeType); // // List<AttributeList> getAttributeLists(); // } // // Path: src/main/java/com/ojn/gexf4j/core/Metadata.java // public interface Metadata { // // boolean isEmpty(); // Metadata clearMetadata(); // // boolean hasLastModified(); // Metadata clearLastModified(); // Date getLastModified(); // Metadata setLastModified(Date lastModified); // // boolean hasCreator(); // Metadata clearCreator(); // String getCreator(); // Metadata setCreator(String creator); // // boolean hasDescription(); // Metadata clearDescription(); // String getDescription(); // Metadata setDescription(String description); // // List<String> getKeywords(); // }
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkState; import com.ojn.gexf4j.core.Gexf; import com.ojn.gexf4j.core.Graph; import com.ojn.gexf4j.core.Metadata;
package com.ojn.gexf4j.core.impl; public class GexfImpl implements Gexf { private static final String VERSION = "1.1"; private String variant = null;
// Path: src/main/java/com/ojn/gexf4j/core/Gexf.java // public interface Gexf { // // String getVersion(); // // boolean hasVariant(); // Gexf clearVariant(); // String getVariant(); // Gexf setVariant(String variant); // // Metadata getMetadata(); // // Graph getGraph(); // // boolean hasVisualization(); // Gexf setVisualization(boolean viz); // } // // Path: src/main/java/com/ojn/gexf4j/core/Graph.java // public interface Graph extends Dynamic<Graph>, HasNodes { // // EdgeType getDefaultEdgeType(); // Graph setDefaultEdgeType(EdgeType edgeType); // // IDType getIDType(); // Graph setIDType(IDType idType); // // Mode getMode(); // Graph setMode(Mode graphMode); // // TimeType getTimeType(); // Graph setTimeType(TimeType timeType); // // List<AttributeList> getAttributeLists(); // } // // Path: src/main/java/com/ojn/gexf4j/core/Metadata.java // public interface Metadata { // // boolean isEmpty(); // Metadata clearMetadata(); // // boolean hasLastModified(); // Metadata clearLastModified(); // Date getLastModified(); // Metadata setLastModified(Date lastModified); // // boolean hasCreator(); // Metadata clearCreator(); // String getCreator(); // Metadata setCreator(String creator); // // boolean hasDescription(); // Metadata clearDescription(); // String getDescription(); // Metadata setDescription(String description); // // List<String> getKeywords(); // } // Path: src/main/java/com/ojn/gexf4j/core/impl/GexfImpl.java import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkState; import com.ojn.gexf4j.core.Gexf; import com.ojn.gexf4j.core.Graph; import com.ojn.gexf4j.core.Metadata; package com.ojn.gexf4j.core.impl; public class GexfImpl implements Gexf { private static final String VERSION = "1.1"; private String variant = null;
private Graph graph = null;
jmcampanini/gexf4j-core
src/main/java/com/ojn/gexf4j/core/impl/GexfImpl.java
// Path: src/main/java/com/ojn/gexf4j/core/Gexf.java // public interface Gexf { // // String getVersion(); // // boolean hasVariant(); // Gexf clearVariant(); // String getVariant(); // Gexf setVariant(String variant); // // Metadata getMetadata(); // // Graph getGraph(); // // boolean hasVisualization(); // Gexf setVisualization(boolean viz); // } // // Path: src/main/java/com/ojn/gexf4j/core/Graph.java // public interface Graph extends Dynamic<Graph>, HasNodes { // // EdgeType getDefaultEdgeType(); // Graph setDefaultEdgeType(EdgeType edgeType); // // IDType getIDType(); // Graph setIDType(IDType idType); // // Mode getMode(); // Graph setMode(Mode graphMode); // // TimeType getTimeType(); // Graph setTimeType(TimeType timeType); // // List<AttributeList> getAttributeLists(); // } // // Path: src/main/java/com/ojn/gexf4j/core/Metadata.java // public interface Metadata { // // boolean isEmpty(); // Metadata clearMetadata(); // // boolean hasLastModified(); // Metadata clearLastModified(); // Date getLastModified(); // Metadata setLastModified(Date lastModified); // // boolean hasCreator(); // Metadata clearCreator(); // String getCreator(); // Metadata setCreator(String creator); // // boolean hasDescription(); // Metadata clearDescription(); // String getDescription(); // Metadata setDescription(String description); // // List<String> getKeywords(); // }
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkState; import com.ojn.gexf4j.core.Gexf; import com.ojn.gexf4j.core.Graph; import com.ojn.gexf4j.core.Metadata;
package com.ojn.gexf4j.core.impl; public class GexfImpl implements Gexf { private static final String VERSION = "1.1"; private String variant = null; private Graph graph = null;
// Path: src/main/java/com/ojn/gexf4j/core/Gexf.java // public interface Gexf { // // String getVersion(); // // boolean hasVariant(); // Gexf clearVariant(); // String getVariant(); // Gexf setVariant(String variant); // // Metadata getMetadata(); // // Graph getGraph(); // // boolean hasVisualization(); // Gexf setVisualization(boolean viz); // } // // Path: src/main/java/com/ojn/gexf4j/core/Graph.java // public interface Graph extends Dynamic<Graph>, HasNodes { // // EdgeType getDefaultEdgeType(); // Graph setDefaultEdgeType(EdgeType edgeType); // // IDType getIDType(); // Graph setIDType(IDType idType); // // Mode getMode(); // Graph setMode(Mode graphMode); // // TimeType getTimeType(); // Graph setTimeType(TimeType timeType); // // List<AttributeList> getAttributeLists(); // } // // Path: src/main/java/com/ojn/gexf4j/core/Metadata.java // public interface Metadata { // // boolean isEmpty(); // Metadata clearMetadata(); // // boolean hasLastModified(); // Metadata clearLastModified(); // Date getLastModified(); // Metadata setLastModified(Date lastModified); // // boolean hasCreator(); // Metadata clearCreator(); // String getCreator(); // Metadata setCreator(String creator); // // boolean hasDescription(); // Metadata clearDescription(); // String getDescription(); // Metadata setDescription(String description); // // List<String> getKeywords(); // } // Path: src/main/java/com/ojn/gexf4j/core/impl/GexfImpl.java import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkState; import com.ojn.gexf4j.core.Gexf; import com.ojn.gexf4j.core.Graph; import com.ojn.gexf4j.core.Metadata; package com.ojn.gexf4j.core.impl; public class GexfImpl implements Gexf { private static final String VERSION = "1.1"; private String variant = null; private Graph graph = null;
private Metadata meta = null;
jmcampanini/gexf4j-core
src/main/java/com/ojn/gexf4j/core/impl/EdgeImpl.java
// Path: src/main/java/com/ojn/gexf4j/core/Edge.java // public interface Edge extends SlicableDatum<Edge> { // // String getId(); // // Node getSource(); // // Node getTarget(); // Edge setTarget(Node target); // // boolean hasLabel(); // Edge clearLabel(); // String getLabel(); // Edge setLabel(String label); // // boolean hasWeight(); // Edge clearWeight(); // float getWeight(); // Edge setWeight(float weight); // // EdgeType getEdgeType(); // Edge setEdgeType(EdgeType edgeType); // // boolean hasColor(); // Edge clearColor(); // Color getColor(); // Edge setColor(Color color); // // boolean hasThickness(); // Edge clearThickness(); // float getThickness(); // Edge setThickness(float thickness); // // EdgeShape getShape(); // Edge setShape(EdgeShape shape); // } // // Path: src/main/java/com/ojn/gexf4j/core/EdgeType.java // public enum EdgeType { // // DIRECTED, // UNDIRECTED, // MUTUAL, // } // // Path: src/main/java/com/ojn/gexf4j/core/Node.java // public interface Node extends SlicableDatum<Node>, HasNodes { // // String getId(); // // String getLabel(); // Node setLabel(String label); // // List<Edge> getEdges(); // // Edge connectTo(Node target); // Edge connectTo(String id, Node target); // // boolean hasEdgeTo(String id); // // boolean hasColor(); // Node clearColor(); // Color getColor(); // Node setColor(Color color); // // boolean hasPosition(); // Node clearPosition(); // Position getPosition(); // Node setPosition(Position position); // // boolean hasSize(); // Node clearSize(); // float getSize(); // Node setSize(float size); // // boolean hasShape(); // Node clearShape(); // NodeShapeEntity getShapeEntity(); // // List<Node> getParentForList(); // // boolean hasPID(); // Node clearPID(); // String getPID(); // Node setPID(String pid); // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/Color.java // public interface Color { // // int getR(); // Color setR(int r); // // int getG(); // Color setG(int g); // // int getB(); // Color setB(int b); // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/EdgeShape.java // public enum EdgeShape { // // SOLID, // DOTTED, // DASHED, // DOUBLE, // NOTSET, // }
import static com.google.common.base.Preconditions.*; import com.ojn.gexf4j.core.Edge; import com.ojn.gexf4j.core.EdgeType; import com.ojn.gexf4j.core.Node; import com.ojn.gexf4j.core.viz.Color; import com.ojn.gexf4j.core.viz.EdgeShape;
package com.ojn.gexf4j.core.impl; public class EdgeImpl extends SliceableDatumBase<Edge> implements Edge { private String id = ""; private String label = null;
// Path: src/main/java/com/ojn/gexf4j/core/Edge.java // public interface Edge extends SlicableDatum<Edge> { // // String getId(); // // Node getSource(); // // Node getTarget(); // Edge setTarget(Node target); // // boolean hasLabel(); // Edge clearLabel(); // String getLabel(); // Edge setLabel(String label); // // boolean hasWeight(); // Edge clearWeight(); // float getWeight(); // Edge setWeight(float weight); // // EdgeType getEdgeType(); // Edge setEdgeType(EdgeType edgeType); // // boolean hasColor(); // Edge clearColor(); // Color getColor(); // Edge setColor(Color color); // // boolean hasThickness(); // Edge clearThickness(); // float getThickness(); // Edge setThickness(float thickness); // // EdgeShape getShape(); // Edge setShape(EdgeShape shape); // } // // Path: src/main/java/com/ojn/gexf4j/core/EdgeType.java // public enum EdgeType { // // DIRECTED, // UNDIRECTED, // MUTUAL, // } // // Path: src/main/java/com/ojn/gexf4j/core/Node.java // public interface Node extends SlicableDatum<Node>, HasNodes { // // String getId(); // // String getLabel(); // Node setLabel(String label); // // List<Edge> getEdges(); // // Edge connectTo(Node target); // Edge connectTo(String id, Node target); // // boolean hasEdgeTo(String id); // // boolean hasColor(); // Node clearColor(); // Color getColor(); // Node setColor(Color color); // // boolean hasPosition(); // Node clearPosition(); // Position getPosition(); // Node setPosition(Position position); // // boolean hasSize(); // Node clearSize(); // float getSize(); // Node setSize(float size); // // boolean hasShape(); // Node clearShape(); // NodeShapeEntity getShapeEntity(); // // List<Node> getParentForList(); // // boolean hasPID(); // Node clearPID(); // String getPID(); // Node setPID(String pid); // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/Color.java // public interface Color { // // int getR(); // Color setR(int r); // // int getG(); // Color setG(int g); // // int getB(); // Color setB(int b); // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/EdgeShape.java // public enum EdgeShape { // // SOLID, // DOTTED, // DASHED, // DOUBLE, // NOTSET, // } // Path: src/main/java/com/ojn/gexf4j/core/impl/EdgeImpl.java import static com.google.common.base.Preconditions.*; import com.ojn.gexf4j.core.Edge; import com.ojn.gexf4j.core.EdgeType; import com.ojn.gexf4j.core.Node; import com.ojn.gexf4j.core.viz.Color; import com.ojn.gexf4j.core.viz.EdgeShape; package com.ojn.gexf4j.core.impl; public class EdgeImpl extends SliceableDatumBase<Edge> implements Edge { private String id = ""; private String label = null;
private Node source = null;
jmcampanini/gexf4j-core
src/main/java/com/ojn/gexf4j/core/impl/EdgeImpl.java
// Path: src/main/java/com/ojn/gexf4j/core/Edge.java // public interface Edge extends SlicableDatum<Edge> { // // String getId(); // // Node getSource(); // // Node getTarget(); // Edge setTarget(Node target); // // boolean hasLabel(); // Edge clearLabel(); // String getLabel(); // Edge setLabel(String label); // // boolean hasWeight(); // Edge clearWeight(); // float getWeight(); // Edge setWeight(float weight); // // EdgeType getEdgeType(); // Edge setEdgeType(EdgeType edgeType); // // boolean hasColor(); // Edge clearColor(); // Color getColor(); // Edge setColor(Color color); // // boolean hasThickness(); // Edge clearThickness(); // float getThickness(); // Edge setThickness(float thickness); // // EdgeShape getShape(); // Edge setShape(EdgeShape shape); // } // // Path: src/main/java/com/ojn/gexf4j/core/EdgeType.java // public enum EdgeType { // // DIRECTED, // UNDIRECTED, // MUTUAL, // } // // Path: src/main/java/com/ojn/gexf4j/core/Node.java // public interface Node extends SlicableDatum<Node>, HasNodes { // // String getId(); // // String getLabel(); // Node setLabel(String label); // // List<Edge> getEdges(); // // Edge connectTo(Node target); // Edge connectTo(String id, Node target); // // boolean hasEdgeTo(String id); // // boolean hasColor(); // Node clearColor(); // Color getColor(); // Node setColor(Color color); // // boolean hasPosition(); // Node clearPosition(); // Position getPosition(); // Node setPosition(Position position); // // boolean hasSize(); // Node clearSize(); // float getSize(); // Node setSize(float size); // // boolean hasShape(); // Node clearShape(); // NodeShapeEntity getShapeEntity(); // // List<Node> getParentForList(); // // boolean hasPID(); // Node clearPID(); // String getPID(); // Node setPID(String pid); // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/Color.java // public interface Color { // // int getR(); // Color setR(int r); // // int getG(); // Color setG(int g); // // int getB(); // Color setB(int b); // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/EdgeShape.java // public enum EdgeShape { // // SOLID, // DOTTED, // DASHED, // DOUBLE, // NOTSET, // }
import static com.google.common.base.Preconditions.*; import com.ojn.gexf4j.core.Edge; import com.ojn.gexf4j.core.EdgeType; import com.ojn.gexf4j.core.Node; import com.ojn.gexf4j.core.viz.Color; import com.ojn.gexf4j.core.viz.EdgeShape;
package com.ojn.gexf4j.core.impl; public class EdgeImpl extends SliceableDatumBase<Edge> implements Edge { private String id = ""; private String label = null; private Node source = null; private Node target = null;
// Path: src/main/java/com/ojn/gexf4j/core/Edge.java // public interface Edge extends SlicableDatum<Edge> { // // String getId(); // // Node getSource(); // // Node getTarget(); // Edge setTarget(Node target); // // boolean hasLabel(); // Edge clearLabel(); // String getLabel(); // Edge setLabel(String label); // // boolean hasWeight(); // Edge clearWeight(); // float getWeight(); // Edge setWeight(float weight); // // EdgeType getEdgeType(); // Edge setEdgeType(EdgeType edgeType); // // boolean hasColor(); // Edge clearColor(); // Color getColor(); // Edge setColor(Color color); // // boolean hasThickness(); // Edge clearThickness(); // float getThickness(); // Edge setThickness(float thickness); // // EdgeShape getShape(); // Edge setShape(EdgeShape shape); // } // // Path: src/main/java/com/ojn/gexf4j/core/EdgeType.java // public enum EdgeType { // // DIRECTED, // UNDIRECTED, // MUTUAL, // } // // Path: src/main/java/com/ojn/gexf4j/core/Node.java // public interface Node extends SlicableDatum<Node>, HasNodes { // // String getId(); // // String getLabel(); // Node setLabel(String label); // // List<Edge> getEdges(); // // Edge connectTo(Node target); // Edge connectTo(String id, Node target); // // boolean hasEdgeTo(String id); // // boolean hasColor(); // Node clearColor(); // Color getColor(); // Node setColor(Color color); // // boolean hasPosition(); // Node clearPosition(); // Position getPosition(); // Node setPosition(Position position); // // boolean hasSize(); // Node clearSize(); // float getSize(); // Node setSize(float size); // // boolean hasShape(); // Node clearShape(); // NodeShapeEntity getShapeEntity(); // // List<Node> getParentForList(); // // boolean hasPID(); // Node clearPID(); // String getPID(); // Node setPID(String pid); // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/Color.java // public interface Color { // // int getR(); // Color setR(int r); // // int getG(); // Color setG(int g); // // int getB(); // Color setB(int b); // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/EdgeShape.java // public enum EdgeShape { // // SOLID, // DOTTED, // DASHED, // DOUBLE, // NOTSET, // } // Path: src/main/java/com/ojn/gexf4j/core/impl/EdgeImpl.java import static com.google.common.base.Preconditions.*; import com.ojn.gexf4j.core.Edge; import com.ojn.gexf4j.core.EdgeType; import com.ojn.gexf4j.core.Node; import com.ojn.gexf4j.core.viz.Color; import com.ojn.gexf4j.core.viz.EdgeShape; package com.ojn.gexf4j.core.impl; public class EdgeImpl extends SliceableDatumBase<Edge> implements Edge { private String id = ""; private String label = null; private Node source = null; private Node target = null;
private Color color = null;
jmcampanini/gexf4j-core
src/main/java/com/ojn/gexf4j/core/impl/EdgeImpl.java
// Path: src/main/java/com/ojn/gexf4j/core/Edge.java // public interface Edge extends SlicableDatum<Edge> { // // String getId(); // // Node getSource(); // // Node getTarget(); // Edge setTarget(Node target); // // boolean hasLabel(); // Edge clearLabel(); // String getLabel(); // Edge setLabel(String label); // // boolean hasWeight(); // Edge clearWeight(); // float getWeight(); // Edge setWeight(float weight); // // EdgeType getEdgeType(); // Edge setEdgeType(EdgeType edgeType); // // boolean hasColor(); // Edge clearColor(); // Color getColor(); // Edge setColor(Color color); // // boolean hasThickness(); // Edge clearThickness(); // float getThickness(); // Edge setThickness(float thickness); // // EdgeShape getShape(); // Edge setShape(EdgeShape shape); // } // // Path: src/main/java/com/ojn/gexf4j/core/EdgeType.java // public enum EdgeType { // // DIRECTED, // UNDIRECTED, // MUTUAL, // } // // Path: src/main/java/com/ojn/gexf4j/core/Node.java // public interface Node extends SlicableDatum<Node>, HasNodes { // // String getId(); // // String getLabel(); // Node setLabel(String label); // // List<Edge> getEdges(); // // Edge connectTo(Node target); // Edge connectTo(String id, Node target); // // boolean hasEdgeTo(String id); // // boolean hasColor(); // Node clearColor(); // Color getColor(); // Node setColor(Color color); // // boolean hasPosition(); // Node clearPosition(); // Position getPosition(); // Node setPosition(Position position); // // boolean hasSize(); // Node clearSize(); // float getSize(); // Node setSize(float size); // // boolean hasShape(); // Node clearShape(); // NodeShapeEntity getShapeEntity(); // // List<Node> getParentForList(); // // boolean hasPID(); // Node clearPID(); // String getPID(); // Node setPID(String pid); // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/Color.java // public interface Color { // // int getR(); // Color setR(int r); // // int getG(); // Color setG(int g); // // int getB(); // Color setB(int b); // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/EdgeShape.java // public enum EdgeShape { // // SOLID, // DOTTED, // DASHED, // DOUBLE, // NOTSET, // }
import static com.google.common.base.Preconditions.*; import com.ojn.gexf4j.core.Edge; import com.ojn.gexf4j.core.EdgeType; import com.ojn.gexf4j.core.Node; import com.ojn.gexf4j.core.viz.Color; import com.ojn.gexf4j.core.viz.EdgeShape;
package com.ojn.gexf4j.core.impl; public class EdgeImpl extends SliceableDatumBase<Edge> implements Edge { private String id = ""; private String label = null; private Node source = null; private Node target = null; private Color color = null;
// Path: src/main/java/com/ojn/gexf4j/core/Edge.java // public interface Edge extends SlicableDatum<Edge> { // // String getId(); // // Node getSource(); // // Node getTarget(); // Edge setTarget(Node target); // // boolean hasLabel(); // Edge clearLabel(); // String getLabel(); // Edge setLabel(String label); // // boolean hasWeight(); // Edge clearWeight(); // float getWeight(); // Edge setWeight(float weight); // // EdgeType getEdgeType(); // Edge setEdgeType(EdgeType edgeType); // // boolean hasColor(); // Edge clearColor(); // Color getColor(); // Edge setColor(Color color); // // boolean hasThickness(); // Edge clearThickness(); // float getThickness(); // Edge setThickness(float thickness); // // EdgeShape getShape(); // Edge setShape(EdgeShape shape); // } // // Path: src/main/java/com/ojn/gexf4j/core/EdgeType.java // public enum EdgeType { // // DIRECTED, // UNDIRECTED, // MUTUAL, // } // // Path: src/main/java/com/ojn/gexf4j/core/Node.java // public interface Node extends SlicableDatum<Node>, HasNodes { // // String getId(); // // String getLabel(); // Node setLabel(String label); // // List<Edge> getEdges(); // // Edge connectTo(Node target); // Edge connectTo(String id, Node target); // // boolean hasEdgeTo(String id); // // boolean hasColor(); // Node clearColor(); // Color getColor(); // Node setColor(Color color); // // boolean hasPosition(); // Node clearPosition(); // Position getPosition(); // Node setPosition(Position position); // // boolean hasSize(); // Node clearSize(); // float getSize(); // Node setSize(float size); // // boolean hasShape(); // Node clearShape(); // NodeShapeEntity getShapeEntity(); // // List<Node> getParentForList(); // // boolean hasPID(); // Node clearPID(); // String getPID(); // Node setPID(String pid); // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/Color.java // public interface Color { // // int getR(); // Color setR(int r); // // int getG(); // Color setG(int g); // // int getB(); // Color setB(int b); // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/EdgeShape.java // public enum EdgeShape { // // SOLID, // DOTTED, // DASHED, // DOUBLE, // NOTSET, // } // Path: src/main/java/com/ojn/gexf4j/core/impl/EdgeImpl.java import static com.google.common.base.Preconditions.*; import com.ojn.gexf4j.core.Edge; import com.ojn.gexf4j.core.EdgeType; import com.ojn.gexf4j.core.Node; import com.ojn.gexf4j.core.viz.Color; import com.ojn.gexf4j.core.viz.EdgeShape; package com.ojn.gexf4j.core.impl; public class EdgeImpl extends SliceableDatumBase<Edge> implements Edge { private String id = ""; private String label = null; private Node source = null; private Node target = null; private Color color = null;
private EdgeShape shape = EdgeShape.NOTSET;
jmcampanini/gexf4j-core
src/main/java/com/ojn/gexf4j/core/impl/EdgeImpl.java
// Path: src/main/java/com/ojn/gexf4j/core/Edge.java // public interface Edge extends SlicableDatum<Edge> { // // String getId(); // // Node getSource(); // // Node getTarget(); // Edge setTarget(Node target); // // boolean hasLabel(); // Edge clearLabel(); // String getLabel(); // Edge setLabel(String label); // // boolean hasWeight(); // Edge clearWeight(); // float getWeight(); // Edge setWeight(float weight); // // EdgeType getEdgeType(); // Edge setEdgeType(EdgeType edgeType); // // boolean hasColor(); // Edge clearColor(); // Color getColor(); // Edge setColor(Color color); // // boolean hasThickness(); // Edge clearThickness(); // float getThickness(); // Edge setThickness(float thickness); // // EdgeShape getShape(); // Edge setShape(EdgeShape shape); // } // // Path: src/main/java/com/ojn/gexf4j/core/EdgeType.java // public enum EdgeType { // // DIRECTED, // UNDIRECTED, // MUTUAL, // } // // Path: src/main/java/com/ojn/gexf4j/core/Node.java // public interface Node extends SlicableDatum<Node>, HasNodes { // // String getId(); // // String getLabel(); // Node setLabel(String label); // // List<Edge> getEdges(); // // Edge connectTo(Node target); // Edge connectTo(String id, Node target); // // boolean hasEdgeTo(String id); // // boolean hasColor(); // Node clearColor(); // Color getColor(); // Node setColor(Color color); // // boolean hasPosition(); // Node clearPosition(); // Position getPosition(); // Node setPosition(Position position); // // boolean hasSize(); // Node clearSize(); // float getSize(); // Node setSize(float size); // // boolean hasShape(); // Node clearShape(); // NodeShapeEntity getShapeEntity(); // // List<Node> getParentForList(); // // boolean hasPID(); // Node clearPID(); // String getPID(); // Node setPID(String pid); // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/Color.java // public interface Color { // // int getR(); // Color setR(int r); // // int getG(); // Color setG(int g); // // int getB(); // Color setB(int b); // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/EdgeShape.java // public enum EdgeShape { // // SOLID, // DOTTED, // DASHED, // DOUBLE, // NOTSET, // }
import static com.google.common.base.Preconditions.*; import com.ojn.gexf4j.core.Edge; import com.ojn.gexf4j.core.EdgeType; import com.ojn.gexf4j.core.Node; import com.ojn.gexf4j.core.viz.Color; import com.ojn.gexf4j.core.viz.EdgeShape;
package com.ojn.gexf4j.core.impl; public class EdgeImpl extends SliceableDatumBase<Edge> implements Edge { private String id = ""; private String label = null; private Node source = null; private Node target = null; private Color color = null; private EdgeShape shape = EdgeShape.NOTSET; private float thickness = Float.MIN_VALUE; private float weight = Float.MIN_VALUE;
// Path: src/main/java/com/ojn/gexf4j/core/Edge.java // public interface Edge extends SlicableDatum<Edge> { // // String getId(); // // Node getSource(); // // Node getTarget(); // Edge setTarget(Node target); // // boolean hasLabel(); // Edge clearLabel(); // String getLabel(); // Edge setLabel(String label); // // boolean hasWeight(); // Edge clearWeight(); // float getWeight(); // Edge setWeight(float weight); // // EdgeType getEdgeType(); // Edge setEdgeType(EdgeType edgeType); // // boolean hasColor(); // Edge clearColor(); // Color getColor(); // Edge setColor(Color color); // // boolean hasThickness(); // Edge clearThickness(); // float getThickness(); // Edge setThickness(float thickness); // // EdgeShape getShape(); // Edge setShape(EdgeShape shape); // } // // Path: src/main/java/com/ojn/gexf4j/core/EdgeType.java // public enum EdgeType { // // DIRECTED, // UNDIRECTED, // MUTUAL, // } // // Path: src/main/java/com/ojn/gexf4j/core/Node.java // public interface Node extends SlicableDatum<Node>, HasNodes { // // String getId(); // // String getLabel(); // Node setLabel(String label); // // List<Edge> getEdges(); // // Edge connectTo(Node target); // Edge connectTo(String id, Node target); // // boolean hasEdgeTo(String id); // // boolean hasColor(); // Node clearColor(); // Color getColor(); // Node setColor(Color color); // // boolean hasPosition(); // Node clearPosition(); // Position getPosition(); // Node setPosition(Position position); // // boolean hasSize(); // Node clearSize(); // float getSize(); // Node setSize(float size); // // boolean hasShape(); // Node clearShape(); // NodeShapeEntity getShapeEntity(); // // List<Node> getParentForList(); // // boolean hasPID(); // Node clearPID(); // String getPID(); // Node setPID(String pid); // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/Color.java // public interface Color { // // int getR(); // Color setR(int r); // // int getG(); // Color setG(int g); // // int getB(); // Color setB(int b); // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/EdgeShape.java // public enum EdgeShape { // // SOLID, // DOTTED, // DASHED, // DOUBLE, // NOTSET, // } // Path: src/main/java/com/ojn/gexf4j/core/impl/EdgeImpl.java import static com.google.common.base.Preconditions.*; import com.ojn.gexf4j.core.Edge; import com.ojn.gexf4j.core.EdgeType; import com.ojn.gexf4j.core.Node; import com.ojn.gexf4j.core.viz.Color; import com.ojn.gexf4j.core.viz.EdgeShape; package com.ojn.gexf4j.core.impl; public class EdgeImpl extends SliceableDatumBase<Edge> implements Edge { private String id = ""; private String label = null; private Node source = null; private Node target = null; private Color color = null; private EdgeShape shape = EdgeShape.NOTSET; private float thickness = Float.MIN_VALUE; private float weight = Float.MIN_VALUE;
private EdgeType edgeType = EdgeType.UNDIRECTED;
jmcampanini/gexf4j-core
src/main/java/com/ojn/gexf4j/core/impl/data/AttributeImpl.java
// Path: src/main/java/com/ojn/gexf4j/core/data/Attribute.java // public interface Attribute { // // String getId(); // // String getTitle(); // Attribute setTitle(String title); // // AttributeType getAttributeType(); // // boolean hasDefaultValue(); // Attribute clearDefaultValue(); // String getDefaultValue(); // Attribute setDefaultValue(String defaultValue); // // List<String> getOptions(); // // AttributeValue createValue(String value); // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeType.java // public enum AttributeType { // // INTEGER, // LONG, // DOUBLE, // FLOAT, // BOOLEAN, // STRING, // LISTSTRING, // ANYURI, // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeValue.java // public interface AttributeValue extends Dynamic<AttributeValue> { // // Attribute getAttribute(); // // String getValue(); // AttributeValue setValue(String value); // }
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkState; import java.util.ArrayList; import java.util.List; import com.ojn.gexf4j.core.data.Attribute; import com.ojn.gexf4j.core.data.AttributeType; import com.ojn.gexf4j.core.data.AttributeValue;
package com.ojn.gexf4j.core.impl.data; public class AttributeImpl implements Attribute { private String id = ""; private String defaultValue = null;
// Path: src/main/java/com/ojn/gexf4j/core/data/Attribute.java // public interface Attribute { // // String getId(); // // String getTitle(); // Attribute setTitle(String title); // // AttributeType getAttributeType(); // // boolean hasDefaultValue(); // Attribute clearDefaultValue(); // String getDefaultValue(); // Attribute setDefaultValue(String defaultValue); // // List<String> getOptions(); // // AttributeValue createValue(String value); // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeType.java // public enum AttributeType { // // INTEGER, // LONG, // DOUBLE, // FLOAT, // BOOLEAN, // STRING, // LISTSTRING, // ANYURI, // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeValue.java // public interface AttributeValue extends Dynamic<AttributeValue> { // // Attribute getAttribute(); // // String getValue(); // AttributeValue setValue(String value); // } // Path: src/main/java/com/ojn/gexf4j/core/impl/data/AttributeImpl.java import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkState; import java.util.ArrayList; import java.util.List; import com.ojn.gexf4j.core.data.Attribute; import com.ojn.gexf4j.core.data.AttributeType; import com.ojn.gexf4j.core.data.AttributeValue; package com.ojn.gexf4j.core.impl.data; public class AttributeImpl implements Attribute { private String id = ""; private String defaultValue = null;
private AttributeType type = AttributeType.STRING;
jmcampanini/gexf4j-core
src/main/java/com/ojn/gexf4j/core/impl/data/AttributeImpl.java
// Path: src/main/java/com/ojn/gexf4j/core/data/Attribute.java // public interface Attribute { // // String getId(); // // String getTitle(); // Attribute setTitle(String title); // // AttributeType getAttributeType(); // // boolean hasDefaultValue(); // Attribute clearDefaultValue(); // String getDefaultValue(); // Attribute setDefaultValue(String defaultValue); // // List<String> getOptions(); // // AttributeValue createValue(String value); // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeType.java // public enum AttributeType { // // INTEGER, // LONG, // DOUBLE, // FLOAT, // BOOLEAN, // STRING, // LISTSTRING, // ANYURI, // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeValue.java // public interface AttributeValue extends Dynamic<AttributeValue> { // // Attribute getAttribute(); // // String getValue(); // AttributeValue setValue(String value); // }
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkState; import java.util.ArrayList; import java.util.List; import com.ojn.gexf4j.core.data.Attribute; import com.ojn.gexf4j.core.data.AttributeType; import com.ojn.gexf4j.core.data.AttributeValue;
public List<String> getOptions() { return options; } @Override public String getTitle() { return title; } @Override public boolean hasDefaultValue() { return (defaultValue != null); } @Override public Attribute setDefaultValue(String defaultValue) { checkArgument(defaultValue != null, "Default Value cannot be null."); this.defaultValue = defaultValue; return this; } @Override public Attribute setTitle(String title) { checkArgument(title != null, "Title cannot be null."); checkArgument(title.trim().isEmpty(), "Title cannot be null or blank."); this.title = title; return this; } @Override
// Path: src/main/java/com/ojn/gexf4j/core/data/Attribute.java // public interface Attribute { // // String getId(); // // String getTitle(); // Attribute setTitle(String title); // // AttributeType getAttributeType(); // // boolean hasDefaultValue(); // Attribute clearDefaultValue(); // String getDefaultValue(); // Attribute setDefaultValue(String defaultValue); // // List<String> getOptions(); // // AttributeValue createValue(String value); // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeType.java // public enum AttributeType { // // INTEGER, // LONG, // DOUBLE, // FLOAT, // BOOLEAN, // STRING, // LISTSTRING, // ANYURI, // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeValue.java // public interface AttributeValue extends Dynamic<AttributeValue> { // // Attribute getAttribute(); // // String getValue(); // AttributeValue setValue(String value); // } // Path: src/main/java/com/ojn/gexf4j/core/impl/data/AttributeImpl.java import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkState; import java.util.ArrayList; import java.util.List; import com.ojn.gexf4j.core.data.Attribute; import com.ojn.gexf4j.core.data.AttributeType; import com.ojn.gexf4j.core.data.AttributeValue; public List<String> getOptions() { return options; } @Override public String getTitle() { return title; } @Override public boolean hasDefaultValue() { return (defaultValue != null); } @Override public Attribute setDefaultValue(String defaultValue) { checkArgument(defaultValue != null, "Default Value cannot be null."); this.defaultValue = defaultValue; return this; } @Override public Attribute setTitle(String title) { checkArgument(title != null, "Title cannot be null."); checkArgument(title.trim().isEmpty(), "Title cannot be null or blank."); this.title = title; return this; } @Override
public AttributeValue createValue(String value) {
jmcampanini/gexf4j-core
src/main/java/com/ojn/gexf4j/core/impl/writer/EdgeEntityWriter.java
// Path: src/main/java/com/ojn/gexf4j/core/Edge.java // public interface Edge extends SlicableDatum<Edge> { // // String getId(); // // Node getSource(); // // Node getTarget(); // Edge setTarget(Node target); // // boolean hasLabel(); // Edge clearLabel(); // String getLabel(); // Edge setLabel(String label); // // boolean hasWeight(); // Edge clearWeight(); // float getWeight(); // Edge setWeight(float weight); // // EdgeType getEdgeType(); // Edge setEdgeType(EdgeType edgeType); // // boolean hasColor(); // Edge clearColor(); // Color getColor(); // Edge setColor(Color color); // // boolean hasThickness(); // Edge clearThickness(); // float getThickness(); // Edge setThickness(float thickness); // // EdgeShape getShape(); // Edge setShape(EdgeShape shape); // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/EdgeShape.java // public enum EdgeShape { // // SOLID, // DOTTED, // DASHED, // DOUBLE, // NOTSET, // }
import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamWriter; import com.ojn.gexf4j.core.Edge; import com.ojn.gexf4j.core.viz.EdgeShape;
package com.ojn.gexf4j.core.impl.writer; public class EdgeEntityWriter extends SlicableDatumEntityWriter<Edge> { private static final String ENTITY = "edge"; private static final String ATTRIB_ID = "id"; private static final String ATTRIB_LABEL = "label"; private static final String ATTRIB_SOURCE = "source"; private static final String ATTRIB_TARGET = "target"; private static final String ATTRIB_WEIGHT = "weight"; private static final String ATTRIB_TYPE = "type"; public EdgeEntityWriter(XMLStreamWriter writer, Edge entity) { super(writer, entity); write(); } @Override protected String getElementName() { return ENTITY; } @Override protected void writeElements() throws XMLStreamException { super.writeElements(); if (entity.hasColor()) { new ColorEntityWriter(writer, entity.getColor()); } if (entity.hasThickness()) { new ValueEntityWriter<Float>(writer, "viz:thickness", entity.getThickness()); }
// Path: src/main/java/com/ojn/gexf4j/core/Edge.java // public interface Edge extends SlicableDatum<Edge> { // // String getId(); // // Node getSource(); // // Node getTarget(); // Edge setTarget(Node target); // // boolean hasLabel(); // Edge clearLabel(); // String getLabel(); // Edge setLabel(String label); // // boolean hasWeight(); // Edge clearWeight(); // float getWeight(); // Edge setWeight(float weight); // // EdgeType getEdgeType(); // Edge setEdgeType(EdgeType edgeType); // // boolean hasColor(); // Edge clearColor(); // Color getColor(); // Edge setColor(Color color); // // boolean hasThickness(); // Edge clearThickness(); // float getThickness(); // Edge setThickness(float thickness); // // EdgeShape getShape(); // Edge setShape(EdgeShape shape); // } // // Path: src/main/java/com/ojn/gexf4j/core/viz/EdgeShape.java // public enum EdgeShape { // // SOLID, // DOTTED, // DASHED, // DOUBLE, // NOTSET, // } // Path: src/main/java/com/ojn/gexf4j/core/impl/writer/EdgeEntityWriter.java import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamWriter; import com.ojn.gexf4j.core.Edge; import com.ojn.gexf4j.core.viz.EdgeShape; package com.ojn.gexf4j.core.impl.writer; public class EdgeEntityWriter extends SlicableDatumEntityWriter<Edge> { private static final String ENTITY = "edge"; private static final String ATTRIB_ID = "id"; private static final String ATTRIB_LABEL = "label"; private static final String ATTRIB_SOURCE = "source"; private static final String ATTRIB_TARGET = "target"; private static final String ATTRIB_WEIGHT = "weight"; private static final String ATTRIB_TYPE = "type"; public EdgeEntityWriter(XMLStreamWriter writer, Edge entity) { super(writer, entity); write(); } @Override protected String getElementName() { return ENTITY; } @Override protected void writeElements() throws XMLStreamException { super.writeElements(); if (entity.hasColor()) { new ColorEntityWriter(writer, entity.getColor()); } if (entity.hasThickness()) { new ValueEntityWriter<Float>(writer, "viz:thickness", entity.getThickness()); }
if (entity.getShape() != EdgeShape.NOTSET) {
jmcampanini/gexf4j-core
src/test/java/com/ojn/gexf4j/core/testgraphs/BasicGraphBuilder.java
// Path: src/main/java/com/ojn/gexf4j/core/Gexf.java // public interface Gexf { // // String getVersion(); // // boolean hasVariant(); // Gexf clearVariant(); // String getVariant(); // Gexf setVariant(String variant); // // Metadata getMetadata(); // // Graph getGraph(); // // boolean hasVisualization(); // Gexf setVisualization(boolean viz); // } // // Path: src/main/java/com/ojn/gexf4j/core/Graph.java // public interface Graph extends Dynamic<Graph>, HasNodes { // // EdgeType getDefaultEdgeType(); // Graph setDefaultEdgeType(EdgeType edgeType); // // IDType getIDType(); // Graph setIDType(IDType idType); // // Mode getMode(); // Graph setMode(Mode graphMode); // // TimeType getTimeType(); // Graph setTimeType(TimeType timeType); // // List<AttributeList> getAttributeLists(); // } // // Path: src/main/java/com/ojn/gexf4j/core/Node.java // public interface Node extends SlicableDatum<Node>, HasNodes { // // String getId(); // // String getLabel(); // Node setLabel(String label); // // List<Edge> getEdges(); // // Edge connectTo(Node target); // Edge connectTo(String id, Node target); // // boolean hasEdgeTo(String id); // // boolean hasColor(); // Node clearColor(); // Color getColor(); // Node setColor(Color color); // // boolean hasPosition(); // Node clearPosition(); // Position getPosition(); // Node setPosition(Position position); // // boolean hasSize(); // Node clearSize(); // float getSize(); // Node setSize(float size); // // boolean hasShape(); // Node clearShape(); // NodeShapeEntity getShapeEntity(); // // List<Node> getParentForList(); // // boolean hasPID(); // Node clearPID(); // String getPID(); // Node setPID(String pid); // } // // Path: src/main/java/com/ojn/gexf4j/core/impl/GexfImpl.java // public class GexfImpl implements Gexf { // private static final String VERSION = "1.1"; // // private String variant = null; // private Graph graph = null; // private Metadata meta = null; // private boolean viz = false; // // public GexfImpl() { // graph = new GraphImpl(); // meta = new MetadataImpl(); // } // // @Override // public Graph getGraph() { // return graph; // } // // @Override // public Metadata getMetadata() { // return meta; // } // // @Override // public String getVersion() { // return VERSION; // } // // @Override // public boolean hasVariant() { // return (variant != null); // } // // @Override // public Gexf clearVariant() { // variant = null; // return this; // } // // @Override // public String getVariant() { // checkState(hasVariant(), "Variant has not been set."); // return variant; // } // // @Override // public Gexf setVariant(String variant) { // checkArgument(variant != null, "Variant cannot be null."); // checkArgument(!variant.trim().isEmpty(), "Variant cannot be empty or blank."); // this.variant = variant; // return this; // } // // @Override // public boolean hasVisualization() { // return viz; // } // // @Override // public Gexf setVisualization(boolean viz) { // this.viz = viz; // return this; // } // }
import com.ojn.gexf4j.core.Gexf; import com.ojn.gexf4j.core.Graph; import com.ojn.gexf4j.core.Node; import com.ojn.gexf4j.core.impl.GexfImpl;
package com.ojn.gexf4j.core.testgraphs; public class BasicGraphBuilder extends GexfBuilder { @Override public String getSuffix() { return "basic"; } @Override
// Path: src/main/java/com/ojn/gexf4j/core/Gexf.java // public interface Gexf { // // String getVersion(); // // boolean hasVariant(); // Gexf clearVariant(); // String getVariant(); // Gexf setVariant(String variant); // // Metadata getMetadata(); // // Graph getGraph(); // // boolean hasVisualization(); // Gexf setVisualization(boolean viz); // } // // Path: src/main/java/com/ojn/gexf4j/core/Graph.java // public interface Graph extends Dynamic<Graph>, HasNodes { // // EdgeType getDefaultEdgeType(); // Graph setDefaultEdgeType(EdgeType edgeType); // // IDType getIDType(); // Graph setIDType(IDType idType); // // Mode getMode(); // Graph setMode(Mode graphMode); // // TimeType getTimeType(); // Graph setTimeType(TimeType timeType); // // List<AttributeList> getAttributeLists(); // } // // Path: src/main/java/com/ojn/gexf4j/core/Node.java // public interface Node extends SlicableDatum<Node>, HasNodes { // // String getId(); // // String getLabel(); // Node setLabel(String label); // // List<Edge> getEdges(); // // Edge connectTo(Node target); // Edge connectTo(String id, Node target); // // boolean hasEdgeTo(String id); // // boolean hasColor(); // Node clearColor(); // Color getColor(); // Node setColor(Color color); // // boolean hasPosition(); // Node clearPosition(); // Position getPosition(); // Node setPosition(Position position); // // boolean hasSize(); // Node clearSize(); // float getSize(); // Node setSize(float size); // // boolean hasShape(); // Node clearShape(); // NodeShapeEntity getShapeEntity(); // // List<Node> getParentForList(); // // boolean hasPID(); // Node clearPID(); // String getPID(); // Node setPID(String pid); // } // // Path: src/main/java/com/ojn/gexf4j/core/impl/GexfImpl.java // public class GexfImpl implements Gexf { // private static final String VERSION = "1.1"; // // private String variant = null; // private Graph graph = null; // private Metadata meta = null; // private boolean viz = false; // // public GexfImpl() { // graph = new GraphImpl(); // meta = new MetadataImpl(); // } // // @Override // public Graph getGraph() { // return graph; // } // // @Override // public Metadata getMetadata() { // return meta; // } // // @Override // public String getVersion() { // return VERSION; // } // // @Override // public boolean hasVariant() { // return (variant != null); // } // // @Override // public Gexf clearVariant() { // variant = null; // return this; // } // // @Override // public String getVariant() { // checkState(hasVariant(), "Variant has not been set."); // return variant; // } // // @Override // public Gexf setVariant(String variant) { // checkArgument(variant != null, "Variant cannot be null."); // checkArgument(!variant.trim().isEmpty(), "Variant cannot be empty or blank."); // this.variant = variant; // return this; // } // // @Override // public boolean hasVisualization() { // return viz; // } // // @Override // public Gexf setVisualization(boolean viz) { // this.viz = viz; // return this; // } // } // Path: src/test/java/com/ojn/gexf4j/core/testgraphs/BasicGraphBuilder.java import com.ojn.gexf4j.core.Gexf; import com.ojn.gexf4j.core.Graph; import com.ojn.gexf4j.core.Node; import com.ojn.gexf4j.core.impl.GexfImpl; package com.ojn.gexf4j.core.testgraphs; public class BasicGraphBuilder extends GexfBuilder { @Override public String getSuffix() { return "basic"; } @Override
public Gexf buildGexf() {
jmcampanini/gexf4j-core
src/test/java/com/ojn/gexf4j/core/testgraphs/BasicGraphBuilder.java
// Path: src/main/java/com/ojn/gexf4j/core/Gexf.java // public interface Gexf { // // String getVersion(); // // boolean hasVariant(); // Gexf clearVariant(); // String getVariant(); // Gexf setVariant(String variant); // // Metadata getMetadata(); // // Graph getGraph(); // // boolean hasVisualization(); // Gexf setVisualization(boolean viz); // } // // Path: src/main/java/com/ojn/gexf4j/core/Graph.java // public interface Graph extends Dynamic<Graph>, HasNodes { // // EdgeType getDefaultEdgeType(); // Graph setDefaultEdgeType(EdgeType edgeType); // // IDType getIDType(); // Graph setIDType(IDType idType); // // Mode getMode(); // Graph setMode(Mode graphMode); // // TimeType getTimeType(); // Graph setTimeType(TimeType timeType); // // List<AttributeList> getAttributeLists(); // } // // Path: src/main/java/com/ojn/gexf4j/core/Node.java // public interface Node extends SlicableDatum<Node>, HasNodes { // // String getId(); // // String getLabel(); // Node setLabel(String label); // // List<Edge> getEdges(); // // Edge connectTo(Node target); // Edge connectTo(String id, Node target); // // boolean hasEdgeTo(String id); // // boolean hasColor(); // Node clearColor(); // Color getColor(); // Node setColor(Color color); // // boolean hasPosition(); // Node clearPosition(); // Position getPosition(); // Node setPosition(Position position); // // boolean hasSize(); // Node clearSize(); // float getSize(); // Node setSize(float size); // // boolean hasShape(); // Node clearShape(); // NodeShapeEntity getShapeEntity(); // // List<Node> getParentForList(); // // boolean hasPID(); // Node clearPID(); // String getPID(); // Node setPID(String pid); // } // // Path: src/main/java/com/ojn/gexf4j/core/impl/GexfImpl.java // public class GexfImpl implements Gexf { // private static final String VERSION = "1.1"; // // private String variant = null; // private Graph graph = null; // private Metadata meta = null; // private boolean viz = false; // // public GexfImpl() { // graph = new GraphImpl(); // meta = new MetadataImpl(); // } // // @Override // public Graph getGraph() { // return graph; // } // // @Override // public Metadata getMetadata() { // return meta; // } // // @Override // public String getVersion() { // return VERSION; // } // // @Override // public boolean hasVariant() { // return (variant != null); // } // // @Override // public Gexf clearVariant() { // variant = null; // return this; // } // // @Override // public String getVariant() { // checkState(hasVariant(), "Variant has not been set."); // return variant; // } // // @Override // public Gexf setVariant(String variant) { // checkArgument(variant != null, "Variant cannot be null."); // checkArgument(!variant.trim().isEmpty(), "Variant cannot be empty or blank."); // this.variant = variant; // return this; // } // // @Override // public boolean hasVisualization() { // return viz; // } // // @Override // public Gexf setVisualization(boolean viz) { // this.viz = viz; // return this; // } // }
import com.ojn.gexf4j.core.Gexf; import com.ojn.gexf4j.core.Graph; import com.ojn.gexf4j.core.Node; import com.ojn.gexf4j.core.impl.GexfImpl;
package com.ojn.gexf4j.core.testgraphs; public class BasicGraphBuilder extends GexfBuilder { @Override public String getSuffix() { return "basic"; } @Override public Gexf buildGexf() {
// Path: src/main/java/com/ojn/gexf4j/core/Gexf.java // public interface Gexf { // // String getVersion(); // // boolean hasVariant(); // Gexf clearVariant(); // String getVariant(); // Gexf setVariant(String variant); // // Metadata getMetadata(); // // Graph getGraph(); // // boolean hasVisualization(); // Gexf setVisualization(boolean viz); // } // // Path: src/main/java/com/ojn/gexf4j/core/Graph.java // public interface Graph extends Dynamic<Graph>, HasNodes { // // EdgeType getDefaultEdgeType(); // Graph setDefaultEdgeType(EdgeType edgeType); // // IDType getIDType(); // Graph setIDType(IDType idType); // // Mode getMode(); // Graph setMode(Mode graphMode); // // TimeType getTimeType(); // Graph setTimeType(TimeType timeType); // // List<AttributeList> getAttributeLists(); // } // // Path: src/main/java/com/ojn/gexf4j/core/Node.java // public interface Node extends SlicableDatum<Node>, HasNodes { // // String getId(); // // String getLabel(); // Node setLabel(String label); // // List<Edge> getEdges(); // // Edge connectTo(Node target); // Edge connectTo(String id, Node target); // // boolean hasEdgeTo(String id); // // boolean hasColor(); // Node clearColor(); // Color getColor(); // Node setColor(Color color); // // boolean hasPosition(); // Node clearPosition(); // Position getPosition(); // Node setPosition(Position position); // // boolean hasSize(); // Node clearSize(); // float getSize(); // Node setSize(float size); // // boolean hasShape(); // Node clearShape(); // NodeShapeEntity getShapeEntity(); // // List<Node> getParentForList(); // // boolean hasPID(); // Node clearPID(); // String getPID(); // Node setPID(String pid); // } // // Path: src/main/java/com/ojn/gexf4j/core/impl/GexfImpl.java // public class GexfImpl implements Gexf { // private static final String VERSION = "1.1"; // // private String variant = null; // private Graph graph = null; // private Metadata meta = null; // private boolean viz = false; // // public GexfImpl() { // graph = new GraphImpl(); // meta = new MetadataImpl(); // } // // @Override // public Graph getGraph() { // return graph; // } // // @Override // public Metadata getMetadata() { // return meta; // } // // @Override // public String getVersion() { // return VERSION; // } // // @Override // public boolean hasVariant() { // return (variant != null); // } // // @Override // public Gexf clearVariant() { // variant = null; // return this; // } // // @Override // public String getVariant() { // checkState(hasVariant(), "Variant has not been set."); // return variant; // } // // @Override // public Gexf setVariant(String variant) { // checkArgument(variant != null, "Variant cannot be null."); // checkArgument(!variant.trim().isEmpty(), "Variant cannot be empty or blank."); // this.variant = variant; // return this; // } // // @Override // public boolean hasVisualization() { // return viz; // } // // @Override // public Gexf setVisualization(boolean viz) { // this.viz = viz; // return this; // } // } // Path: src/test/java/com/ojn/gexf4j/core/testgraphs/BasicGraphBuilder.java import com.ojn.gexf4j.core.Gexf; import com.ojn.gexf4j.core.Graph; import com.ojn.gexf4j.core.Node; import com.ojn.gexf4j.core.impl.GexfImpl; package com.ojn.gexf4j.core.testgraphs; public class BasicGraphBuilder extends GexfBuilder { @Override public String getSuffix() { return "basic"; } @Override public Gexf buildGexf() {
Gexf gexf = new GexfImpl();
jmcampanini/gexf4j-core
src/test/java/com/ojn/gexf4j/core/testgraphs/BasicGraphBuilder.java
// Path: src/main/java/com/ojn/gexf4j/core/Gexf.java // public interface Gexf { // // String getVersion(); // // boolean hasVariant(); // Gexf clearVariant(); // String getVariant(); // Gexf setVariant(String variant); // // Metadata getMetadata(); // // Graph getGraph(); // // boolean hasVisualization(); // Gexf setVisualization(boolean viz); // } // // Path: src/main/java/com/ojn/gexf4j/core/Graph.java // public interface Graph extends Dynamic<Graph>, HasNodes { // // EdgeType getDefaultEdgeType(); // Graph setDefaultEdgeType(EdgeType edgeType); // // IDType getIDType(); // Graph setIDType(IDType idType); // // Mode getMode(); // Graph setMode(Mode graphMode); // // TimeType getTimeType(); // Graph setTimeType(TimeType timeType); // // List<AttributeList> getAttributeLists(); // } // // Path: src/main/java/com/ojn/gexf4j/core/Node.java // public interface Node extends SlicableDatum<Node>, HasNodes { // // String getId(); // // String getLabel(); // Node setLabel(String label); // // List<Edge> getEdges(); // // Edge connectTo(Node target); // Edge connectTo(String id, Node target); // // boolean hasEdgeTo(String id); // // boolean hasColor(); // Node clearColor(); // Color getColor(); // Node setColor(Color color); // // boolean hasPosition(); // Node clearPosition(); // Position getPosition(); // Node setPosition(Position position); // // boolean hasSize(); // Node clearSize(); // float getSize(); // Node setSize(float size); // // boolean hasShape(); // Node clearShape(); // NodeShapeEntity getShapeEntity(); // // List<Node> getParentForList(); // // boolean hasPID(); // Node clearPID(); // String getPID(); // Node setPID(String pid); // } // // Path: src/main/java/com/ojn/gexf4j/core/impl/GexfImpl.java // public class GexfImpl implements Gexf { // private static final String VERSION = "1.1"; // // private String variant = null; // private Graph graph = null; // private Metadata meta = null; // private boolean viz = false; // // public GexfImpl() { // graph = new GraphImpl(); // meta = new MetadataImpl(); // } // // @Override // public Graph getGraph() { // return graph; // } // // @Override // public Metadata getMetadata() { // return meta; // } // // @Override // public String getVersion() { // return VERSION; // } // // @Override // public boolean hasVariant() { // return (variant != null); // } // // @Override // public Gexf clearVariant() { // variant = null; // return this; // } // // @Override // public String getVariant() { // checkState(hasVariant(), "Variant has not been set."); // return variant; // } // // @Override // public Gexf setVariant(String variant) { // checkArgument(variant != null, "Variant cannot be null."); // checkArgument(!variant.trim().isEmpty(), "Variant cannot be empty or blank."); // this.variant = variant; // return this; // } // // @Override // public boolean hasVisualization() { // return viz; // } // // @Override // public Gexf setVisualization(boolean viz) { // this.viz = viz; // return this; // } // }
import com.ojn.gexf4j.core.Gexf; import com.ojn.gexf4j.core.Graph; import com.ojn.gexf4j.core.Node; import com.ojn.gexf4j.core.impl.GexfImpl;
package com.ojn.gexf4j.core.testgraphs; public class BasicGraphBuilder extends GexfBuilder { @Override public String getSuffix() { return "basic"; } @Override public Gexf buildGexf() { Gexf gexf = new GexfImpl();
// Path: src/main/java/com/ojn/gexf4j/core/Gexf.java // public interface Gexf { // // String getVersion(); // // boolean hasVariant(); // Gexf clearVariant(); // String getVariant(); // Gexf setVariant(String variant); // // Metadata getMetadata(); // // Graph getGraph(); // // boolean hasVisualization(); // Gexf setVisualization(boolean viz); // } // // Path: src/main/java/com/ojn/gexf4j/core/Graph.java // public interface Graph extends Dynamic<Graph>, HasNodes { // // EdgeType getDefaultEdgeType(); // Graph setDefaultEdgeType(EdgeType edgeType); // // IDType getIDType(); // Graph setIDType(IDType idType); // // Mode getMode(); // Graph setMode(Mode graphMode); // // TimeType getTimeType(); // Graph setTimeType(TimeType timeType); // // List<AttributeList> getAttributeLists(); // } // // Path: src/main/java/com/ojn/gexf4j/core/Node.java // public interface Node extends SlicableDatum<Node>, HasNodes { // // String getId(); // // String getLabel(); // Node setLabel(String label); // // List<Edge> getEdges(); // // Edge connectTo(Node target); // Edge connectTo(String id, Node target); // // boolean hasEdgeTo(String id); // // boolean hasColor(); // Node clearColor(); // Color getColor(); // Node setColor(Color color); // // boolean hasPosition(); // Node clearPosition(); // Position getPosition(); // Node setPosition(Position position); // // boolean hasSize(); // Node clearSize(); // float getSize(); // Node setSize(float size); // // boolean hasShape(); // Node clearShape(); // NodeShapeEntity getShapeEntity(); // // List<Node> getParentForList(); // // boolean hasPID(); // Node clearPID(); // String getPID(); // Node setPID(String pid); // } // // Path: src/main/java/com/ojn/gexf4j/core/impl/GexfImpl.java // public class GexfImpl implements Gexf { // private static final String VERSION = "1.1"; // // private String variant = null; // private Graph graph = null; // private Metadata meta = null; // private boolean viz = false; // // public GexfImpl() { // graph = new GraphImpl(); // meta = new MetadataImpl(); // } // // @Override // public Graph getGraph() { // return graph; // } // // @Override // public Metadata getMetadata() { // return meta; // } // // @Override // public String getVersion() { // return VERSION; // } // // @Override // public boolean hasVariant() { // return (variant != null); // } // // @Override // public Gexf clearVariant() { // variant = null; // return this; // } // // @Override // public String getVariant() { // checkState(hasVariant(), "Variant has not been set."); // return variant; // } // // @Override // public Gexf setVariant(String variant) { // checkArgument(variant != null, "Variant cannot be null."); // checkArgument(!variant.trim().isEmpty(), "Variant cannot be empty or blank."); // this.variant = variant; // return this; // } // // @Override // public boolean hasVisualization() { // return viz; // } // // @Override // public Gexf setVisualization(boolean viz) { // this.viz = viz; // return this; // } // } // Path: src/test/java/com/ojn/gexf4j/core/testgraphs/BasicGraphBuilder.java import com.ojn.gexf4j.core.Gexf; import com.ojn.gexf4j.core.Graph; import com.ojn.gexf4j.core.Node; import com.ojn.gexf4j.core.impl.GexfImpl; package com.ojn.gexf4j.core.testgraphs; public class BasicGraphBuilder extends GexfBuilder { @Override public String getSuffix() { return "basic"; } @Override public Gexf buildGexf() { Gexf gexf = new GexfImpl();
Graph g = gexf.getGraph();
jmcampanini/gexf4j-core
src/test/java/com/ojn/gexf4j/core/testgraphs/BasicGraphBuilder.java
// Path: src/main/java/com/ojn/gexf4j/core/Gexf.java // public interface Gexf { // // String getVersion(); // // boolean hasVariant(); // Gexf clearVariant(); // String getVariant(); // Gexf setVariant(String variant); // // Metadata getMetadata(); // // Graph getGraph(); // // boolean hasVisualization(); // Gexf setVisualization(boolean viz); // } // // Path: src/main/java/com/ojn/gexf4j/core/Graph.java // public interface Graph extends Dynamic<Graph>, HasNodes { // // EdgeType getDefaultEdgeType(); // Graph setDefaultEdgeType(EdgeType edgeType); // // IDType getIDType(); // Graph setIDType(IDType idType); // // Mode getMode(); // Graph setMode(Mode graphMode); // // TimeType getTimeType(); // Graph setTimeType(TimeType timeType); // // List<AttributeList> getAttributeLists(); // } // // Path: src/main/java/com/ojn/gexf4j/core/Node.java // public interface Node extends SlicableDatum<Node>, HasNodes { // // String getId(); // // String getLabel(); // Node setLabel(String label); // // List<Edge> getEdges(); // // Edge connectTo(Node target); // Edge connectTo(String id, Node target); // // boolean hasEdgeTo(String id); // // boolean hasColor(); // Node clearColor(); // Color getColor(); // Node setColor(Color color); // // boolean hasPosition(); // Node clearPosition(); // Position getPosition(); // Node setPosition(Position position); // // boolean hasSize(); // Node clearSize(); // float getSize(); // Node setSize(float size); // // boolean hasShape(); // Node clearShape(); // NodeShapeEntity getShapeEntity(); // // List<Node> getParentForList(); // // boolean hasPID(); // Node clearPID(); // String getPID(); // Node setPID(String pid); // } // // Path: src/main/java/com/ojn/gexf4j/core/impl/GexfImpl.java // public class GexfImpl implements Gexf { // private static final String VERSION = "1.1"; // // private String variant = null; // private Graph graph = null; // private Metadata meta = null; // private boolean viz = false; // // public GexfImpl() { // graph = new GraphImpl(); // meta = new MetadataImpl(); // } // // @Override // public Graph getGraph() { // return graph; // } // // @Override // public Metadata getMetadata() { // return meta; // } // // @Override // public String getVersion() { // return VERSION; // } // // @Override // public boolean hasVariant() { // return (variant != null); // } // // @Override // public Gexf clearVariant() { // variant = null; // return this; // } // // @Override // public String getVariant() { // checkState(hasVariant(), "Variant has not been set."); // return variant; // } // // @Override // public Gexf setVariant(String variant) { // checkArgument(variant != null, "Variant cannot be null."); // checkArgument(!variant.trim().isEmpty(), "Variant cannot be empty or blank."); // this.variant = variant; // return this; // } // // @Override // public boolean hasVisualization() { // return viz; // } // // @Override // public Gexf setVisualization(boolean viz) { // this.viz = viz; // return this; // } // }
import com.ojn.gexf4j.core.Gexf; import com.ojn.gexf4j.core.Graph; import com.ojn.gexf4j.core.Node; import com.ojn.gexf4j.core.impl.GexfImpl;
package com.ojn.gexf4j.core.testgraphs; public class BasicGraphBuilder extends GexfBuilder { @Override public String getSuffix() { return "basic"; } @Override public Gexf buildGexf() { Gexf gexf = new GexfImpl(); Graph g = gexf.getGraph();
// Path: src/main/java/com/ojn/gexf4j/core/Gexf.java // public interface Gexf { // // String getVersion(); // // boolean hasVariant(); // Gexf clearVariant(); // String getVariant(); // Gexf setVariant(String variant); // // Metadata getMetadata(); // // Graph getGraph(); // // boolean hasVisualization(); // Gexf setVisualization(boolean viz); // } // // Path: src/main/java/com/ojn/gexf4j/core/Graph.java // public interface Graph extends Dynamic<Graph>, HasNodes { // // EdgeType getDefaultEdgeType(); // Graph setDefaultEdgeType(EdgeType edgeType); // // IDType getIDType(); // Graph setIDType(IDType idType); // // Mode getMode(); // Graph setMode(Mode graphMode); // // TimeType getTimeType(); // Graph setTimeType(TimeType timeType); // // List<AttributeList> getAttributeLists(); // } // // Path: src/main/java/com/ojn/gexf4j/core/Node.java // public interface Node extends SlicableDatum<Node>, HasNodes { // // String getId(); // // String getLabel(); // Node setLabel(String label); // // List<Edge> getEdges(); // // Edge connectTo(Node target); // Edge connectTo(String id, Node target); // // boolean hasEdgeTo(String id); // // boolean hasColor(); // Node clearColor(); // Color getColor(); // Node setColor(Color color); // // boolean hasPosition(); // Node clearPosition(); // Position getPosition(); // Node setPosition(Position position); // // boolean hasSize(); // Node clearSize(); // float getSize(); // Node setSize(float size); // // boolean hasShape(); // Node clearShape(); // NodeShapeEntity getShapeEntity(); // // List<Node> getParentForList(); // // boolean hasPID(); // Node clearPID(); // String getPID(); // Node setPID(String pid); // } // // Path: src/main/java/com/ojn/gexf4j/core/impl/GexfImpl.java // public class GexfImpl implements Gexf { // private static final String VERSION = "1.1"; // // private String variant = null; // private Graph graph = null; // private Metadata meta = null; // private boolean viz = false; // // public GexfImpl() { // graph = new GraphImpl(); // meta = new MetadataImpl(); // } // // @Override // public Graph getGraph() { // return graph; // } // // @Override // public Metadata getMetadata() { // return meta; // } // // @Override // public String getVersion() { // return VERSION; // } // // @Override // public boolean hasVariant() { // return (variant != null); // } // // @Override // public Gexf clearVariant() { // variant = null; // return this; // } // // @Override // public String getVariant() { // checkState(hasVariant(), "Variant has not been set."); // return variant; // } // // @Override // public Gexf setVariant(String variant) { // checkArgument(variant != null, "Variant cannot be null."); // checkArgument(!variant.trim().isEmpty(), "Variant cannot be empty or blank."); // this.variant = variant; // return this; // } // // @Override // public boolean hasVisualization() { // return viz; // } // // @Override // public Gexf setVisualization(boolean viz) { // this.viz = viz; // return this; // } // } // Path: src/test/java/com/ojn/gexf4j/core/testgraphs/BasicGraphBuilder.java import com.ojn.gexf4j.core.Gexf; import com.ojn.gexf4j.core.Graph; import com.ojn.gexf4j.core.Node; import com.ojn.gexf4j.core.impl.GexfImpl; package com.ojn.gexf4j.core.testgraphs; public class BasicGraphBuilder extends GexfBuilder { @Override public String getSuffix() { return "basic"; } @Override public Gexf buildGexf() { Gexf gexf = new GexfImpl(); Graph g = gexf.getGraph();
Node hello = g.createNode("0")
jmcampanini/gexf4j-core
src/main/java/com/ojn/gexf4j/core/impl/data/AttributeListImpl.java
// Path: src/main/java/com/ojn/gexf4j/core/Mode.java // public enum Mode { // // STATIC, // DYNAMIC, // } // // Path: src/main/java/com/ojn/gexf4j/core/data/Attribute.java // public interface Attribute { // // String getId(); // // String getTitle(); // Attribute setTitle(String title); // // AttributeType getAttributeType(); // // boolean hasDefaultValue(); // Attribute clearDefaultValue(); // String getDefaultValue(); // Attribute setDefaultValue(String defaultValue); // // List<String> getOptions(); // // AttributeValue createValue(String value); // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeClass.java // public enum AttributeClass { // // NODE, // EDGE, // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeList.java // public interface AttributeList extends List<Attribute>, Dynamic<AttributeList> { // // AttributeClass getAttributeClass(); // // Mode getMode(); // AttributeList setMode(Mode mode); // // Attribute createAttribute(AttributeType type, String title); // Attribute createAttribute(String id, AttributeType type, String title); // // AttributeList addAttribute(AttributeType type, String title); // AttributeList addAttribute(String id, AttributeType type, String title); // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeType.java // public enum AttributeType { // // INTEGER, // LONG, // DOUBLE, // FLOAT, // BOOLEAN, // STRING, // LISTSTRING, // ANYURI, // }
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkState; import java.util.ArrayList; import java.util.Date; import java.util.UUID; import com.ojn.gexf4j.core.Mode; import com.ojn.gexf4j.core.data.Attribute; import com.ojn.gexf4j.core.data.AttributeClass; import com.ojn.gexf4j.core.data.AttributeList; import com.ojn.gexf4j.core.data.AttributeType;
package com.ojn.gexf4j.core.impl.data; public class AttributeListImpl extends ArrayList<Attribute> implements AttributeList { private static final long serialVersionUID = 8240096318919688740L; private Date endDate = null; private Date startDate = null;
// Path: src/main/java/com/ojn/gexf4j/core/Mode.java // public enum Mode { // // STATIC, // DYNAMIC, // } // // Path: src/main/java/com/ojn/gexf4j/core/data/Attribute.java // public interface Attribute { // // String getId(); // // String getTitle(); // Attribute setTitle(String title); // // AttributeType getAttributeType(); // // boolean hasDefaultValue(); // Attribute clearDefaultValue(); // String getDefaultValue(); // Attribute setDefaultValue(String defaultValue); // // List<String> getOptions(); // // AttributeValue createValue(String value); // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeClass.java // public enum AttributeClass { // // NODE, // EDGE, // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeList.java // public interface AttributeList extends List<Attribute>, Dynamic<AttributeList> { // // AttributeClass getAttributeClass(); // // Mode getMode(); // AttributeList setMode(Mode mode); // // Attribute createAttribute(AttributeType type, String title); // Attribute createAttribute(String id, AttributeType type, String title); // // AttributeList addAttribute(AttributeType type, String title); // AttributeList addAttribute(String id, AttributeType type, String title); // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeType.java // public enum AttributeType { // // INTEGER, // LONG, // DOUBLE, // FLOAT, // BOOLEAN, // STRING, // LISTSTRING, // ANYURI, // } // Path: src/main/java/com/ojn/gexf4j/core/impl/data/AttributeListImpl.java import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkState; import java.util.ArrayList; import java.util.Date; import java.util.UUID; import com.ojn.gexf4j.core.Mode; import com.ojn.gexf4j.core.data.Attribute; import com.ojn.gexf4j.core.data.AttributeClass; import com.ojn.gexf4j.core.data.AttributeList; import com.ojn.gexf4j.core.data.AttributeType; package com.ojn.gexf4j.core.impl.data; public class AttributeListImpl extends ArrayList<Attribute> implements AttributeList { private static final long serialVersionUID = 8240096318919688740L; private Date endDate = null; private Date startDate = null;
private AttributeClass attrClass = AttributeClass.NODE;
jmcampanini/gexf4j-core
src/main/java/com/ojn/gexf4j/core/impl/data/AttributeListImpl.java
// Path: src/main/java/com/ojn/gexf4j/core/Mode.java // public enum Mode { // // STATIC, // DYNAMIC, // } // // Path: src/main/java/com/ojn/gexf4j/core/data/Attribute.java // public interface Attribute { // // String getId(); // // String getTitle(); // Attribute setTitle(String title); // // AttributeType getAttributeType(); // // boolean hasDefaultValue(); // Attribute clearDefaultValue(); // String getDefaultValue(); // Attribute setDefaultValue(String defaultValue); // // List<String> getOptions(); // // AttributeValue createValue(String value); // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeClass.java // public enum AttributeClass { // // NODE, // EDGE, // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeList.java // public interface AttributeList extends List<Attribute>, Dynamic<AttributeList> { // // AttributeClass getAttributeClass(); // // Mode getMode(); // AttributeList setMode(Mode mode); // // Attribute createAttribute(AttributeType type, String title); // Attribute createAttribute(String id, AttributeType type, String title); // // AttributeList addAttribute(AttributeType type, String title); // AttributeList addAttribute(String id, AttributeType type, String title); // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeType.java // public enum AttributeType { // // INTEGER, // LONG, // DOUBLE, // FLOAT, // BOOLEAN, // STRING, // LISTSTRING, // ANYURI, // }
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkState; import java.util.ArrayList; import java.util.Date; import java.util.UUID; import com.ojn.gexf4j.core.Mode; import com.ojn.gexf4j.core.data.Attribute; import com.ojn.gexf4j.core.data.AttributeClass; import com.ojn.gexf4j.core.data.AttributeList; import com.ojn.gexf4j.core.data.AttributeType;
package com.ojn.gexf4j.core.impl.data; public class AttributeListImpl extends ArrayList<Attribute> implements AttributeList { private static final long serialVersionUID = 8240096318919688740L; private Date endDate = null; private Date startDate = null; private AttributeClass attrClass = AttributeClass.NODE;
// Path: src/main/java/com/ojn/gexf4j/core/Mode.java // public enum Mode { // // STATIC, // DYNAMIC, // } // // Path: src/main/java/com/ojn/gexf4j/core/data/Attribute.java // public interface Attribute { // // String getId(); // // String getTitle(); // Attribute setTitle(String title); // // AttributeType getAttributeType(); // // boolean hasDefaultValue(); // Attribute clearDefaultValue(); // String getDefaultValue(); // Attribute setDefaultValue(String defaultValue); // // List<String> getOptions(); // // AttributeValue createValue(String value); // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeClass.java // public enum AttributeClass { // // NODE, // EDGE, // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeList.java // public interface AttributeList extends List<Attribute>, Dynamic<AttributeList> { // // AttributeClass getAttributeClass(); // // Mode getMode(); // AttributeList setMode(Mode mode); // // Attribute createAttribute(AttributeType type, String title); // Attribute createAttribute(String id, AttributeType type, String title); // // AttributeList addAttribute(AttributeType type, String title); // AttributeList addAttribute(String id, AttributeType type, String title); // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeType.java // public enum AttributeType { // // INTEGER, // LONG, // DOUBLE, // FLOAT, // BOOLEAN, // STRING, // LISTSTRING, // ANYURI, // } // Path: src/main/java/com/ojn/gexf4j/core/impl/data/AttributeListImpl.java import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkState; import java.util.ArrayList; import java.util.Date; import java.util.UUID; import com.ojn.gexf4j.core.Mode; import com.ojn.gexf4j.core.data.Attribute; import com.ojn.gexf4j.core.data.AttributeClass; import com.ojn.gexf4j.core.data.AttributeList; import com.ojn.gexf4j.core.data.AttributeType; package com.ojn.gexf4j.core.impl.data; public class AttributeListImpl extends ArrayList<Attribute> implements AttributeList { private static final long serialVersionUID = 8240096318919688740L; private Date endDate = null; private Date startDate = null; private AttributeClass attrClass = AttributeClass.NODE;
private Mode mode = Mode.STATIC;
jmcampanini/gexf4j-core
src/main/java/com/ojn/gexf4j/core/impl/data/AttributeListImpl.java
// Path: src/main/java/com/ojn/gexf4j/core/Mode.java // public enum Mode { // // STATIC, // DYNAMIC, // } // // Path: src/main/java/com/ojn/gexf4j/core/data/Attribute.java // public interface Attribute { // // String getId(); // // String getTitle(); // Attribute setTitle(String title); // // AttributeType getAttributeType(); // // boolean hasDefaultValue(); // Attribute clearDefaultValue(); // String getDefaultValue(); // Attribute setDefaultValue(String defaultValue); // // List<String> getOptions(); // // AttributeValue createValue(String value); // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeClass.java // public enum AttributeClass { // // NODE, // EDGE, // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeList.java // public interface AttributeList extends List<Attribute>, Dynamic<AttributeList> { // // AttributeClass getAttributeClass(); // // Mode getMode(); // AttributeList setMode(Mode mode); // // Attribute createAttribute(AttributeType type, String title); // Attribute createAttribute(String id, AttributeType type, String title); // // AttributeList addAttribute(AttributeType type, String title); // AttributeList addAttribute(String id, AttributeType type, String title); // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeType.java // public enum AttributeType { // // INTEGER, // LONG, // DOUBLE, // FLOAT, // BOOLEAN, // STRING, // LISTSTRING, // ANYURI, // }
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkState; import java.util.ArrayList; import java.util.Date; import java.util.UUID; import com.ojn.gexf4j.core.Mode; import com.ojn.gexf4j.core.data.Attribute; import com.ojn.gexf4j.core.data.AttributeClass; import com.ojn.gexf4j.core.data.AttributeList; import com.ojn.gexf4j.core.data.AttributeType;
public Date getStartDate() { checkState(startDate != null, "Start Date has not been set."); return startDate; } @Override public boolean hasEndDate() { return (endDate != null); } @Override public boolean hasStartDate() { return (startDate != null); } @Override public AttributeList setEndDate(Date endDate) { checkArgument(endDate != null, "End Date cannot be null."); this.endDate = endDate; return this; } @Override public AttributeList setStartDate(Date startDate) { checkArgument(startDate != null, "Start Date cannot be null."); this.endDate = startDate; return this; } @Override
// Path: src/main/java/com/ojn/gexf4j/core/Mode.java // public enum Mode { // // STATIC, // DYNAMIC, // } // // Path: src/main/java/com/ojn/gexf4j/core/data/Attribute.java // public interface Attribute { // // String getId(); // // String getTitle(); // Attribute setTitle(String title); // // AttributeType getAttributeType(); // // boolean hasDefaultValue(); // Attribute clearDefaultValue(); // String getDefaultValue(); // Attribute setDefaultValue(String defaultValue); // // List<String> getOptions(); // // AttributeValue createValue(String value); // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeClass.java // public enum AttributeClass { // // NODE, // EDGE, // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeList.java // public interface AttributeList extends List<Attribute>, Dynamic<AttributeList> { // // AttributeClass getAttributeClass(); // // Mode getMode(); // AttributeList setMode(Mode mode); // // Attribute createAttribute(AttributeType type, String title); // Attribute createAttribute(String id, AttributeType type, String title); // // AttributeList addAttribute(AttributeType type, String title); // AttributeList addAttribute(String id, AttributeType type, String title); // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeType.java // public enum AttributeType { // // INTEGER, // LONG, // DOUBLE, // FLOAT, // BOOLEAN, // STRING, // LISTSTRING, // ANYURI, // } // Path: src/main/java/com/ojn/gexf4j/core/impl/data/AttributeListImpl.java import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkState; import java.util.ArrayList; import java.util.Date; import java.util.UUID; import com.ojn.gexf4j.core.Mode; import com.ojn.gexf4j.core.data.Attribute; import com.ojn.gexf4j.core.data.AttributeClass; import com.ojn.gexf4j.core.data.AttributeList; import com.ojn.gexf4j.core.data.AttributeType; public Date getStartDate() { checkState(startDate != null, "Start Date has not been set."); return startDate; } @Override public boolean hasEndDate() { return (endDate != null); } @Override public boolean hasStartDate() { return (startDate != null); } @Override public AttributeList setEndDate(Date endDate) { checkArgument(endDate != null, "End Date cannot be null."); this.endDate = endDate; return this; } @Override public AttributeList setStartDate(Date startDate) { checkArgument(startDate != null, "Start Date cannot be null."); this.endDate = startDate; return this; } @Override
public Attribute createAttribute(AttributeType type, String title) {
jmcampanini/gexf4j-core
src/main/java/com/ojn/gexf4j/core/data/AttributeList.java
// Path: src/main/java/com/ojn/gexf4j/core/Mode.java // public enum Mode { // // STATIC, // DYNAMIC, // } // // Path: src/main/java/com/ojn/gexf4j/core/dynamic/Dynamic.java // public interface Dynamic<T extends Object> { // // boolean hasStartDate(); // T clearStartDate(); // Date getStartDate(); // T setStartDate(Date startDate); // // boolean hasEndDate(); // T clearEndDate(); // Date getEndDate(); // T setEndDate(Date endDate); // }
import java.util.List; import com.ojn.gexf4j.core.Mode; import com.ojn.gexf4j.core.dynamic.Dynamic;
package com.ojn.gexf4j.core.data; public interface AttributeList extends List<Attribute>, Dynamic<AttributeList> { AttributeClass getAttributeClass();
// Path: src/main/java/com/ojn/gexf4j/core/Mode.java // public enum Mode { // // STATIC, // DYNAMIC, // } // // Path: src/main/java/com/ojn/gexf4j/core/dynamic/Dynamic.java // public interface Dynamic<T extends Object> { // // boolean hasStartDate(); // T clearStartDate(); // Date getStartDate(); // T setStartDate(Date startDate); // // boolean hasEndDate(); // T clearEndDate(); // Date getEndDate(); // T setEndDate(Date endDate); // } // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeList.java import java.util.List; import com.ojn.gexf4j.core.Mode; import com.ojn.gexf4j.core.dynamic.Dynamic; package com.ojn.gexf4j.core.data; public interface AttributeList extends List<Attribute>, Dynamic<AttributeList> { AttributeClass getAttributeClass();
Mode getMode();
jmcampanini/gexf4j-core
src/main/java/com/ojn/gexf4j/core/impl/StaxGraphReader.java
// Path: src/main/java/com/ojn/gexf4j/core/Gexf.java // public interface Gexf { // // String getVersion(); // // boolean hasVariant(); // Gexf clearVariant(); // String getVariant(); // Gexf setVariant(String variant); // // Metadata getMetadata(); // // Graph getGraph(); // // boolean hasVisualization(); // Gexf setVisualization(boolean viz); // } // // Path: src/main/java/com/ojn/gexf4j/core/GexfReader.java // public interface GexfReader { // // Gexf readFromStream(InputStream in) throws IOException; // }
import java.io.IOException; import java.io.InputStream; import com.ojn.gexf4j.core.Gexf; import com.ojn.gexf4j.core.GexfReader;
package com.ojn.gexf4j.core.impl; public class StaxGraphReader implements GexfReader { @Override
// Path: src/main/java/com/ojn/gexf4j/core/Gexf.java // public interface Gexf { // // String getVersion(); // // boolean hasVariant(); // Gexf clearVariant(); // String getVariant(); // Gexf setVariant(String variant); // // Metadata getMetadata(); // // Graph getGraph(); // // boolean hasVisualization(); // Gexf setVisualization(boolean viz); // } // // Path: src/main/java/com/ojn/gexf4j/core/GexfReader.java // public interface GexfReader { // // Gexf readFromStream(InputStream in) throws IOException; // } // Path: src/main/java/com/ojn/gexf4j/core/impl/StaxGraphReader.java import java.io.IOException; import java.io.InputStream; import com.ojn.gexf4j.core.Gexf; import com.ojn.gexf4j.core.GexfReader; package com.ojn.gexf4j.core.impl; public class StaxGraphReader implements GexfReader { @Override
public Gexf readFromStream(InputStream in) throws IOException {
jmcampanini/gexf4j-core
src/test/java/com/ojn/gexf4j/core/impl/EdgeImplTest.java
// Path: src/main/java/com/ojn/gexf4j/core/Edge.java // public interface Edge extends SlicableDatum<Edge> { // // String getId(); // // Node getSource(); // // Node getTarget(); // Edge setTarget(Node target); // // boolean hasLabel(); // Edge clearLabel(); // String getLabel(); // Edge setLabel(String label); // // boolean hasWeight(); // Edge clearWeight(); // float getWeight(); // Edge setWeight(float weight); // // EdgeType getEdgeType(); // Edge setEdgeType(EdgeType edgeType); // // boolean hasColor(); // Edge clearColor(); // Color getColor(); // Edge setColor(Color color); // // boolean hasThickness(); // Edge clearThickness(); // float getThickness(); // Edge setThickness(float thickness); // // EdgeShape getShape(); // Edge setShape(EdgeShape shape); // } // // Path: src/test/java/com/ojn/gexf4j/core/EdgeTest.java // public abstract class EdgeTest { // // protected abstract Node newNode(); // protected abstract Edge newEdge(String id, Node source, Node target); // // private Node s = null; // private Node t = null; // private String edgeId = ""; // private Edge e = null; // // @Before // public void before() { // s = newNode(); // t = newNode(); // edgeId = UUID.randomUUID().toString(); // e = newEdge(edgeId, s, t); // } // // @Test // public void getId() { // assertThat(e.getId(), is(equalTo(edgeId))); // } // // @Test // public void setLabelValid() { // String label = UUID.randomUUID().toString(); // e.setLabel(label); // assertThat(e.getLabel(), is(equalTo(label))); // } // // @Test(expected=IllegalArgumentException.class) // public void setLabelNull() { // e.setLabel(null); // } // // @Test // public void getSource() { // assertThat(e.getSource(), is(equalTo(s))); // } // // @Test // public void setTargetValid() { // Node newTarget = newNode(); // e.setTarget(newTarget); // // assertThat(e.getTarget(), is(equalTo(newTarget))); // } // // @Test(expected=IllegalArgumentException.class) // public void setTargetNull() { // e.setTarget(null); // } // // @Test // public void setWeight() { // Random rnd = new Random(); // float weight = rnd.nextFloat(); // e.setWeight(weight); // // assertThat(e.getWeight(), is(equalTo(weight))); // } // // @Test // public void setEdgeType() { // for (EdgeType et : EdgeType.values()) { // e.setEdgeType(et); // assertThat(e.getEdgeType(), is(equalTo(et))); // } // } // // @Test // public void getAttributeValues() { // Attribute attrib = new AttributeImpl(AttributeType.STRING, "test", AttributeClass.EDGE); // AttributeValue av = attrib.createValue("testing"); // // int a = e.getAttributeValues().size(); // e.getAttributeValues().add(av); // int b = e.getAttributeValues().size(); // // assertThat(b, is(equalTo(a+1))); // assertThat(e.getAttributeValues().contains(av), is(true)); // } // } // // Path: src/main/java/com/ojn/gexf4j/core/Node.java // public interface Node extends SlicableDatum<Node>, HasNodes { // // String getId(); // // String getLabel(); // Node setLabel(String label); // // List<Edge> getEdges(); // // Edge connectTo(Node target); // Edge connectTo(String id, Node target); // // boolean hasEdgeTo(String id); // // boolean hasColor(); // Node clearColor(); // Color getColor(); // Node setColor(Color color); // // boolean hasPosition(); // Node clearPosition(); // Position getPosition(); // Node setPosition(Position position); // // boolean hasSize(); // Node clearSize(); // float getSize(); // Node setSize(float size); // // boolean hasShape(); // Node clearShape(); // NodeShapeEntity getShapeEntity(); // // List<Node> getParentForList(); // // boolean hasPID(); // Node clearPID(); // String getPID(); // Node setPID(String pid); // }
import java.util.UUID; import com.ojn.gexf4j.core.Edge; import com.ojn.gexf4j.core.EdgeTest; import com.ojn.gexf4j.core.Node;
package com.ojn.gexf4j.core.impl; public class EdgeImplTest extends EdgeTest { @Override
// Path: src/main/java/com/ojn/gexf4j/core/Edge.java // public interface Edge extends SlicableDatum<Edge> { // // String getId(); // // Node getSource(); // // Node getTarget(); // Edge setTarget(Node target); // // boolean hasLabel(); // Edge clearLabel(); // String getLabel(); // Edge setLabel(String label); // // boolean hasWeight(); // Edge clearWeight(); // float getWeight(); // Edge setWeight(float weight); // // EdgeType getEdgeType(); // Edge setEdgeType(EdgeType edgeType); // // boolean hasColor(); // Edge clearColor(); // Color getColor(); // Edge setColor(Color color); // // boolean hasThickness(); // Edge clearThickness(); // float getThickness(); // Edge setThickness(float thickness); // // EdgeShape getShape(); // Edge setShape(EdgeShape shape); // } // // Path: src/test/java/com/ojn/gexf4j/core/EdgeTest.java // public abstract class EdgeTest { // // protected abstract Node newNode(); // protected abstract Edge newEdge(String id, Node source, Node target); // // private Node s = null; // private Node t = null; // private String edgeId = ""; // private Edge e = null; // // @Before // public void before() { // s = newNode(); // t = newNode(); // edgeId = UUID.randomUUID().toString(); // e = newEdge(edgeId, s, t); // } // // @Test // public void getId() { // assertThat(e.getId(), is(equalTo(edgeId))); // } // // @Test // public void setLabelValid() { // String label = UUID.randomUUID().toString(); // e.setLabel(label); // assertThat(e.getLabel(), is(equalTo(label))); // } // // @Test(expected=IllegalArgumentException.class) // public void setLabelNull() { // e.setLabel(null); // } // // @Test // public void getSource() { // assertThat(e.getSource(), is(equalTo(s))); // } // // @Test // public void setTargetValid() { // Node newTarget = newNode(); // e.setTarget(newTarget); // // assertThat(e.getTarget(), is(equalTo(newTarget))); // } // // @Test(expected=IllegalArgumentException.class) // public void setTargetNull() { // e.setTarget(null); // } // // @Test // public void setWeight() { // Random rnd = new Random(); // float weight = rnd.nextFloat(); // e.setWeight(weight); // // assertThat(e.getWeight(), is(equalTo(weight))); // } // // @Test // public void setEdgeType() { // for (EdgeType et : EdgeType.values()) { // e.setEdgeType(et); // assertThat(e.getEdgeType(), is(equalTo(et))); // } // } // // @Test // public void getAttributeValues() { // Attribute attrib = new AttributeImpl(AttributeType.STRING, "test", AttributeClass.EDGE); // AttributeValue av = attrib.createValue("testing"); // // int a = e.getAttributeValues().size(); // e.getAttributeValues().add(av); // int b = e.getAttributeValues().size(); // // assertThat(b, is(equalTo(a+1))); // assertThat(e.getAttributeValues().contains(av), is(true)); // } // } // // Path: src/main/java/com/ojn/gexf4j/core/Node.java // public interface Node extends SlicableDatum<Node>, HasNodes { // // String getId(); // // String getLabel(); // Node setLabel(String label); // // List<Edge> getEdges(); // // Edge connectTo(Node target); // Edge connectTo(String id, Node target); // // boolean hasEdgeTo(String id); // // boolean hasColor(); // Node clearColor(); // Color getColor(); // Node setColor(Color color); // // boolean hasPosition(); // Node clearPosition(); // Position getPosition(); // Node setPosition(Position position); // // boolean hasSize(); // Node clearSize(); // float getSize(); // Node setSize(float size); // // boolean hasShape(); // Node clearShape(); // NodeShapeEntity getShapeEntity(); // // List<Node> getParentForList(); // // boolean hasPID(); // Node clearPID(); // String getPID(); // Node setPID(String pid); // } // Path: src/test/java/com/ojn/gexf4j/core/impl/EdgeImplTest.java import java.util.UUID; import com.ojn.gexf4j.core.Edge; import com.ojn.gexf4j.core.EdgeTest; import com.ojn.gexf4j.core.Node; package com.ojn.gexf4j.core.impl; public class EdgeImplTest extends EdgeTest { @Override
protected Edge newEdge(String id, Node source, Node target) {
jmcampanini/gexf4j-core
src/test/java/com/ojn/gexf4j/core/impl/EdgeImplTest.java
// Path: src/main/java/com/ojn/gexf4j/core/Edge.java // public interface Edge extends SlicableDatum<Edge> { // // String getId(); // // Node getSource(); // // Node getTarget(); // Edge setTarget(Node target); // // boolean hasLabel(); // Edge clearLabel(); // String getLabel(); // Edge setLabel(String label); // // boolean hasWeight(); // Edge clearWeight(); // float getWeight(); // Edge setWeight(float weight); // // EdgeType getEdgeType(); // Edge setEdgeType(EdgeType edgeType); // // boolean hasColor(); // Edge clearColor(); // Color getColor(); // Edge setColor(Color color); // // boolean hasThickness(); // Edge clearThickness(); // float getThickness(); // Edge setThickness(float thickness); // // EdgeShape getShape(); // Edge setShape(EdgeShape shape); // } // // Path: src/test/java/com/ojn/gexf4j/core/EdgeTest.java // public abstract class EdgeTest { // // protected abstract Node newNode(); // protected abstract Edge newEdge(String id, Node source, Node target); // // private Node s = null; // private Node t = null; // private String edgeId = ""; // private Edge e = null; // // @Before // public void before() { // s = newNode(); // t = newNode(); // edgeId = UUID.randomUUID().toString(); // e = newEdge(edgeId, s, t); // } // // @Test // public void getId() { // assertThat(e.getId(), is(equalTo(edgeId))); // } // // @Test // public void setLabelValid() { // String label = UUID.randomUUID().toString(); // e.setLabel(label); // assertThat(e.getLabel(), is(equalTo(label))); // } // // @Test(expected=IllegalArgumentException.class) // public void setLabelNull() { // e.setLabel(null); // } // // @Test // public void getSource() { // assertThat(e.getSource(), is(equalTo(s))); // } // // @Test // public void setTargetValid() { // Node newTarget = newNode(); // e.setTarget(newTarget); // // assertThat(e.getTarget(), is(equalTo(newTarget))); // } // // @Test(expected=IllegalArgumentException.class) // public void setTargetNull() { // e.setTarget(null); // } // // @Test // public void setWeight() { // Random rnd = new Random(); // float weight = rnd.nextFloat(); // e.setWeight(weight); // // assertThat(e.getWeight(), is(equalTo(weight))); // } // // @Test // public void setEdgeType() { // for (EdgeType et : EdgeType.values()) { // e.setEdgeType(et); // assertThat(e.getEdgeType(), is(equalTo(et))); // } // } // // @Test // public void getAttributeValues() { // Attribute attrib = new AttributeImpl(AttributeType.STRING, "test", AttributeClass.EDGE); // AttributeValue av = attrib.createValue("testing"); // // int a = e.getAttributeValues().size(); // e.getAttributeValues().add(av); // int b = e.getAttributeValues().size(); // // assertThat(b, is(equalTo(a+1))); // assertThat(e.getAttributeValues().contains(av), is(true)); // } // } // // Path: src/main/java/com/ojn/gexf4j/core/Node.java // public interface Node extends SlicableDatum<Node>, HasNodes { // // String getId(); // // String getLabel(); // Node setLabel(String label); // // List<Edge> getEdges(); // // Edge connectTo(Node target); // Edge connectTo(String id, Node target); // // boolean hasEdgeTo(String id); // // boolean hasColor(); // Node clearColor(); // Color getColor(); // Node setColor(Color color); // // boolean hasPosition(); // Node clearPosition(); // Position getPosition(); // Node setPosition(Position position); // // boolean hasSize(); // Node clearSize(); // float getSize(); // Node setSize(float size); // // boolean hasShape(); // Node clearShape(); // NodeShapeEntity getShapeEntity(); // // List<Node> getParentForList(); // // boolean hasPID(); // Node clearPID(); // String getPID(); // Node setPID(String pid); // }
import java.util.UUID; import com.ojn.gexf4j.core.Edge; import com.ojn.gexf4j.core.EdgeTest; import com.ojn.gexf4j.core.Node;
package com.ojn.gexf4j.core.impl; public class EdgeImplTest extends EdgeTest { @Override
// Path: src/main/java/com/ojn/gexf4j/core/Edge.java // public interface Edge extends SlicableDatum<Edge> { // // String getId(); // // Node getSource(); // // Node getTarget(); // Edge setTarget(Node target); // // boolean hasLabel(); // Edge clearLabel(); // String getLabel(); // Edge setLabel(String label); // // boolean hasWeight(); // Edge clearWeight(); // float getWeight(); // Edge setWeight(float weight); // // EdgeType getEdgeType(); // Edge setEdgeType(EdgeType edgeType); // // boolean hasColor(); // Edge clearColor(); // Color getColor(); // Edge setColor(Color color); // // boolean hasThickness(); // Edge clearThickness(); // float getThickness(); // Edge setThickness(float thickness); // // EdgeShape getShape(); // Edge setShape(EdgeShape shape); // } // // Path: src/test/java/com/ojn/gexf4j/core/EdgeTest.java // public abstract class EdgeTest { // // protected abstract Node newNode(); // protected abstract Edge newEdge(String id, Node source, Node target); // // private Node s = null; // private Node t = null; // private String edgeId = ""; // private Edge e = null; // // @Before // public void before() { // s = newNode(); // t = newNode(); // edgeId = UUID.randomUUID().toString(); // e = newEdge(edgeId, s, t); // } // // @Test // public void getId() { // assertThat(e.getId(), is(equalTo(edgeId))); // } // // @Test // public void setLabelValid() { // String label = UUID.randomUUID().toString(); // e.setLabel(label); // assertThat(e.getLabel(), is(equalTo(label))); // } // // @Test(expected=IllegalArgumentException.class) // public void setLabelNull() { // e.setLabel(null); // } // // @Test // public void getSource() { // assertThat(e.getSource(), is(equalTo(s))); // } // // @Test // public void setTargetValid() { // Node newTarget = newNode(); // e.setTarget(newTarget); // // assertThat(e.getTarget(), is(equalTo(newTarget))); // } // // @Test(expected=IllegalArgumentException.class) // public void setTargetNull() { // e.setTarget(null); // } // // @Test // public void setWeight() { // Random rnd = new Random(); // float weight = rnd.nextFloat(); // e.setWeight(weight); // // assertThat(e.getWeight(), is(equalTo(weight))); // } // // @Test // public void setEdgeType() { // for (EdgeType et : EdgeType.values()) { // e.setEdgeType(et); // assertThat(e.getEdgeType(), is(equalTo(et))); // } // } // // @Test // public void getAttributeValues() { // Attribute attrib = new AttributeImpl(AttributeType.STRING, "test", AttributeClass.EDGE); // AttributeValue av = attrib.createValue("testing"); // // int a = e.getAttributeValues().size(); // e.getAttributeValues().add(av); // int b = e.getAttributeValues().size(); // // assertThat(b, is(equalTo(a+1))); // assertThat(e.getAttributeValues().contains(av), is(true)); // } // } // // Path: src/main/java/com/ojn/gexf4j/core/Node.java // public interface Node extends SlicableDatum<Node>, HasNodes { // // String getId(); // // String getLabel(); // Node setLabel(String label); // // List<Edge> getEdges(); // // Edge connectTo(Node target); // Edge connectTo(String id, Node target); // // boolean hasEdgeTo(String id); // // boolean hasColor(); // Node clearColor(); // Color getColor(); // Node setColor(Color color); // // boolean hasPosition(); // Node clearPosition(); // Position getPosition(); // Node setPosition(Position position); // // boolean hasSize(); // Node clearSize(); // float getSize(); // Node setSize(float size); // // boolean hasShape(); // Node clearShape(); // NodeShapeEntity getShapeEntity(); // // List<Node> getParentForList(); // // boolean hasPID(); // Node clearPID(); // String getPID(); // Node setPID(String pid); // } // Path: src/test/java/com/ojn/gexf4j/core/impl/EdgeImplTest.java import java.util.UUID; import com.ojn.gexf4j.core.Edge; import com.ojn.gexf4j.core.EdgeTest; import com.ojn.gexf4j.core.Node; package com.ojn.gexf4j.core.impl; public class EdgeImplTest extends EdgeTest { @Override
protected Edge newEdge(String id, Node source, Node target) {
jmcampanini/gexf4j-core
src/main/java/com/ojn/gexf4j/core/impl/writer/AbstractEntityWriter.java
// Path: src/main/java/com/ojn/gexf4j/core/dynamic/TimeType.java // public enum TimeType { // // DATE, // FLOAT, // }
import static com.google.common.base.Preconditions.checkArgument; import java.text.SimpleDateFormat; import java.util.Date; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamWriter; import com.ojn.gexf4j.core.dynamic.TimeType;
package com.ojn.gexf4j.core.impl.writer; public abstract class AbstractEntityWriter<T extends Object> { private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
// Path: src/main/java/com/ojn/gexf4j/core/dynamic/TimeType.java // public enum TimeType { // // DATE, // FLOAT, // } // Path: src/main/java/com/ojn/gexf4j/core/impl/writer/AbstractEntityWriter.java import static com.google.common.base.Preconditions.checkArgument; import java.text.SimpleDateFormat; import java.util.Date; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamWriter; import com.ojn.gexf4j.core.dynamic.TimeType; package com.ojn.gexf4j.core.impl.writer; public abstract class AbstractEntityWriter<T extends Object> { private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
protected static TimeType writerTimeType = TimeType.DATE;
jmcampanini/gexf4j-core
src/test/java/com/ojn/gexf4j/core/impl/data/AttributeImplTest.java
// Path: src/main/java/com/ojn/gexf4j/core/data/Attribute.java // public interface Attribute { // // String getId(); // // String getTitle(); // Attribute setTitle(String title); // // AttributeType getAttributeType(); // // boolean hasDefaultValue(); // Attribute clearDefaultValue(); // String getDefaultValue(); // Attribute setDefaultValue(String defaultValue); // // List<String> getOptions(); // // AttributeValue createValue(String value); // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeClass.java // public enum AttributeClass { // // NODE, // EDGE, // } // // Path: src/test/java/com/ojn/gexf4j/core/data/AttributeTest.java // public abstract class AttributeTest { // // protected abstract Attribute newAttribute(AttributeType type, String id, AttributeClass attribClass); // // private String id = null; // private Attribute attrib = null; // // @Before // public void before() { // id = UUID.randomUUID().toString(); // attrib = newAttribute(AttributeType.STRING, id, AttributeClass.NODE); // } // // @Test // public void getId() { // assertThat(attrib.getId(), is(equalTo(id))); // } // // @Test // public void getAttributeType() { // Attribute curAttrib = null; // for (AttributeType at : AttributeType.values()) { // curAttrib = newAttribute(at, UUID.randomUUID().toString(), AttributeClass.NODE); // assertThat(curAttrib.getAttributeType(), is(equalTo(at))); // } // } // // @Test // public void setTitleValid() { // String title = UUID.randomUUID().toString(); // attrib.setTitle(title); // // assertThat(attrib.getTitle(), is(equalTo(title))); // } // // @Test(expected=IllegalArgumentException.class) // public void setTitleNull() { // attrib.setTitle(null); // } // // @Test // public void createValueValid() { // String value = UUID.randomUUID().toString(); // AttributeValue av = attrib.createValue(value); // // assertThat(av.getValue(), is(equalTo(value))); // } // // @Test(expected=IllegalArgumentException.class) // public void createValueNull() { // attrib.createValue(null); // } // // @Test // public void setDefaultValueValid() { // String defaultValue = UUID.randomUUID().toString(); // attrib.setDefaultValue(defaultValue); // // assertThat(attrib.getDefaultValue(), is(equalTo(defaultValue))); // } // // @Test(expected=IllegalArgumentException.class) // public void setDefaultValueNull() { // attrib.setDefaultValue(null); // } // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeType.java // public enum AttributeType { // // INTEGER, // LONG, // DOUBLE, // FLOAT, // BOOLEAN, // STRING, // LISTSTRING, // ANYURI, // }
import com.ojn.gexf4j.core.data.Attribute; import com.ojn.gexf4j.core.data.AttributeClass; import com.ojn.gexf4j.core.data.AttributeTest; import com.ojn.gexf4j.core.data.AttributeType;
package com.ojn.gexf4j.core.impl.data; public class AttributeImplTest extends AttributeTest { @Override
// Path: src/main/java/com/ojn/gexf4j/core/data/Attribute.java // public interface Attribute { // // String getId(); // // String getTitle(); // Attribute setTitle(String title); // // AttributeType getAttributeType(); // // boolean hasDefaultValue(); // Attribute clearDefaultValue(); // String getDefaultValue(); // Attribute setDefaultValue(String defaultValue); // // List<String> getOptions(); // // AttributeValue createValue(String value); // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeClass.java // public enum AttributeClass { // // NODE, // EDGE, // } // // Path: src/test/java/com/ojn/gexf4j/core/data/AttributeTest.java // public abstract class AttributeTest { // // protected abstract Attribute newAttribute(AttributeType type, String id, AttributeClass attribClass); // // private String id = null; // private Attribute attrib = null; // // @Before // public void before() { // id = UUID.randomUUID().toString(); // attrib = newAttribute(AttributeType.STRING, id, AttributeClass.NODE); // } // // @Test // public void getId() { // assertThat(attrib.getId(), is(equalTo(id))); // } // // @Test // public void getAttributeType() { // Attribute curAttrib = null; // for (AttributeType at : AttributeType.values()) { // curAttrib = newAttribute(at, UUID.randomUUID().toString(), AttributeClass.NODE); // assertThat(curAttrib.getAttributeType(), is(equalTo(at))); // } // } // // @Test // public void setTitleValid() { // String title = UUID.randomUUID().toString(); // attrib.setTitle(title); // // assertThat(attrib.getTitle(), is(equalTo(title))); // } // // @Test(expected=IllegalArgumentException.class) // public void setTitleNull() { // attrib.setTitle(null); // } // // @Test // public void createValueValid() { // String value = UUID.randomUUID().toString(); // AttributeValue av = attrib.createValue(value); // // assertThat(av.getValue(), is(equalTo(value))); // } // // @Test(expected=IllegalArgumentException.class) // public void createValueNull() { // attrib.createValue(null); // } // // @Test // public void setDefaultValueValid() { // String defaultValue = UUID.randomUUID().toString(); // attrib.setDefaultValue(defaultValue); // // assertThat(attrib.getDefaultValue(), is(equalTo(defaultValue))); // } // // @Test(expected=IllegalArgumentException.class) // public void setDefaultValueNull() { // attrib.setDefaultValue(null); // } // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeType.java // public enum AttributeType { // // INTEGER, // LONG, // DOUBLE, // FLOAT, // BOOLEAN, // STRING, // LISTSTRING, // ANYURI, // } // Path: src/test/java/com/ojn/gexf4j/core/impl/data/AttributeImplTest.java import com.ojn.gexf4j.core.data.Attribute; import com.ojn.gexf4j.core.data.AttributeClass; import com.ojn.gexf4j.core.data.AttributeTest; import com.ojn.gexf4j.core.data.AttributeType; package com.ojn.gexf4j.core.impl.data; public class AttributeImplTest extends AttributeTest { @Override
protected Attribute newAttribute(AttributeType type, String id, AttributeClass attribClass) {
jmcampanini/gexf4j-core
src/test/java/com/ojn/gexf4j/core/impl/data/AttributeImplTest.java
// Path: src/main/java/com/ojn/gexf4j/core/data/Attribute.java // public interface Attribute { // // String getId(); // // String getTitle(); // Attribute setTitle(String title); // // AttributeType getAttributeType(); // // boolean hasDefaultValue(); // Attribute clearDefaultValue(); // String getDefaultValue(); // Attribute setDefaultValue(String defaultValue); // // List<String> getOptions(); // // AttributeValue createValue(String value); // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeClass.java // public enum AttributeClass { // // NODE, // EDGE, // } // // Path: src/test/java/com/ojn/gexf4j/core/data/AttributeTest.java // public abstract class AttributeTest { // // protected abstract Attribute newAttribute(AttributeType type, String id, AttributeClass attribClass); // // private String id = null; // private Attribute attrib = null; // // @Before // public void before() { // id = UUID.randomUUID().toString(); // attrib = newAttribute(AttributeType.STRING, id, AttributeClass.NODE); // } // // @Test // public void getId() { // assertThat(attrib.getId(), is(equalTo(id))); // } // // @Test // public void getAttributeType() { // Attribute curAttrib = null; // for (AttributeType at : AttributeType.values()) { // curAttrib = newAttribute(at, UUID.randomUUID().toString(), AttributeClass.NODE); // assertThat(curAttrib.getAttributeType(), is(equalTo(at))); // } // } // // @Test // public void setTitleValid() { // String title = UUID.randomUUID().toString(); // attrib.setTitle(title); // // assertThat(attrib.getTitle(), is(equalTo(title))); // } // // @Test(expected=IllegalArgumentException.class) // public void setTitleNull() { // attrib.setTitle(null); // } // // @Test // public void createValueValid() { // String value = UUID.randomUUID().toString(); // AttributeValue av = attrib.createValue(value); // // assertThat(av.getValue(), is(equalTo(value))); // } // // @Test(expected=IllegalArgumentException.class) // public void createValueNull() { // attrib.createValue(null); // } // // @Test // public void setDefaultValueValid() { // String defaultValue = UUID.randomUUID().toString(); // attrib.setDefaultValue(defaultValue); // // assertThat(attrib.getDefaultValue(), is(equalTo(defaultValue))); // } // // @Test(expected=IllegalArgumentException.class) // public void setDefaultValueNull() { // attrib.setDefaultValue(null); // } // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeType.java // public enum AttributeType { // // INTEGER, // LONG, // DOUBLE, // FLOAT, // BOOLEAN, // STRING, // LISTSTRING, // ANYURI, // }
import com.ojn.gexf4j.core.data.Attribute; import com.ojn.gexf4j.core.data.AttributeClass; import com.ojn.gexf4j.core.data.AttributeTest; import com.ojn.gexf4j.core.data.AttributeType;
package com.ojn.gexf4j.core.impl.data; public class AttributeImplTest extends AttributeTest { @Override
// Path: src/main/java/com/ojn/gexf4j/core/data/Attribute.java // public interface Attribute { // // String getId(); // // String getTitle(); // Attribute setTitle(String title); // // AttributeType getAttributeType(); // // boolean hasDefaultValue(); // Attribute clearDefaultValue(); // String getDefaultValue(); // Attribute setDefaultValue(String defaultValue); // // List<String> getOptions(); // // AttributeValue createValue(String value); // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeClass.java // public enum AttributeClass { // // NODE, // EDGE, // } // // Path: src/test/java/com/ojn/gexf4j/core/data/AttributeTest.java // public abstract class AttributeTest { // // protected abstract Attribute newAttribute(AttributeType type, String id, AttributeClass attribClass); // // private String id = null; // private Attribute attrib = null; // // @Before // public void before() { // id = UUID.randomUUID().toString(); // attrib = newAttribute(AttributeType.STRING, id, AttributeClass.NODE); // } // // @Test // public void getId() { // assertThat(attrib.getId(), is(equalTo(id))); // } // // @Test // public void getAttributeType() { // Attribute curAttrib = null; // for (AttributeType at : AttributeType.values()) { // curAttrib = newAttribute(at, UUID.randomUUID().toString(), AttributeClass.NODE); // assertThat(curAttrib.getAttributeType(), is(equalTo(at))); // } // } // // @Test // public void setTitleValid() { // String title = UUID.randomUUID().toString(); // attrib.setTitle(title); // // assertThat(attrib.getTitle(), is(equalTo(title))); // } // // @Test(expected=IllegalArgumentException.class) // public void setTitleNull() { // attrib.setTitle(null); // } // // @Test // public void createValueValid() { // String value = UUID.randomUUID().toString(); // AttributeValue av = attrib.createValue(value); // // assertThat(av.getValue(), is(equalTo(value))); // } // // @Test(expected=IllegalArgumentException.class) // public void createValueNull() { // attrib.createValue(null); // } // // @Test // public void setDefaultValueValid() { // String defaultValue = UUID.randomUUID().toString(); // attrib.setDefaultValue(defaultValue); // // assertThat(attrib.getDefaultValue(), is(equalTo(defaultValue))); // } // // @Test(expected=IllegalArgumentException.class) // public void setDefaultValueNull() { // attrib.setDefaultValue(null); // } // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeType.java // public enum AttributeType { // // INTEGER, // LONG, // DOUBLE, // FLOAT, // BOOLEAN, // STRING, // LISTSTRING, // ANYURI, // } // Path: src/test/java/com/ojn/gexf4j/core/impl/data/AttributeImplTest.java import com.ojn.gexf4j.core.data.Attribute; import com.ojn.gexf4j.core.data.AttributeClass; import com.ojn.gexf4j.core.data.AttributeTest; import com.ojn.gexf4j.core.data.AttributeType; package com.ojn.gexf4j.core.impl.data; public class AttributeImplTest extends AttributeTest { @Override
protected Attribute newAttribute(AttributeType type, String id, AttributeClass attribClass) {
jmcampanini/gexf4j-core
src/test/java/com/ojn/gexf4j/core/impl/data/AttributeImplTest.java
// Path: src/main/java/com/ojn/gexf4j/core/data/Attribute.java // public interface Attribute { // // String getId(); // // String getTitle(); // Attribute setTitle(String title); // // AttributeType getAttributeType(); // // boolean hasDefaultValue(); // Attribute clearDefaultValue(); // String getDefaultValue(); // Attribute setDefaultValue(String defaultValue); // // List<String> getOptions(); // // AttributeValue createValue(String value); // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeClass.java // public enum AttributeClass { // // NODE, // EDGE, // } // // Path: src/test/java/com/ojn/gexf4j/core/data/AttributeTest.java // public abstract class AttributeTest { // // protected abstract Attribute newAttribute(AttributeType type, String id, AttributeClass attribClass); // // private String id = null; // private Attribute attrib = null; // // @Before // public void before() { // id = UUID.randomUUID().toString(); // attrib = newAttribute(AttributeType.STRING, id, AttributeClass.NODE); // } // // @Test // public void getId() { // assertThat(attrib.getId(), is(equalTo(id))); // } // // @Test // public void getAttributeType() { // Attribute curAttrib = null; // for (AttributeType at : AttributeType.values()) { // curAttrib = newAttribute(at, UUID.randomUUID().toString(), AttributeClass.NODE); // assertThat(curAttrib.getAttributeType(), is(equalTo(at))); // } // } // // @Test // public void setTitleValid() { // String title = UUID.randomUUID().toString(); // attrib.setTitle(title); // // assertThat(attrib.getTitle(), is(equalTo(title))); // } // // @Test(expected=IllegalArgumentException.class) // public void setTitleNull() { // attrib.setTitle(null); // } // // @Test // public void createValueValid() { // String value = UUID.randomUUID().toString(); // AttributeValue av = attrib.createValue(value); // // assertThat(av.getValue(), is(equalTo(value))); // } // // @Test(expected=IllegalArgumentException.class) // public void createValueNull() { // attrib.createValue(null); // } // // @Test // public void setDefaultValueValid() { // String defaultValue = UUID.randomUUID().toString(); // attrib.setDefaultValue(defaultValue); // // assertThat(attrib.getDefaultValue(), is(equalTo(defaultValue))); // } // // @Test(expected=IllegalArgumentException.class) // public void setDefaultValueNull() { // attrib.setDefaultValue(null); // } // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeType.java // public enum AttributeType { // // INTEGER, // LONG, // DOUBLE, // FLOAT, // BOOLEAN, // STRING, // LISTSTRING, // ANYURI, // }
import com.ojn.gexf4j.core.data.Attribute; import com.ojn.gexf4j.core.data.AttributeClass; import com.ojn.gexf4j.core.data.AttributeTest; import com.ojn.gexf4j.core.data.AttributeType;
package com.ojn.gexf4j.core.impl.data; public class AttributeImplTest extends AttributeTest { @Override
// Path: src/main/java/com/ojn/gexf4j/core/data/Attribute.java // public interface Attribute { // // String getId(); // // String getTitle(); // Attribute setTitle(String title); // // AttributeType getAttributeType(); // // boolean hasDefaultValue(); // Attribute clearDefaultValue(); // String getDefaultValue(); // Attribute setDefaultValue(String defaultValue); // // List<String> getOptions(); // // AttributeValue createValue(String value); // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeClass.java // public enum AttributeClass { // // NODE, // EDGE, // } // // Path: src/test/java/com/ojn/gexf4j/core/data/AttributeTest.java // public abstract class AttributeTest { // // protected abstract Attribute newAttribute(AttributeType type, String id, AttributeClass attribClass); // // private String id = null; // private Attribute attrib = null; // // @Before // public void before() { // id = UUID.randomUUID().toString(); // attrib = newAttribute(AttributeType.STRING, id, AttributeClass.NODE); // } // // @Test // public void getId() { // assertThat(attrib.getId(), is(equalTo(id))); // } // // @Test // public void getAttributeType() { // Attribute curAttrib = null; // for (AttributeType at : AttributeType.values()) { // curAttrib = newAttribute(at, UUID.randomUUID().toString(), AttributeClass.NODE); // assertThat(curAttrib.getAttributeType(), is(equalTo(at))); // } // } // // @Test // public void setTitleValid() { // String title = UUID.randomUUID().toString(); // attrib.setTitle(title); // // assertThat(attrib.getTitle(), is(equalTo(title))); // } // // @Test(expected=IllegalArgumentException.class) // public void setTitleNull() { // attrib.setTitle(null); // } // // @Test // public void createValueValid() { // String value = UUID.randomUUID().toString(); // AttributeValue av = attrib.createValue(value); // // assertThat(av.getValue(), is(equalTo(value))); // } // // @Test(expected=IllegalArgumentException.class) // public void createValueNull() { // attrib.createValue(null); // } // // @Test // public void setDefaultValueValid() { // String defaultValue = UUID.randomUUID().toString(); // attrib.setDefaultValue(defaultValue); // // assertThat(attrib.getDefaultValue(), is(equalTo(defaultValue))); // } // // @Test(expected=IllegalArgumentException.class) // public void setDefaultValueNull() { // attrib.setDefaultValue(null); // } // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeType.java // public enum AttributeType { // // INTEGER, // LONG, // DOUBLE, // FLOAT, // BOOLEAN, // STRING, // LISTSTRING, // ANYURI, // } // Path: src/test/java/com/ojn/gexf4j/core/impl/data/AttributeImplTest.java import com.ojn.gexf4j.core.data.Attribute; import com.ojn.gexf4j.core.data.AttributeClass; import com.ojn.gexf4j.core.data.AttributeTest; import com.ojn.gexf4j.core.data.AttributeType; package com.ojn.gexf4j.core.impl.data; public class AttributeImplTest extends AttributeTest { @Override
protected Attribute newAttribute(AttributeType type, String id, AttributeClass attribClass) {
jmcampanini/gexf4j-core
src/test/java/com/ojn/gexf4j/core/EdgeTest.java
// Path: src/main/java/com/ojn/gexf4j/core/data/Attribute.java // public interface Attribute { // // String getId(); // // String getTitle(); // Attribute setTitle(String title); // // AttributeType getAttributeType(); // // boolean hasDefaultValue(); // Attribute clearDefaultValue(); // String getDefaultValue(); // Attribute setDefaultValue(String defaultValue); // // List<String> getOptions(); // // AttributeValue createValue(String value); // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeClass.java // public enum AttributeClass { // // NODE, // EDGE, // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeType.java // public enum AttributeType { // // INTEGER, // LONG, // DOUBLE, // FLOAT, // BOOLEAN, // STRING, // LISTSTRING, // ANYURI, // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeValue.java // public interface AttributeValue extends Dynamic<AttributeValue> { // // Attribute getAttribute(); // // String getValue(); // AttributeValue setValue(String value); // } // // Path: src/main/java/com/ojn/gexf4j/core/impl/data/AttributeImpl.java // public class AttributeImpl implements Attribute { // // private String id = ""; // private String defaultValue = null; // private AttributeType type = AttributeType.STRING; // private List<String> options = null; // private String title = ""; // // public AttributeImpl(String id, AttributeType type, String title) { // checkArgument(id != null, "ID cannot be null."); // checkArgument(!id.trim().isEmpty(), "ID cannot be empty or blank."); // checkArgument(title != null, "Title cannot be null."); // checkArgument(!title.trim().isEmpty(), "Title cannot be null or blank."); // // this.id = id; // this.type = type; // this.options = new ArrayList<String>(); // this.title = title; // } // // @Override // public Attribute clearDefaultValue() { // defaultValue = null; // return this; // } // // @Override // public AttributeType getAttributeType() { // return type; // } // // @Override // public String getDefaultValue() { // checkState(hasDefaultValue(), "Default Value has not been set."); // return defaultValue; // } // // @Override // public String getId() { // return id; // } // // @Override // public List<String> getOptions() { // return options; // } // // @Override // public String getTitle() { // return title; // } // // @Override // public boolean hasDefaultValue() { // return (defaultValue != null); // } // // @Override // public Attribute setDefaultValue(String defaultValue) { // checkArgument(defaultValue != null, "Default Value cannot be null."); // this.defaultValue = defaultValue; // return this; // } // // @Override // public Attribute setTitle(String title) { // checkArgument(title != null, "Title cannot be null."); // checkArgument(title.trim().isEmpty(), "Title cannot be null or blank."); // this.title = title; // return this; // } // // @Override // public AttributeValue createValue(String value) { // checkArgument(value != null, "Value cannot be null."); // AttributeValue rv = new AttributeValueImpl(this); // rv.setValue(value); // return rv; // } // }
import static org.hamcrest.MatcherAssert.*; import static org.hamcrest.Matchers.*; import java.util.Random; import java.util.UUID; import org.junit.Before; import org.junit.Test; import com.ojn.gexf4j.core.data.Attribute; import com.ojn.gexf4j.core.data.AttributeClass; import com.ojn.gexf4j.core.data.AttributeType; import com.ojn.gexf4j.core.data.AttributeValue; import com.ojn.gexf4j.core.impl.data.AttributeImpl;
Node newTarget = newNode(); e.setTarget(newTarget); assertThat(e.getTarget(), is(equalTo(newTarget))); } @Test(expected=IllegalArgumentException.class) public void setTargetNull() { e.setTarget(null); } @Test public void setWeight() { Random rnd = new Random(); float weight = rnd.nextFloat(); e.setWeight(weight); assertThat(e.getWeight(), is(equalTo(weight))); } @Test public void setEdgeType() { for (EdgeType et : EdgeType.values()) { e.setEdgeType(et); assertThat(e.getEdgeType(), is(equalTo(et))); } } @Test public void getAttributeValues() {
// Path: src/main/java/com/ojn/gexf4j/core/data/Attribute.java // public interface Attribute { // // String getId(); // // String getTitle(); // Attribute setTitle(String title); // // AttributeType getAttributeType(); // // boolean hasDefaultValue(); // Attribute clearDefaultValue(); // String getDefaultValue(); // Attribute setDefaultValue(String defaultValue); // // List<String> getOptions(); // // AttributeValue createValue(String value); // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeClass.java // public enum AttributeClass { // // NODE, // EDGE, // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeType.java // public enum AttributeType { // // INTEGER, // LONG, // DOUBLE, // FLOAT, // BOOLEAN, // STRING, // LISTSTRING, // ANYURI, // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeValue.java // public interface AttributeValue extends Dynamic<AttributeValue> { // // Attribute getAttribute(); // // String getValue(); // AttributeValue setValue(String value); // } // // Path: src/main/java/com/ojn/gexf4j/core/impl/data/AttributeImpl.java // public class AttributeImpl implements Attribute { // // private String id = ""; // private String defaultValue = null; // private AttributeType type = AttributeType.STRING; // private List<String> options = null; // private String title = ""; // // public AttributeImpl(String id, AttributeType type, String title) { // checkArgument(id != null, "ID cannot be null."); // checkArgument(!id.trim().isEmpty(), "ID cannot be empty or blank."); // checkArgument(title != null, "Title cannot be null."); // checkArgument(!title.trim().isEmpty(), "Title cannot be null or blank."); // // this.id = id; // this.type = type; // this.options = new ArrayList<String>(); // this.title = title; // } // // @Override // public Attribute clearDefaultValue() { // defaultValue = null; // return this; // } // // @Override // public AttributeType getAttributeType() { // return type; // } // // @Override // public String getDefaultValue() { // checkState(hasDefaultValue(), "Default Value has not been set."); // return defaultValue; // } // // @Override // public String getId() { // return id; // } // // @Override // public List<String> getOptions() { // return options; // } // // @Override // public String getTitle() { // return title; // } // // @Override // public boolean hasDefaultValue() { // return (defaultValue != null); // } // // @Override // public Attribute setDefaultValue(String defaultValue) { // checkArgument(defaultValue != null, "Default Value cannot be null."); // this.defaultValue = defaultValue; // return this; // } // // @Override // public Attribute setTitle(String title) { // checkArgument(title != null, "Title cannot be null."); // checkArgument(title.trim().isEmpty(), "Title cannot be null or blank."); // this.title = title; // return this; // } // // @Override // public AttributeValue createValue(String value) { // checkArgument(value != null, "Value cannot be null."); // AttributeValue rv = new AttributeValueImpl(this); // rv.setValue(value); // return rv; // } // } // Path: src/test/java/com/ojn/gexf4j/core/EdgeTest.java import static org.hamcrest.MatcherAssert.*; import static org.hamcrest.Matchers.*; import java.util.Random; import java.util.UUID; import org.junit.Before; import org.junit.Test; import com.ojn.gexf4j.core.data.Attribute; import com.ojn.gexf4j.core.data.AttributeClass; import com.ojn.gexf4j.core.data.AttributeType; import com.ojn.gexf4j.core.data.AttributeValue; import com.ojn.gexf4j.core.impl.data.AttributeImpl; Node newTarget = newNode(); e.setTarget(newTarget); assertThat(e.getTarget(), is(equalTo(newTarget))); } @Test(expected=IllegalArgumentException.class) public void setTargetNull() { e.setTarget(null); } @Test public void setWeight() { Random rnd = new Random(); float weight = rnd.nextFloat(); e.setWeight(weight); assertThat(e.getWeight(), is(equalTo(weight))); } @Test public void setEdgeType() { for (EdgeType et : EdgeType.values()) { e.setEdgeType(et); assertThat(e.getEdgeType(), is(equalTo(et))); } } @Test public void getAttributeValues() {
Attribute attrib = new AttributeImpl(AttributeType.STRING, "test", AttributeClass.EDGE);
jmcampanini/gexf4j-core
src/test/java/com/ojn/gexf4j/core/EdgeTest.java
// Path: src/main/java/com/ojn/gexf4j/core/data/Attribute.java // public interface Attribute { // // String getId(); // // String getTitle(); // Attribute setTitle(String title); // // AttributeType getAttributeType(); // // boolean hasDefaultValue(); // Attribute clearDefaultValue(); // String getDefaultValue(); // Attribute setDefaultValue(String defaultValue); // // List<String> getOptions(); // // AttributeValue createValue(String value); // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeClass.java // public enum AttributeClass { // // NODE, // EDGE, // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeType.java // public enum AttributeType { // // INTEGER, // LONG, // DOUBLE, // FLOAT, // BOOLEAN, // STRING, // LISTSTRING, // ANYURI, // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeValue.java // public interface AttributeValue extends Dynamic<AttributeValue> { // // Attribute getAttribute(); // // String getValue(); // AttributeValue setValue(String value); // } // // Path: src/main/java/com/ojn/gexf4j/core/impl/data/AttributeImpl.java // public class AttributeImpl implements Attribute { // // private String id = ""; // private String defaultValue = null; // private AttributeType type = AttributeType.STRING; // private List<String> options = null; // private String title = ""; // // public AttributeImpl(String id, AttributeType type, String title) { // checkArgument(id != null, "ID cannot be null."); // checkArgument(!id.trim().isEmpty(), "ID cannot be empty or blank."); // checkArgument(title != null, "Title cannot be null."); // checkArgument(!title.trim().isEmpty(), "Title cannot be null or blank."); // // this.id = id; // this.type = type; // this.options = new ArrayList<String>(); // this.title = title; // } // // @Override // public Attribute clearDefaultValue() { // defaultValue = null; // return this; // } // // @Override // public AttributeType getAttributeType() { // return type; // } // // @Override // public String getDefaultValue() { // checkState(hasDefaultValue(), "Default Value has not been set."); // return defaultValue; // } // // @Override // public String getId() { // return id; // } // // @Override // public List<String> getOptions() { // return options; // } // // @Override // public String getTitle() { // return title; // } // // @Override // public boolean hasDefaultValue() { // return (defaultValue != null); // } // // @Override // public Attribute setDefaultValue(String defaultValue) { // checkArgument(defaultValue != null, "Default Value cannot be null."); // this.defaultValue = defaultValue; // return this; // } // // @Override // public Attribute setTitle(String title) { // checkArgument(title != null, "Title cannot be null."); // checkArgument(title.trim().isEmpty(), "Title cannot be null or blank."); // this.title = title; // return this; // } // // @Override // public AttributeValue createValue(String value) { // checkArgument(value != null, "Value cannot be null."); // AttributeValue rv = new AttributeValueImpl(this); // rv.setValue(value); // return rv; // } // }
import static org.hamcrest.MatcherAssert.*; import static org.hamcrest.Matchers.*; import java.util.Random; import java.util.UUID; import org.junit.Before; import org.junit.Test; import com.ojn.gexf4j.core.data.Attribute; import com.ojn.gexf4j.core.data.AttributeClass; import com.ojn.gexf4j.core.data.AttributeType; import com.ojn.gexf4j.core.data.AttributeValue; import com.ojn.gexf4j.core.impl.data.AttributeImpl;
Node newTarget = newNode(); e.setTarget(newTarget); assertThat(e.getTarget(), is(equalTo(newTarget))); } @Test(expected=IllegalArgumentException.class) public void setTargetNull() { e.setTarget(null); } @Test public void setWeight() { Random rnd = new Random(); float weight = rnd.nextFloat(); e.setWeight(weight); assertThat(e.getWeight(), is(equalTo(weight))); } @Test public void setEdgeType() { for (EdgeType et : EdgeType.values()) { e.setEdgeType(et); assertThat(e.getEdgeType(), is(equalTo(et))); } } @Test public void getAttributeValues() {
// Path: src/main/java/com/ojn/gexf4j/core/data/Attribute.java // public interface Attribute { // // String getId(); // // String getTitle(); // Attribute setTitle(String title); // // AttributeType getAttributeType(); // // boolean hasDefaultValue(); // Attribute clearDefaultValue(); // String getDefaultValue(); // Attribute setDefaultValue(String defaultValue); // // List<String> getOptions(); // // AttributeValue createValue(String value); // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeClass.java // public enum AttributeClass { // // NODE, // EDGE, // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeType.java // public enum AttributeType { // // INTEGER, // LONG, // DOUBLE, // FLOAT, // BOOLEAN, // STRING, // LISTSTRING, // ANYURI, // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeValue.java // public interface AttributeValue extends Dynamic<AttributeValue> { // // Attribute getAttribute(); // // String getValue(); // AttributeValue setValue(String value); // } // // Path: src/main/java/com/ojn/gexf4j/core/impl/data/AttributeImpl.java // public class AttributeImpl implements Attribute { // // private String id = ""; // private String defaultValue = null; // private AttributeType type = AttributeType.STRING; // private List<String> options = null; // private String title = ""; // // public AttributeImpl(String id, AttributeType type, String title) { // checkArgument(id != null, "ID cannot be null."); // checkArgument(!id.trim().isEmpty(), "ID cannot be empty or blank."); // checkArgument(title != null, "Title cannot be null."); // checkArgument(!title.trim().isEmpty(), "Title cannot be null or blank."); // // this.id = id; // this.type = type; // this.options = new ArrayList<String>(); // this.title = title; // } // // @Override // public Attribute clearDefaultValue() { // defaultValue = null; // return this; // } // // @Override // public AttributeType getAttributeType() { // return type; // } // // @Override // public String getDefaultValue() { // checkState(hasDefaultValue(), "Default Value has not been set."); // return defaultValue; // } // // @Override // public String getId() { // return id; // } // // @Override // public List<String> getOptions() { // return options; // } // // @Override // public String getTitle() { // return title; // } // // @Override // public boolean hasDefaultValue() { // return (defaultValue != null); // } // // @Override // public Attribute setDefaultValue(String defaultValue) { // checkArgument(defaultValue != null, "Default Value cannot be null."); // this.defaultValue = defaultValue; // return this; // } // // @Override // public Attribute setTitle(String title) { // checkArgument(title != null, "Title cannot be null."); // checkArgument(title.trim().isEmpty(), "Title cannot be null or blank."); // this.title = title; // return this; // } // // @Override // public AttributeValue createValue(String value) { // checkArgument(value != null, "Value cannot be null."); // AttributeValue rv = new AttributeValueImpl(this); // rv.setValue(value); // return rv; // } // } // Path: src/test/java/com/ojn/gexf4j/core/EdgeTest.java import static org.hamcrest.MatcherAssert.*; import static org.hamcrest.Matchers.*; import java.util.Random; import java.util.UUID; import org.junit.Before; import org.junit.Test; import com.ojn.gexf4j.core.data.Attribute; import com.ojn.gexf4j.core.data.AttributeClass; import com.ojn.gexf4j.core.data.AttributeType; import com.ojn.gexf4j.core.data.AttributeValue; import com.ojn.gexf4j.core.impl.data.AttributeImpl; Node newTarget = newNode(); e.setTarget(newTarget); assertThat(e.getTarget(), is(equalTo(newTarget))); } @Test(expected=IllegalArgumentException.class) public void setTargetNull() { e.setTarget(null); } @Test public void setWeight() { Random rnd = new Random(); float weight = rnd.nextFloat(); e.setWeight(weight); assertThat(e.getWeight(), is(equalTo(weight))); } @Test public void setEdgeType() { for (EdgeType et : EdgeType.values()) { e.setEdgeType(et); assertThat(e.getEdgeType(), is(equalTo(et))); } } @Test public void getAttributeValues() {
Attribute attrib = new AttributeImpl(AttributeType.STRING, "test", AttributeClass.EDGE);
jmcampanini/gexf4j-core
src/test/java/com/ojn/gexf4j/core/EdgeTest.java
// Path: src/main/java/com/ojn/gexf4j/core/data/Attribute.java // public interface Attribute { // // String getId(); // // String getTitle(); // Attribute setTitle(String title); // // AttributeType getAttributeType(); // // boolean hasDefaultValue(); // Attribute clearDefaultValue(); // String getDefaultValue(); // Attribute setDefaultValue(String defaultValue); // // List<String> getOptions(); // // AttributeValue createValue(String value); // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeClass.java // public enum AttributeClass { // // NODE, // EDGE, // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeType.java // public enum AttributeType { // // INTEGER, // LONG, // DOUBLE, // FLOAT, // BOOLEAN, // STRING, // LISTSTRING, // ANYURI, // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeValue.java // public interface AttributeValue extends Dynamic<AttributeValue> { // // Attribute getAttribute(); // // String getValue(); // AttributeValue setValue(String value); // } // // Path: src/main/java/com/ojn/gexf4j/core/impl/data/AttributeImpl.java // public class AttributeImpl implements Attribute { // // private String id = ""; // private String defaultValue = null; // private AttributeType type = AttributeType.STRING; // private List<String> options = null; // private String title = ""; // // public AttributeImpl(String id, AttributeType type, String title) { // checkArgument(id != null, "ID cannot be null."); // checkArgument(!id.trim().isEmpty(), "ID cannot be empty or blank."); // checkArgument(title != null, "Title cannot be null."); // checkArgument(!title.trim().isEmpty(), "Title cannot be null or blank."); // // this.id = id; // this.type = type; // this.options = new ArrayList<String>(); // this.title = title; // } // // @Override // public Attribute clearDefaultValue() { // defaultValue = null; // return this; // } // // @Override // public AttributeType getAttributeType() { // return type; // } // // @Override // public String getDefaultValue() { // checkState(hasDefaultValue(), "Default Value has not been set."); // return defaultValue; // } // // @Override // public String getId() { // return id; // } // // @Override // public List<String> getOptions() { // return options; // } // // @Override // public String getTitle() { // return title; // } // // @Override // public boolean hasDefaultValue() { // return (defaultValue != null); // } // // @Override // public Attribute setDefaultValue(String defaultValue) { // checkArgument(defaultValue != null, "Default Value cannot be null."); // this.defaultValue = defaultValue; // return this; // } // // @Override // public Attribute setTitle(String title) { // checkArgument(title != null, "Title cannot be null."); // checkArgument(title.trim().isEmpty(), "Title cannot be null or blank."); // this.title = title; // return this; // } // // @Override // public AttributeValue createValue(String value) { // checkArgument(value != null, "Value cannot be null."); // AttributeValue rv = new AttributeValueImpl(this); // rv.setValue(value); // return rv; // } // }
import static org.hamcrest.MatcherAssert.*; import static org.hamcrest.Matchers.*; import java.util.Random; import java.util.UUID; import org.junit.Before; import org.junit.Test; import com.ojn.gexf4j.core.data.Attribute; import com.ojn.gexf4j.core.data.AttributeClass; import com.ojn.gexf4j.core.data.AttributeType; import com.ojn.gexf4j.core.data.AttributeValue; import com.ojn.gexf4j.core.impl.data.AttributeImpl;
Node newTarget = newNode(); e.setTarget(newTarget); assertThat(e.getTarget(), is(equalTo(newTarget))); } @Test(expected=IllegalArgumentException.class) public void setTargetNull() { e.setTarget(null); } @Test public void setWeight() { Random rnd = new Random(); float weight = rnd.nextFloat(); e.setWeight(weight); assertThat(e.getWeight(), is(equalTo(weight))); } @Test public void setEdgeType() { for (EdgeType et : EdgeType.values()) { e.setEdgeType(et); assertThat(e.getEdgeType(), is(equalTo(et))); } } @Test public void getAttributeValues() {
// Path: src/main/java/com/ojn/gexf4j/core/data/Attribute.java // public interface Attribute { // // String getId(); // // String getTitle(); // Attribute setTitle(String title); // // AttributeType getAttributeType(); // // boolean hasDefaultValue(); // Attribute clearDefaultValue(); // String getDefaultValue(); // Attribute setDefaultValue(String defaultValue); // // List<String> getOptions(); // // AttributeValue createValue(String value); // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeClass.java // public enum AttributeClass { // // NODE, // EDGE, // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeType.java // public enum AttributeType { // // INTEGER, // LONG, // DOUBLE, // FLOAT, // BOOLEAN, // STRING, // LISTSTRING, // ANYURI, // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeValue.java // public interface AttributeValue extends Dynamic<AttributeValue> { // // Attribute getAttribute(); // // String getValue(); // AttributeValue setValue(String value); // } // // Path: src/main/java/com/ojn/gexf4j/core/impl/data/AttributeImpl.java // public class AttributeImpl implements Attribute { // // private String id = ""; // private String defaultValue = null; // private AttributeType type = AttributeType.STRING; // private List<String> options = null; // private String title = ""; // // public AttributeImpl(String id, AttributeType type, String title) { // checkArgument(id != null, "ID cannot be null."); // checkArgument(!id.trim().isEmpty(), "ID cannot be empty or blank."); // checkArgument(title != null, "Title cannot be null."); // checkArgument(!title.trim().isEmpty(), "Title cannot be null or blank."); // // this.id = id; // this.type = type; // this.options = new ArrayList<String>(); // this.title = title; // } // // @Override // public Attribute clearDefaultValue() { // defaultValue = null; // return this; // } // // @Override // public AttributeType getAttributeType() { // return type; // } // // @Override // public String getDefaultValue() { // checkState(hasDefaultValue(), "Default Value has not been set."); // return defaultValue; // } // // @Override // public String getId() { // return id; // } // // @Override // public List<String> getOptions() { // return options; // } // // @Override // public String getTitle() { // return title; // } // // @Override // public boolean hasDefaultValue() { // return (defaultValue != null); // } // // @Override // public Attribute setDefaultValue(String defaultValue) { // checkArgument(defaultValue != null, "Default Value cannot be null."); // this.defaultValue = defaultValue; // return this; // } // // @Override // public Attribute setTitle(String title) { // checkArgument(title != null, "Title cannot be null."); // checkArgument(title.trim().isEmpty(), "Title cannot be null or blank."); // this.title = title; // return this; // } // // @Override // public AttributeValue createValue(String value) { // checkArgument(value != null, "Value cannot be null."); // AttributeValue rv = new AttributeValueImpl(this); // rv.setValue(value); // return rv; // } // } // Path: src/test/java/com/ojn/gexf4j/core/EdgeTest.java import static org.hamcrest.MatcherAssert.*; import static org.hamcrest.Matchers.*; import java.util.Random; import java.util.UUID; import org.junit.Before; import org.junit.Test; import com.ojn.gexf4j.core.data.Attribute; import com.ojn.gexf4j.core.data.AttributeClass; import com.ojn.gexf4j.core.data.AttributeType; import com.ojn.gexf4j.core.data.AttributeValue; import com.ojn.gexf4j.core.impl.data.AttributeImpl; Node newTarget = newNode(); e.setTarget(newTarget); assertThat(e.getTarget(), is(equalTo(newTarget))); } @Test(expected=IllegalArgumentException.class) public void setTargetNull() { e.setTarget(null); } @Test public void setWeight() { Random rnd = new Random(); float weight = rnd.nextFloat(); e.setWeight(weight); assertThat(e.getWeight(), is(equalTo(weight))); } @Test public void setEdgeType() { for (EdgeType et : EdgeType.values()) { e.setEdgeType(et); assertThat(e.getEdgeType(), is(equalTo(et))); } } @Test public void getAttributeValues() {
Attribute attrib = new AttributeImpl(AttributeType.STRING, "test", AttributeClass.EDGE);
jmcampanini/gexf4j-core
src/test/java/com/ojn/gexf4j/core/EdgeTest.java
// Path: src/main/java/com/ojn/gexf4j/core/data/Attribute.java // public interface Attribute { // // String getId(); // // String getTitle(); // Attribute setTitle(String title); // // AttributeType getAttributeType(); // // boolean hasDefaultValue(); // Attribute clearDefaultValue(); // String getDefaultValue(); // Attribute setDefaultValue(String defaultValue); // // List<String> getOptions(); // // AttributeValue createValue(String value); // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeClass.java // public enum AttributeClass { // // NODE, // EDGE, // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeType.java // public enum AttributeType { // // INTEGER, // LONG, // DOUBLE, // FLOAT, // BOOLEAN, // STRING, // LISTSTRING, // ANYURI, // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeValue.java // public interface AttributeValue extends Dynamic<AttributeValue> { // // Attribute getAttribute(); // // String getValue(); // AttributeValue setValue(String value); // } // // Path: src/main/java/com/ojn/gexf4j/core/impl/data/AttributeImpl.java // public class AttributeImpl implements Attribute { // // private String id = ""; // private String defaultValue = null; // private AttributeType type = AttributeType.STRING; // private List<String> options = null; // private String title = ""; // // public AttributeImpl(String id, AttributeType type, String title) { // checkArgument(id != null, "ID cannot be null."); // checkArgument(!id.trim().isEmpty(), "ID cannot be empty or blank."); // checkArgument(title != null, "Title cannot be null."); // checkArgument(!title.trim().isEmpty(), "Title cannot be null or blank."); // // this.id = id; // this.type = type; // this.options = new ArrayList<String>(); // this.title = title; // } // // @Override // public Attribute clearDefaultValue() { // defaultValue = null; // return this; // } // // @Override // public AttributeType getAttributeType() { // return type; // } // // @Override // public String getDefaultValue() { // checkState(hasDefaultValue(), "Default Value has not been set."); // return defaultValue; // } // // @Override // public String getId() { // return id; // } // // @Override // public List<String> getOptions() { // return options; // } // // @Override // public String getTitle() { // return title; // } // // @Override // public boolean hasDefaultValue() { // return (defaultValue != null); // } // // @Override // public Attribute setDefaultValue(String defaultValue) { // checkArgument(defaultValue != null, "Default Value cannot be null."); // this.defaultValue = defaultValue; // return this; // } // // @Override // public Attribute setTitle(String title) { // checkArgument(title != null, "Title cannot be null."); // checkArgument(title.trim().isEmpty(), "Title cannot be null or blank."); // this.title = title; // return this; // } // // @Override // public AttributeValue createValue(String value) { // checkArgument(value != null, "Value cannot be null."); // AttributeValue rv = new AttributeValueImpl(this); // rv.setValue(value); // return rv; // } // }
import static org.hamcrest.MatcherAssert.*; import static org.hamcrest.Matchers.*; import java.util.Random; import java.util.UUID; import org.junit.Before; import org.junit.Test; import com.ojn.gexf4j.core.data.Attribute; import com.ojn.gexf4j.core.data.AttributeClass; import com.ojn.gexf4j.core.data.AttributeType; import com.ojn.gexf4j.core.data.AttributeValue; import com.ojn.gexf4j.core.impl.data.AttributeImpl;
Node newTarget = newNode(); e.setTarget(newTarget); assertThat(e.getTarget(), is(equalTo(newTarget))); } @Test(expected=IllegalArgumentException.class) public void setTargetNull() { e.setTarget(null); } @Test public void setWeight() { Random rnd = new Random(); float weight = rnd.nextFloat(); e.setWeight(weight); assertThat(e.getWeight(), is(equalTo(weight))); } @Test public void setEdgeType() { for (EdgeType et : EdgeType.values()) { e.setEdgeType(et); assertThat(e.getEdgeType(), is(equalTo(et))); } } @Test public void getAttributeValues() {
// Path: src/main/java/com/ojn/gexf4j/core/data/Attribute.java // public interface Attribute { // // String getId(); // // String getTitle(); // Attribute setTitle(String title); // // AttributeType getAttributeType(); // // boolean hasDefaultValue(); // Attribute clearDefaultValue(); // String getDefaultValue(); // Attribute setDefaultValue(String defaultValue); // // List<String> getOptions(); // // AttributeValue createValue(String value); // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeClass.java // public enum AttributeClass { // // NODE, // EDGE, // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeType.java // public enum AttributeType { // // INTEGER, // LONG, // DOUBLE, // FLOAT, // BOOLEAN, // STRING, // LISTSTRING, // ANYURI, // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeValue.java // public interface AttributeValue extends Dynamic<AttributeValue> { // // Attribute getAttribute(); // // String getValue(); // AttributeValue setValue(String value); // } // // Path: src/main/java/com/ojn/gexf4j/core/impl/data/AttributeImpl.java // public class AttributeImpl implements Attribute { // // private String id = ""; // private String defaultValue = null; // private AttributeType type = AttributeType.STRING; // private List<String> options = null; // private String title = ""; // // public AttributeImpl(String id, AttributeType type, String title) { // checkArgument(id != null, "ID cannot be null."); // checkArgument(!id.trim().isEmpty(), "ID cannot be empty or blank."); // checkArgument(title != null, "Title cannot be null."); // checkArgument(!title.trim().isEmpty(), "Title cannot be null or blank."); // // this.id = id; // this.type = type; // this.options = new ArrayList<String>(); // this.title = title; // } // // @Override // public Attribute clearDefaultValue() { // defaultValue = null; // return this; // } // // @Override // public AttributeType getAttributeType() { // return type; // } // // @Override // public String getDefaultValue() { // checkState(hasDefaultValue(), "Default Value has not been set."); // return defaultValue; // } // // @Override // public String getId() { // return id; // } // // @Override // public List<String> getOptions() { // return options; // } // // @Override // public String getTitle() { // return title; // } // // @Override // public boolean hasDefaultValue() { // return (defaultValue != null); // } // // @Override // public Attribute setDefaultValue(String defaultValue) { // checkArgument(defaultValue != null, "Default Value cannot be null."); // this.defaultValue = defaultValue; // return this; // } // // @Override // public Attribute setTitle(String title) { // checkArgument(title != null, "Title cannot be null."); // checkArgument(title.trim().isEmpty(), "Title cannot be null or blank."); // this.title = title; // return this; // } // // @Override // public AttributeValue createValue(String value) { // checkArgument(value != null, "Value cannot be null."); // AttributeValue rv = new AttributeValueImpl(this); // rv.setValue(value); // return rv; // } // } // Path: src/test/java/com/ojn/gexf4j/core/EdgeTest.java import static org.hamcrest.MatcherAssert.*; import static org.hamcrest.Matchers.*; import java.util.Random; import java.util.UUID; import org.junit.Before; import org.junit.Test; import com.ojn.gexf4j.core.data.Attribute; import com.ojn.gexf4j.core.data.AttributeClass; import com.ojn.gexf4j.core.data.AttributeType; import com.ojn.gexf4j.core.data.AttributeValue; import com.ojn.gexf4j.core.impl.data.AttributeImpl; Node newTarget = newNode(); e.setTarget(newTarget); assertThat(e.getTarget(), is(equalTo(newTarget))); } @Test(expected=IllegalArgumentException.class) public void setTargetNull() { e.setTarget(null); } @Test public void setWeight() { Random rnd = new Random(); float weight = rnd.nextFloat(); e.setWeight(weight); assertThat(e.getWeight(), is(equalTo(weight))); } @Test public void setEdgeType() { for (EdgeType et : EdgeType.values()) { e.setEdgeType(et); assertThat(e.getEdgeType(), is(equalTo(et))); } } @Test public void getAttributeValues() {
Attribute attrib = new AttributeImpl(AttributeType.STRING, "test", AttributeClass.EDGE);
jmcampanini/gexf4j-core
src/test/java/com/ojn/gexf4j/core/EdgeTest.java
// Path: src/main/java/com/ojn/gexf4j/core/data/Attribute.java // public interface Attribute { // // String getId(); // // String getTitle(); // Attribute setTitle(String title); // // AttributeType getAttributeType(); // // boolean hasDefaultValue(); // Attribute clearDefaultValue(); // String getDefaultValue(); // Attribute setDefaultValue(String defaultValue); // // List<String> getOptions(); // // AttributeValue createValue(String value); // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeClass.java // public enum AttributeClass { // // NODE, // EDGE, // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeType.java // public enum AttributeType { // // INTEGER, // LONG, // DOUBLE, // FLOAT, // BOOLEAN, // STRING, // LISTSTRING, // ANYURI, // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeValue.java // public interface AttributeValue extends Dynamic<AttributeValue> { // // Attribute getAttribute(); // // String getValue(); // AttributeValue setValue(String value); // } // // Path: src/main/java/com/ojn/gexf4j/core/impl/data/AttributeImpl.java // public class AttributeImpl implements Attribute { // // private String id = ""; // private String defaultValue = null; // private AttributeType type = AttributeType.STRING; // private List<String> options = null; // private String title = ""; // // public AttributeImpl(String id, AttributeType type, String title) { // checkArgument(id != null, "ID cannot be null."); // checkArgument(!id.trim().isEmpty(), "ID cannot be empty or blank."); // checkArgument(title != null, "Title cannot be null."); // checkArgument(!title.trim().isEmpty(), "Title cannot be null or blank."); // // this.id = id; // this.type = type; // this.options = new ArrayList<String>(); // this.title = title; // } // // @Override // public Attribute clearDefaultValue() { // defaultValue = null; // return this; // } // // @Override // public AttributeType getAttributeType() { // return type; // } // // @Override // public String getDefaultValue() { // checkState(hasDefaultValue(), "Default Value has not been set."); // return defaultValue; // } // // @Override // public String getId() { // return id; // } // // @Override // public List<String> getOptions() { // return options; // } // // @Override // public String getTitle() { // return title; // } // // @Override // public boolean hasDefaultValue() { // return (defaultValue != null); // } // // @Override // public Attribute setDefaultValue(String defaultValue) { // checkArgument(defaultValue != null, "Default Value cannot be null."); // this.defaultValue = defaultValue; // return this; // } // // @Override // public Attribute setTitle(String title) { // checkArgument(title != null, "Title cannot be null."); // checkArgument(title.trim().isEmpty(), "Title cannot be null or blank."); // this.title = title; // return this; // } // // @Override // public AttributeValue createValue(String value) { // checkArgument(value != null, "Value cannot be null."); // AttributeValue rv = new AttributeValueImpl(this); // rv.setValue(value); // return rv; // } // }
import static org.hamcrest.MatcherAssert.*; import static org.hamcrest.Matchers.*; import java.util.Random; import java.util.UUID; import org.junit.Before; import org.junit.Test; import com.ojn.gexf4j.core.data.Attribute; import com.ojn.gexf4j.core.data.AttributeClass; import com.ojn.gexf4j.core.data.AttributeType; import com.ojn.gexf4j.core.data.AttributeValue; import com.ojn.gexf4j.core.impl.data.AttributeImpl;
e.setTarget(newTarget); assertThat(e.getTarget(), is(equalTo(newTarget))); } @Test(expected=IllegalArgumentException.class) public void setTargetNull() { e.setTarget(null); } @Test public void setWeight() { Random rnd = new Random(); float weight = rnd.nextFloat(); e.setWeight(weight); assertThat(e.getWeight(), is(equalTo(weight))); } @Test public void setEdgeType() { for (EdgeType et : EdgeType.values()) { e.setEdgeType(et); assertThat(e.getEdgeType(), is(equalTo(et))); } } @Test public void getAttributeValues() { Attribute attrib = new AttributeImpl(AttributeType.STRING, "test", AttributeClass.EDGE);
// Path: src/main/java/com/ojn/gexf4j/core/data/Attribute.java // public interface Attribute { // // String getId(); // // String getTitle(); // Attribute setTitle(String title); // // AttributeType getAttributeType(); // // boolean hasDefaultValue(); // Attribute clearDefaultValue(); // String getDefaultValue(); // Attribute setDefaultValue(String defaultValue); // // List<String> getOptions(); // // AttributeValue createValue(String value); // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeClass.java // public enum AttributeClass { // // NODE, // EDGE, // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeType.java // public enum AttributeType { // // INTEGER, // LONG, // DOUBLE, // FLOAT, // BOOLEAN, // STRING, // LISTSTRING, // ANYURI, // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeValue.java // public interface AttributeValue extends Dynamic<AttributeValue> { // // Attribute getAttribute(); // // String getValue(); // AttributeValue setValue(String value); // } // // Path: src/main/java/com/ojn/gexf4j/core/impl/data/AttributeImpl.java // public class AttributeImpl implements Attribute { // // private String id = ""; // private String defaultValue = null; // private AttributeType type = AttributeType.STRING; // private List<String> options = null; // private String title = ""; // // public AttributeImpl(String id, AttributeType type, String title) { // checkArgument(id != null, "ID cannot be null."); // checkArgument(!id.trim().isEmpty(), "ID cannot be empty or blank."); // checkArgument(title != null, "Title cannot be null."); // checkArgument(!title.trim().isEmpty(), "Title cannot be null or blank."); // // this.id = id; // this.type = type; // this.options = new ArrayList<String>(); // this.title = title; // } // // @Override // public Attribute clearDefaultValue() { // defaultValue = null; // return this; // } // // @Override // public AttributeType getAttributeType() { // return type; // } // // @Override // public String getDefaultValue() { // checkState(hasDefaultValue(), "Default Value has not been set."); // return defaultValue; // } // // @Override // public String getId() { // return id; // } // // @Override // public List<String> getOptions() { // return options; // } // // @Override // public String getTitle() { // return title; // } // // @Override // public boolean hasDefaultValue() { // return (defaultValue != null); // } // // @Override // public Attribute setDefaultValue(String defaultValue) { // checkArgument(defaultValue != null, "Default Value cannot be null."); // this.defaultValue = defaultValue; // return this; // } // // @Override // public Attribute setTitle(String title) { // checkArgument(title != null, "Title cannot be null."); // checkArgument(title.trim().isEmpty(), "Title cannot be null or blank."); // this.title = title; // return this; // } // // @Override // public AttributeValue createValue(String value) { // checkArgument(value != null, "Value cannot be null."); // AttributeValue rv = new AttributeValueImpl(this); // rv.setValue(value); // return rv; // } // } // Path: src/test/java/com/ojn/gexf4j/core/EdgeTest.java import static org.hamcrest.MatcherAssert.*; import static org.hamcrest.Matchers.*; import java.util.Random; import java.util.UUID; import org.junit.Before; import org.junit.Test; import com.ojn.gexf4j.core.data.Attribute; import com.ojn.gexf4j.core.data.AttributeClass; import com.ojn.gexf4j.core.data.AttributeType; import com.ojn.gexf4j.core.data.AttributeValue; import com.ojn.gexf4j.core.impl.data.AttributeImpl; e.setTarget(newTarget); assertThat(e.getTarget(), is(equalTo(newTarget))); } @Test(expected=IllegalArgumentException.class) public void setTargetNull() { e.setTarget(null); } @Test public void setWeight() { Random rnd = new Random(); float weight = rnd.nextFloat(); e.setWeight(weight); assertThat(e.getWeight(), is(equalTo(weight))); } @Test public void setEdgeType() { for (EdgeType et : EdgeType.values()) { e.setEdgeType(et); assertThat(e.getEdgeType(), is(equalTo(et))); } } @Test public void getAttributeValues() { Attribute attrib = new AttributeImpl(AttributeType.STRING, "test", AttributeClass.EDGE);
AttributeValue av = attrib.createValue("testing");
jmcampanini/gexf4j-core
src/main/java/com/ojn/gexf4j/core/impl/writer/GraphEntityWriter.java
// Path: src/main/java/com/ojn/gexf4j/core/Graph.java // public interface Graph extends Dynamic<Graph>, HasNodes { // // EdgeType getDefaultEdgeType(); // Graph setDefaultEdgeType(EdgeType edgeType); // // IDType getIDType(); // Graph setIDType(IDType idType); // // Mode getMode(); // Graph setMode(Mode graphMode); // // TimeType getTimeType(); // Graph setTimeType(TimeType timeType); // // List<AttributeList> getAttributeLists(); // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeList.java // public interface AttributeList extends List<Attribute>, Dynamic<AttributeList> { // // AttributeClass getAttributeClass(); // // Mode getMode(); // AttributeList setMode(Mode mode); // // Attribute createAttribute(AttributeType type, String title); // Attribute createAttribute(String id, AttributeType type, String title); // // AttributeList addAttribute(AttributeType type, String title); // AttributeList addAttribute(String id, AttributeType type, String title); // }
import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamWriter; import com.ojn.gexf4j.core.Graph; import com.ojn.gexf4j.core.data.AttributeList;
@Override protected String getElementName() { return ENTITY; } @Override protected void writeAttributes() throws XMLStreamException { writer.writeAttribute( ATTRIB_EDGETYPE, entity.getDefaultEdgeType().toString().toLowerCase()); writer.writeAttribute( ATTRIB_IDTYPE, entity.getIDType().toString().toLowerCase()); writer.writeAttribute( ATTRIB_MODE, entity.getMode().toString().toLowerCase()); writer.writeAttribute( ATTRIB_TIMETYPE, entity.getTimeType().toString().toLowerCase()); AbstractEntityWriter.writerTimeType = entity.getTimeType(); super.writeAttributes(); } @Override protected void writeElements() throws XMLStreamException {
// Path: src/main/java/com/ojn/gexf4j/core/Graph.java // public interface Graph extends Dynamic<Graph>, HasNodes { // // EdgeType getDefaultEdgeType(); // Graph setDefaultEdgeType(EdgeType edgeType); // // IDType getIDType(); // Graph setIDType(IDType idType); // // Mode getMode(); // Graph setMode(Mode graphMode); // // TimeType getTimeType(); // Graph setTimeType(TimeType timeType); // // List<AttributeList> getAttributeLists(); // } // // Path: src/main/java/com/ojn/gexf4j/core/data/AttributeList.java // public interface AttributeList extends List<Attribute>, Dynamic<AttributeList> { // // AttributeClass getAttributeClass(); // // Mode getMode(); // AttributeList setMode(Mode mode); // // Attribute createAttribute(AttributeType type, String title); // Attribute createAttribute(String id, AttributeType type, String title); // // AttributeList addAttribute(AttributeType type, String title); // AttributeList addAttribute(String id, AttributeType type, String title); // } // Path: src/main/java/com/ojn/gexf4j/core/impl/writer/GraphEntityWriter.java import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamWriter; import com.ojn.gexf4j.core.Graph; import com.ojn.gexf4j.core.data.AttributeList; @Override protected String getElementName() { return ENTITY; } @Override protected void writeAttributes() throws XMLStreamException { writer.writeAttribute( ATTRIB_EDGETYPE, entity.getDefaultEdgeType().toString().toLowerCase()); writer.writeAttribute( ATTRIB_IDTYPE, entity.getIDType().toString().toLowerCase()); writer.writeAttribute( ATTRIB_MODE, entity.getMode().toString().toLowerCase()); writer.writeAttribute( ATTRIB_TIMETYPE, entity.getTimeType().toString().toLowerCase()); AbstractEntityWriter.writerTimeType = entity.getTimeType(); super.writeAttributes(); } @Override protected void writeElements() throws XMLStreamException {
for (AttributeList attList : entity.getAttributeLists()) {
jmcampanini/gexf4j-core
src/test/java/com/ojn/gexf4j/core/GraphReaderTest.java
// Path: src/main/java/com/ojn/gexf4j/core/impl/StaxGraphReader.java // public class StaxGraphReader implements GexfReader { // // @Override // public Gexf readFromStream(InputStream in) throws IOException { // // TODO Auto-generated method stub // return null; // } // // }
import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import javax.xml.stream.XMLStreamException; import org.junit.Test; import com.ojn.gexf4j.core.impl.StaxGraphReader;
package com.ojn.gexf4j.core; public class GraphReaderTest { @Test public void quickTest() throws XMLStreamException, IOException {
// Path: src/main/java/com/ojn/gexf4j/core/impl/StaxGraphReader.java // public class StaxGraphReader implements GexfReader { // // @Override // public Gexf readFromStream(InputStream in) throws IOException { // // TODO Auto-generated method stub // return null; // } // // } // Path: src/test/java/com/ojn/gexf4j/core/GraphReaderTest.java import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import javax.xml.stream.XMLStreamException; import org.junit.Test; import com.ojn.gexf4j.core.impl.StaxGraphReader; package com.ojn.gexf4j.core; public class GraphReaderTest { @Test public void quickTest() throws XMLStreamException, IOException {
GexfReader gr = new StaxGraphReader();
jmcampanini/gexf4j-core
src/main/java/com/ojn/gexf4j/core/impl/reader/NodesEntityParser.java
// Path: src/main/java/com/ojn/gexf4j/core/Graph.java // public interface Graph extends Dynamic<Graph>, HasNodes { // // EdgeType getDefaultEdgeType(); // Graph setDefaultEdgeType(EdgeType edgeType); // // IDType getIDType(); // Graph setIDType(IDType idType); // // Mode getMode(); // Graph setMode(Mode graphMode); // // TimeType getTimeType(); // Graph setTimeType(TimeType timeType); // // List<AttributeList> getAttributeLists(); // } // // Path: src/main/java/com/ojn/gexf4j/core/Node.java // public interface Node extends SlicableDatum<Node>, HasNodes { // // String getId(); // // String getLabel(); // Node setLabel(String label); // // List<Edge> getEdges(); // // Edge connectTo(Node target); // Edge connectTo(String id, Node target); // // boolean hasEdgeTo(String id); // // boolean hasColor(); // Node clearColor(); // Color getColor(); // Node setColor(Color color); // // boolean hasPosition(); // Node clearPosition(); // Position getPosition(); // Node setPosition(Position position); // // boolean hasSize(); // Node clearSize(); // float getSize(); // Node setSize(float size); // // boolean hasShape(); // Node clearShape(); // NodeShapeEntity getShapeEntity(); // // List<Node> getParentForList(); // // boolean hasPID(); // Node clearPID(); // String getPID(); // Node setPID(String pid); // }
import java.util.List; import javax.xml.stream.XMLStreamReader; import com.ojn.gexf4j.core.Graph; import com.ojn.gexf4j.core.Node;
package com.ojn.gexf4j.core.impl.reader; public class NodesEntityParser extends AbstractEntityParser<List<Node>> { private static final String ENTITY_NODE = "node";
// Path: src/main/java/com/ojn/gexf4j/core/Graph.java // public interface Graph extends Dynamic<Graph>, HasNodes { // // EdgeType getDefaultEdgeType(); // Graph setDefaultEdgeType(EdgeType edgeType); // // IDType getIDType(); // Graph setIDType(IDType idType); // // Mode getMode(); // Graph setMode(Mode graphMode); // // TimeType getTimeType(); // Graph setTimeType(TimeType timeType); // // List<AttributeList> getAttributeLists(); // } // // Path: src/main/java/com/ojn/gexf4j/core/Node.java // public interface Node extends SlicableDatum<Node>, HasNodes { // // String getId(); // // String getLabel(); // Node setLabel(String label); // // List<Edge> getEdges(); // // Edge connectTo(Node target); // Edge connectTo(String id, Node target); // // boolean hasEdgeTo(String id); // // boolean hasColor(); // Node clearColor(); // Color getColor(); // Node setColor(Color color); // // boolean hasPosition(); // Node clearPosition(); // Position getPosition(); // Node setPosition(Position position); // // boolean hasSize(); // Node clearSize(); // float getSize(); // Node setSize(float size); // // boolean hasShape(); // Node clearShape(); // NodeShapeEntity getShapeEntity(); // // List<Node> getParentForList(); // // boolean hasPID(); // Node clearPID(); // String getPID(); // Node setPID(String pid); // } // Path: src/main/java/com/ojn/gexf4j/core/impl/reader/NodesEntityParser.java import java.util.List; import javax.xml.stream.XMLStreamReader; import com.ojn.gexf4j.core.Graph; import com.ojn.gexf4j.core.Node; package com.ojn.gexf4j.core.impl.reader; public class NodesEntityParser extends AbstractEntityParser<List<Node>> { private static final String ENTITY_NODE = "node";
private Graph graph = null;
jmcampanini/gexf4j-core
src/test/java/com/ojn/gexf4j/core/testgraphs/HierarchyInlineBuilder.java
// Path: src/main/java/com/ojn/gexf4j/core/EdgeType.java // public enum EdgeType { // // DIRECTED, // UNDIRECTED, // MUTUAL, // } // // Path: src/main/java/com/ojn/gexf4j/core/Gexf.java // public interface Gexf { // // String getVersion(); // // boolean hasVariant(); // Gexf clearVariant(); // String getVariant(); // Gexf setVariant(String variant); // // Metadata getMetadata(); // // Graph getGraph(); // // boolean hasVisualization(); // Gexf setVisualization(boolean viz); // } // // Path: src/main/java/com/ojn/gexf4j/core/Mode.java // public enum Mode { // // STATIC, // DYNAMIC, // } // // Path: src/main/java/com/ojn/gexf4j/core/Node.java // public interface Node extends SlicableDatum<Node>, HasNodes { // // String getId(); // // String getLabel(); // Node setLabel(String label); // // List<Edge> getEdges(); // // Edge connectTo(Node target); // Edge connectTo(String id, Node target); // // boolean hasEdgeTo(String id); // // boolean hasColor(); // Node clearColor(); // Color getColor(); // Node setColor(Color color); // // boolean hasPosition(); // Node clearPosition(); // Position getPosition(); // Node setPosition(Position position); // // boolean hasSize(); // Node clearSize(); // float getSize(); // Node setSize(float size); // // boolean hasShape(); // Node clearShape(); // NodeShapeEntity getShapeEntity(); // // List<Node> getParentForList(); // // boolean hasPID(); // Node clearPID(); // String getPID(); // Node setPID(String pid); // } // // Path: src/main/java/com/ojn/gexf4j/core/impl/GexfImpl.java // public class GexfImpl implements Gexf { // private static final String VERSION = "1.1"; // // private String variant = null; // private Graph graph = null; // private Metadata meta = null; // private boolean viz = false; // // public GexfImpl() { // graph = new GraphImpl(); // meta = new MetadataImpl(); // } // // @Override // public Graph getGraph() { // return graph; // } // // @Override // public Metadata getMetadata() { // return meta; // } // // @Override // public String getVersion() { // return VERSION; // } // // @Override // public boolean hasVariant() { // return (variant != null); // } // // @Override // public Gexf clearVariant() { // variant = null; // return this; // } // // @Override // public String getVariant() { // checkState(hasVariant(), "Variant has not been set."); // return variant; // } // // @Override // public Gexf setVariant(String variant) { // checkArgument(variant != null, "Variant cannot be null."); // checkArgument(!variant.trim().isEmpty(), "Variant cannot be empty or blank."); // this.variant = variant; // return this; // } // // @Override // public boolean hasVisualization() { // return viz; // } // // @Override // public Gexf setVisualization(boolean viz) { // this.viz = viz; // return this; // } // }
import com.ojn.gexf4j.core.EdgeType; import com.ojn.gexf4j.core.Gexf; import com.ojn.gexf4j.core.Mode; import com.ojn.gexf4j.core.Node; import com.ojn.gexf4j.core.impl.GexfImpl;
package com.ojn.gexf4j.core.testgraphs; public class HierarchyInlineBuilder extends GexfBuilder { @Override public String getSuffix() { return "hierarchyInline"; } @Override
// Path: src/main/java/com/ojn/gexf4j/core/EdgeType.java // public enum EdgeType { // // DIRECTED, // UNDIRECTED, // MUTUAL, // } // // Path: src/main/java/com/ojn/gexf4j/core/Gexf.java // public interface Gexf { // // String getVersion(); // // boolean hasVariant(); // Gexf clearVariant(); // String getVariant(); // Gexf setVariant(String variant); // // Metadata getMetadata(); // // Graph getGraph(); // // boolean hasVisualization(); // Gexf setVisualization(boolean viz); // } // // Path: src/main/java/com/ojn/gexf4j/core/Mode.java // public enum Mode { // // STATIC, // DYNAMIC, // } // // Path: src/main/java/com/ojn/gexf4j/core/Node.java // public interface Node extends SlicableDatum<Node>, HasNodes { // // String getId(); // // String getLabel(); // Node setLabel(String label); // // List<Edge> getEdges(); // // Edge connectTo(Node target); // Edge connectTo(String id, Node target); // // boolean hasEdgeTo(String id); // // boolean hasColor(); // Node clearColor(); // Color getColor(); // Node setColor(Color color); // // boolean hasPosition(); // Node clearPosition(); // Position getPosition(); // Node setPosition(Position position); // // boolean hasSize(); // Node clearSize(); // float getSize(); // Node setSize(float size); // // boolean hasShape(); // Node clearShape(); // NodeShapeEntity getShapeEntity(); // // List<Node> getParentForList(); // // boolean hasPID(); // Node clearPID(); // String getPID(); // Node setPID(String pid); // } // // Path: src/main/java/com/ojn/gexf4j/core/impl/GexfImpl.java // public class GexfImpl implements Gexf { // private static final String VERSION = "1.1"; // // private String variant = null; // private Graph graph = null; // private Metadata meta = null; // private boolean viz = false; // // public GexfImpl() { // graph = new GraphImpl(); // meta = new MetadataImpl(); // } // // @Override // public Graph getGraph() { // return graph; // } // // @Override // public Metadata getMetadata() { // return meta; // } // // @Override // public String getVersion() { // return VERSION; // } // // @Override // public boolean hasVariant() { // return (variant != null); // } // // @Override // public Gexf clearVariant() { // variant = null; // return this; // } // // @Override // public String getVariant() { // checkState(hasVariant(), "Variant has not been set."); // return variant; // } // // @Override // public Gexf setVariant(String variant) { // checkArgument(variant != null, "Variant cannot be null."); // checkArgument(!variant.trim().isEmpty(), "Variant cannot be empty or blank."); // this.variant = variant; // return this; // } // // @Override // public boolean hasVisualization() { // return viz; // } // // @Override // public Gexf setVisualization(boolean viz) { // this.viz = viz; // return this; // } // } // Path: src/test/java/com/ojn/gexf4j/core/testgraphs/HierarchyInlineBuilder.java import com.ojn.gexf4j.core.EdgeType; import com.ojn.gexf4j.core.Gexf; import com.ojn.gexf4j.core.Mode; import com.ojn.gexf4j.core.Node; import com.ojn.gexf4j.core.impl.GexfImpl; package com.ojn.gexf4j.core.testgraphs; public class HierarchyInlineBuilder extends GexfBuilder { @Override public String getSuffix() { return "hierarchyInline"; } @Override
public Gexf buildGexf() {