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
ezoerner/c-star-path-j
thrift/src/main/java/com/ebuddy/cassandra/dao/SuperColumnFamilyTemplate.java
// Path: api/src/main/java/com/ebuddy/cassandra/BatchContext.java // public interface BatchContext { } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/mapper/ColumnMapper.java // public interface ColumnMapper<T,N,V> { // // T mapColumn(N columnName, V columnValue); // // } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/mapper/ColumnMapperWithTimestamps.java // public interface ColumnMapperWithTimestamps<T,N,V> { // // T mapColumn(N columnName, V columnValue, long timestamp); // } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/mapper/SuperColumnFamilyRowMapper.java // public interface SuperColumnFamilyRowMapper<T,K,SN,N,V> { // T mapRow(K rowKey, List<HSuperColumn<SN,N,V>> superColumns); // } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/mapper/SuperColumnMapper.java // public interface SuperColumnMapper<T,K,SN,N,V> { // // T mapSuperColumn(K rowKey, SN superColumnName, List<HColumn<N,V>> columns); // // } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/visitor/ColumnVisitor.java // public interface ColumnVisitor<N, V> { // // /** // * Visit easy column and evaluates a logic. // * @param columnName the name of the column // * @param columnValue the value of the column // * @param timestamp the cassandra timestamp when the column was written // * @param ttl the time to live for that column value // */ // void visit(N columnName, V columnValue, long timestamp, int ttl); // // }
import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.apache.commons.lang3.Validate; import com.ebuddy.cassandra.BatchContext; import com.ebuddy.cassandra.dao.mapper.ColumnMapper; import com.ebuddy.cassandra.dao.mapper.ColumnMapperWithTimestamps; import com.ebuddy.cassandra.dao.mapper.SuperColumnFamilyRowMapper; import com.ebuddy.cassandra.dao.mapper.SuperColumnMapper; import com.ebuddy.cassandra.dao.visitor.ColumnVisitor; import com.google.common.collect.Lists; import me.prettyprint.hector.api.Keyspace; import me.prettyprint.hector.api.Serializer; import me.prettyprint.hector.api.beans.ColumnSlice; import me.prettyprint.hector.api.beans.HColumn; import me.prettyprint.hector.api.beans.HSuperColumn; import me.prettyprint.hector.api.beans.Row; import me.prettyprint.hector.api.beans.Rows; import me.prettyprint.hector.api.beans.SuperRow; import me.prettyprint.hector.api.beans.SuperRows; import me.prettyprint.hector.api.beans.SuperSlice; import me.prettyprint.hector.api.factory.HFactory; import me.prettyprint.hector.api.mutation.Mutator; import me.prettyprint.hector.api.query.MultigetSubSliceQuery; import me.prettyprint.hector.api.query.MultigetSuperSliceQuery; import me.prettyprint.hector.api.query.QueryResult; import me.prettyprint.hector.api.query.SubColumnQuery; import me.prettyprint.hector.api.query.SubSliceQuery; import me.prettyprint.hector.api.query.SuperSliceQuery;
} return results; // we used to translate hector exceptions into spring exceptions here, but spring dependency was removed } /** * Set subcolumn values for a specified super column and execute immediately. * * @param rowKey the row key of type K * @param superColumnName the super column name of type SN * @param columnMap a map of column names type N and column values type V. */ @Override public void writeColumns(K rowKey, SN superColumnName, Map<N,V> columnMap) { basicWriteColumns(rowKey, superColumnName, columnMap, null); } /** * Set subcolumn values for a specified super column as a batch operation. * * @param rowKey the row key of type K * @param superColumnName the super column name of type SN * @param columnMap a map of column names type N and column values type V. * @param txnContext BatchContext for batch operations */ @Override public void writeColumns(K rowKey, SN superColumnName, Map<N,V> columnMap,
// Path: api/src/main/java/com/ebuddy/cassandra/BatchContext.java // public interface BatchContext { } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/mapper/ColumnMapper.java // public interface ColumnMapper<T,N,V> { // // T mapColumn(N columnName, V columnValue); // // } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/mapper/ColumnMapperWithTimestamps.java // public interface ColumnMapperWithTimestamps<T,N,V> { // // T mapColumn(N columnName, V columnValue, long timestamp); // } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/mapper/SuperColumnFamilyRowMapper.java // public interface SuperColumnFamilyRowMapper<T,K,SN,N,V> { // T mapRow(K rowKey, List<HSuperColumn<SN,N,V>> superColumns); // } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/mapper/SuperColumnMapper.java // public interface SuperColumnMapper<T,K,SN,N,V> { // // T mapSuperColumn(K rowKey, SN superColumnName, List<HColumn<N,V>> columns); // // } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/visitor/ColumnVisitor.java // public interface ColumnVisitor<N, V> { // // /** // * Visit easy column and evaluates a logic. // * @param columnName the name of the column // * @param columnValue the value of the column // * @param timestamp the cassandra timestamp when the column was written // * @param ttl the time to live for that column value // */ // void visit(N columnName, V columnValue, long timestamp, int ttl); // // } // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/SuperColumnFamilyTemplate.java import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.apache.commons.lang3.Validate; import com.ebuddy.cassandra.BatchContext; import com.ebuddy.cassandra.dao.mapper.ColumnMapper; import com.ebuddy.cassandra.dao.mapper.ColumnMapperWithTimestamps; import com.ebuddy.cassandra.dao.mapper.SuperColumnFamilyRowMapper; import com.ebuddy.cassandra.dao.mapper.SuperColumnMapper; import com.ebuddy.cassandra.dao.visitor.ColumnVisitor; import com.google.common.collect.Lists; import me.prettyprint.hector.api.Keyspace; import me.prettyprint.hector.api.Serializer; import me.prettyprint.hector.api.beans.ColumnSlice; import me.prettyprint.hector.api.beans.HColumn; import me.prettyprint.hector.api.beans.HSuperColumn; import me.prettyprint.hector.api.beans.Row; import me.prettyprint.hector.api.beans.Rows; import me.prettyprint.hector.api.beans.SuperRow; import me.prettyprint.hector.api.beans.SuperRows; import me.prettyprint.hector.api.beans.SuperSlice; import me.prettyprint.hector.api.factory.HFactory; import me.prettyprint.hector.api.mutation.Mutator; import me.prettyprint.hector.api.query.MultigetSubSliceQuery; import me.prettyprint.hector.api.query.MultigetSuperSliceQuery; import me.prettyprint.hector.api.query.QueryResult; import me.prettyprint.hector.api.query.SubColumnQuery; import me.prettyprint.hector.api.query.SubSliceQuery; import me.prettyprint.hector.api.query.SuperSliceQuery; } return results; // we used to translate hector exceptions into spring exceptions here, but spring dependency was removed } /** * Set subcolumn values for a specified super column and execute immediately. * * @param rowKey the row key of type K * @param superColumnName the super column name of type SN * @param columnMap a map of column names type N and column values type V. */ @Override public void writeColumns(K rowKey, SN superColumnName, Map<N,V> columnMap) { basicWriteColumns(rowKey, superColumnName, columnMap, null); } /** * Set subcolumn values for a specified super column as a batch operation. * * @param rowKey the row key of type K * @param superColumnName the super column name of type SN * @param columnMap a map of column names type N and column values type V. * @param txnContext BatchContext for batch operations */ @Override public void writeColumns(K rowKey, SN superColumnName, Map<N,V> columnMap,
@Nonnull BatchContext txnContext) {
ezoerner/c-star-path-j
thrift/src/main/java/com/ebuddy/cassandra/dao/SuperColumnFamilyOperations.java
// Path: api/src/main/java/com/ebuddy/cassandra/BatchContext.java // public interface BatchContext { } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/mapper/ColumnMapper.java // public interface ColumnMapper<T,N,V> { // // T mapColumn(N columnName, V columnValue); // // } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/mapper/ColumnMapperWithTimestamps.java // public interface ColumnMapperWithTimestamps<T,N,V> { // // T mapColumn(N columnName, V columnValue, long timestamp); // } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/mapper/SuperColumnFamilyRowMapper.java // public interface SuperColumnFamilyRowMapper<T,K,SN,N,V> { // T mapRow(K rowKey, List<HSuperColumn<SN,N,V>> superColumns); // } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/mapper/SuperColumnMapper.java // public interface SuperColumnMapper<T,K,SN,N,V> { // // T mapSuperColumn(K rowKey, SN superColumnName, List<HColumn<N,V>> columns); // // } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/visitor/ColumnVisitor.java // public interface ColumnVisitor<N, V> { // // /** // * Visit easy column and evaluates a logic. // * @param columnName the name of the column // * @param columnValue the value of the column // * @param timestamp the cassandra timestamp when the column was written // * @param ttl the time to live for that column value // */ // void visit(N columnName, V columnValue, long timestamp, int ttl); // // }
import java.util.Collection; import java.util.List; import java.util.Map; import javax.annotation.Nonnull; import com.ebuddy.cassandra.BatchContext; import com.ebuddy.cassandra.dao.mapper.ColumnMapper; import com.ebuddy.cassandra.dao.mapper.ColumnMapperWithTimestamps; import com.ebuddy.cassandra.dao.mapper.SuperColumnFamilyRowMapper; import com.ebuddy.cassandra.dao.mapper.SuperColumnMapper; import com.ebuddy.cassandra.dao.visitor.ColumnVisitor;
/* * Copyright 2013 eBuddy B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.ebuddy.cassandra.dao; /** * Operations for a super column family. * @param <K> the Row Key type. * @param <SN> The supercolumn name type. * @param <N> The subcolumn name type. * @param <V> The column value type. * @author Eric Zoerner <a href="mailto:ezoerner@ebuddy.com">ezoerner@ebuddy.com</a> */ public interface SuperColumnFamilyOperations<K,SN,N,V> { /** * Create a BatchContext for use with this keyspace. * * @return the BatchContext */ BatchContext begin(); /** * Execute a batch of updates. * * @param batchContext the BatchContext */ void commit(@Nonnull BatchContext batchContext); V readColumnValue(K rowKey, SN superColumnName, N columnName); Map<N,V> readColumnsAsMap(K rowKey, SN superColumnName, N... columnNames); Map<N,V> readColumnsAsMap(K rowKey, SN superColumnName, N start, N finish, int count, boolean reversed);
// Path: api/src/main/java/com/ebuddy/cassandra/BatchContext.java // public interface BatchContext { } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/mapper/ColumnMapper.java // public interface ColumnMapper<T,N,V> { // // T mapColumn(N columnName, V columnValue); // // } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/mapper/ColumnMapperWithTimestamps.java // public interface ColumnMapperWithTimestamps<T,N,V> { // // T mapColumn(N columnName, V columnValue, long timestamp); // } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/mapper/SuperColumnFamilyRowMapper.java // public interface SuperColumnFamilyRowMapper<T,K,SN,N,V> { // T mapRow(K rowKey, List<HSuperColumn<SN,N,V>> superColumns); // } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/mapper/SuperColumnMapper.java // public interface SuperColumnMapper<T,K,SN,N,V> { // // T mapSuperColumn(K rowKey, SN superColumnName, List<HColumn<N,V>> columns); // // } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/visitor/ColumnVisitor.java // public interface ColumnVisitor<N, V> { // // /** // * Visit easy column and evaluates a logic. // * @param columnName the name of the column // * @param columnValue the value of the column // * @param timestamp the cassandra timestamp when the column was written // * @param ttl the time to live for that column value // */ // void visit(N columnName, V columnValue, long timestamp, int ttl); // // } // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/SuperColumnFamilyOperations.java import java.util.Collection; import java.util.List; import java.util.Map; import javax.annotation.Nonnull; import com.ebuddy.cassandra.BatchContext; import com.ebuddy.cassandra.dao.mapper.ColumnMapper; import com.ebuddy.cassandra.dao.mapper.ColumnMapperWithTimestamps; import com.ebuddy.cassandra.dao.mapper.SuperColumnFamilyRowMapper; import com.ebuddy.cassandra.dao.mapper.SuperColumnMapper; import com.ebuddy.cassandra.dao.visitor.ColumnVisitor; /* * Copyright 2013 eBuddy B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.ebuddy.cassandra.dao; /** * Operations for a super column family. * @param <K> the Row Key type. * @param <SN> The supercolumn name type. * @param <N> The subcolumn name type. * @param <V> The column value type. * @author Eric Zoerner <a href="mailto:ezoerner@ebuddy.com">ezoerner@ebuddy.com</a> */ public interface SuperColumnFamilyOperations<K,SN,N,V> { /** * Create a BatchContext for use with this keyspace. * * @return the BatchContext */ BatchContext begin(); /** * Execute a batch of updates. * * @param batchContext the BatchContext */ void commit(@Nonnull BatchContext batchContext); V readColumnValue(K rowKey, SN superColumnName, N columnName); Map<N,V> readColumnsAsMap(K rowKey, SN superColumnName, N... columnNames); Map<N,V> readColumnsAsMap(K rowKey, SN superColumnName, N start, N finish, int count, boolean reversed);
<T> List<T> readColumns(K rowKey, SN superColumnName, ColumnMapper<T,N,V> columnMapper);
ezoerner/c-star-path-j
thrift/src/main/java/com/ebuddy/cassandra/dao/SuperColumnFamilyOperations.java
// Path: api/src/main/java/com/ebuddy/cassandra/BatchContext.java // public interface BatchContext { } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/mapper/ColumnMapper.java // public interface ColumnMapper<T,N,V> { // // T mapColumn(N columnName, V columnValue); // // } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/mapper/ColumnMapperWithTimestamps.java // public interface ColumnMapperWithTimestamps<T,N,V> { // // T mapColumn(N columnName, V columnValue, long timestamp); // } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/mapper/SuperColumnFamilyRowMapper.java // public interface SuperColumnFamilyRowMapper<T,K,SN,N,V> { // T mapRow(K rowKey, List<HSuperColumn<SN,N,V>> superColumns); // } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/mapper/SuperColumnMapper.java // public interface SuperColumnMapper<T,K,SN,N,V> { // // T mapSuperColumn(K rowKey, SN superColumnName, List<HColumn<N,V>> columns); // // } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/visitor/ColumnVisitor.java // public interface ColumnVisitor<N, V> { // // /** // * Visit easy column and evaluates a logic. // * @param columnName the name of the column // * @param columnValue the value of the column // * @param timestamp the cassandra timestamp when the column was written // * @param ttl the time to live for that column value // */ // void visit(N columnName, V columnValue, long timestamp, int ttl); // // }
import java.util.Collection; import java.util.List; import java.util.Map; import javax.annotation.Nonnull; import com.ebuddy.cassandra.BatchContext; import com.ebuddy.cassandra.dao.mapper.ColumnMapper; import com.ebuddy.cassandra.dao.mapper.ColumnMapperWithTimestamps; import com.ebuddy.cassandra.dao.mapper.SuperColumnFamilyRowMapper; import com.ebuddy.cassandra.dao.mapper.SuperColumnMapper; import com.ebuddy.cassandra.dao.visitor.ColumnVisitor;
/* * Copyright 2013 eBuddy B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.ebuddy.cassandra.dao; /** * Operations for a super column family. * @param <K> the Row Key type. * @param <SN> The supercolumn name type. * @param <N> The subcolumn name type. * @param <V> The column value type. * @author Eric Zoerner <a href="mailto:ezoerner@ebuddy.com">ezoerner@ebuddy.com</a> */ public interface SuperColumnFamilyOperations<K,SN,N,V> { /** * Create a BatchContext for use with this keyspace. * * @return the BatchContext */ BatchContext begin(); /** * Execute a batch of updates. * * @param batchContext the BatchContext */ void commit(@Nonnull BatchContext batchContext); V readColumnValue(K rowKey, SN superColumnName, N columnName); Map<N,V> readColumnsAsMap(K rowKey, SN superColumnName, N... columnNames); Map<N,V> readColumnsAsMap(K rowKey, SN superColumnName, N start, N finish, int count, boolean reversed); <T> List<T> readColumns(K rowKey, SN superColumnName, ColumnMapper<T,N,V> columnMapper); <T> List<T> readColumns(K rowKey, SN superColumnName, N start, N finish, int count, boolean reversed, ColumnMapper<T, N, V> columnMapper); <T> List<T> readColumnsWithTimestamps(K rowKey, SN superColumnName, N start, N finish, int count, boolean reversed,
// Path: api/src/main/java/com/ebuddy/cassandra/BatchContext.java // public interface BatchContext { } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/mapper/ColumnMapper.java // public interface ColumnMapper<T,N,V> { // // T mapColumn(N columnName, V columnValue); // // } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/mapper/ColumnMapperWithTimestamps.java // public interface ColumnMapperWithTimestamps<T,N,V> { // // T mapColumn(N columnName, V columnValue, long timestamp); // } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/mapper/SuperColumnFamilyRowMapper.java // public interface SuperColumnFamilyRowMapper<T,K,SN,N,V> { // T mapRow(K rowKey, List<HSuperColumn<SN,N,V>> superColumns); // } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/mapper/SuperColumnMapper.java // public interface SuperColumnMapper<T,K,SN,N,V> { // // T mapSuperColumn(K rowKey, SN superColumnName, List<HColumn<N,V>> columns); // // } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/visitor/ColumnVisitor.java // public interface ColumnVisitor<N, V> { // // /** // * Visit easy column and evaluates a logic. // * @param columnName the name of the column // * @param columnValue the value of the column // * @param timestamp the cassandra timestamp when the column was written // * @param ttl the time to live for that column value // */ // void visit(N columnName, V columnValue, long timestamp, int ttl); // // } // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/SuperColumnFamilyOperations.java import java.util.Collection; import java.util.List; import java.util.Map; import javax.annotation.Nonnull; import com.ebuddy.cassandra.BatchContext; import com.ebuddy.cassandra.dao.mapper.ColumnMapper; import com.ebuddy.cassandra.dao.mapper.ColumnMapperWithTimestamps; import com.ebuddy.cassandra.dao.mapper.SuperColumnFamilyRowMapper; import com.ebuddy.cassandra.dao.mapper.SuperColumnMapper; import com.ebuddy.cassandra.dao.visitor.ColumnVisitor; /* * Copyright 2013 eBuddy B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.ebuddy.cassandra.dao; /** * Operations for a super column family. * @param <K> the Row Key type. * @param <SN> The supercolumn name type. * @param <N> The subcolumn name type. * @param <V> The column value type. * @author Eric Zoerner <a href="mailto:ezoerner@ebuddy.com">ezoerner@ebuddy.com</a> */ public interface SuperColumnFamilyOperations<K,SN,N,V> { /** * Create a BatchContext for use with this keyspace. * * @return the BatchContext */ BatchContext begin(); /** * Execute a batch of updates. * * @param batchContext the BatchContext */ void commit(@Nonnull BatchContext batchContext); V readColumnValue(K rowKey, SN superColumnName, N columnName); Map<N,V> readColumnsAsMap(K rowKey, SN superColumnName, N... columnNames); Map<N,V> readColumnsAsMap(K rowKey, SN superColumnName, N start, N finish, int count, boolean reversed); <T> List<T> readColumns(K rowKey, SN superColumnName, ColumnMapper<T,N,V> columnMapper); <T> List<T> readColumns(K rowKey, SN superColumnName, N start, N finish, int count, boolean reversed, ColumnMapper<T, N, V> columnMapper); <T> List<T> readColumnsWithTimestamps(K rowKey, SN superColumnName, N start, N finish, int count, boolean reversed,
ColumnMapperWithTimestamps<T,N,V> columnMapper);
ezoerner/c-star-path-j
thrift/src/main/java/com/ebuddy/cassandra/dao/SuperColumnFamilyOperations.java
// Path: api/src/main/java/com/ebuddy/cassandra/BatchContext.java // public interface BatchContext { } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/mapper/ColumnMapper.java // public interface ColumnMapper<T,N,V> { // // T mapColumn(N columnName, V columnValue); // // } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/mapper/ColumnMapperWithTimestamps.java // public interface ColumnMapperWithTimestamps<T,N,V> { // // T mapColumn(N columnName, V columnValue, long timestamp); // } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/mapper/SuperColumnFamilyRowMapper.java // public interface SuperColumnFamilyRowMapper<T,K,SN,N,V> { // T mapRow(K rowKey, List<HSuperColumn<SN,N,V>> superColumns); // } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/mapper/SuperColumnMapper.java // public interface SuperColumnMapper<T,K,SN,N,V> { // // T mapSuperColumn(K rowKey, SN superColumnName, List<HColumn<N,V>> columns); // // } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/visitor/ColumnVisitor.java // public interface ColumnVisitor<N, V> { // // /** // * Visit easy column and evaluates a logic. // * @param columnName the name of the column // * @param columnValue the value of the column // * @param timestamp the cassandra timestamp when the column was written // * @param ttl the time to live for that column value // */ // void visit(N columnName, V columnValue, long timestamp, int ttl); // // }
import java.util.Collection; import java.util.List; import java.util.Map; import javax.annotation.Nonnull; import com.ebuddy.cassandra.BatchContext; import com.ebuddy.cassandra.dao.mapper.ColumnMapper; import com.ebuddy.cassandra.dao.mapper.ColumnMapperWithTimestamps; import com.ebuddy.cassandra.dao.mapper.SuperColumnFamilyRowMapper; import com.ebuddy.cassandra.dao.mapper.SuperColumnMapper; import com.ebuddy.cassandra.dao.visitor.ColumnVisitor;
SN superColumnName, N start, N finish, int count, boolean reversed); <T> List<T> readColumns(K rowKey, SN superColumnName, ColumnMapper<T,N,V> columnMapper); <T> List<T> readColumns(K rowKey, SN superColumnName, N start, N finish, int count, boolean reversed, ColumnMapper<T, N, V> columnMapper); <T> List<T> readColumnsWithTimestamps(K rowKey, SN superColumnName, N start, N finish, int count, boolean reversed, ColumnMapperWithTimestamps<T,N,V> columnMapper); void visitColumns(K rowKey, SN superColumnName, N start, N finish, int count, boolean reversed,
// Path: api/src/main/java/com/ebuddy/cassandra/BatchContext.java // public interface BatchContext { } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/mapper/ColumnMapper.java // public interface ColumnMapper<T,N,V> { // // T mapColumn(N columnName, V columnValue); // // } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/mapper/ColumnMapperWithTimestamps.java // public interface ColumnMapperWithTimestamps<T,N,V> { // // T mapColumn(N columnName, V columnValue, long timestamp); // } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/mapper/SuperColumnFamilyRowMapper.java // public interface SuperColumnFamilyRowMapper<T,K,SN,N,V> { // T mapRow(K rowKey, List<HSuperColumn<SN,N,V>> superColumns); // } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/mapper/SuperColumnMapper.java // public interface SuperColumnMapper<T,K,SN,N,V> { // // T mapSuperColumn(K rowKey, SN superColumnName, List<HColumn<N,V>> columns); // // } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/visitor/ColumnVisitor.java // public interface ColumnVisitor<N, V> { // // /** // * Visit easy column and evaluates a logic. // * @param columnName the name of the column // * @param columnValue the value of the column // * @param timestamp the cassandra timestamp when the column was written // * @param ttl the time to live for that column value // */ // void visit(N columnName, V columnValue, long timestamp, int ttl); // // } // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/SuperColumnFamilyOperations.java import java.util.Collection; import java.util.List; import java.util.Map; import javax.annotation.Nonnull; import com.ebuddy.cassandra.BatchContext; import com.ebuddy.cassandra.dao.mapper.ColumnMapper; import com.ebuddy.cassandra.dao.mapper.ColumnMapperWithTimestamps; import com.ebuddy.cassandra.dao.mapper.SuperColumnFamilyRowMapper; import com.ebuddy.cassandra.dao.mapper.SuperColumnMapper; import com.ebuddy.cassandra.dao.visitor.ColumnVisitor; SN superColumnName, N start, N finish, int count, boolean reversed); <T> List<T> readColumns(K rowKey, SN superColumnName, ColumnMapper<T,N,V> columnMapper); <T> List<T> readColumns(K rowKey, SN superColumnName, N start, N finish, int count, boolean reversed, ColumnMapper<T, N, V> columnMapper); <T> List<T> readColumnsWithTimestamps(K rowKey, SN superColumnName, N start, N finish, int count, boolean reversed, ColumnMapperWithTimestamps<T,N,V> columnMapper); void visitColumns(K rowKey, SN superColumnName, N start, N finish, int count, boolean reversed,
ColumnVisitor<N, V> columnVisitor);
ezoerner/c-star-path-j
thrift/src/main/java/com/ebuddy/cassandra/dao/SuperColumnFamilyOperations.java
// Path: api/src/main/java/com/ebuddy/cassandra/BatchContext.java // public interface BatchContext { } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/mapper/ColumnMapper.java // public interface ColumnMapper<T,N,V> { // // T mapColumn(N columnName, V columnValue); // // } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/mapper/ColumnMapperWithTimestamps.java // public interface ColumnMapperWithTimestamps<T,N,V> { // // T mapColumn(N columnName, V columnValue, long timestamp); // } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/mapper/SuperColumnFamilyRowMapper.java // public interface SuperColumnFamilyRowMapper<T,K,SN,N,V> { // T mapRow(K rowKey, List<HSuperColumn<SN,N,V>> superColumns); // } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/mapper/SuperColumnMapper.java // public interface SuperColumnMapper<T,K,SN,N,V> { // // T mapSuperColumn(K rowKey, SN superColumnName, List<HColumn<N,V>> columns); // // } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/visitor/ColumnVisitor.java // public interface ColumnVisitor<N, V> { // // /** // * Visit easy column and evaluates a logic. // * @param columnName the name of the column // * @param columnValue the value of the column // * @param timestamp the cassandra timestamp when the column was written // * @param ttl the time to live for that column value // */ // void visit(N columnName, V columnValue, long timestamp, int ttl); // // }
import java.util.Collection; import java.util.List; import java.util.Map; import javax.annotation.Nonnull; import com.ebuddy.cassandra.BatchContext; import com.ebuddy.cassandra.dao.mapper.ColumnMapper; import com.ebuddy.cassandra.dao.mapper.ColumnMapperWithTimestamps; import com.ebuddy.cassandra.dao.mapper.SuperColumnFamilyRowMapper; import com.ebuddy.cassandra.dao.mapper.SuperColumnMapper; import com.ebuddy.cassandra.dao.visitor.ColumnVisitor;
<T> List<T> readColumns(K rowKey, SN superColumnName, N start, N finish, int count, boolean reversed, ColumnMapper<T, N, V> columnMapper); <T> List<T> readColumnsWithTimestamps(K rowKey, SN superColumnName, N start, N finish, int count, boolean reversed, ColumnMapperWithTimestamps<T,N,V> columnMapper); void visitColumns(K rowKey, SN superColumnName, N start, N finish, int count, boolean reversed, ColumnVisitor<N, V> columnVisitor); Map<K,Map<N,V>> multiGetAsMap(Collection<K> rowKeys, SN superColumnName); Map<K,Map<N,V>> multiGetColumnsAsMap(Collection<K> rowKeys, SN superColumnName, N... columnNames); <T> List<T> multiGetSuperColumn(Collection<K> rowKeys, SN superColumnName,
// Path: api/src/main/java/com/ebuddy/cassandra/BatchContext.java // public interface BatchContext { } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/mapper/ColumnMapper.java // public interface ColumnMapper<T,N,V> { // // T mapColumn(N columnName, V columnValue); // // } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/mapper/ColumnMapperWithTimestamps.java // public interface ColumnMapperWithTimestamps<T,N,V> { // // T mapColumn(N columnName, V columnValue, long timestamp); // } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/mapper/SuperColumnFamilyRowMapper.java // public interface SuperColumnFamilyRowMapper<T,K,SN,N,V> { // T mapRow(K rowKey, List<HSuperColumn<SN,N,V>> superColumns); // } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/mapper/SuperColumnMapper.java // public interface SuperColumnMapper<T,K,SN,N,V> { // // T mapSuperColumn(K rowKey, SN superColumnName, List<HColumn<N,V>> columns); // // } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/visitor/ColumnVisitor.java // public interface ColumnVisitor<N, V> { // // /** // * Visit easy column and evaluates a logic. // * @param columnName the name of the column // * @param columnValue the value of the column // * @param timestamp the cassandra timestamp when the column was written // * @param ttl the time to live for that column value // */ // void visit(N columnName, V columnValue, long timestamp, int ttl); // // } // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/SuperColumnFamilyOperations.java import java.util.Collection; import java.util.List; import java.util.Map; import javax.annotation.Nonnull; import com.ebuddy.cassandra.BatchContext; import com.ebuddy.cassandra.dao.mapper.ColumnMapper; import com.ebuddy.cassandra.dao.mapper.ColumnMapperWithTimestamps; import com.ebuddy.cassandra.dao.mapper.SuperColumnFamilyRowMapper; import com.ebuddy.cassandra.dao.mapper.SuperColumnMapper; import com.ebuddy.cassandra.dao.visitor.ColumnVisitor; <T> List<T> readColumns(K rowKey, SN superColumnName, N start, N finish, int count, boolean reversed, ColumnMapper<T, N, V> columnMapper); <T> List<T> readColumnsWithTimestamps(K rowKey, SN superColumnName, N start, N finish, int count, boolean reversed, ColumnMapperWithTimestamps<T,N,V> columnMapper); void visitColumns(K rowKey, SN superColumnName, N start, N finish, int count, boolean reversed, ColumnVisitor<N, V> columnVisitor); Map<K,Map<N,V>> multiGetAsMap(Collection<K> rowKeys, SN superColumnName); Map<K,Map<N,V>> multiGetColumnsAsMap(Collection<K> rowKeys, SN superColumnName, N... columnNames); <T> List<T> multiGetSuperColumn(Collection<K> rowKeys, SN superColumnName,
SuperColumnMapper<T,K,SN,N,V> superColumnMapper);
ezoerner/c-star-path-j
thrift/src/main/java/com/ebuddy/cassandra/dao/SuperColumnFamilyOperations.java
// Path: api/src/main/java/com/ebuddy/cassandra/BatchContext.java // public interface BatchContext { } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/mapper/ColumnMapper.java // public interface ColumnMapper<T,N,V> { // // T mapColumn(N columnName, V columnValue); // // } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/mapper/ColumnMapperWithTimestamps.java // public interface ColumnMapperWithTimestamps<T,N,V> { // // T mapColumn(N columnName, V columnValue, long timestamp); // } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/mapper/SuperColumnFamilyRowMapper.java // public interface SuperColumnFamilyRowMapper<T,K,SN,N,V> { // T mapRow(K rowKey, List<HSuperColumn<SN,N,V>> superColumns); // } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/mapper/SuperColumnMapper.java // public interface SuperColumnMapper<T,K,SN,N,V> { // // T mapSuperColumn(K rowKey, SN superColumnName, List<HColumn<N,V>> columns); // // } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/visitor/ColumnVisitor.java // public interface ColumnVisitor<N, V> { // // /** // * Visit easy column and evaluates a logic. // * @param columnName the name of the column // * @param columnValue the value of the column // * @param timestamp the cassandra timestamp when the column was written // * @param ttl the time to live for that column value // */ // void visit(N columnName, V columnValue, long timestamp, int ttl); // // }
import java.util.Collection; import java.util.List; import java.util.Map; import javax.annotation.Nonnull; import com.ebuddy.cassandra.BatchContext; import com.ebuddy.cassandra.dao.mapper.ColumnMapper; import com.ebuddy.cassandra.dao.mapper.ColumnMapperWithTimestamps; import com.ebuddy.cassandra.dao.mapper.SuperColumnFamilyRowMapper; import com.ebuddy.cassandra.dao.mapper.SuperColumnMapper; import com.ebuddy.cassandra.dao.visitor.ColumnVisitor;
N finish, int count, boolean reversed, ColumnMapper<T, N, V> columnMapper); <T> List<T> readColumnsWithTimestamps(K rowKey, SN superColumnName, N start, N finish, int count, boolean reversed, ColumnMapperWithTimestamps<T,N,V> columnMapper); void visitColumns(K rowKey, SN superColumnName, N start, N finish, int count, boolean reversed, ColumnVisitor<N, V> columnVisitor); Map<K,Map<N,V>> multiGetAsMap(Collection<K> rowKeys, SN superColumnName); Map<K,Map<N,V>> multiGetColumnsAsMap(Collection<K> rowKeys, SN superColumnName, N... columnNames); <T> List<T> multiGetSuperColumn(Collection<K> rowKeys, SN superColumnName, SuperColumnMapper<T,K,SN,N,V> superColumnMapper); <T> List<T> multiGetAllSuperColumns(Collection<K> rowKeys,
// Path: api/src/main/java/com/ebuddy/cassandra/BatchContext.java // public interface BatchContext { } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/mapper/ColumnMapper.java // public interface ColumnMapper<T,N,V> { // // T mapColumn(N columnName, V columnValue); // // } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/mapper/ColumnMapperWithTimestamps.java // public interface ColumnMapperWithTimestamps<T,N,V> { // // T mapColumn(N columnName, V columnValue, long timestamp); // } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/mapper/SuperColumnFamilyRowMapper.java // public interface SuperColumnFamilyRowMapper<T,K,SN,N,V> { // T mapRow(K rowKey, List<HSuperColumn<SN,N,V>> superColumns); // } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/mapper/SuperColumnMapper.java // public interface SuperColumnMapper<T,K,SN,N,V> { // // T mapSuperColumn(K rowKey, SN superColumnName, List<HColumn<N,V>> columns); // // } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/visitor/ColumnVisitor.java // public interface ColumnVisitor<N, V> { // // /** // * Visit easy column and evaluates a logic. // * @param columnName the name of the column // * @param columnValue the value of the column // * @param timestamp the cassandra timestamp when the column was written // * @param ttl the time to live for that column value // */ // void visit(N columnName, V columnValue, long timestamp, int ttl); // // } // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/SuperColumnFamilyOperations.java import java.util.Collection; import java.util.List; import java.util.Map; import javax.annotation.Nonnull; import com.ebuddy.cassandra.BatchContext; import com.ebuddy.cassandra.dao.mapper.ColumnMapper; import com.ebuddy.cassandra.dao.mapper.ColumnMapperWithTimestamps; import com.ebuddy.cassandra.dao.mapper.SuperColumnFamilyRowMapper; import com.ebuddy.cassandra.dao.mapper.SuperColumnMapper; import com.ebuddy.cassandra.dao.visitor.ColumnVisitor; N finish, int count, boolean reversed, ColumnMapper<T, N, V> columnMapper); <T> List<T> readColumnsWithTimestamps(K rowKey, SN superColumnName, N start, N finish, int count, boolean reversed, ColumnMapperWithTimestamps<T,N,V> columnMapper); void visitColumns(K rowKey, SN superColumnName, N start, N finish, int count, boolean reversed, ColumnVisitor<N, V> columnVisitor); Map<K,Map<N,V>> multiGetAsMap(Collection<K> rowKeys, SN superColumnName); Map<K,Map<N,V>> multiGetColumnsAsMap(Collection<K> rowKeys, SN superColumnName, N... columnNames); <T> List<T> multiGetSuperColumn(Collection<K> rowKeys, SN superColumnName, SuperColumnMapper<T,K,SN,N,V> superColumnMapper); <T> List<T> multiGetAllSuperColumns(Collection<K> rowKeys,
SuperColumnFamilyRowMapper<T,K,SN,N,V> superColumnFamilyRowMapper);
ezoerner/c-star-path-j
thrift/src/main/java/com/ebuddy/cassandra/dao/ColumnFamilyTemplate.java
// Path: api/src/main/java/com/ebuddy/cassandra/BatchContext.java // public interface BatchContext { } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/mapper/ColumnFamilyRowMapper.java // public interface ColumnFamilyRowMapper<T,K,N,V> { // // T mapRow(K rowKey, List<HColumn<N,V>> columns); // // } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/mapper/ColumnMapper.java // public interface ColumnMapper<T,N,V> { // // T mapColumn(N columnName, V columnValue); // // }
import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.apache.commons.lang3.Validate; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.ebuddy.cassandra.BatchContext; import com.ebuddy.cassandra.dao.mapper.ColumnFamilyRowMapper; import com.ebuddy.cassandra.dao.mapper.ColumnMapper; import me.prettyprint.hector.api.Keyspace; import me.prettyprint.hector.api.Serializer; import me.prettyprint.hector.api.beans.ColumnSlice; import me.prettyprint.hector.api.beans.HColumn; import me.prettyprint.hector.api.beans.OrderedRows; import me.prettyprint.hector.api.beans.Row; import me.prettyprint.hector.api.beans.Rows; import me.prettyprint.hector.api.factory.HFactory; import me.prettyprint.hector.api.mutation.Mutator; import me.prettyprint.hector.api.query.ColumnQuery; import me.prettyprint.hector.api.query.MultigetSliceQuery; import me.prettyprint.hector.api.query.QueryResult; import me.prettyprint.hector.api.query.RangeSlicesQuery; import me.prettyprint.hector.api.query.SliceQuery;
/* * Copyright 2013 eBuddy B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.ebuddy.cassandra.dao; /** * A Data access template for accessing a (regular) Column Family. * * @param <K> the type of the row keys * @param <N> the type of the column names * @param <V> the type of the column values * @author Eric Zoerner <a href="mailto:ezoerner@ebuddy.com">ezoerner@ebuddy.com</a> */ public class ColumnFamilyTemplate<K,N,V> extends AbstractColumnFamilyTemplate<K,N,V> implements ColumnFamilyOperations<K,N,V> { private static final Logger LOG = LoggerFactory.getLogger(ColumnFamilyTemplate.class);
// Path: api/src/main/java/com/ebuddy/cassandra/BatchContext.java // public interface BatchContext { } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/mapper/ColumnFamilyRowMapper.java // public interface ColumnFamilyRowMapper<T,K,N,V> { // // T mapRow(K rowKey, List<HColumn<N,V>> columns); // // } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/mapper/ColumnMapper.java // public interface ColumnMapper<T,N,V> { // // T mapColumn(N columnName, V columnValue); // // } // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/ColumnFamilyTemplate.java import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.apache.commons.lang3.Validate; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.ebuddy.cassandra.BatchContext; import com.ebuddy.cassandra.dao.mapper.ColumnFamilyRowMapper; import com.ebuddy.cassandra.dao.mapper.ColumnMapper; import me.prettyprint.hector.api.Keyspace; import me.prettyprint.hector.api.Serializer; import me.prettyprint.hector.api.beans.ColumnSlice; import me.prettyprint.hector.api.beans.HColumn; import me.prettyprint.hector.api.beans.OrderedRows; import me.prettyprint.hector.api.beans.Row; import me.prettyprint.hector.api.beans.Rows; import me.prettyprint.hector.api.factory.HFactory; import me.prettyprint.hector.api.mutation.Mutator; import me.prettyprint.hector.api.query.ColumnQuery; import me.prettyprint.hector.api.query.MultigetSliceQuery; import me.prettyprint.hector.api.query.QueryResult; import me.prettyprint.hector.api.query.RangeSlicesQuery; import me.prettyprint.hector.api.query.SliceQuery; /* * Copyright 2013 eBuddy B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.ebuddy.cassandra.dao; /** * A Data access template for accessing a (regular) Column Family. * * @param <K> the type of the row keys * @param <N> the type of the column names * @param <V> the type of the column values * @author Eric Zoerner <a href="mailto:ezoerner@ebuddy.com">ezoerner@ebuddy.com</a> */ public class ColumnFamilyTemplate<K,N,V> extends AbstractColumnFamilyTemplate<K,N,V> implements ColumnFamilyOperations<K,N,V> { private static final Logger LOG = LoggerFactory.getLogger(ColumnFamilyTemplate.class);
private final ColumnMapper<N,N,V> columnMapperToGetColumnNames = new ColumnMapper<N,N,V>() {
ezoerner/c-star-path-j
thrift/src/main/java/com/ebuddy/cassandra/dao/ColumnFamilyTemplate.java
// Path: api/src/main/java/com/ebuddy/cassandra/BatchContext.java // public interface BatchContext { } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/mapper/ColumnFamilyRowMapper.java // public interface ColumnFamilyRowMapper<T,K,N,V> { // // T mapRow(K rowKey, List<HColumn<N,V>> columns); // // } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/mapper/ColumnMapper.java // public interface ColumnMapper<T,N,V> { // // T mapColumn(N columnName, V columnValue); // // }
import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.apache.commons.lang3.Validate; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.ebuddy.cassandra.BatchContext; import com.ebuddy.cassandra.dao.mapper.ColumnFamilyRowMapper; import com.ebuddy.cassandra.dao.mapper.ColumnMapper; import me.prettyprint.hector.api.Keyspace; import me.prettyprint.hector.api.Serializer; import me.prettyprint.hector.api.beans.ColumnSlice; import me.prettyprint.hector.api.beans.HColumn; import me.prettyprint.hector.api.beans.OrderedRows; import me.prettyprint.hector.api.beans.Row; import me.prettyprint.hector.api.beans.Rows; import me.prettyprint.hector.api.factory.HFactory; import me.prettyprint.hector.api.mutation.Mutator; import me.prettyprint.hector.api.query.ColumnQuery; import me.prettyprint.hector.api.query.MultigetSliceQuery; import me.prettyprint.hector.api.query.QueryResult; import me.prettyprint.hector.api.query.RangeSlicesQuery; import me.prettyprint.hector.api.query.SliceQuery;
getValueSerializer()); rangeSlicesQuery.setColumnFamily(getColumnFamily()); rangeSlicesQuery.setRange(null, null, false, ALL); rangeSlicesQuery.setRowCount(ALL); QueryResult<OrderedRows<K, N, V>> result = rangeSlicesQuery.execute(); for (Row<K,N,V> row : result.get()) { K key = row.getKey(); ColumnSlice<N,V> slice = row.getColumnSlice(); Map<N,V> columns = new HashMap<N,V>(); for (HColumn<N,V> column : slice.getColumns()) { V value = column.getValue(); columns.put(column.getName(), value); } resultMap.put(key, columns); } // we used to translate hector exceptions into spring exceptions here, but spring dependency was removed if (LOG.isDebugEnabled()) { LOG.debug("Returning result from multiGetColumnsAsMap: " + resultMap); } return resultMap; } /** * Read all columns from multiple rows using a mapper for the result. * * @param rowKeys a collection of rows to read */ @Override
// Path: api/src/main/java/com/ebuddy/cassandra/BatchContext.java // public interface BatchContext { } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/mapper/ColumnFamilyRowMapper.java // public interface ColumnFamilyRowMapper<T,K,N,V> { // // T mapRow(K rowKey, List<HColumn<N,V>> columns); // // } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/mapper/ColumnMapper.java // public interface ColumnMapper<T,N,V> { // // T mapColumn(N columnName, V columnValue); // // } // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/ColumnFamilyTemplate.java import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.apache.commons.lang3.Validate; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.ebuddy.cassandra.BatchContext; import com.ebuddy.cassandra.dao.mapper.ColumnFamilyRowMapper; import com.ebuddy.cassandra.dao.mapper.ColumnMapper; import me.prettyprint.hector.api.Keyspace; import me.prettyprint.hector.api.Serializer; import me.prettyprint.hector.api.beans.ColumnSlice; import me.prettyprint.hector.api.beans.HColumn; import me.prettyprint.hector.api.beans.OrderedRows; import me.prettyprint.hector.api.beans.Row; import me.prettyprint.hector.api.beans.Rows; import me.prettyprint.hector.api.factory.HFactory; import me.prettyprint.hector.api.mutation.Mutator; import me.prettyprint.hector.api.query.ColumnQuery; import me.prettyprint.hector.api.query.MultigetSliceQuery; import me.prettyprint.hector.api.query.QueryResult; import me.prettyprint.hector.api.query.RangeSlicesQuery; import me.prettyprint.hector.api.query.SliceQuery; getValueSerializer()); rangeSlicesQuery.setColumnFamily(getColumnFamily()); rangeSlicesQuery.setRange(null, null, false, ALL); rangeSlicesQuery.setRowCount(ALL); QueryResult<OrderedRows<K, N, V>> result = rangeSlicesQuery.execute(); for (Row<K,N,V> row : result.get()) { K key = row.getKey(); ColumnSlice<N,V> slice = row.getColumnSlice(); Map<N,V> columns = new HashMap<N,V>(); for (HColumn<N,V> column : slice.getColumns()) { V value = column.getValue(); columns.put(column.getName(), value); } resultMap.put(key, columns); } // we used to translate hector exceptions into spring exceptions here, but spring dependency was removed if (LOG.isDebugEnabled()) { LOG.debug("Returning result from multiGetColumnsAsMap: " + resultMap); } return resultMap; } /** * Read all columns from multiple rows using a mapper for the result. * * @param rowKeys a collection of rows to read */ @Override
public <T> List<T> multiGet(Iterable<K> rowKeys, ColumnFamilyRowMapper<T,K,N,V> rowMapper) {
ezoerner/c-star-path-j
thrift/src/main/java/com/ebuddy/cassandra/dao/ColumnFamilyTemplate.java
// Path: api/src/main/java/com/ebuddy/cassandra/BatchContext.java // public interface BatchContext { } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/mapper/ColumnFamilyRowMapper.java // public interface ColumnFamilyRowMapper<T,K,N,V> { // // T mapRow(K rowKey, List<HColumn<N,V>> columns); // // } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/mapper/ColumnMapper.java // public interface ColumnMapper<T,N,V> { // // T mapColumn(N columnName, V columnValue); // // }
import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.apache.commons.lang3.Validate; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.ebuddy.cassandra.BatchContext; import com.ebuddy.cassandra.dao.mapper.ColumnFamilyRowMapper; import com.ebuddy.cassandra.dao.mapper.ColumnMapper; import me.prettyprint.hector.api.Keyspace; import me.prettyprint.hector.api.Serializer; import me.prettyprint.hector.api.beans.ColumnSlice; import me.prettyprint.hector.api.beans.HColumn; import me.prettyprint.hector.api.beans.OrderedRows; import me.prettyprint.hector.api.beans.Row; import me.prettyprint.hector.api.beans.Rows; import me.prettyprint.hector.api.factory.HFactory; import me.prettyprint.hector.api.mutation.Mutator; import me.prettyprint.hector.api.query.ColumnQuery; import me.prettyprint.hector.api.query.MultigetSliceQuery; import me.prettyprint.hector.api.query.QueryResult; import me.prettyprint.hector.api.query.RangeSlicesQuery; import me.prettyprint.hector.api.query.SliceQuery;
*/ @Override public void writeColumn(K rowKey, N columnName, V columnValue) { basicWriteColumn(rowKey, columnName, columnValue, 0, null, null); } /** * Write a column value immediately with a time to live. * * @param rowKey the row key of type K * @param columnName the column name * @param columnValue the column value * @param timeToLive a positive time to live * @param timeToLiveTimeUnit the time unit for timeToLive */ @Override public void writeColumn(K rowKey, N columnName, V columnValue, long timeToLive, TimeUnit timeToLiveTimeUnit) { basicWriteColumn(rowKey, columnName, columnValue, timeToLive, timeToLiveTimeUnit, null); } /** * Write a column value as batch operation. * * @param rowKey the row key of type K * @param columnName the column name * @param columnValue the column value * @param batchContext BatchContext */ @Override
// Path: api/src/main/java/com/ebuddy/cassandra/BatchContext.java // public interface BatchContext { } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/mapper/ColumnFamilyRowMapper.java // public interface ColumnFamilyRowMapper<T,K,N,V> { // // T mapRow(K rowKey, List<HColumn<N,V>> columns); // // } // // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/mapper/ColumnMapper.java // public interface ColumnMapper<T,N,V> { // // T mapColumn(N columnName, V columnValue); // // } // Path: thrift/src/main/java/com/ebuddy/cassandra/dao/ColumnFamilyTemplate.java import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.apache.commons.lang3.Validate; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.ebuddy.cassandra.BatchContext; import com.ebuddy.cassandra.dao.mapper.ColumnFamilyRowMapper; import com.ebuddy.cassandra.dao.mapper.ColumnMapper; import me.prettyprint.hector.api.Keyspace; import me.prettyprint.hector.api.Serializer; import me.prettyprint.hector.api.beans.ColumnSlice; import me.prettyprint.hector.api.beans.HColumn; import me.prettyprint.hector.api.beans.OrderedRows; import me.prettyprint.hector.api.beans.Row; import me.prettyprint.hector.api.beans.Rows; import me.prettyprint.hector.api.factory.HFactory; import me.prettyprint.hector.api.mutation.Mutator; import me.prettyprint.hector.api.query.ColumnQuery; import me.prettyprint.hector.api.query.MultigetSliceQuery; import me.prettyprint.hector.api.query.QueryResult; import me.prettyprint.hector.api.query.RangeSlicesQuery; import me.prettyprint.hector.api.query.SliceQuery; */ @Override public void writeColumn(K rowKey, N columnName, V columnValue) { basicWriteColumn(rowKey, columnName, columnValue, 0, null, null); } /** * Write a column value immediately with a time to live. * * @param rowKey the row key of type K * @param columnName the column name * @param columnValue the column value * @param timeToLive a positive time to live * @param timeToLiveTimeUnit the time unit for timeToLive */ @Override public void writeColumn(K rowKey, N columnName, V columnValue, long timeToLive, TimeUnit timeToLiveTimeUnit) { basicWriteColumn(rowKey, columnName, columnValue, timeToLive, timeToLiveTimeUnit, null); } /** * Write a column value as batch operation. * * @param rowKey the row key of type K * @param columnName the column name * @param columnValue the column value * @param batchContext BatchContext */ @Override
public void writeColumn(K rowKey, N columnName, V columnValue, @Nonnull BatchContext batchContext) {
prezi/gradle-haskell-plugin
src/main/java/com/prezi/haskell/gradle/incubating/typeconversion/TimeUnitsParser.java
// Path: src/main/java/com/prezi/haskell/gradle/incubating/typeconversion/NormalizedTimeUnit.java // public static NormalizedTimeUnit millis(int value) { // return new NormalizedTimeUnit(value, TimeUnit.MILLISECONDS); // }
import org.gradle.api.InvalidUserDataException; import java.util.concurrent.TimeUnit; import static com.prezi.haskell.gradle.incubating.typeconversion.NormalizedTimeUnit.millis;
/* * Copyright 2013 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.prezi.haskell.gradle.incubating.typeconversion; public class TimeUnitsParser { public NormalizedTimeUnit parseNotation(CharSequence notation, int value) { String candidate = notation.toString().toUpperCase(); //jdk5 does not have days, hours or minutes, normalizing to millis if (candidate.equals("DAYS")) {
// Path: src/main/java/com/prezi/haskell/gradle/incubating/typeconversion/NormalizedTimeUnit.java // public static NormalizedTimeUnit millis(int value) { // return new NormalizedTimeUnit(value, TimeUnit.MILLISECONDS); // } // Path: src/main/java/com/prezi/haskell/gradle/incubating/typeconversion/TimeUnitsParser.java import org.gradle.api.InvalidUserDataException; import java.util.concurrent.TimeUnit; import static com.prezi.haskell.gradle.incubating.typeconversion.NormalizedTimeUnit.millis; /* * Copyright 2013 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.prezi.haskell.gradle.incubating.typeconversion; public class TimeUnitsParser { public NormalizedTimeUnit parseNotation(CharSequence notation, int value) { String candidate = notation.toString().toUpperCase(); //jdk5 does not have days, hours or minutes, normalizing to millis if (candidate.equals("DAYS")) {
return millis(value * 24 * 60 * 60 * 1000);
rprobinson/MediPi
Clinician/MediPiClinical/src/main/java/org/medipi/clinical/MediPiClinicalSbApplication.java
// Path: Clinician/MediPiClinical/src/main/java/org/medipi/clinical/services/SSLClientHttpRequestFactory.java // @Component // public class SSLClientHttpRequestFactory { // // @Value("${medipi.clinical.keystore.location}") // private String keystoreLocation; // @Value("${medipi.clinical.keystore.password}") // private String keystorePass; // @Value("${medipi.clinical.truststore.location}") // private String truststoreLocation; // @Value("${medipi.clinical.truststore.password}") // private String truststorePass; // @Value("${medipi.clinical.connecttimeout}") // private String connectTO; // @Value("${medipi.clinical.connectionrequesttimeout}") // private String connectionRT; // @Value("${medipi.clinical.readtimeout}") // private String readTO; // // private int connectTimeout = 0; // private int connectionRequestTimeout = 0; // private int readTimeout = 0; // // public SSLClientHttpRequestFactory() { // // } // // public ClientHttpRequestFactory getClientHttpRequestFactory() throws Exception { // try{ // connectTimeout = Integer.parseInt(connectTO); // connectionRequestTimeout = Integer.parseInt(connectionRT); // readTimeout = Integer.parseInt(readTO); // }catch(Exception nfe){ // // } // //Create RestTemplate to send message to MediPiConcentrator // SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(createSSLContext(), NoopHostnameVerifier.INSTANCE); // HttpClient httpClient = HttpClients.custom().setSSLSocketFactory(socketFactory).build(); // HttpComponentsClientHttpRequestFactory componentsRequestFactory = new HttpComponentsClientHttpRequestFactory(httpClient); // componentsRequestFactory.setConnectTimeout(connectTimeout); // componentsRequestFactory.setConnectionRequestTimeout(connectionRequestTimeout); // componentsRequestFactory.setReadTimeout(readTimeout); // ClientHttpRequestFactory requestFactory = componentsRequestFactory; // return requestFactory; // } // // private SSLContext createSSLContext() throws Exception { // if (truststoreLocation == null || truststoreLocation.trim().equals("")) { // MediPiLogger.getInstance().log(SSLClientHttpRequestFactory.class // .getName() + "constructor", "MediPi truststore is not set"); // System.out.println("MediPi truststore is not set and secure transmission of data will not work"); // // } // if (truststorePass == null || truststorePass.trim().equals("")) { // MediPiLogger.getInstance().log(SSLClientHttpRequestFactory.class // .getName() + "constructor", "MediPi truststore password is not set"); // System.out.println("MediPi truststore password is not set and secure transmission of data will not work"); // // } // if (keystoreLocation == null || keystoreLocation.trim().equals("")) { // MediPiLogger.getInstance().log(SSLClientHttpRequestFactory.class // .getName() + "constructor", "MediPi keystore is not set"); // System.out.println("MediPi keystore is not set and secure transmission of data will not work"); // // } // if (keystorePass == null || keystorePass.trim().equals("")) { // MediPiLogger.getInstance().log(SSLClientHttpRequestFactory.class // .getName() + "constructor", "MediPi keystore password is not set"); // System.out.println("MediPi keystore password is not set and secure transmission of data will not work"); // } // KeyStore trustStore = loadStore(truststoreLocation, truststorePass); // // TrustManagerFactory tmf // = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); // tmf.init(trustStore); // // KeyStore keyStore = loadStore(keystoreLocation, keystorePass); // // KeyManagerFactory kmf // = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); // kmf.init(keyStore, keystorePass.toCharArray()); // SSLContext sslContext = SSLContext.getInstance("TLS"); // sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), new SecureRandom()); // // return sslContext; // } // // private KeyStore loadStore(String trustStoreFile, String password) throws Exception { // KeyStore store = KeyStore.getInstance("JKS"); // store.load(new FileInputStream(trustStoreFile), password.toCharArray()); // return store; // } // }
import java.io.File; import java.util.Date; import java.util.Properties; import org.medipi.clinical.logging.MediPiLogger; import org.medipi.clinical.services.SSLClientHttpRequestFactory; import org.medipi.clinical.utilities.Utilities; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.CommandLineRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.scheduling.annotation.EnableScheduling;
/* Copyright 2016 Richard Robinson @ NHS Digital <rrobinson@nhs.net> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package org.medipi.clinical; /** * Class bootstrap the Spring Boot Application * * This class calls all the configuration necessary to boot the concentrator It * should be called using one argument - location of the MediPiConcentrator * properties file * * @author rick@robinsonhq.com */ @SpringBootApplication @EnableAutoConfiguration @Configuration @ComponentScan @EnableScheduling public class MediPiClinicalSbApplication implements CommandLineRunner { private static final String LOG = "medipi.log"; // MediPi version Number private static final String MEDIPINAME = "MediPi Clinical"; private static final String VERSION = "MediPiClinical_v1.0.5"; private static final String VERSIONNAME = "PILOT-20170921-1"; private final MediPiLogger logger = MediPiLogger.getInstance(); @Autowired
// Path: Clinician/MediPiClinical/src/main/java/org/medipi/clinical/services/SSLClientHttpRequestFactory.java // @Component // public class SSLClientHttpRequestFactory { // // @Value("${medipi.clinical.keystore.location}") // private String keystoreLocation; // @Value("${medipi.clinical.keystore.password}") // private String keystorePass; // @Value("${medipi.clinical.truststore.location}") // private String truststoreLocation; // @Value("${medipi.clinical.truststore.password}") // private String truststorePass; // @Value("${medipi.clinical.connecttimeout}") // private String connectTO; // @Value("${medipi.clinical.connectionrequesttimeout}") // private String connectionRT; // @Value("${medipi.clinical.readtimeout}") // private String readTO; // // private int connectTimeout = 0; // private int connectionRequestTimeout = 0; // private int readTimeout = 0; // // public SSLClientHttpRequestFactory() { // // } // // public ClientHttpRequestFactory getClientHttpRequestFactory() throws Exception { // try{ // connectTimeout = Integer.parseInt(connectTO); // connectionRequestTimeout = Integer.parseInt(connectionRT); // readTimeout = Integer.parseInt(readTO); // }catch(Exception nfe){ // // } // //Create RestTemplate to send message to MediPiConcentrator // SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(createSSLContext(), NoopHostnameVerifier.INSTANCE); // HttpClient httpClient = HttpClients.custom().setSSLSocketFactory(socketFactory).build(); // HttpComponentsClientHttpRequestFactory componentsRequestFactory = new HttpComponentsClientHttpRequestFactory(httpClient); // componentsRequestFactory.setConnectTimeout(connectTimeout); // componentsRequestFactory.setConnectionRequestTimeout(connectionRequestTimeout); // componentsRequestFactory.setReadTimeout(readTimeout); // ClientHttpRequestFactory requestFactory = componentsRequestFactory; // return requestFactory; // } // // private SSLContext createSSLContext() throws Exception { // if (truststoreLocation == null || truststoreLocation.trim().equals("")) { // MediPiLogger.getInstance().log(SSLClientHttpRequestFactory.class // .getName() + "constructor", "MediPi truststore is not set"); // System.out.println("MediPi truststore is not set and secure transmission of data will not work"); // // } // if (truststorePass == null || truststorePass.trim().equals("")) { // MediPiLogger.getInstance().log(SSLClientHttpRequestFactory.class // .getName() + "constructor", "MediPi truststore password is not set"); // System.out.println("MediPi truststore password is not set and secure transmission of data will not work"); // // } // if (keystoreLocation == null || keystoreLocation.trim().equals("")) { // MediPiLogger.getInstance().log(SSLClientHttpRequestFactory.class // .getName() + "constructor", "MediPi keystore is not set"); // System.out.println("MediPi keystore is not set and secure transmission of data will not work"); // // } // if (keystorePass == null || keystorePass.trim().equals("")) { // MediPiLogger.getInstance().log(SSLClientHttpRequestFactory.class // .getName() + "constructor", "MediPi keystore password is not set"); // System.out.println("MediPi keystore password is not set and secure transmission of data will not work"); // } // KeyStore trustStore = loadStore(truststoreLocation, truststorePass); // // TrustManagerFactory tmf // = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); // tmf.init(trustStore); // // KeyStore keyStore = loadStore(keystoreLocation, keystorePass); // // KeyManagerFactory kmf // = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); // kmf.init(keyStore, keystorePass.toCharArray()); // SSLContext sslContext = SSLContext.getInstance("TLS"); // sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), new SecureRandom()); // // return sslContext; // } // // private KeyStore loadStore(String trustStoreFile, String password) throws Exception { // KeyStore store = KeyStore.getInstance("JKS"); // store.load(new FileInputStream(trustStoreFile), password.toCharArray()); // return store; // } // } // Path: Clinician/MediPiClinical/src/main/java/org/medipi/clinical/MediPiClinicalSbApplication.java import java.io.File; import java.util.Date; import java.util.Properties; import org.medipi.clinical.logging.MediPiLogger; import org.medipi.clinical.services.SSLClientHttpRequestFactory; import org.medipi.clinical.utilities.Utilities; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.CommandLineRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.scheduling.annotation.EnableScheduling; /* Copyright 2016 Richard Robinson @ NHS Digital <rrobinson@nhs.net> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package org.medipi.clinical; /** * Class bootstrap the Spring Boot Application * * This class calls all the configuration necessary to boot the concentrator It * should be called using one argument - location of the MediPiConcentrator * properties file * * @author rick@robinsonhq.com */ @SpringBootApplication @EnableAutoConfiguration @Configuration @ComponentScan @EnableScheduling public class MediPiClinicalSbApplication implements CommandLineRunner { private static final String LOG = "medipi.log"; // MediPi version Number private static final String MEDIPINAME = "MediPi Clinical"; private static final String VERSION = "MediPiClinical_v1.0.5"; private static final String VERSIONNAME = "PILOT-20170921-1"; private final MediPiLogger logger = MediPiLogger.getInstance(); @Autowired
private SSLClientHttpRequestFactory requestFactory;
rprobinson/MediPi
Android/app/src/main/java/uk/gov/nhs/digital/telehealth/connection/service/BluetoothConnectionService.java
// Path: Android/app/src/main/java/uk/gov/nhs/digital/telehealth/exceptions/BluetoothAdapterException.java // public class BluetoothAdapterException extends Exception { // public BluetoothAdapterException() { // super(); // } // // public BluetoothAdapterException(String detailMessage) { // super(detailMessage); // } // // public BluetoothAdapterException(String detailMessage, Throwable throwable) { // super(detailMessage, throwable); // } // // public BluetoothAdapterException(Throwable throwable) { // super(throwable); // } // } // // Path: Android/app/src/main/java/uk/gov/nhs/digital/telehealth/exceptions/DeviceConnectionException.java // public class DeviceConnectionException extends Exception { // public DeviceConnectionException() { // super(); // } // // public DeviceConnectionException(String detailMessage) { // super(detailMessage); // } // // public DeviceConnectionException(String detailMessage, Throwable throwable) { // super(detailMessage, throwable); // } // // public DeviceConnectionException(Throwable throwable) { // super(throwable); // } // } // // Path: Android/app/src/main/java/uk/gov/nhs/digital/telehealth/exceptions/DeviceNotFoundException.java // public class DeviceNotFoundException extends Exception { // public DeviceNotFoundException() { // super(); // } // // public DeviceNotFoundException(String detailMessage) { // super(detailMessage); // } // // public DeviceNotFoundException(String detailMessage, Throwable throwable) { // super(detailMessage, throwable); // } // // public DeviceNotFoundException(Throwable throwable) { // super(throwable); // } // } // // Path: Android/app/src/main/java/uk/gov/nhs/digital/telehealth/connection/service/ConnectionService.java // public interface ConnectionService { // Collection<?> getAllDevices(Context context) throws DeviceConnectionException; // Object getDevice(Context context, String deviceName) throws DeviceNotFoundException, DeviceConnectionException; // Object getConnection(Context context, Object device) throws DeviceConnectionException; // }
import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothSocket; import android.content.Context; import com.hoho.android.usbserial.driver.UsbSerialDriver; import uk.gov.nhs.digital.telehealth.exceptions.BluetoothAdapterException; import uk.gov.nhs.digital.telehealth.exceptions.DeviceConnectionException; import uk.gov.nhs.digital.telehealth.exceptions.DeviceNotFoundException; import uk.gov.nhs.digital.telehealth.connection.service.ConnectionService; import java.io.IOException; import java.lang.reflect.Method; import java.util.Collection; import java.util.List; import java.util.Set; import java.util.UUID;
package uk.gov.nhs.digital.telehealth.connection.service; public class BluetoothConnectionService implements ConnectionService { private UUID DEFAULT_UUID = UUID.fromString("00001101-0000-1000-8000-00805f9b34fb"); //private UUID DEFAULT_UUID = UUID.fromString("8ce255c0-200a-11e0-ac64-0800200c9a66");
// Path: Android/app/src/main/java/uk/gov/nhs/digital/telehealth/exceptions/BluetoothAdapterException.java // public class BluetoothAdapterException extends Exception { // public BluetoothAdapterException() { // super(); // } // // public BluetoothAdapterException(String detailMessage) { // super(detailMessage); // } // // public BluetoothAdapterException(String detailMessage, Throwable throwable) { // super(detailMessage, throwable); // } // // public BluetoothAdapterException(Throwable throwable) { // super(throwable); // } // } // // Path: Android/app/src/main/java/uk/gov/nhs/digital/telehealth/exceptions/DeviceConnectionException.java // public class DeviceConnectionException extends Exception { // public DeviceConnectionException() { // super(); // } // // public DeviceConnectionException(String detailMessage) { // super(detailMessage); // } // // public DeviceConnectionException(String detailMessage, Throwable throwable) { // super(detailMessage, throwable); // } // // public DeviceConnectionException(Throwable throwable) { // super(throwable); // } // } // // Path: Android/app/src/main/java/uk/gov/nhs/digital/telehealth/exceptions/DeviceNotFoundException.java // public class DeviceNotFoundException extends Exception { // public DeviceNotFoundException() { // super(); // } // // public DeviceNotFoundException(String detailMessage) { // super(detailMessage); // } // // public DeviceNotFoundException(String detailMessage, Throwable throwable) { // super(detailMessage, throwable); // } // // public DeviceNotFoundException(Throwable throwable) { // super(throwable); // } // } // // Path: Android/app/src/main/java/uk/gov/nhs/digital/telehealth/connection/service/ConnectionService.java // public interface ConnectionService { // Collection<?> getAllDevices(Context context) throws DeviceConnectionException; // Object getDevice(Context context, String deviceName) throws DeviceNotFoundException, DeviceConnectionException; // Object getConnection(Context context, Object device) throws DeviceConnectionException; // } // Path: Android/app/src/main/java/uk/gov/nhs/digital/telehealth/connection/service/BluetoothConnectionService.java import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothSocket; import android.content.Context; import com.hoho.android.usbserial.driver.UsbSerialDriver; import uk.gov.nhs.digital.telehealth.exceptions.BluetoothAdapterException; import uk.gov.nhs.digital.telehealth.exceptions.DeviceConnectionException; import uk.gov.nhs.digital.telehealth.exceptions.DeviceNotFoundException; import uk.gov.nhs.digital.telehealth.connection.service.ConnectionService; import java.io.IOException; import java.lang.reflect.Method; import java.util.Collection; import java.util.List; import java.util.Set; import java.util.UUID; package uk.gov.nhs.digital.telehealth.connection.service; public class BluetoothConnectionService implements ConnectionService { private UUID DEFAULT_UUID = UUID.fromString("00001101-0000-1000-8000-00805f9b34fb"); //private UUID DEFAULT_UUID = UUID.fromString("8ce255c0-200a-11e0-ac64-0800200c9a66");
private BluetoothAdapter getBluetoothAdapter() throws BluetoothAdapterException {
rprobinson/MediPi
Android/app/src/main/java/uk/gov/nhs/digital/telehealth/connection/service/BluetoothConnectionService.java
// Path: Android/app/src/main/java/uk/gov/nhs/digital/telehealth/exceptions/BluetoothAdapterException.java // public class BluetoothAdapterException extends Exception { // public BluetoothAdapterException() { // super(); // } // // public BluetoothAdapterException(String detailMessage) { // super(detailMessage); // } // // public BluetoothAdapterException(String detailMessage, Throwable throwable) { // super(detailMessage, throwable); // } // // public BluetoothAdapterException(Throwable throwable) { // super(throwable); // } // } // // Path: Android/app/src/main/java/uk/gov/nhs/digital/telehealth/exceptions/DeviceConnectionException.java // public class DeviceConnectionException extends Exception { // public DeviceConnectionException() { // super(); // } // // public DeviceConnectionException(String detailMessage) { // super(detailMessage); // } // // public DeviceConnectionException(String detailMessage, Throwable throwable) { // super(detailMessage, throwable); // } // // public DeviceConnectionException(Throwable throwable) { // super(throwable); // } // } // // Path: Android/app/src/main/java/uk/gov/nhs/digital/telehealth/exceptions/DeviceNotFoundException.java // public class DeviceNotFoundException extends Exception { // public DeviceNotFoundException() { // super(); // } // // public DeviceNotFoundException(String detailMessage) { // super(detailMessage); // } // // public DeviceNotFoundException(String detailMessage, Throwable throwable) { // super(detailMessage, throwable); // } // // public DeviceNotFoundException(Throwable throwable) { // super(throwable); // } // } // // Path: Android/app/src/main/java/uk/gov/nhs/digital/telehealth/connection/service/ConnectionService.java // public interface ConnectionService { // Collection<?> getAllDevices(Context context) throws DeviceConnectionException; // Object getDevice(Context context, String deviceName) throws DeviceNotFoundException, DeviceConnectionException; // Object getConnection(Context context, Object device) throws DeviceConnectionException; // }
import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothSocket; import android.content.Context; import com.hoho.android.usbserial.driver.UsbSerialDriver; import uk.gov.nhs.digital.telehealth.exceptions.BluetoothAdapterException; import uk.gov.nhs.digital.telehealth.exceptions.DeviceConnectionException; import uk.gov.nhs.digital.telehealth.exceptions.DeviceNotFoundException; import uk.gov.nhs.digital.telehealth.connection.service.ConnectionService; import java.io.IOException; import java.lang.reflect.Method; import java.util.Collection; import java.util.List; import java.util.Set; import java.util.UUID;
package uk.gov.nhs.digital.telehealth.connection.service; public class BluetoothConnectionService implements ConnectionService { private UUID DEFAULT_UUID = UUID.fromString("00001101-0000-1000-8000-00805f9b34fb"); //private UUID DEFAULT_UUID = UUID.fromString("8ce255c0-200a-11e0-ac64-0800200c9a66"); private BluetoothAdapter getBluetoothAdapter() throws BluetoothAdapterException { BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); if (!bluetoothAdapter.isEnabled()) { throw new BluetoothAdapterException("Bluetooth is not enabled."); } return bluetoothAdapter; } @Override
// Path: Android/app/src/main/java/uk/gov/nhs/digital/telehealth/exceptions/BluetoothAdapterException.java // public class BluetoothAdapterException extends Exception { // public BluetoothAdapterException() { // super(); // } // // public BluetoothAdapterException(String detailMessage) { // super(detailMessage); // } // // public BluetoothAdapterException(String detailMessage, Throwable throwable) { // super(detailMessage, throwable); // } // // public BluetoothAdapterException(Throwable throwable) { // super(throwable); // } // } // // Path: Android/app/src/main/java/uk/gov/nhs/digital/telehealth/exceptions/DeviceConnectionException.java // public class DeviceConnectionException extends Exception { // public DeviceConnectionException() { // super(); // } // // public DeviceConnectionException(String detailMessage) { // super(detailMessage); // } // // public DeviceConnectionException(String detailMessage, Throwable throwable) { // super(detailMessage, throwable); // } // // public DeviceConnectionException(Throwable throwable) { // super(throwable); // } // } // // Path: Android/app/src/main/java/uk/gov/nhs/digital/telehealth/exceptions/DeviceNotFoundException.java // public class DeviceNotFoundException extends Exception { // public DeviceNotFoundException() { // super(); // } // // public DeviceNotFoundException(String detailMessage) { // super(detailMessage); // } // // public DeviceNotFoundException(String detailMessage, Throwable throwable) { // super(detailMessage, throwable); // } // // public DeviceNotFoundException(Throwable throwable) { // super(throwable); // } // } // // Path: Android/app/src/main/java/uk/gov/nhs/digital/telehealth/connection/service/ConnectionService.java // public interface ConnectionService { // Collection<?> getAllDevices(Context context) throws DeviceConnectionException; // Object getDevice(Context context, String deviceName) throws DeviceNotFoundException, DeviceConnectionException; // Object getConnection(Context context, Object device) throws DeviceConnectionException; // } // Path: Android/app/src/main/java/uk/gov/nhs/digital/telehealth/connection/service/BluetoothConnectionService.java import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothSocket; import android.content.Context; import com.hoho.android.usbserial.driver.UsbSerialDriver; import uk.gov.nhs.digital.telehealth.exceptions.BluetoothAdapterException; import uk.gov.nhs.digital.telehealth.exceptions.DeviceConnectionException; import uk.gov.nhs.digital.telehealth.exceptions.DeviceNotFoundException; import uk.gov.nhs.digital.telehealth.connection.service.ConnectionService; import java.io.IOException; import java.lang.reflect.Method; import java.util.Collection; import java.util.List; import java.util.Set; import java.util.UUID; package uk.gov.nhs.digital.telehealth.connection.service; public class BluetoothConnectionService implements ConnectionService { private UUID DEFAULT_UUID = UUID.fromString("00001101-0000-1000-8000-00805f9b34fb"); //private UUID DEFAULT_UUID = UUID.fromString("8ce255c0-200a-11e0-ac64-0800200c9a66"); private BluetoothAdapter getBluetoothAdapter() throws BluetoothAdapterException { BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); if (!bluetoothAdapter.isEnabled()) { throw new BluetoothAdapterException("Bluetooth is not enabled."); } return bluetoothAdapter; } @Override
public Collection<?> getAllDevices(Context context) throws DeviceConnectionException {
rprobinson/MediPi
Android/app/src/main/java/uk/gov/nhs/digital/telehealth/connection/service/BluetoothConnectionService.java
// Path: Android/app/src/main/java/uk/gov/nhs/digital/telehealth/exceptions/BluetoothAdapterException.java // public class BluetoothAdapterException extends Exception { // public BluetoothAdapterException() { // super(); // } // // public BluetoothAdapterException(String detailMessage) { // super(detailMessage); // } // // public BluetoothAdapterException(String detailMessage, Throwable throwable) { // super(detailMessage, throwable); // } // // public BluetoothAdapterException(Throwable throwable) { // super(throwable); // } // } // // Path: Android/app/src/main/java/uk/gov/nhs/digital/telehealth/exceptions/DeviceConnectionException.java // public class DeviceConnectionException extends Exception { // public DeviceConnectionException() { // super(); // } // // public DeviceConnectionException(String detailMessage) { // super(detailMessage); // } // // public DeviceConnectionException(String detailMessage, Throwable throwable) { // super(detailMessage, throwable); // } // // public DeviceConnectionException(Throwable throwable) { // super(throwable); // } // } // // Path: Android/app/src/main/java/uk/gov/nhs/digital/telehealth/exceptions/DeviceNotFoundException.java // public class DeviceNotFoundException extends Exception { // public DeviceNotFoundException() { // super(); // } // // public DeviceNotFoundException(String detailMessage) { // super(detailMessage); // } // // public DeviceNotFoundException(String detailMessage, Throwable throwable) { // super(detailMessage, throwable); // } // // public DeviceNotFoundException(Throwable throwable) { // super(throwable); // } // } // // Path: Android/app/src/main/java/uk/gov/nhs/digital/telehealth/connection/service/ConnectionService.java // public interface ConnectionService { // Collection<?> getAllDevices(Context context) throws DeviceConnectionException; // Object getDevice(Context context, String deviceName) throws DeviceNotFoundException, DeviceConnectionException; // Object getConnection(Context context, Object device) throws DeviceConnectionException; // }
import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothSocket; import android.content.Context; import com.hoho.android.usbserial.driver.UsbSerialDriver; import uk.gov.nhs.digital.telehealth.exceptions.BluetoothAdapterException; import uk.gov.nhs.digital.telehealth.exceptions.DeviceConnectionException; import uk.gov.nhs.digital.telehealth.exceptions.DeviceNotFoundException; import uk.gov.nhs.digital.telehealth.connection.service.ConnectionService; import java.io.IOException; import java.lang.reflect.Method; import java.util.Collection; import java.util.List; import java.util.Set; import java.util.UUID;
package uk.gov.nhs.digital.telehealth.connection.service; public class BluetoothConnectionService implements ConnectionService { private UUID DEFAULT_UUID = UUID.fromString("00001101-0000-1000-8000-00805f9b34fb"); //private UUID DEFAULT_UUID = UUID.fromString("8ce255c0-200a-11e0-ac64-0800200c9a66"); private BluetoothAdapter getBluetoothAdapter() throws BluetoothAdapterException { BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); if (!bluetoothAdapter.isEnabled()) { throw new BluetoothAdapterException("Bluetooth is not enabled."); } return bluetoothAdapter; } @Override public Collection<?> getAllDevices(Context context) throws DeviceConnectionException { BluetoothAdapter bluetoothAdapter = null; try { bluetoothAdapter = getBluetoothAdapter(); } catch (BluetoothAdapterException e) { throw new DeviceConnectionException(e); } Set<BluetoothDevice> availableDevices = bluetoothAdapter.getBondedDevices(); if (availableDevices.isEmpty()) { throw new DeviceConnectionException("No devices connected"); } return availableDevices; }
// Path: Android/app/src/main/java/uk/gov/nhs/digital/telehealth/exceptions/BluetoothAdapterException.java // public class BluetoothAdapterException extends Exception { // public BluetoothAdapterException() { // super(); // } // // public BluetoothAdapterException(String detailMessage) { // super(detailMessage); // } // // public BluetoothAdapterException(String detailMessage, Throwable throwable) { // super(detailMessage, throwable); // } // // public BluetoothAdapterException(Throwable throwable) { // super(throwable); // } // } // // Path: Android/app/src/main/java/uk/gov/nhs/digital/telehealth/exceptions/DeviceConnectionException.java // public class DeviceConnectionException extends Exception { // public DeviceConnectionException() { // super(); // } // // public DeviceConnectionException(String detailMessage) { // super(detailMessage); // } // // public DeviceConnectionException(String detailMessage, Throwable throwable) { // super(detailMessage, throwable); // } // // public DeviceConnectionException(Throwable throwable) { // super(throwable); // } // } // // Path: Android/app/src/main/java/uk/gov/nhs/digital/telehealth/exceptions/DeviceNotFoundException.java // public class DeviceNotFoundException extends Exception { // public DeviceNotFoundException() { // super(); // } // // public DeviceNotFoundException(String detailMessage) { // super(detailMessage); // } // // public DeviceNotFoundException(String detailMessage, Throwable throwable) { // super(detailMessage, throwable); // } // // public DeviceNotFoundException(Throwable throwable) { // super(throwable); // } // } // // Path: Android/app/src/main/java/uk/gov/nhs/digital/telehealth/connection/service/ConnectionService.java // public interface ConnectionService { // Collection<?> getAllDevices(Context context) throws DeviceConnectionException; // Object getDevice(Context context, String deviceName) throws DeviceNotFoundException, DeviceConnectionException; // Object getConnection(Context context, Object device) throws DeviceConnectionException; // } // Path: Android/app/src/main/java/uk/gov/nhs/digital/telehealth/connection/service/BluetoothConnectionService.java import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothSocket; import android.content.Context; import com.hoho.android.usbserial.driver.UsbSerialDriver; import uk.gov.nhs.digital.telehealth.exceptions.BluetoothAdapterException; import uk.gov.nhs.digital.telehealth.exceptions.DeviceConnectionException; import uk.gov.nhs.digital.telehealth.exceptions.DeviceNotFoundException; import uk.gov.nhs.digital.telehealth.connection.service.ConnectionService; import java.io.IOException; import java.lang.reflect.Method; import java.util.Collection; import java.util.List; import java.util.Set; import java.util.UUID; package uk.gov.nhs.digital.telehealth.connection.service; public class BluetoothConnectionService implements ConnectionService { private UUID DEFAULT_UUID = UUID.fromString("00001101-0000-1000-8000-00805f9b34fb"); //private UUID DEFAULT_UUID = UUID.fromString("8ce255c0-200a-11e0-ac64-0800200c9a66"); private BluetoothAdapter getBluetoothAdapter() throws BluetoothAdapterException { BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); if (!bluetoothAdapter.isEnabled()) { throw new BluetoothAdapterException("Bluetooth is not enabled."); } return bluetoothAdapter; } @Override public Collection<?> getAllDevices(Context context) throws DeviceConnectionException { BluetoothAdapter bluetoothAdapter = null; try { bluetoothAdapter = getBluetoothAdapter(); } catch (BluetoothAdapterException e) { throw new DeviceConnectionException(e); } Set<BluetoothDevice> availableDevices = bluetoothAdapter.getBondedDevices(); if (availableDevices.isEmpty()) { throw new DeviceConnectionException("No devices connected"); } return availableDevices; }
public Object getDriver(Context context, String deviceName) throws DeviceNotFoundException, DeviceConnectionException {
rprobinson/MediPi
Android/app/src/main/java/uk/gov/nhs/digital/telehealth/domain/BloodPressure.java
// Path: Android/app/src/main/java/uk/gov/nhs/digital/telehealth/util/TimestampUtil.java // public class TimestampUtil { // // public static Timestamp getTimestamp(String format, String dateString) throws ParseException { // //SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS"); // SimpleDateFormat dateFormat = new SimpleDateFormat(format); // Date parsedDate = dateFormat.parse(dateString); // Timestamp timestamp = new java.sql.Timestamp(parsedDate.getTime()); // return timestamp; // } // }
import uk.gov.nhs.digital.telehealth.util.TimestampUtil; import java.sql.Timestamp; import java.text.ParseException;
String minute = null; BM55User user = null; if(data[3]<0) { this.restingIndicator = true; month = String.valueOf(data[3] + 128); } else { month = String.valueOf(data[3]); } if(data[4]<0) { this.user = BM55User.B; day = String.valueOf(data[4] + 128); } else { this.user = BM55User.A; day = String.valueOf(data[4]); } hour = String.valueOf(data[5]); minute = String.valueOf(data[6]); if(data[7]<0) { this.arrhythmia = true; year = String.valueOf(data[7] + 128 + 2000); } else { year = String.valueOf(data[7]+ 2000); } String stringMeasurementTime = year + "-" + month + "-" + day + " " + hour + ":" + minute; try {
// Path: Android/app/src/main/java/uk/gov/nhs/digital/telehealth/util/TimestampUtil.java // public class TimestampUtil { // // public static Timestamp getTimestamp(String format, String dateString) throws ParseException { // //SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS"); // SimpleDateFormat dateFormat = new SimpleDateFormat(format); // Date parsedDate = dateFormat.parse(dateString); // Timestamp timestamp = new java.sql.Timestamp(parsedDate.getTime()); // return timestamp; // } // } // Path: Android/app/src/main/java/uk/gov/nhs/digital/telehealth/domain/BloodPressure.java import uk.gov.nhs.digital.telehealth.util.TimestampUtil; import java.sql.Timestamp; import java.text.ParseException; String minute = null; BM55User user = null; if(data[3]<0) { this.restingIndicator = true; month = String.valueOf(data[3] + 128); } else { month = String.valueOf(data[3]); } if(data[4]<0) { this.user = BM55User.B; day = String.valueOf(data[4] + 128); } else { this.user = BM55User.A; day = String.valueOf(data[4]); } hour = String.valueOf(data[5]); minute = String.valueOf(data[6]); if(data[7]<0) { this.arrhythmia = true; year = String.valueOf(data[7] + 128 + 2000); } else { year = String.valueOf(data[7]+ 2000); } String stringMeasurementTime = year + "-" + month + "-" + day + " " + hour + ":" + minute; try {
this.measuredTime = TimestampUtil.getTimestamp("yyyy-MM-dd hh:mm", stringMeasurementTime);
rprobinson/MediPi
Clinician/MediPiClinical/src/main/java/org/medipi/clinical/services/SendAlertService.java
// Path: Commons/MediPiTransportTools/src/main/java/org/medipi/model/DirectPatientMessage.java // public interface DirectPatientMessage { // // public String getPatientUuid(); // // // }
import java.io.Serializable; import java.net.URI; import java.util.List; import org.medipi.clinical.logging.MediPiLogger; import org.medipi.clinical.utilities.Utilities; import org.medipi.model.DirectPatientMessage; import org.medipi.security.CertificateDefinitions; import org.medipi.model.EncryptedAndSignedUploadDO; import org.medipi.security.UploadEncryptionAdapter; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpEntity; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Component; import org.springframework.web.client.HttpClientErrorException; import org.springframework.web.client.HttpServerErrorException; import org.springframework.web.client.RestClientException; import org.springframework.web.client.RestTemplate; import org.springframework.web.util.UriComponentsBuilder;
/* Copyright 2016 Richard Robinson @ NHS Digital <rrobinson@nhs.net> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package org.medipi.clinical.services; /** * * @author rick@robinsonhq.com */ @Component public class SendAlertService { @Autowired private Utilities utils; //Path for posting alerts for patients @Value("${medipi.clinical.patientcertificate.resourcepath}") private String patientCertificateResourcePath; public void resendDirectMessages(Tester tester, RestTemplate restTemplate) {
// Path: Commons/MediPiTransportTools/src/main/java/org/medipi/model/DirectPatientMessage.java // public interface DirectPatientMessage { // // public String getPatientUuid(); // // // } // Path: Clinician/MediPiClinical/src/main/java/org/medipi/clinical/services/SendAlertService.java import java.io.Serializable; import java.net.URI; import java.util.List; import org.medipi.clinical.logging.MediPiLogger; import org.medipi.clinical.utilities.Utilities; import org.medipi.model.DirectPatientMessage; import org.medipi.security.CertificateDefinitions; import org.medipi.model.EncryptedAndSignedUploadDO; import org.medipi.security.UploadEncryptionAdapter; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpEntity; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Component; import org.springframework.web.client.HttpClientErrorException; import org.springframework.web.client.HttpServerErrorException; import org.springframework.web.client.RestClientException; import org.springframework.web.client.RestTemplate; import org.springframework.web.util.UriComponentsBuilder; /* Copyright 2016 Richard Robinson @ NHS Digital <rrobinson@nhs.net> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package org.medipi.clinical.services; /** * * @author rick@robinsonhq.com */ @Component public class SendAlertService { @Autowired private Utilities utils; //Path for posting alerts for patients @Value("${medipi.clinical.patientcertificate.resourcepath}") private String patientCertificateResourcePath; public void resendDirectMessages(Tester tester, RestTemplate restTemplate) {
List<DirectPatientMessage> retryDirectMessageList = tester.findDirectPatientMessagesToResend();
rprobinson/MediPi
MediPiPatient/MediPi/src/main/java/org/medipi/devices/ScheduleWatcher.java
// Path: MediPiPatient/MediPi/src/main/java/org/medipi/MediPiMessageBox.java // public class MediPiMessageBox { // // private MediPi medipi; // private HashMap<String, Alert> liveMessages = new HashMap<>(); // // private MediPiMessageBox() { // } // // /** // * returns the one and only instance of the singleton // * // * @return singleton instance // */ // public static MediPiMessageBox getInstance() { // return MediPiHolder.INSTANCE; // } // // /** // * Sets a reference to the main MediPi class for callbacks and access // * // * @param m medipi reference to the main class // */ // public void setMediPi(MediPi m) { // medipi = m; // } // // /** // * Method for displaying an error messagebox to the screen. // * // * @param message String message // * @param except exception which this message arose from - null if not // * applicable // */ // public void makeErrorMessage(String message, Exception except) { // try { // String uniqueString; // if (except == null) { // uniqueString = message; // } else { // uniqueString = message + except.getLocalizedMessage(); // } // String debugString = getDebugString(except); // // MediPiLogger.getInstance().log(MediPiMessageBox.class.getName() + ".makeErrorMessage", "MediPi informed the user that: " + message + " " + except); // if (except != null) { // except.printStackTrace(); // } // // if (Platform.isFxApplicationThread()) { // AlertBox ab = new AlertBox(); // ab.showAlertBox(uniqueString, message, debugString, liveMessages, medipi); // } else { // Platform.runLater(() -> { // AlertBox ab = new AlertBox(); // ab.showAlertBox(uniqueString, message, debugString, liveMessages, medipi); // }); // } // } catch (Exception ex) { // medipi.makeFatalErrorMessage("Fatal Error - Unable to display error message", ex); // } // } // // /** // * Method to make a general information message // * // * @param message String representation of the message to be displayed // */ // public void makeMessage(String message) { // try { // String uniqueString = message; // // MediPiLogger.getInstance().log(MediPiMessageBox.class.getName() + ".makeMessage", "MediPi informed the user that: " + message); // if (Platform.isFxApplicationThread()) { // AlertBox ab = new AlertBox(); // ab.showMessageBox(uniqueString, message, liveMessages, medipi); // } else { // Platform.runLater(() -> { // AlertBox ab = new AlertBox(); // ab.showMessageBox(uniqueString, message, liveMessages, medipi); // }); // } // } catch (Exception ex) { // medipi.makeFatalErrorMessage("Fatal Error - Unable to display error message", ex); // } // } // // private String getDebugString(Exception ex) { // if (ex == null) { // return ""; // } else { // return "\n" + ex.toString(); // } // } // // private static class MediPiHolder { // // private static final MediPiMessageBox INSTANCE = new MediPiMessageBox(); // } // }
import java.io.IOException; import java.nio.file.FileSystems; import java.nio.file.Path; import static java.nio.file.StandardWatchEventKinds.ENTRY_MODIFY; import java.nio.file.WatchEvent; import java.nio.file.WatchKey; import java.nio.file.WatchService; import java.util.logging.Level; import java.util.logging.Logger; import org.medipi.MediPiMessageBox;
/* Copyright 2016 Richard Robinson @ NHS Digital <rrobinson@nhs.net> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package org.medipi.devices; /** * Class to watch the .scheduler file to be informed of any changes * * When a the .scheduler file is changed the schedule in Scheduler is refreshed */ public class ScheduleWatcher extends Thread { private WatchService watchService; private String fileName; private Path dir; private Scheduler sched; private WatchKey watchKey; @SuppressWarnings("unchecked") static <T> WatchEvent<T> cast(WatchEvent<?> event) { return (WatchEvent<T>) event; } /** * Creates a WatchService and registers the given directory */ ScheduleWatcher(Path d, String f, Scheduler s) { dir = d; fileName = f; sched = s; try { this.watchService = FileSystems.getDefault().newWatchService(); this.watchKey = dir.register(watchService, ENTRY_MODIFY); start(); } catch (IOException ex) { Logger.getLogger(ScheduleWatcher.class.getName()).log(Level.SEVERE, null, ex); } } /** * Process all events for keys queued to the watcher */ @Override public void run() { for (;;) { // wait for key to be signalled try { watchKey = watchService.take(); } catch (InterruptedException x) {
// Path: MediPiPatient/MediPi/src/main/java/org/medipi/MediPiMessageBox.java // public class MediPiMessageBox { // // private MediPi medipi; // private HashMap<String, Alert> liveMessages = new HashMap<>(); // // private MediPiMessageBox() { // } // // /** // * returns the one and only instance of the singleton // * // * @return singleton instance // */ // public static MediPiMessageBox getInstance() { // return MediPiHolder.INSTANCE; // } // // /** // * Sets a reference to the main MediPi class for callbacks and access // * // * @param m medipi reference to the main class // */ // public void setMediPi(MediPi m) { // medipi = m; // } // // /** // * Method for displaying an error messagebox to the screen. // * // * @param message String message // * @param except exception which this message arose from - null if not // * applicable // */ // public void makeErrorMessage(String message, Exception except) { // try { // String uniqueString; // if (except == null) { // uniqueString = message; // } else { // uniqueString = message + except.getLocalizedMessage(); // } // String debugString = getDebugString(except); // // MediPiLogger.getInstance().log(MediPiMessageBox.class.getName() + ".makeErrorMessage", "MediPi informed the user that: " + message + " " + except); // if (except != null) { // except.printStackTrace(); // } // // if (Platform.isFxApplicationThread()) { // AlertBox ab = new AlertBox(); // ab.showAlertBox(uniqueString, message, debugString, liveMessages, medipi); // } else { // Platform.runLater(() -> { // AlertBox ab = new AlertBox(); // ab.showAlertBox(uniqueString, message, debugString, liveMessages, medipi); // }); // } // } catch (Exception ex) { // medipi.makeFatalErrorMessage("Fatal Error - Unable to display error message", ex); // } // } // // /** // * Method to make a general information message // * // * @param message String representation of the message to be displayed // */ // public void makeMessage(String message) { // try { // String uniqueString = message; // // MediPiLogger.getInstance().log(MediPiMessageBox.class.getName() + ".makeMessage", "MediPi informed the user that: " + message); // if (Platform.isFxApplicationThread()) { // AlertBox ab = new AlertBox(); // ab.showMessageBox(uniqueString, message, liveMessages, medipi); // } else { // Platform.runLater(() -> { // AlertBox ab = new AlertBox(); // ab.showMessageBox(uniqueString, message, liveMessages, medipi); // }); // } // } catch (Exception ex) { // medipi.makeFatalErrorMessage("Fatal Error - Unable to display error message", ex); // } // } // // private String getDebugString(Exception ex) { // if (ex == null) { // return ""; // } else { // return "\n" + ex.toString(); // } // } // // private static class MediPiHolder { // // private static final MediPiMessageBox INSTANCE = new MediPiMessageBox(); // } // } // Path: MediPiPatient/MediPi/src/main/java/org/medipi/devices/ScheduleWatcher.java import java.io.IOException; import java.nio.file.FileSystems; import java.nio.file.Path; import static java.nio.file.StandardWatchEventKinds.ENTRY_MODIFY; import java.nio.file.WatchEvent; import java.nio.file.WatchKey; import java.nio.file.WatchService; import java.util.logging.Level; import java.util.logging.Logger; import org.medipi.MediPiMessageBox; /* Copyright 2016 Richard Robinson @ NHS Digital <rrobinson@nhs.net> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package org.medipi.devices; /** * Class to watch the .scheduler file to be informed of any changes * * When a the .scheduler file is changed the schedule in Scheduler is refreshed */ public class ScheduleWatcher extends Thread { private WatchService watchService; private String fileName; private Path dir; private Scheduler sched; private WatchKey watchKey; @SuppressWarnings("unchecked") static <T> WatchEvent<T> cast(WatchEvent<?> event) { return (WatchEvent<T>) event; } /** * Creates a WatchService and registers the given directory */ ScheduleWatcher(Path d, String f, Scheduler s) { dir = d; fileName = f; sched = s; try { this.watchService = FileSystems.getDefault().newWatchService(); this.watchKey = dir.register(watchService, ENTRY_MODIFY); start(); } catch (IOException ex) { Logger.getLogger(ScheduleWatcher.class.getName()).log(Level.SEVERE, null, ex); } } /** * Process all events for keys queued to the watcher */ @Override public void run() { for (;;) { // wait for key to be signalled try { watchKey = watchService.take(); } catch (InterruptedException x) {
MediPiMessageBox.getInstance().makeErrorMessage("Scheduler - failed to instantiate key", x);
rprobinson/MediPi
Clinician/MediPiClinical/src/main/java/org/medipi/clinical/services/Tester.java
// Path: Commons/MediPiTransportTools/src/main/java/org/medipi/model/DirectPatientMessage.java // public interface DirectPatientMessage { // // public String getPatientUuid(); // // // }
import org.medipi.model.DirectPatientMessage; import java.util.List;
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package org.medipi.clinical.services; /** * * @author riro */ public interface Tester { public boolean isEnabled(); public String getDirectPatientMessageResourcePath();
// Path: Commons/MediPiTransportTools/src/main/java/org/medipi/model/DirectPatientMessage.java // public interface DirectPatientMessage { // // public String getPatientUuid(); // // // } // Path: Clinician/MediPiClinical/src/main/java/org/medipi/clinical/services/Tester.java import org.medipi.model.DirectPatientMessage; import java.util.List; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package org.medipi.clinical.services; /** * * @author riro */ public interface Tester { public boolean isEnabled(); public String getDirectPatientMessageResourcePath();
public boolean updateDirectPatientMessageTableWithSuccess(DirectPatientMessage directPatientMessage) throws Exception;
rprobinson/MediPi
Android/app/src/main/java/uk/gov/nhs/digital/telehealth/connection/service/ConnectionService.java
// Path: Android/app/src/main/java/uk/gov/nhs/digital/telehealth/exceptions/DeviceConnectionException.java // public class DeviceConnectionException extends Exception { // public DeviceConnectionException() { // super(); // } // // public DeviceConnectionException(String detailMessage) { // super(detailMessage); // } // // public DeviceConnectionException(String detailMessage, Throwable throwable) { // super(detailMessage, throwable); // } // // public DeviceConnectionException(Throwable throwable) { // super(throwable); // } // } // // Path: Android/app/src/main/java/uk/gov/nhs/digital/telehealth/exceptions/DeviceNotFoundException.java // public class DeviceNotFoundException extends Exception { // public DeviceNotFoundException() { // super(); // } // // public DeviceNotFoundException(String detailMessage) { // super(detailMessage); // } // // public DeviceNotFoundException(String detailMessage, Throwable throwable) { // super(detailMessage, throwable); // } // // public DeviceNotFoundException(Throwable throwable) { // super(throwable); // } // }
import android.content.Context; import uk.gov.nhs.digital.telehealth.exceptions.DeviceConnectionException; import uk.gov.nhs.digital.telehealth.exceptions.DeviceNotFoundException; import java.util.Collection;
package uk.gov.nhs.digital.telehealth.connection.service; public interface ConnectionService { Collection<?> getAllDevices(Context context) throws DeviceConnectionException;
// Path: Android/app/src/main/java/uk/gov/nhs/digital/telehealth/exceptions/DeviceConnectionException.java // public class DeviceConnectionException extends Exception { // public DeviceConnectionException() { // super(); // } // // public DeviceConnectionException(String detailMessage) { // super(detailMessage); // } // // public DeviceConnectionException(String detailMessage, Throwable throwable) { // super(detailMessage, throwable); // } // // public DeviceConnectionException(Throwable throwable) { // super(throwable); // } // } // // Path: Android/app/src/main/java/uk/gov/nhs/digital/telehealth/exceptions/DeviceNotFoundException.java // public class DeviceNotFoundException extends Exception { // public DeviceNotFoundException() { // super(); // } // // public DeviceNotFoundException(String detailMessage) { // super(detailMessage); // } // // public DeviceNotFoundException(String detailMessage, Throwable throwable) { // super(detailMessage, throwable); // } // // public DeviceNotFoundException(Throwable throwable) { // super(throwable); // } // } // Path: Android/app/src/main/java/uk/gov/nhs/digital/telehealth/connection/service/ConnectionService.java import android.content.Context; import uk.gov.nhs.digital.telehealth.exceptions.DeviceConnectionException; import uk.gov.nhs.digital.telehealth.exceptions.DeviceNotFoundException; import java.util.Collection; package uk.gov.nhs.digital.telehealth.connection.service; public interface ConnectionService { Collection<?> getAllDevices(Context context) throws DeviceConnectionException;
Object getDevice(Context context, String deviceName) throws DeviceNotFoundException, DeviceConnectionException;
rprobinson/MediPi
Android/app/src/main/java/uk/gov/nhs/digital/telehealth/connection/service/USBConnectionService.java
// Path: Android/app/src/main/java/uk/gov/nhs/digital/telehealth/exceptions/DeviceConnectionException.java // public class DeviceConnectionException extends Exception { // public DeviceConnectionException() { // super(); // } // // public DeviceConnectionException(String detailMessage) { // super(detailMessage); // } // // public DeviceConnectionException(String detailMessage, Throwable throwable) { // super(detailMessage, throwable); // } // // public DeviceConnectionException(Throwable throwable) { // super(throwable); // } // } // // Path: Android/app/src/main/java/uk/gov/nhs/digital/telehealth/exceptions/DeviceNotFoundException.java // public class DeviceNotFoundException extends Exception { // public DeviceNotFoundException() { // super(); // } // // public DeviceNotFoundException(String detailMessage) { // super(detailMessage); // } // // public DeviceNotFoundException(String detailMessage, Throwable throwable) { // super(detailMessage, throwable); // } // // public DeviceNotFoundException(Throwable throwable) { // super(throwable); // } // }
import android.content.Context; import android.hardware.usb.UsbDevice; import android.hardware.usb.UsbDeviceConnection; import android.hardware.usb.UsbManager; import com.hoho.android.usbserial.driver.UsbSerialDriver; import com.hoho.android.usbserial.driver.UsbSerialProber; import uk.gov.nhs.digital.telehealth.exceptions.DeviceConnectionException; import uk.gov.nhs.digital.telehealth.exceptions.DeviceNotFoundException; import java.util.Collection; import java.util.List;
package uk.gov.nhs.digital.telehealth.connection.service; public class USBConnectionService implements ConnectionService { public UsbManager getUsbManager(Context context) { return (UsbManager) context.getSystemService(Context.USB_SERVICE); } @Override
// Path: Android/app/src/main/java/uk/gov/nhs/digital/telehealth/exceptions/DeviceConnectionException.java // public class DeviceConnectionException extends Exception { // public DeviceConnectionException() { // super(); // } // // public DeviceConnectionException(String detailMessage) { // super(detailMessage); // } // // public DeviceConnectionException(String detailMessage, Throwable throwable) { // super(detailMessage, throwable); // } // // public DeviceConnectionException(Throwable throwable) { // super(throwable); // } // } // // Path: Android/app/src/main/java/uk/gov/nhs/digital/telehealth/exceptions/DeviceNotFoundException.java // public class DeviceNotFoundException extends Exception { // public DeviceNotFoundException() { // super(); // } // // public DeviceNotFoundException(String detailMessage) { // super(detailMessage); // } // // public DeviceNotFoundException(String detailMessage, Throwable throwable) { // super(detailMessage, throwable); // } // // public DeviceNotFoundException(Throwable throwable) { // super(throwable); // } // } // Path: Android/app/src/main/java/uk/gov/nhs/digital/telehealth/connection/service/USBConnectionService.java import android.content.Context; import android.hardware.usb.UsbDevice; import android.hardware.usb.UsbDeviceConnection; import android.hardware.usb.UsbManager; import com.hoho.android.usbserial.driver.UsbSerialDriver; import com.hoho.android.usbserial.driver.UsbSerialProber; import uk.gov.nhs.digital.telehealth.exceptions.DeviceConnectionException; import uk.gov.nhs.digital.telehealth.exceptions.DeviceNotFoundException; import java.util.Collection; import java.util.List; package uk.gov.nhs.digital.telehealth.connection.service; public class USBConnectionService implements ConnectionService { public UsbManager getUsbManager(Context context) { return (UsbManager) context.getSystemService(Context.USB_SERVICE); } @Override
public Collection<?> getAllDevices(Context context) throws DeviceConnectionException {
rprobinson/MediPi
Android/app/src/main/java/uk/gov/nhs/digital/telehealth/connection/service/USBConnectionService.java
// Path: Android/app/src/main/java/uk/gov/nhs/digital/telehealth/exceptions/DeviceConnectionException.java // public class DeviceConnectionException extends Exception { // public DeviceConnectionException() { // super(); // } // // public DeviceConnectionException(String detailMessage) { // super(detailMessage); // } // // public DeviceConnectionException(String detailMessage, Throwable throwable) { // super(detailMessage, throwable); // } // // public DeviceConnectionException(Throwable throwable) { // super(throwable); // } // } // // Path: Android/app/src/main/java/uk/gov/nhs/digital/telehealth/exceptions/DeviceNotFoundException.java // public class DeviceNotFoundException extends Exception { // public DeviceNotFoundException() { // super(); // } // // public DeviceNotFoundException(String detailMessage) { // super(detailMessage); // } // // public DeviceNotFoundException(String detailMessage, Throwable throwable) { // super(detailMessage, throwable); // } // // public DeviceNotFoundException(Throwable throwable) { // super(throwable); // } // }
import android.content.Context; import android.hardware.usb.UsbDevice; import android.hardware.usb.UsbDeviceConnection; import android.hardware.usb.UsbManager; import com.hoho.android.usbserial.driver.UsbSerialDriver; import com.hoho.android.usbserial.driver.UsbSerialProber; import uk.gov.nhs.digital.telehealth.exceptions.DeviceConnectionException; import uk.gov.nhs.digital.telehealth.exceptions.DeviceNotFoundException; import java.util.Collection; import java.util.List;
package uk.gov.nhs.digital.telehealth.connection.service; public class USBConnectionService implements ConnectionService { public UsbManager getUsbManager(Context context) { return (UsbManager) context.getSystemService(Context.USB_SERVICE); } @Override public Collection<?> getAllDevices(Context context) throws DeviceConnectionException { UsbManager manager = getUsbManager(context); Collection<UsbDevice> availableDevices = manager.getDeviceList().values(); if (availableDevices.isEmpty()) { throw new DeviceConnectionException("No devices connected"); } return availableDevices; } public List<?> getAllDrivers(Context context) throws DeviceConnectionException { UsbManager manager = getUsbManager(context); List<UsbSerialDriver> availableDrivers = UsbSerialProber.getDefaultProber().findAllDrivers(manager); if (availableDrivers.isEmpty()) { throw new DeviceConnectionException("No devices connected"); } return availableDrivers; }
// Path: Android/app/src/main/java/uk/gov/nhs/digital/telehealth/exceptions/DeviceConnectionException.java // public class DeviceConnectionException extends Exception { // public DeviceConnectionException() { // super(); // } // // public DeviceConnectionException(String detailMessage) { // super(detailMessage); // } // // public DeviceConnectionException(String detailMessage, Throwable throwable) { // super(detailMessage, throwable); // } // // public DeviceConnectionException(Throwable throwable) { // super(throwable); // } // } // // Path: Android/app/src/main/java/uk/gov/nhs/digital/telehealth/exceptions/DeviceNotFoundException.java // public class DeviceNotFoundException extends Exception { // public DeviceNotFoundException() { // super(); // } // // public DeviceNotFoundException(String detailMessage) { // super(detailMessage); // } // // public DeviceNotFoundException(String detailMessage, Throwable throwable) { // super(detailMessage, throwable); // } // // public DeviceNotFoundException(Throwable throwable) { // super(throwable); // } // } // Path: Android/app/src/main/java/uk/gov/nhs/digital/telehealth/connection/service/USBConnectionService.java import android.content.Context; import android.hardware.usb.UsbDevice; import android.hardware.usb.UsbDeviceConnection; import android.hardware.usb.UsbManager; import com.hoho.android.usbserial.driver.UsbSerialDriver; import com.hoho.android.usbserial.driver.UsbSerialProber; import uk.gov.nhs.digital.telehealth.exceptions.DeviceConnectionException; import uk.gov.nhs.digital.telehealth.exceptions.DeviceNotFoundException; import java.util.Collection; import java.util.List; package uk.gov.nhs.digital.telehealth.connection.service; public class USBConnectionService implements ConnectionService { public UsbManager getUsbManager(Context context) { return (UsbManager) context.getSystemService(Context.USB_SERVICE); } @Override public Collection<?> getAllDevices(Context context) throws DeviceConnectionException { UsbManager manager = getUsbManager(context); Collection<UsbDevice> availableDevices = manager.getDeviceList().values(); if (availableDevices.isEmpty()) { throw new DeviceConnectionException("No devices connected"); } return availableDevices; } public List<?> getAllDrivers(Context context) throws DeviceConnectionException { UsbManager manager = getUsbManager(context); List<UsbSerialDriver> availableDrivers = UsbSerialProber.getDefaultProber().findAllDrivers(manager); if (availableDrivers.isEmpty()) { throw new DeviceConnectionException("No devices connected"); } return availableDrivers; }
public Object getDriver(Context context, String deviceName) throws DeviceNotFoundException, DeviceConnectionException {
CodeCrafter47/BungeeTabListPlus
bungee/src/main/java/codecrafter47/bungeetablistplus/handler/GetGamemodeLogic.java
// Path: bungee/src/main/java/codecrafter47/bungeetablistplus/protocol/AbstractPacketHandler.java // public abstract class AbstractPacketHandler implements PacketHandler { // // private final PacketHandler parent; // // public AbstractPacketHandler(@Nonnull @NonNull PacketHandler parent) { // this.parent = parent; // } // // @Override // public PacketListenerResult onPlayerListPacket(PlayerListItem packet) { // return parent.onPlayerListPacket(packet); // } // // @Override // public PacketListenerResult onTeamPacket(Team packet) { // return parent.onTeamPacket(packet); // } // // @Override // public PacketListenerResult onPlayerListHeaderFooterPacket(PlayerListHeaderFooter packet) { // return parent.onPlayerListHeaderFooterPacket(packet); // } // // @Override // public void onServerSwitch(boolean is13OrLater) { // parent.onServerSwitch(is13OrLater); // } // } // // Path: bungee/src/main/java/codecrafter47/bungeetablistplus/protocol/PacketHandler.java // public interface PacketHandler { // // PacketListenerResult onPlayerListPacket(PlayerListItem packet); // // PacketListenerResult onTeamPacket(Team packet); // // PacketListenerResult onPlayerListHeaderFooterPacket(PlayerListHeaderFooter packet); // // void onServerSwitch(boolean is13OrLater); // } // // Path: bungee/src/main/java/codecrafter47/bungeetablistplus/protocol/PacketListenerResult.java // public enum PacketListenerResult { // PASS, MODIFIED, CANCEL; // }
import codecrafter47.bungeetablistplus.protocol.AbstractPacketHandler; import codecrafter47.bungeetablistplus.protocol.PacketHandler; import codecrafter47.bungeetablistplus.protocol.PacketListenerResult; import net.md_5.bungee.UserConnection; import net.md_5.bungee.protocol.packet.PlayerListItem;
/* * Copyright (C) 2020 Florian Stober * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package codecrafter47.bungeetablistplus.handler; public class GetGamemodeLogic extends AbstractPacketHandler { private final UserConnection userConnection;
// Path: bungee/src/main/java/codecrafter47/bungeetablistplus/protocol/AbstractPacketHandler.java // public abstract class AbstractPacketHandler implements PacketHandler { // // private final PacketHandler parent; // // public AbstractPacketHandler(@Nonnull @NonNull PacketHandler parent) { // this.parent = parent; // } // // @Override // public PacketListenerResult onPlayerListPacket(PlayerListItem packet) { // return parent.onPlayerListPacket(packet); // } // // @Override // public PacketListenerResult onTeamPacket(Team packet) { // return parent.onTeamPacket(packet); // } // // @Override // public PacketListenerResult onPlayerListHeaderFooterPacket(PlayerListHeaderFooter packet) { // return parent.onPlayerListHeaderFooterPacket(packet); // } // // @Override // public void onServerSwitch(boolean is13OrLater) { // parent.onServerSwitch(is13OrLater); // } // } // // Path: bungee/src/main/java/codecrafter47/bungeetablistplus/protocol/PacketHandler.java // public interface PacketHandler { // // PacketListenerResult onPlayerListPacket(PlayerListItem packet); // // PacketListenerResult onTeamPacket(Team packet); // // PacketListenerResult onPlayerListHeaderFooterPacket(PlayerListHeaderFooter packet); // // void onServerSwitch(boolean is13OrLater); // } // // Path: bungee/src/main/java/codecrafter47/bungeetablistplus/protocol/PacketListenerResult.java // public enum PacketListenerResult { // PASS, MODIFIED, CANCEL; // } // Path: bungee/src/main/java/codecrafter47/bungeetablistplus/handler/GetGamemodeLogic.java import codecrafter47.bungeetablistplus.protocol.AbstractPacketHandler; import codecrafter47.bungeetablistplus.protocol.PacketHandler; import codecrafter47.bungeetablistplus.protocol.PacketListenerResult; import net.md_5.bungee.UserConnection; import net.md_5.bungee.protocol.packet.PlayerListItem; /* * Copyright (C) 2020 Florian Stober * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package codecrafter47.bungeetablistplus.handler; public class GetGamemodeLogic extends AbstractPacketHandler { private final UserConnection userConnection;
public GetGamemodeLogic(PacketHandler parent, UserConnection userConnection) {
CodeCrafter47/BungeeTabListPlus
bungee/src/main/java/codecrafter47/bungeetablistplus/handler/GetGamemodeLogic.java
// Path: bungee/src/main/java/codecrafter47/bungeetablistplus/protocol/AbstractPacketHandler.java // public abstract class AbstractPacketHandler implements PacketHandler { // // private final PacketHandler parent; // // public AbstractPacketHandler(@Nonnull @NonNull PacketHandler parent) { // this.parent = parent; // } // // @Override // public PacketListenerResult onPlayerListPacket(PlayerListItem packet) { // return parent.onPlayerListPacket(packet); // } // // @Override // public PacketListenerResult onTeamPacket(Team packet) { // return parent.onTeamPacket(packet); // } // // @Override // public PacketListenerResult onPlayerListHeaderFooterPacket(PlayerListHeaderFooter packet) { // return parent.onPlayerListHeaderFooterPacket(packet); // } // // @Override // public void onServerSwitch(boolean is13OrLater) { // parent.onServerSwitch(is13OrLater); // } // } // // Path: bungee/src/main/java/codecrafter47/bungeetablistplus/protocol/PacketHandler.java // public interface PacketHandler { // // PacketListenerResult onPlayerListPacket(PlayerListItem packet); // // PacketListenerResult onTeamPacket(Team packet); // // PacketListenerResult onPlayerListHeaderFooterPacket(PlayerListHeaderFooter packet); // // void onServerSwitch(boolean is13OrLater); // } // // Path: bungee/src/main/java/codecrafter47/bungeetablistplus/protocol/PacketListenerResult.java // public enum PacketListenerResult { // PASS, MODIFIED, CANCEL; // }
import codecrafter47.bungeetablistplus.protocol.AbstractPacketHandler; import codecrafter47.bungeetablistplus.protocol.PacketHandler; import codecrafter47.bungeetablistplus.protocol.PacketListenerResult; import net.md_5.bungee.UserConnection; import net.md_5.bungee.protocol.packet.PlayerListItem;
/* * Copyright (C) 2020 Florian Stober * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package codecrafter47.bungeetablistplus.handler; public class GetGamemodeLogic extends AbstractPacketHandler { private final UserConnection userConnection; public GetGamemodeLogic(PacketHandler parent, UserConnection userConnection) { super(parent); this.userConnection = userConnection; } @Override
// Path: bungee/src/main/java/codecrafter47/bungeetablistplus/protocol/AbstractPacketHandler.java // public abstract class AbstractPacketHandler implements PacketHandler { // // private final PacketHandler parent; // // public AbstractPacketHandler(@Nonnull @NonNull PacketHandler parent) { // this.parent = parent; // } // // @Override // public PacketListenerResult onPlayerListPacket(PlayerListItem packet) { // return parent.onPlayerListPacket(packet); // } // // @Override // public PacketListenerResult onTeamPacket(Team packet) { // return parent.onTeamPacket(packet); // } // // @Override // public PacketListenerResult onPlayerListHeaderFooterPacket(PlayerListHeaderFooter packet) { // return parent.onPlayerListHeaderFooterPacket(packet); // } // // @Override // public void onServerSwitch(boolean is13OrLater) { // parent.onServerSwitch(is13OrLater); // } // } // // Path: bungee/src/main/java/codecrafter47/bungeetablistplus/protocol/PacketHandler.java // public interface PacketHandler { // // PacketListenerResult onPlayerListPacket(PlayerListItem packet); // // PacketListenerResult onTeamPacket(Team packet); // // PacketListenerResult onPlayerListHeaderFooterPacket(PlayerListHeaderFooter packet); // // void onServerSwitch(boolean is13OrLater); // } // // Path: bungee/src/main/java/codecrafter47/bungeetablistplus/protocol/PacketListenerResult.java // public enum PacketListenerResult { // PASS, MODIFIED, CANCEL; // } // Path: bungee/src/main/java/codecrafter47/bungeetablistplus/handler/GetGamemodeLogic.java import codecrafter47.bungeetablistplus.protocol.AbstractPacketHandler; import codecrafter47.bungeetablistplus.protocol.PacketHandler; import codecrafter47.bungeetablistplus.protocol.PacketListenerResult; import net.md_5.bungee.UserConnection; import net.md_5.bungee.protocol.packet.PlayerListItem; /* * Copyright (C) 2020 Florian Stober * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package codecrafter47.bungeetablistplus.handler; public class GetGamemodeLogic extends AbstractPacketHandler { private final UserConnection userConnection; public GetGamemodeLogic(PacketHandler parent, UserConnection userConnection) { super(parent); this.userConnection = userConnection; } @Override
public PacketListenerResult onPlayerListPacket(PlayerListItem packet) {
CodeCrafter47/BungeeTabListPlus
bungee/src/test/java/codecrafter47/bungeetablistplus/tablisthandler/logic/AbstractTabListLogicTest.java
// Path: api-bungee/src/main/java/codecrafter47/bungeetablistplus/api/bungee/Icon.java // @Data // public class Icon implements Serializable { // // private static final long serialVersionUID = 1L; // // private final UUID player; // @NonNull // private final String[][] properties; // // /** // * The default icon. The client will show a random Alex/ Steve face when using this. // */ // public static final Icon DEFAULT = new Icon(null, new String[0][]); // }
import codecrafter47.bungeetablistplus.api.bungee.Icon; import com.google.common.base.Charsets; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; import net.md_5.bungee.protocol.packet.PlayerListItem; import org.junit.Before; import org.junit.Test; import java.util.Set; import java.util.UUID; import static org.junit.Assert.*;
/* * Copyright (C) 2020 Florian Stober * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package codecrafter47.bungeetablistplus.tablisthandler.logic; public class AbstractTabListLogicTest extends AbstractTabListLogicTestBase { private static final String[] usernames = new String[160]; private static final UUID[] uuids = new UUID[160]; static { for (int i = 0; i < 160; i++) { usernames[i] = String.format("Player %3d", i); uuids[i] = UUID.nameUUIDFromBytes(("OfflinePlayer:" + usernames[i]).getBytes(Charsets.UTF_8)); } assertEquals(ImmutableSet.copyOf(uuids).size(), uuids.length); assertEquals(ImmutableSet.copyOf(usernames).size(), usernames.length); } @Before public void setClientUUID() { uuids[47] = clientUUID; } @Test public void testPassthrough() { assertEquals(0, clientTabList.getSize()); tabListHandler.setPassThrough(false); assertEquals(0, clientTabList.getSize()); tabListHandler.setSize(1); assertEquals(1, clientTabList.getSize()); tabListHandler.setPassThrough(true); assertEquals(0, clientTabList.getSize()); tabListHandler.setSize(2); assertEquals(0, clientTabList.getSize());
// Path: api-bungee/src/main/java/codecrafter47/bungeetablistplus/api/bungee/Icon.java // @Data // public class Icon implements Serializable { // // private static final long serialVersionUID = 1L; // // private final UUID player; // @NonNull // private final String[][] properties; // // /** // * The default icon. The client will show a random Alex/ Steve face when using this. // */ // public static final Icon DEFAULT = new Icon(null, new String[0][]); // } // Path: bungee/src/test/java/codecrafter47/bungeetablistplus/tablisthandler/logic/AbstractTabListLogicTest.java import codecrafter47.bungeetablistplus.api.bungee.Icon; import com.google.common.base.Charsets; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; import net.md_5.bungee.protocol.packet.PlayerListItem; import org.junit.Before; import org.junit.Test; import java.util.Set; import java.util.UUID; import static org.junit.Assert.*; /* * Copyright (C) 2020 Florian Stober * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package codecrafter47.bungeetablistplus.tablisthandler.logic; public class AbstractTabListLogicTest extends AbstractTabListLogicTestBase { private static final String[] usernames = new String[160]; private static final UUID[] uuids = new UUID[160]; static { for (int i = 0; i < 160; i++) { usernames[i] = String.format("Player %3d", i); uuids[i] = UUID.nameUUIDFromBytes(("OfflinePlayer:" + usernames[i]).getBytes(Charsets.UTF_8)); } assertEquals(ImmutableSet.copyOf(uuids).size(), uuids.length); assertEquals(ImmutableSet.copyOf(usernames).size(), usernames.length); } @Before public void setClientUUID() { uuids[47] = clientUUID; } @Test public void testPassthrough() { assertEquals(0, clientTabList.getSize()); tabListHandler.setPassThrough(false); assertEquals(0, clientTabList.getSize()); tabListHandler.setSize(1); assertEquals(1, clientTabList.getSize()); tabListHandler.setPassThrough(true); assertEquals(0, clientTabList.getSize()); tabListHandler.setSize(2); assertEquals(0, clientTabList.getSize());
tabListHandler.setSlot(1, Icon.DEFAULT, "Slot", 1);
CodeCrafter47/BungeeTabListPlus
bungee/src/test/java/codecrafter47/bungeetablistplus/tablisthandler/logic/TabListHandler.java
// Path: api-bungee/src/main/java/codecrafter47/bungeetablistplus/api/bungee/Icon.java // @Data // public class Icon implements Serializable { // // private static final long serialVersionUID = 1L; // // private final UUID player; // @NonNull // private final String[][] properties; // // /** // * The default icon. The client will show a random Alex/ Steve face when using this. // */ // public static final Icon DEFAULT = new Icon(null, new String[0][]); // } // // Path: bungee/src/main/java/codecrafter47/bungeetablistplus/protocol/PacketHandler.java // public interface PacketHandler { // // PacketListenerResult onPlayerListPacket(PlayerListItem packet); // // PacketListenerResult onTeamPacket(Team packet); // // PacketListenerResult onPlayerListHeaderFooterPacket(PlayerListHeaderFooter packet); // // void onServerSwitch(boolean is13OrLater); // } // // Path: bungee/src/main/java/codecrafter47/bungeetablistplus/protocol/PacketListenerResult.java // public enum PacketListenerResult { // PASS, MODIFIED, CANCEL; // }
import codecrafter47.bungeetablistplus.api.bungee.Icon; import codecrafter47.bungeetablistplus.protocol.PacketHandler; import codecrafter47.bungeetablistplus.protocol.PacketListenerResult; import lombok.AllArgsConstructor; import net.md_5.bungee.protocol.packet.PlayerListHeaderFooter; import net.md_5.bungee.protocol.packet.PlayerListItem; import net.md_5.bungee.protocol.packet.Team;
/* * Copyright (C) 2020 Florian Stober * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package codecrafter47.bungeetablistplus.tablisthandler.logic; @AllArgsConstructor public class TabListHandler implements PacketHandler { private final TabListHandler parent; public void onConnected() { if (parent != null) { parent.onConnected(); } } public void onDisconnected() { if (parent != null) { parent.onDisconnected(); } } @Override
// Path: api-bungee/src/main/java/codecrafter47/bungeetablistplus/api/bungee/Icon.java // @Data // public class Icon implements Serializable { // // private static final long serialVersionUID = 1L; // // private final UUID player; // @NonNull // private final String[][] properties; // // /** // * The default icon. The client will show a random Alex/ Steve face when using this. // */ // public static final Icon DEFAULT = new Icon(null, new String[0][]); // } // // Path: bungee/src/main/java/codecrafter47/bungeetablistplus/protocol/PacketHandler.java // public interface PacketHandler { // // PacketListenerResult onPlayerListPacket(PlayerListItem packet); // // PacketListenerResult onTeamPacket(Team packet); // // PacketListenerResult onPlayerListHeaderFooterPacket(PlayerListHeaderFooter packet); // // void onServerSwitch(boolean is13OrLater); // } // // Path: bungee/src/main/java/codecrafter47/bungeetablistplus/protocol/PacketListenerResult.java // public enum PacketListenerResult { // PASS, MODIFIED, CANCEL; // } // Path: bungee/src/test/java/codecrafter47/bungeetablistplus/tablisthandler/logic/TabListHandler.java import codecrafter47.bungeetablistplus.api.bungee.Icon; import codecrafter47.bungeetablistplus.protocol.PacketHandler; import codecrafter47.bungeetablistplus.protocol.PacketListenerResult; import lombok.AllArgsConstructor; import net.md_5.bungee.protocol.packet.PlayerListHeaderFooter; import net.md_5.bungee.protocol.packet.PlayerListItem; import net.md_5.bungee.protocol.packet.Team; /* * Copyright (C) 2020 Florian Stober * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package codecrafter47.bungeetablistplus.tablisthandler.logic; @AllArgsConstructor public class TabListHandler implements PacketHandler { private final TabListHandler parent; public void onConnected() { if (parent != null) { parent.onConnected(); } } public void onDisconnected() { if (parent != null) { parent.onDisconnected(); } } @Override
public PacketListenerResult onPlayerListPacket(PlayerListItem packet) {
CodeCrafter47/BungeeTabListPlus
bungee/src/test/java/codecrafter47/bungeetablistplus/tablisthandler/logic/TabListHandler.java
// Path: api-bungee/src/main/java/codecrafter47/bungeetablistplus/api/bungee/Icon.java // @Data // public class Icon implements Serializable { // // private static final long serialVersionUID = 1L; // // private final UUID player; // @NonNull // private final String[][] properties; // // /** // * The default icon. The client will show a random Alex/ Steve face when using this. // */ // public static final Icon DEFAULT = new Icon(null, new String[0][]); // } // // Path: bungee/src/main/java/codecrafter47/bungeetablistplus/protocol/PacketHandler.java // public interface PacketHandler { // // PacketListenerResult onPlayerListPacket(PlayerListItem packet); // // PacketListenerResult onTeamPacket(Team packet); // // PacketListenerResult onPlayerListHeaderFooterPacket(PlayerListHeaderFooter packet); // // void onServerSwitch(boolean is13OrLater); // } // // Path: bungee/src/main/java/codecrafter47/bungeetablistplus/protocol/PacketListenerResult.java // public enum PacketListenerResult { // PASS, MODIFIED, CANCEL; // }
import codecrafter47.bungeetablistplus.api.bungee.Icon; import codecrafter47.bungeetablistplus.protocol.PacketHandler; import codecrafter47.bungeetablistplus.protocol.PacketListenerResult; import lombok.AllArgsConstructor; import net.md_5.bungee.protocol.packet.PlayerListHeaderFooter; import net.md_5.bungee.protocol.packet.PlayerListItem; import net.md_5.bungee.protocol.packet.Team;
@Override public PacketListenerResult onTeamPacket(Team packet) { return parent != null ? parent.onTeamPacket(packet) : PacketListenerResult.PASS; } @Override public PacketListenerResult onPlayerListHeaderFooterPacket(PlayerListHeaderFooter packet) { return parent != null ? parent.onPlayerListHeaderFooterPacket(packet) : PacketListenerResult.PASS; } @Override public void onServerSwitch(boolean is13OrLater) { if (parent != null) { parent.onServerSwitch(is13OrLater); } } public void setPassThrough(boolean passTrough) { if (parent != null) { parent.setPassThrough(passTrough); } } public void setSize(int size) { if (parent != null) { parent.setSize(size); } }
// Path: api-bungee/src/main/java/codecrafter47/bungeetablistplus/api/bungee/Icon.java // @Data // public class Icon implements Serializable { // // private static final long serialVersionUID = 1L; // // private final UUID player; // @NonNull // private final String[][] properties; // // /** // * The default icon. The client will show a random Alex/ Steve face when using this. // */ // public static final Icon DEFAULT = new Icon(null, new String[0][]); // } // // Path: bungee/src/main/java/codecrafter47/bungeetablistplus/protocol/PacketHandler.java // public interface PacketHandler { // // PacketListenerResult onPlayerListPacket(PlayerListItem packet); // // PacketListenerResult onTeamPacket(Team packet); // // PacketListenerResult onPlayerListHeaderFooterPacket(PlayerListHeaderFooter packet); // // void onServerSwitch(boolean is13OrLater); // } // // Path: bungee/src/main/java/codecrafter47/bungeetablistplus/protocol/PacketListenerResult.java // public enum PacketListenerResult { // PASS, MODIFIED, CANCEL; // } // Path: bungee/src/test/java/codecrafter47/bungeetablistplus/tablisthandler/logic/TabListHandler.java import codecrafter47.bungeetablistplus.api.bungee.Icon; import codecrafter47.bungeetablistplus.protocol.PacketHandler; import codecrafter47.bungeetablistplus.protocol.PacketListenerResult; import lombok.AllArgsConstructor; import net.md_5.bungee.protocol.packet.PlayerListHeaderFooter; import net.md_5.bungee.protocol.packet.PlayerListItem; import net.md_5.bungee.protocol.packet.Team; @Override public PacketListenerResult onTeamPacket(Team packet) { return parent != null ? parent.onTeamPacket(packet) : PacketListenerResult.PASS; } @Override public PacketListenerResult onPlayerListHeaderFooterPacket(PlayerListHeaderFooter packet) { return parent != null ? parent.onPlayerListHeaderFooterPacket(packet) : PacketListenerResult.PASS; } @Override public void onServerSwitch(boolean is13OrLater) { if (parent != null) { parent.onServerSwitch(is13OrLater); } } public void setPassThrough(boolean passTrough) { if (parent != null) { parent.setPassThrough(passTrough); } } public void setSize(int size) { if (parent != null) { parent.setSize(size); } }
public void setSlot(int index, Icon icon, String text, int ping) {
CodeCrafter47/BungeeTabListPlus
api-bungee/src/main/java/codecrafter47/bungeetablistplus/api/bungee/tablist/FakePlayer.java
// Path: api-bungee/src/main/java/codecrafter47/bungeetablistplus/api/bungee/Icon.java // @Data // public class Icon implements Serializable { // // private static final long serialVersionUID = 1L; // // private final UUID player; // @NonNull // private final String[][] properties; // // /** // * The default icon. The client will show a random Alex/ Steve face when using this. // */ // public static final Icon DEFAULT = new Icon(null, new String[0][]); // }
import codecrafter47.bungeetablistplus.api.bungee.Icon; import net.md_5.bungee.api.config.ServerInfo; import java.util.Optional; import java.util.UUID;
/* * Copyright (C) 2020 Florian Stober * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package codecrafter47.bungeetablistplus.api.bungee.tablist; /** * Represents a fake player on the tab list. */ public interface FakePlayer { /** * get the username of the player * * @return the username */ String getName(); /** * get the uuid of the player * * @return the uuid of the player */ UUID getUniqueID(); /** * get the server the player is connected to * * @return the server the player is connected to */ Optional<ServerInfo> getServer(); /** * get the ping of the player * * @return the ping */ int getPing(); /** * get the icon displayed on the tab list * * @return the icon */
// Path: api-bungee/src/main/java/codecrafter47/bungeetablistplus/api/bungee/Icon.java // @Data // public class Icon implements Serializable { // // private static final long serialVersionUID = 1L; // // private final UUID player; // @NonNull // private final String[][] properties; // // /** // * The default icon. The client will show a random Alex/ Steve face when using this. // */ // public static final Icon DEFAULT = new Icon(null, new String[0][]); // } // Path: api-bungee/src/main/java/codecrafter47/bungeetablistplus/api/bungee/tablist/FakePlayer.java import codecrafter47.bungeetablistplus.api.bungee.Icon; import net.md_5.bungee.api.config.ServerInfo; import java.util.Optional; import java.util.UUID; /* * Copyright (C) 2020 Florian Stober * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package codecrafter47.bungeetablistplus.api.bungee.tablist; /** * Represents a fake player on the tab list. */ public interface FakePlayer { /** * get the username of the player * * @return the username */ String getName(); /** * get the uuid of the player * * @return the uuid of the player */ UUID getUniqueID(); /** * get the server the player is connected to * * @return the server the player is connected to */ Optional<ServerInfo> getServer(); /** * get the ping of the player * * @return the ping */ int getPing(); /** * get the icon displayed on the tab list * * @return the icon */
Icon getIcon();
CodeCrafter47/BungeeTabListPlus
bungee/src/test/java/codecrafter47/bungeetablistplus/eventlog/Transformer.java
// Path: api-bungee/src/main/java/codecrafter47/bungeetablistplus/api/bungee/Icon.java // @Data // public class Icon implements Serializable { // // private static final long serialVersionUID = 1L; // // private final UUID player; // @NonNull // private final String[][] properties; // // /** // * The default icon. The client will show a random Alex/ Steve face when using this. // */ // public static final Icon DEFAULT = new Icon(null, new String[0][]); // }
import codecrafter47.bungeetablistplus.api.bungee.Icon; import lombok.AllArgsConstructor; import lombok.NoArgsConstructor; import net.md_5.bungee.protocol.packet.PlayerListItem; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.UUID; import java.util.stream.Collectors;
/* * Copyright (C) 2020 Florian Stober * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package codecrafter47.bungeetablistplus.eventlog; public class Transformer { private final Map<Properties, String> skinCache = new HashMap<>(); private long nextSkinId = 0; public String wrapProperties(String[][] properties) { return skinCache.computeIfAbsent(new Properties(properties), p -> "Skin-" + (nextSkinId++)); }
// Path: api-bungee/src/main/java/codecrafter47/bungeetablistplus/api/bungee/Icon.java // @Data // public class Icon implements Serializable { // // private static final long serialVersionUID = 1L; // // private final UUID player; // @NonNull // private final String[][] properties; // // /** // * The default icon. The client will show a random Alex/ Steve face when using this. // */ // public static final Icon DEFAULT = new Icon(null, new String[0][]); // } // Path: bungee/src/test/java/codecrafter47/bungeetablistplus/eventlog/Transformer.java import codecrafter47.bungeetablistplus.api.bungee.Icon; import lombok.AllArgsConstructor; import lombok.NoArgsConstructor; import net.md_5.bungee.protocol.packet.PlayerListItem; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.UUID; import java.util.stream.Collectors; /* * Copyright (C) 2020 Florian Stober * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package codecrafter47.bungeetablistplus.eventlog; public class Transformer { private final Map<Properties, String> skinCache = new HashMap<>(); private long nextSkinId = 0; public String wrapProperties(String[][] properties) { return skinCache.computeIfAbsent(new Properties(properties), p -> "Skin-" + (nextSkinId++)); }
public PlayerSkinWrapper wrapPlayerSkin(Icon skin) {
CodeCrafter47/BungeeTabListPlus
example/bukkit/src/main/java/de/codecrafter47/bungeetablistplus/demo/DemoPlugin.java
// Path: api-bukkit/src/main/java/codecrafter47/bungeetablistplus/api/bukkit/BungeeTabListPlusBukkitAPI.java // public abstract class BungeeTabListPlusBukkitAPI { // private static BungeeTabListPlusBukkitAPI instance; // // /** // * Registers a custom variable // * <p> // * You cannot use this to replace existing variables. If registering a variable which already // * exists there may be an exception thrown but there is no guarantee that an exception // * is thrown in that case. // * // * @param plugin your plugin // * @param variable your variable // */ // public static void registerVariable(Plugin plugin, Variable variable) { // Preconditions.checkState(instance != null, "instance is null, is the plugin enabled?"); // instance.registerVariable0(plugin, variable); // } // // protected abstract void registerVariable0(Plugin plugin, Variable variable); // // /** // * Registers a custom per server variable // * <p> // * You cannot use this to replace existing variables. If registering a variable which already // * exists there may be an exception thrown but there is no guarantee that an exception // * is thrown in that case. // * // * @param plugin your plugin // * @param variable your variable // */ // public static void registerVariable(Plugin plugin, ServerVariable variable) { // Preconditions.checkState(instance != null, "instance is null, is the plugin enabled?"); // instance.registerVariable0(plugin, variable); // } // // protected abstract void registerVariable0(Plugin plugin, ServerVariable variable); // // /** // * Unregisters a variable // * // * @param variable the variable // */ // public static void unregisterVariable(Variable variable) { // Preconditions.checkState(instance != null, "instance is null, is the plugin enabled?"); // instance.unregisterVariable0(variable); // } // // protected abstract void unregisterVariable0(Variable variable); // // /** // * Unregisters a variable // * // * @param variable the variable // */ // public static void unregisterVariable(ServerVariable variable) { // Preconditions.checkState(instance != null, "instance is null, is the plugin enabled?"); // instance.unregisterVariable0(variable); // } // // protected abstract void unregisterVariable0(ServerVariable variable); // // /** // * Unregisters all variables registered by the give plugin // * // * @param plugin the plugin // */ // public static void unregisterVariables(Plugin plugin) { // Preconditions.checkState(instance != null, "instance is null, is the plugin enabled?"); // instance.unregisterVariables0(plugin); // } // // protected abstract void unregisterVariables0(Plugin plugin); // }
import codecrafter47.bungeetablistplus.api.bukkit.BungeeTabListPlusBukkitAPI; import org.bukkit.plugin.java.JavaPlugin;
/* * Copyright (C) 2020 Florian Stober * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package de.codecrafter47.bungeetablistplus.demo; public class DemoPlugin extends JavaPlugin { @Override public void onEnable() {
// Path: api-bukkit/src/main/java/codecrafter47/bungeetablistplus/api/bukkit/BungeeTabListPlusBukkitAPI.java // public abstract class BungeeTabListPlusBukkitAPI { // private static BungeeTabListPlusBukkitAPI instance; // // /** // * Registers a custom variable // * <p> // * You cannot use this to replace existing variables. If registering a variable which already // * exists there may be an exception thrown but there is no guarantee that an exception // * is thrown in that case. // * // * @param plugin your plugin // * @param variable your variable // */ // public static void registerVariable(Plugin plugin, Variable variable) { // Preconditions.checkState(instance != null, "instance is null, is the plugin enabled?"); // instance.registerVariable0(plugin, variable); // } // // protected abstract void registerVariable0(Plugin plugin, Variable variable); // // /** // * Registers a custom per server variable // * <p> // * You cannot use this to replace existing variables. If registering a variable which already // * exists there may be an exception thrown but there is no guarantee that an exception // * is thrown in that case. // * // * @param plugin your plugin // * @param variable your variable // */ // public static void registerVariable(Plugin plugin, ServerVariable variable) { // Preconditions.checkState(instance != null, "instance is null, is the plugin enabled?"); // instance.registerVariable0(plugin, variable); // } // // protected abstract void registerVariable0(Plugin plugin, ServerVariable variable); // // /** // * Unregisters a variable // * // * @param variable the variable // */ // public static void unregisterVariable(Variable variable) { // Preconditions.checkState(instance != null, "instance is null, is the plugin enabled?"); // instance.unregisterVariable0(variable); // } // // protected abstract void unregisterVariable0(Variable variable); // // /** // * Unregisters a variable // * // * @param variable the variable // */ // public static void unregisterVariable(ServerVariable variable) { // Preconditions.checkState(instance != null, "instance is null, is the plugin enabled?"); // instance.unregisterVariable0(variable); // } // // protected abstract void unregisterVariable0(ServerVariable variable); // // /** // * Unregisters all variables registered by the give plugin // * // * @param plugin the plugin // */ // public static void unregisterVariables(Plugin plugin) { // Preconditions.checkState(instance != null, "instance is null, is the plugin enabled?"); // instance.unregisterVariables0(plugin); // } // // protected abstract void unregisterVariables0(Plugin plugin); // } // Path: example/bukkit/src/main/java/de/codecrafter47/bungeetablistplus/demo/DemoPlugin.java import codecrafter47.bungeetablistplus.api.bukkit.BungeeTabListPlusBukkitAPI; import org.bukkit.plugin.java.JavaPlugin; /* * Copyright (C) 2020 Florian Stober * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package de.codecrafter47.bungeetablistplus.demo; public class DemoPlugin extends JavaPlugin { @Override public void onEnable() {
BungeeTabListPlusBukkitAPI.registerVariable(this, new TestVariable());
CodeCrafter47/BungeeTabListPlus
bungee/src/test/java/codecrafter47/bungeetablistplus/handler/AbstractLegacyTabOverlayHandlerTest.java
// Path: bungee/src/main/java/codecrafter47/bungeetablistplus/protocol/PacketListenerResult.java // public enum PacketListenerResult { // PASS, MODIFIED, CANCEL; // }
import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.logging.Logger; import static org.junit.Assert.*; import codecrafter47.bungeetablistplus.protocol.PacketListenerResult; import de.codecrafter47.taboverlay.handler.ContentOperationMode; import de.codecrafter47.taboverlay.handler.RectangularTabOverlay; import de.codecrafter47.taboverlay.handler.SimpleTabOverlay; import net.md_5.bungee.api.score.Team; import net.md_5.bungee.protocol.DefinedPacket; import net.md_5.bungee.protocol.packet.PlayerListHeaderFooter; import net.md_5.bungee.protocol.packet.PlayerListItem; import org.junit.After; import org.junit.Before; import org.junit.Test; import java.util.ArrayList;
assertNotNull(t); if (((net.md_5.bungee.protocol.packet.Team) packet).getMode() == 0 || ((net.md_5.bungee.protocol.packet.Team) packet).getMode() == 2) { t.setDisplayName(((net.md_5.bungee.protocol.packet.Team) packet).getDisplayName()); t.setPrefix(((net.md_5.bungee.protocol.packet.Team) packet).getPrefix()); t.setSuffix(((net.md_5.bungee.protocol.packet.Team) packet).getSuffix()); t.setFriendlyFire(((net.md_5.bungee.protocol.packet.Team) packet).getFriendlyFire()); t.setNameTagVisibility(((net.md_5.bungee.protocol.packet.Team) packet).getNameTagVisibility()); t.setCollisionRule(((net.md_5.bungee.protocol.packet.Team) packet).getCollisionRule()); t.setColor(((net.md_5.bungee.protocol.packet.Team) packet).getColor()); } if (((net.md_5.bungee.protocol.packet.Team) packet).getPlayers() != null) { for (String s : ((net.md_5.bungee.protocol.packet.Team) packet).getPlayers()) { if (((net.md_5.bungee.protocol.packet.Team) packet).getMode() == 0 || ((net.md_5.bungee.protocol.packet.Team) packet).getMode() == 3) { if (clientTabList.playerToTeamMap.containsKey(s)) { clientTabList.teams.get(clientTabList.playerToTeamMap.get(s)).removePlayer(s); } t.addPlayer(s); clientTabList.playerToTeamMap.put(s, t.getName()); } else { t.removePlayer(s); assertTrue("Tried to remove player not in team.", clientTabList.playerToTeamMap.remove(s, t.getName())); } } } } } } @Override
// Path: bungee/src/main/java/codecrafter47/bungeetablistplus/protocol/PacketListenerResult.java // public enum PacketListenerResult { // PASS, MODIFIED, CANCEL; // } // Path: bungee/src/test/java/codecrafter47/bungeetablistplus/handler/AbstractLegacyTabOverlayHandlerTest.java import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.logging.Logger; import static org.junit.Assert.*; import codecrafter47.bungeetablistplus.protocol.PacketListenerResult; import de.codecrafter47.taboverlay.handler.ContentOperationMode; import de.codecrafter47.taboverlay.handler.RectangularTabOverlay; import de.codecrafter47.taboverlay.handler.SimpleTabOverlay; import net.md_5.bungee.api.score.Team; import net.md_5.bungee.protocol.DefinedPacket; import net.md_5.bungee.protocol.packet.PlayerListHeaderFooter; import net.md_5.bungee.protocol.packet.PlayerListItem; import org.junit.After; import org.junit.Before; import org.junit.Test; import java.util.ArrayList; assertNotNull(t); if (((net.md_5.bungee.protocol.packet.Team) packet).getMode() == 0 || ((net.md_5.bungee.protocol.packet.Team) packet).getMode() == 2) { t.setDisplayName(((net.md_5.bungee.protocol.packet.Team) packet).getDisplayName()); t.setPrefix(((net.md_5.bungee.protocol.packet.Team) packet).getPrefix()); t.setSuffix(((net.md_5.bungee.protocol.packet.Team) packet).getSuffix()); t.setFriendlyFire(((net.md_5.bungee.protocol.packet.Team) packet).getFriendlyFire()); t.setNameTagVisibility(((net.md_5.bungee.protocol.packet.Team) packet).getNameTagVisibility()); t.setCollisionRule(((net.md_5.bungee.protocol.packet.Team) packet).getCollisionRule()); t.setColor(((net.md_5.bungee.protocol.packet.Team) packet).getColor()); } if (((net.md_5.bungee.protocol.packet.Team) packet).getPlayers() != null) { for (String s : ((net.md_5.bungee.protocol.packet.Team) packet).getPlayers()) { if (((net.md_5.bungee.protocol.packet.Team) packet).getMode() == 0 || ((net.md_5.bungee.protocol.packet.Team) packet).getMode() == 3) { if (clientTabList.playerToTeamMap.containsKey(s)) { clientTabList.teams.get(clientTabList.playerToTeamMap.get(s)).removePlayer(s); } t.addPlayer(s); clientTabList.playerToTeamMap.put(s, t.getName()); } else { t.removePlayer(s); assertTrue("Tried to remove player not in team.", clientTabList.playerToTeamMap.remove(s, t.getName())); } } } } } } @Override
public PacketListenerResult onPlayerListPacket(PlayerListItem packet) {
CodeCrafter47/BungeeTabListPlus
bungee/src/main/java/codecrafter47/bungeetablistplus/tablist/DefaultCustomTablist.java
// Path: bungee/src/main/java/codecrafter47/bungeetablistplus/util/IconUtil.java // @UtilityClass // public class IconUtil { // // public Icon convert(codecrafter47.bungeetablistplus.api.bungee.Icon icon) { // String[][] properties = icon.getProperties(); // if (properties.length == 0) { // return Icon.DEFAULT_STEVE; // } // return new Icon(new ProfileProperty(properties[0][0], properties[0][1], properties[0][2])); // } // // public codecrafter47.bungeetablistplus.api.bungee.Icon convert(Icon icon) { // if (icon.hasTextureProperty()) { // ProfileProperty property = icon.getTextureProperty(); // return new codecrafter47.bungeetablistplus.api.bungee.Icon(null, new String[][]{{property.getName(), property.getValue(), property.getSignature()}}); // } else { // return new codecrafter47.bungeetablistplus.api.bungee.Icon(null, new String[0][]); // } // } // // @Nonnull // public Icon getIconFromPlayer(ProxiedPlayer player) { // LoginResult loginResult = ((UserConnection) player).getPendingConnection().getLoginProfile(); // if (loginResult != null) { // LoginResult.Property[] properties = loginResult.getProperties(); // if (properties != null) { // for (LoginResult.Property s : properties) { // if (s.getName().equals("textures")) { // return new Icon(new ProfileProperty(s.getName(), s.getValue(), s.getSignature())); // } // } // } // } // if ((player.getUniqueId().hashCode() & 1) == 1) { // return Icon.DEFAULT_ALEX; // } else { // return Icon.DEFAULT_STEVE; // } // } // }
import codecrafter47.bungeetablistplus.util.IconUtil; import de.codecrafter47.taboverlay.Icon; import de.codecrafter47.taboverlay.TabOverlayProvider; import de.codecrafter47.taboverlay.TabView; import de.codecrafter47.taboverlay.handler.*; import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet; import it.unimi.dsi.fastutil.objects.ReferenceSet; import static java.lang.Integer.min;
@Override protected void detach(TabView tabView) { handlers.remove(this); } @Override protected void activate(TabView tabView, TabOverlayHandler handler) { synchronized (DefaultCustomTablist.this) { tabOverlay = handler.enterContentOperationMode(ContentOperationMode.SIMPLE); headerAndFooterHandle = handler.enterHeaderAndFooterOperationMode(HeaderAndFooterOperationMode.CUSTOM); int size = min(80, getSize()); tabOverlay.setSize(size); updateAllSlots(); headerAndFooterHandle.setHeaderFooter(getHeader(), getFooter()); } } @Override protected void deactivate(TabView tabView) { } @Override protected boolean shouldActivate(TabView tabView) { return true; } private void updateAllSlots() { for (int column = 0; column < getColumns(); column++) { for (int row = 0; row < getRows(); row++) {
// Path: bungee/src/main/java/codecrafter47/bungeetablistplus/util/IconUtil.java // @UtilityClass // public class IconUtil { // // public Icon convert(codecrafter47.bungeetablistplus.api.bungee.Icon icon) { // String[][] properties = icon.getProperties(); // if (properties.length == 0) { // return Icon.DEFAULT_STEVE; // } // return new Icon(new ProfileProperty(properties[0][0], properties[0][1], properties[0][2])); // } // // public codecrafter47.bungeetablistplus.api.bungee.Icon convert(Icon icon) { // if (icon.hasTextureProperty()) { // ProfileProperty property = icon.getTextureProperty(); // return new codecrafter47.bungeetablistplus.api.bungee.Icon(null, new String[][]{{property.getName(), property.getValue(), property.getSignature()}}); // } else { // return new codecrafter47.bungeetablistplus.api.bungee.Icon(null, new String[0][]); // } // } // // @Nonnull // public Icon getIconFromPlayer(ProxiedPlayer player) { // LoginResult loginResult = ((UserConnection) player).getPendingConnection().getLoginProfile(); // if (loginResult != null) { // LoginResult.Property[] properties = loginResult.getProperties(); // if (properties != null) { // for (LoginResult.Property s : properties) { // if (s.getName().equals("textures")) { // return new Icon(new ProfileProperty(s.getName(), s.getValue(), s.getSignature())); // } // } // } // } // if ((player.getUniqueId().hashCode() & 1) == 1) { // return Icon.DEFAULT_ALEX; // } else { // return Icon.DEFAULT_STEVE; // } // } // } // Path: bungee/src/main/java/codecrafter47/bungeetablistplus/tablist/DefaultCustomTablist.java import codecrafter47.bungeetablistplus.util.IconUtil; import de.codecrafter47.taboverlay.Icon; import de.codecrafter47.taboverlay.TabOverlayProvider; import de.codecrafter47.taboverlay.TabView; import de.codecrafter47.taboverlay.handler.*; import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet; import it.unimi.dsi.fastutil.objects.ReferenceSet; import static java.lang.Integer.min; @Override protected void detach(TabView tabView) { handlers.remove(this); } @Override protected void activate(TabView tabView, TabOverlayHandler handler) { synchronized (DefaultCustomTablist.this) { tabOverlay = handler.enterContentOperationMode(ContentOperationMode.SIMPLE); headerAndFooterHandle = handler.enterHeaderAndFooterOperationMode(HeaderAndFooterOperationMode.CUSTOM); int size = min(80, getSize()); tabOverlay.setSize(size); updateAllSlots(); headerAndFooterHandle.setHeaderFooter(getHeader(), getFooter()); } } @Override protected void deactivate(TabView tabView) { } @Override protected boolean shouldActivate(TabView tabView) { return true; } private void updateAllSlots() { for (int column = 0; column < getColumns(); column++) { for (int row = 0; row < getRows(); row++) {
Icon icon = IconUtil.convert(getIcon(row, column));
CodeCrafter47/BungeeTabListPlus
bungee/src/main/java/codecrafter47/bungeetablistplus/handler/RewriteLogic.java
// Path: bungee/src/main/java/codecrafter47/bungeetablistplus/protocol/AbstractPacketHandler.java // public abstract class AbstractPacketHandler implements PacketHandler { // // private final PacketHandler parent; // // public AbstractPacketHandler(@Nonnull @NonNull PacketHandler parent) { // this.parent = parent; // } // // @Override // public PacketListenerResult onPlayerListPacket(PlayerListItem packet) { // return parent.onPlayerListPacket(packet); // } // // @Override // public PacketListenerResult onTeamPacket(Team packet) { // return parent.onTeamPacket(packet); // } // // @Override // public PacketListenerResult onPlayerListHeaderFooterPacket(PlayerListHeaderFooter packet) { // return parent.onPlayerListHeaderFooterPacket(packet); // } // // @Override // public void onServerSwitch(boolean is13OrLater) { // parent.onServerSwitch(is13OrLater); // } // } // // Path: bungee/src/main/java/codecrafter47/bungeetablistplus/protocol/PacketHandler.java // public interface PacketHandler { // // PacketListenerResult onPlayerListPacket(PlayerListItem packet); // // PacketListenerResult onTeamPacket(Team packet); // // PacketListenerResult onPlayerListHeaderFooterPacket(PlayerListHeaderFooter packet); // // void onServerSwitch(boolean is13OrLater); // } // // Path: bungee/src/main/java/codecrafter47/bungeetablistplus/protocol/PacketListenerResult.java // public enum PacketListenerResult { // PASS, MODIFIED, CANCEL; // }
import codecrafter47.bungeetablistplus.protocol.AbstractPacketHandler; import codecrafter47.bungeetablistplus.protocol.PacketHandler; import codecrafter47.bungeetablistplus.protocol.PacketListenerResult; import com.google.common.base.MoreObjects; import net.md_5.bungee.BungeeCord; import net.md_5.bungee.UserConnection; import net.md_5.bungee.connection.LoginResult; import net.md_5.bungee.protocol.packet.PlayerListItem; import java.util.HashMap; import java.util.Map; import java.util.UUID;
/* * Copyright (C) 2020 Florian Stober * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package codecrafter47.bungeetablistplus.handler; public class RewriteLogic extends AbstractPacketHandler { private final Map<UUID, UUID> rewriteMap = new HashMap<>();
// Path: bungee/src/main/java/codecrafter47/bungeetablistplus/protocol/AbstractPacketHandler.java // public abstract class AbstractPacketHandler implements PacketHandler { // // private final PacketHandler parent; // // public AbstractPacketHandler(@Nonnull @NonNull PacketHandler parent) { // this.parent = parent; // } // // @Override // public PacketListenerResult onPlayerListPacket(PlayerListItem packet) { // return parent.onPlayerListPacket(packet); // } // // @Override // public PacketListenerResult onTeamPacket(Team packet) { // return parent.onTeamPacket(packet); // } // // @Override // public PacketListenerResult onPlayerListHeaderFooterPacket(PlayerListHeaderFooter packet) { // return parent.onPlayerListHeaderFooterPacket(packet); // } // // @Override // public void onServerSwitch(boolean is13OrLater) { // parent.onServerSwitch(is13OrLater); // } // } // // Path: bungee/src/main/java/codecrafter47/bungeetablistplus/protocol/PacketHandler.java // public interface PacketHandler { // // PacketListenerResult onPlayerListPacket(PlayerListItem packet); // // PacketListenerResult onTeamPacket(Team packet); // // PacketListenerResult onPlayerListHeaderFooterPacket(PlayerListHeaderFooter packet); // // void onServerSwitch(boolean is13OrLater); // } // // Path: bungee/src/main/java/codecrafter47/bungeetablistplus/protocol/PacketListenerResult.java // public enum PacketListenerResult { // PASS, MODIFIED, CANCEL; // } // Path: bungee/src/main/java/codecrafter47/bungeetablistplus/handler/RewriteLogic.java import codecrafter47.bungeetablistplus.protocol.AbstractPacketHandler; import codecrafter47.bungeetablistplus.protocol.PacketHandler; import codecrafter47.bungeetablistplus.protocol.PacketListenerResult; import com.google.common.base.MoreObjects; import net.md_5.bungee.BungeeCord; import net.md_5.bungee.UserConnection; import net.md_5.bungee.connection.LoginResult; import net.md_5.bungee.protocol.packet.PlayerListItem; import java.util.HashMap; import java.util.Map; import java.util.UUID; /* * Copyright (C) 2020 Florian Stober * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package codecrafter47.bungeetablistplus.handler; public class RewriteLogic extends AbstractPacketHandler { private final Map<UUID, UUID> rewriteMap = new HashMap<>();
public RewriteLogic(PacketHandler parent) {
CodeCrafter47/BungeeTabListPlus
bungee/src/main/java/codecrafter47/bungeetablistplus/handler/RewriteLogic.java
// Path: bungee/src/main/java/codecrafter47/bungeetablistplus/protocol/AbstractPacketHandler.java // public abstract class AbstractPacketHandler implements PacketHandler { // // private final PacketHandler parent; // // public AbstractPacketHandler(@Nonnull @NonNull PacketHandler parent) { // this.parent = parent; // } // // @Override // public PacketListenerResult onPlayerListPacket(PlayerListItem packet) { // return parent.onPlayerListPacket(packet); // } // // @Override // public PacketListenerResult onTeamPacket(Team packet) { // return parent.onTeamPacket(packet); // } // // @Override // public PacketListenerResult onPlayerListHeaderFooterPacket(PlayerListHeaderFooter packet) { // return parent.onPlayerListHeaderFooterPacket(packet); // } // // @Override // public void onServerSwitch(boolean is13OrLater) { // parent.onServerSwitch(is13OrLater); // } // } // // Path: bungee/src/main/java/codecrafter47/bungeetablistplus/protocol/PacketHandler.java // public interface PacketHandler { // // PacketListenerResult onPlayerListPacket(PlayerListItem packet); // // PacketListenerResult onTeamPacket(Team packet); // // PacketListenerResult onPlayerListHeaderFooterPacket(PlayerListHeaderFooter packet); // // void onServerSwitch(boolean is13OrLater); // } // // Path: bungee/src/main/java/codecrafter47/bungeetablistplus/protocol/PacketListenerResult.java // public enum PacketListenerResult { // PASS, MODIFIED, CANCEL; // }
import codecrafter47.bungeetablistplus.protocol.AbstractPacketHandler; import codecrafter47.bungeetablistplus.protocol.PacketHandler; import codecrafter47.bungeetablistplus.protocol.PacketListenerResult; import com.google.common.base.MoreObjects; import net.md_5.bungee.BungeeCord; import net.md_5.bungee.UserConnection; import net.md_5.bungee.connection.LoginResult; import net.md_5.bungee.protocol.packet.PlayerListItem; import java.util.HashMap; import java.util.Map; import java.util.UUID;
/* * Copyright (C) 2020 Florian Stober * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package codecrafter47.bungeetablistplus.handler; public class RewriteLogic extends AbstractPacketHandler { private final Map<UUID, UUID> rewriteMap = new HashMap<>(); public RewriteLogic(PacketHandler parent) { super(parent); } @Override
// Path: bungee/src/main/java/codecrafter47/bungeetablistplus/protocol/AbstractPacketHandler.java // public abstract class AbstractPacketHandler implements PacketHandler { // // private final PacketHandler parent; // // public AbstractPacketHandler(@Nonnull @NonNull PacketHandler parent) { // this.parent = parent; // } // // @Override // public PacketListenerResult onPlayerListPacket(PlayerListItem packet) { // return parent.onPlayerListPacket(packet); // } // // @Override // public PacketListenerResult onTeamPacket(Team packet) { // return parent.onTeamPacket(packet); // } // // @Override // public PacketListenerResult onPlayerListHeaderFooterPacket(PlayerListHeaderFooter packet) { // return parent.onPlayerListHeaderFooterPacket(packet); // } // // @Override // public void onServerSwitch(boolean is13OrLater) { // parent.onServerSwitch(is13OrLater); // } // } // // Path: bungee/src/main/java/codecrafter47/bungeetablistplus/protocol/PacketHandler.java // public interface PacketHandler { // // PacketListenerResult onPlayerListPacket(PlayerListItem packet); // // PacketListenerResult onTeamPacket(Team packet); // // PacketListenerResult onPlayerListHeaderFooterPacket(PlayerListHeaderFooter packet); // // void onServerSwitch(boolean is13OrLater); // } // // Path: bungee/src/main/java/codecrafter47/bungeetablistplus/protocol/PacketListenerResult.java // public enum PacketListenerResult { // PASS, MODIFIED, CANCEL; // } // Path: bungee/src/main/java/codecrafter47/bungeetablistplus/handler/RewriteLogic.java import codecrafter47.bungeetablistplus.protocol.AbstractPacketHandler; import codecrafter47.bungeetablistplus.protocol.PacketHandler; import codecrafter47.bungeetablistplus.protocol.PacketListenerResult; import com.google.common.base.MoreObjects; import net.md_5.bungee.BungeeCord; import net.md_5.bungee.UserConnection; import net.md_5.bungee.connection.LoginResult; import net.md_5.bungee.protocol.packet.PlayerListItem; import java.util.HashMap; import java.util.Map; import java.util.UUID; /* * Copyright (C) 2020 Florian Stober * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package codecrafter47.bungeetablistplus.handler; public class RewriteLogic extends AbstractPacketHandler { private final Map<UUID, UUID> rewriteMap = new HashMap<>(); public RewriteLogic(PacketHandler parent) { super(parent); } @Override
public PacketListenerResult onPlayerListPacket(PlayerListItem packet) {
CodeCrafter47/BungeeTabListPlus
bukkit/src/main/java/codecrafter47/bungeetablistplus/bukkitbridge/placeholderapi/PlaceholderAPIDataAccess.java
// Path: common/src/main/java/codecrafter47/bungeetablistplus/common/BTLPDataKeys.java // public final class BTLPDataKeys implements DataKeyCatalogue { // // public static final DataKey<String> PAPIPlaceholder = new DataKey<>("btlp:placeholderAPI", MinecraftData.SCOPE_PLAYER, TypeToken.STRING); // public static final DataKey<List<String>> PAPI_REGISTERED_PLACEHOLDER_PLUGINS = new DataKey<>("btlp:placeholderAPI:plugins", MinecraftData.SCOPE_SERVER, TypeToken.STRING_LIST); // // public static DataKey<String> createPlaceholderAPIDataKey(String placeholder) { // return PAPIPlaceholder.withParameter(placeholder); // } // // public static final DataKey<String> ThirdPartyPlaceholder = new DataKey<>("btlp:thirdPartyPlaceholder", MinecraftData.SCOPE_PLAYER, TypeToken.STRING); // // public static DataKey<String> createThirdPartyVariableDataKey(String name) { // return ThirdPartyPlaceholder.withParameter(name); // } // // public static final DataKey<String> ThirdPartyServerPlaceholder = new DataKey<>("btlp:thirdPartyServerPlaceholder", MinecraftData.SCOPE_SERVER, TypeToken.STRING); // // public static DataKey<String> createThirdPartyServerVariableDataKey(String name) { // return ThirdPartyServerPlaceholder.withParameter(name); // } // // public final static DataKey<List<String>> REGISTERED_THIRD_PARTY_VARIABLES = new DataKey<>("thirdparty-variables", MinecraftData.SCOPE_SERVER, TypeToken.STRING_LIST); // // public final static DataKey<List<String>> REGISTERED_THIRD_PARTY_SERVER_VARIABLES = new DataKey<>("thirdparty-server-variables", MinecraftData.SCOPE_SERVER, TypeToken.STRING_LIST); // // public final static DataKey<Boolean> PLACEHOLDERAPI_PRESENT = new DataKey<>("placeholderapi-present", MinecraftData.SCOPE_SERVER, TypeToken.BOOLEAN); // }
import codecrafter47.bungeetablistplus.common.BTLPDataKeys; import de.codecrafter47.data.bukkit.AbstractBukkitDataAccess; import me.clip.placeholderapi.PlaceholderAPI; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; import java.util.logging.Level; import java.util.logging.Logger;
/* * Copyright (C) 2020 Florian Stober * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package codecrafter47.bungeetablistplus.bukkitbridge.placeholderapi; public class PlaceholderAPIDataAccess extends AbstractBukkitDataAccess<Player> { public PlaceholderAPIDataAccess(Logger logger, Plugin plugin) { super(logger, plugin);
// Path: common/src/main/java/codecrafter47/bungeetablistplus/common/BTLPDataKeys.java // public final class BTLPDataKeys implements DataKeyCatalogue { // // public static final DataKey<String> PAPIPlaceholder = new DataKey<>("btlp:placeholderAPI", MinecraftData.SCOPE_PLAYER, TypeToken.STRING); // public static final DataKey<List<String>> PAPI_REGISTERED_PLACEHOLDER_PLUGINS = new DataKey<>("btlp:placeholderAPI:plugins", MinecraftData.SCOPE_SERVER, TypeToken.STRING_LIST); // // public static DataKey<String> createPlaceholderAPIDataKey(String placeholder) { // return PAPIPlaceholder.withParameter(placeholder); // } // // public static final DataKey<String> ThirdPartyPlaceholder = new DataKey<>("btlp:thirdPartyPlaceholder", MinecraftData.SCOPE_PLAYER, TypeToken.STRING); // // public static DataKey<String> createThirdPartyVariableDataKey(String name) { // return ThirdPartyPlaceholder.withParameter(name); // } // // public static final DataKey<String> ThirdPartyServerPlaceholder = new DataKey<>("btlp:thirdPartyServerPlaceholder", MinecraftData.SCOPE_SERVER, TypeToken.STRING); // // public static DataKey<String> createThirdPartyServerVariableDataKey(String name) { // return ThirdPartyServerPlaceholder.withParameter(name); // } // // public final static DataKey<List<String>> REGISTERED_THIRD_PARTY_VARIABLES = new DataKey<>("thirdparty-variables", MinecraftData.SCOPE_SERVER, TypeToken.STRING_LIST); // // public final static DataKey<List<String>> REGISTERED_THIRD_PARTY_SERVER_VARIABLES = new DataKey<>("thirdparty-server-variables", MinecraftData.SCOPE_SERVER, TypeToken.STRING_LIST); // // public final static DataKey<Boolean> PLACEHOLDERAPI_PRESENT = new DataKey<>("placeholderapi-present", MinecraftData.SCOPE_SERVER, TypeToken.BOOLEAN); // } // Path: bukkit/src/main/java/codecrafter47/bungeetablistplus/bukkitbridge/placeholderapi/PlaceholderAPIDataAccess.java import codecrafter47.bungeetablistplus.common.BTLPDataKeys; import de.codecrafter47.data.bukkit.AbstractBukkitDataAccess; import me.clip.placeholderapi.PlaceholderAPI; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; import java.util.logging.Level; import java.util.logging.Logger; /* * Copyright (C) 2020 Florian Stober * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package codecrafter47.bungeetablistplus.bukkitbridge.placeholderapi; public class PlaceholderAPIDataAccess extends AbstractBukkitDataAccess<Player> { public PlaceholderAPIDataAccess(Logger logger, Plugin plugin) { super(logger, plugin);
addProvider(BTLPDataKeys.PAPIPlaceholder, (player, key) -> {
CodeCrafter47/BungeeTabListPlus
sponge/src/main/java/codecrafter47/bungeetablistplus/spongebridge/placeholderapi/PlaceholderAPIDataAccess.java
// Path: common/src/main/java/codecrafter47/bungeetablistplus/common/BTLPDataKeys.java // public final class BTLPDataKeys implements DataKeyCatalogue { // // public static final DataKey<String> PAPIPlaceholder = new DataKey<>("btlp:placeholderAPI", MinecraftData.SCOPE_PLAYER, TypeToken.STRING); // public static final DataKey<List<String>> PAPI_REGISTERED_PLACEHOLDER_PLUGINS = new DataKey<>("btlp:placeholderAPI:plugins", MinecraftData.SCOPE_SERVER, TypeToken.STRING_LIST); // // public static DataKey<String> createPlaceholderAPIDataKey(String placeholder) { // return PAPIPlaceholder.withParameter(placeholder); // } // // public static final DataKey<String> ThirdPartyPlaceholder = new DataKey<>("btlp:thirdPartyPlaceholder", MinecraftData.SCOPE_PLAYER, TypeToken.STRING); // // public static DataKey<String> createThirdPartyVariableDataKey(String name) { // return ThirdPartyPlaceholder.withParameter(name); // } // // public static final DataKey<String> ThirdPartyServerPlaceholder = new DataKey<>("btlp:thirdPartyServerPlaceholder", MinecraftData.SCOPE_SERVER, TypeToken.STRING); // // public static DataKey<String> createThirdPartyServerVariableDataKey(String name) { // return ThirdPartyServerPlaceholder.withParameter(name); // } // // public final static DataKey<List<String>> REGISTERED_THIRD_PARTY_VARIABLES = new DataKey<>("thirdparty-variables", MinecraftData.SCOPE_SERVER, TypeToken.STRING_LIST); // // public final static DataKey<List<String>> REGISTERED_THIRD_PARTY_SERVER_VARIABLES = new DataKey<>("thirdparty-server-variables", MinecraftData.SCOPE_SERVER, TypeToken.STRING_LIST); // // public final static DataKey<Boolean> PLACEHOLDERAPI_PRESENT = new DataKey<>("placeholderapi-present", MinecraftData.SCOPE_SERVER, TypeToken.BOOLEAN); // }
import codecrafter47.bungeetablistplus.common.BTLPDataKeys; import de.codecrafter47.data.sponge.AbstractSpongeDataAccess; import me.rojo8399.placeholderapi.PlaceholderService; import org.slf4j.Logger; import org.spongepowered.api.Sponge; import org.spongepowered.api.entity.living.player.Player; import org.spongepowered.api.text.Text; import org.spongepowered.api.text.serializer.TextSerializers;
/* * Copyright (C) 2020 Florian Stober * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package codecrafter47.bungeetablistplus.spongebridge.placeholderapi; public class PlaceholderAPIDataAccess extends AbstractSpongeDataAccess<Player> { public PlaceholderAPIDataAccess(Logger logger) { super(logger);
// Path: common/src/main/java/codecrafter47/bungeetablistplus/common/BTLPDataKeys.java // public final class BTLPDataKeys implements DataKeyCatalogue { // // public static final DataKey<String> PAPIPlaceholder = new DataKey<>("btlp:placeholderAPI", MinecraftData.SCOPE_PLAYER, TypeToken.STRING); // public static final DataKey<List<String>> PAPI_REGISTERED_PLACEHOLDER_PLUGINS = new DataKey<>("btlp:placeholderAPI:plugins", MinecraftData.SCOPE_SERVER, TypeToken.STRING_LIST); // // public static DataKey<String> createPlaceholderAPIDataKey(String placeholder) { // return PAPIPlaceholder.withParameter(placeholder); // } // // public static final DataKey<String> ThirdPartyPlaceholder = new DataKey<>("btlp:thirdPartyPlaceholder", MinecraftData.SCOPE_PLAYER, TypeToken.STRING); // // public static DataKey<String> createThirdPartyVariableDataKey(String name) { // return ThirdPartyPlaceholder.withParameter(name); // } // // public static final DataKey<String> ThirdPartyServerPlaceholder = new DataKey<>("btlp:thirdPartyServerPlaceholder", MinecraftData.SCOPE_SERVER, TypeToken.STRING); // // public static DataKey<String> createThirdPartyServerVariableDataKey(String name) { // return ThirdPartyServerPlaceholder.withParameter(name); // } // // public final static DataKey<List<String>> REGISTERED_THIRD_PARTY_VARIABLES = new DataKey<>("thirdparty-variables", MinecraftData.SCOPE_SERVER, TypeToken.STRING_LIST); // // public final static DataKey<List<String>> REGISTERED_THIRD_PARTY_SERVER_VARIABLES = new DataKey<>("thirdparty-server-variables", MinecraftData.SCOPE_SERVER, TypeToken.STRING_LIST); // // public final static DataKey<Boolean> PLACEHOLDERAPI_PRESENT = new DataKey<>("placeholderapi-present", MinecraftData.SCOPE_SERVER, TypeToken.BOOLEAN); // } // Path: sponge/src/main/java/codecrafter47/bungeetablistplus/spongebridge/placeholderapi/PlaceholderAPIDataAccess.java import codecrafter47.bungeetablistplus.common.BTLPDataKeys; import de.codecrafter47.data.sponge.AbstractSpongeDataAccess; import me.rojo8399.placeholderapi.PlaceholderService; import org.slf4j.Logger; import org.spongepowered.api.Sponge; import org.spongepowered.api.entity.living.player.Player; import org.spongepowered.api.text.Text; import org.spongepowered.api.text.serializer.TextSerializers; /* * Copyright (C) 2020 Florian Stober * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package codecrafter47.bungeetablistplus.spongebridge.placeholderapi; public class PlaceholderAPIDataAccess extends AbstractSpongeDataAccess<Player> { public PlaceholderAPIDataAccess(Logger logger) { super(logger);
addProvider(BTLPDataKeys.PAPIPlaceholder, (player, key) -> {
CodeCrafter47/BungeeTabListPlus
bungee/src/main/java/codecrafter47/bungeetablistplus/handler/LowMemoryTabOverlayHandlerImpl.java
// Path: bungee/src/main/java/codecrafter47/bungeetablistplus/protocol/PacketListenerResult.java // public enum PacketListenerResult { // PASS, MODIFIED, CANCEL; // } // // Path: waterfall_compat/src/main/java/de/codecrafter47/bungeetablistplus/bungee/compat/WaterfallCompat.java // public class WaterfallCompat { // // public static boolean isDisableEntityMetadataRewrite() { // if ("Waterfall".equals(ProxyServer.getInstance().getName())) { // return ProxyServer.getInstance().getConfig().isDisableEntityMetadataRewrite(); // } else { // return false; // } // } // }
import codecrafter47.bungeetablistplus.protocol.PacketListenerResult; import de.codecrafter47.bungeetablistplus.bungee.compat.WaterfallCompat; import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.protocol.packet.Team; import java.util.UUID; import java.util.concurrent.Executor; import java.util.logging.Logger;
/* * Copyright (C) 2020 Florian Stober * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package codecrafter47.bungeetablistplus.handler; /** * Dirty hack to reduce memory usage of the plugin. Should be removed as soon as * the underlying problem is fixed in BungeeCord. */ public class LowMemoryTabOverlayHandlerImpl extends TabOverlayHandlerImpl { public LowMemoryTabOverlayHandlerImpl(Logger logger, Executor eventLoopExecutor, UUID viewerUuid, ProxiedPlayer player, boolean is18, boolean has113OrLater) { super(logger, eventLoopExecutor, viewerUuid, player, is18, has113OrLater); } @Override
// Path: bungee/src/main/java/codecrafter47/bungeetablistplus/protocol/PacketListenerResult.java // public enum PacketListenerResult { // PASS, MODIFIED, CANCEL; // } // // Path: waterfall_compat/src/main/java/de/codecrafter47/bungeetablistplus/bungee/compat/WaterfallCompat.java // public class WaterfallCompat { // // public static boolean isDisableEntityMetadataRewrite() { // if ("Waterfall".equals(ProxyServer.getInstance().getName())) { // return ProxyServer.getInstance().getConfig().isDisableEntityMetadataRewrite(); // } else { // return false; // } // } // } // Path: bungee/src/main/java/codecrafter47/bungeetablistplus/handler/LowMemoryTabOverlayHandlerImpl.java import codecrafter47.bungeetablistplus.protocol.PacketListenerResult; import de.codecrafter47.bungeetablistplus.bungee.compat.WaterfallCompat; import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.protocol.packet.Team; import java.util.UUID; import java.util.concurrent.Executor; import java.util.logging.Logger; /* * Copyright (C) 2020 Florian Stober * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package codecrafter47.bungeetablistplus.handler; /** * Dirty hack to reduce memory usage of the plugin. Should be removed as soon as * the underlying problem is fixed in BungeeCord. */ public class LowMemoryTabOverlayHandlerImpl extends TabOverlayHandlerImpl { public LowMemoryTabOverlayHandlerImpl(Logger logger, Executor eventLoopExecutor, UUID viewerUuid, ProxiedPlayer player, boolean is18, boolean has113OrLater) { super(logger, eventLoopExecutor, viewerUuid, player, is18, has113OrLater); } @Override
public PacketListenerResult onTeamPacket(Team packet) {
CodeCrafter47/BungeeTabListPlus
bungee/src/main/java/codecrafter47/bungeetablistplus/handler/LowMemoryTabOverlayHandlerImpl.java
// Path: bungee/src/main/java/codecrafter47/bungeetablistplus/protocol/PacketListenerResult.java // public enum PacketListenerResult { // PASS, MODIFIED, CANCEL; // } // // Path: waterfall_compat/src/main/java/de/codecrafter47/bungeetablistplus/bungee/compat/WaterfallCompat.java // public class WaterfallCompat { // // public static boolean isDisableEntityMetadataRewrite() { // if ("Waterfall".equals(ProxyServer.getInstance().getName())) { // return ProxyServer.getInstance().getConfig().isDisableEntityMetadataRewrite(); // } else { // return false; // } // } // }
import codecrafter47.bungeetablistplus.protocol.PacketListenerResult; import de.codecrafter47.bungeetablistplus.bungee.compat.WaterfallCompat; import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.protocol.packet.Team; import java.util.UUID; import java.util.concurrent.Executor; import java.util.logging.Logger;
/* * Copyright (C) 2020 Florian Stober * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package codecrafter47.bungeetablistplus.handler; /** * Dirty hack to reduce memory usage of the plugin. Should be removed as soon as * the underlying problem is fixed in BungeeCord. */ public class LowMemoryTabOverlayHandlerImpl extends TabOverlayHandlerImpl { public LowMemoryTabOverlayHandlerImpl(Logger logger, Executor eventLoopExecutor, UUID viewerUuid, ProxiedPlayer player, boolean is18, boolean has113OrLater) { super(logger, eventLoopExecutor, viewerUuid, player, is18, has113OrLater); } @Override public PacketListenerResult onTeamPacket(Team packet) { if (super.onTeamPacket(packet) != PacketListenerResult.CANCEL) { sendPacket(packet); } return PacketListenerResult.CANCEL; } @Override public void onServerSwitch(boolean is13OrLater) {
// Path: bungee/src/main/java/codecrafter47/bungeetablistplus/protocol/PacketListenerResult.java // public enum PacketListenerResult { // PASS, MODIFIED, CANCEL; // } // // Path: waterfall_compat/src/main/java/de/codecrafter47/bungeetablistplus/bungee/compat/WaterfallCompat.java // public class WaterfallCompat { // // public static boolean isDisableEntityMetadataRewrite() { // if ("Waterfall".equals(ProxyServer.getInstance().getName())) { // return ProxyServer.getInstance().getConfig().isDisableEntityMetadataRewrite(); // } else { // return false; // } // } // } // Path: bungee/src/main/java/codecrafter47/bungeetablistplus/handler/LowMemoryTabOverlayHandlerImpl.java import codecrafter47.bungeetablistplus.protocol.PacketListenerResult; import de.codecrafter47.bungeetablistplus.bungee.compat.WaterfallCompat; import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.protocol.packet.Team; import java.util.UUID; import java.util.concurrent.Executor; import java.util.logging.Logger; /* * Copyright (C) 2020 Florian Stober * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package codecrafter47.bungeetablistplus.handler; /** * Dirty hack to reduce memory usage of the plugin. Should be removed as soon as * the underlying problem is fixed in BungeeCord. */ public class LowMemoryTabOverlayHandlerImpl extends TabOverlayHandlerImpl { public LowMemoryTabOverlayHandlerImpl(Logger logger, Executor eventLoopExecutor, UUID viewerUuid, ProxiedPlayer player, boolean is18, boolean has113OrLater) { super(logger, eventLoopExecutor, viewerUuid, player, is18, has113OrLater); } @Override public PacketListenerResult onTeamPacket(Team packet) { if (super.onTeamPacket(packet) != PacketListenerResult.CANCEL) { sendPacket(packet); } return PacketListenerResult.CANCEL; } @Override public void onServerSwitch(boolean is13OrLater) {
if (!WaterfallCompat.isDisableEntityMetadataRewrite()) {
growbit/turbogwt-http
src/main/java/org/turbogwt/net/serialization/client/json/JsonSerdes.java
// Path: src/main/java/org/turbogwt/net/serialization/client/DeserializationContext.java // public abstract class DeserializationContext { // // private final ContainerFactoryManager containerFactoryManager; // // public DeserializationContext(ContainerFactoryManager containerFactoryManager) { // this.containerFactoryManager = containerFactoryManager; // } // // public <C extends Collection> C getContainerInstance(Class<C> type) { // final Factory<C> factory = containerFactoryManager.getFactory(type); // if (factory == null) // throw new UnableToDeserializeException("Could not get container instance because there's no factory " + // "registered in the requestor."); // return factory.get(); // } // // protected ContainerFactoryManager getContainerFactoryManager() { // return containerFactoryManager; // } // } // // Path: src/main/java/org/turbogwt/net/serialization/client/Serdes.java // public interface Serdes<T> extends Deserializer<T>, Serializer<T> { // // /** // * Method for accessing type of the Object this de/serializer can handle. // * // * @return The class which this de/serializer can de/serialize // */ // @Override // Class<T> handledType(); // } // // Path: src/main/java/org/turbogwt/net/serialization/client/SerializationContext.java // public abstract class SerializationContext { // } // // Path: src/main/java/org/turbogwt/net/serialization/client/UnableToDeserializeException.java // public class UnableToDeserializeException extends SerializationException { // // public UnableToDeserializeException() { // } // // public UnableToDeserializeException(String s) { // super(s); // } // // public UnableToDeserializeException(String s, Throwable throwable) { // super(s, throwable); // } // }
import java.util.Collection; import org.turbogwt.net.serialization.client.DeserializationContext; import org.turbogwt.net.serialization.client.Serdes; import org.turbogwt.net.serialization.client.SerializationContext; import org.turbogwt.net.serialization.client.UnableToDeserializeException;
/* * Copyright 2014 Grow Bit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.turbogwt.net.serialization.client.json; /** * Base class for all SerDes that manipulates serialized JSON. * * @param <T> Type of the object to be serialized/deserialized * * @author Danilo Reinert */ public abstract class JsonSerdes<T> implements Serdes<T> { public static String[] ACCEPT_PATTERNS = new String[] { "application/json", "application/javascript" }; public static String[] CONTENT_TYPE_PATTERNS = new String[] { "application/json", "application/javascript" }; private final Class<T> handledType; protected JsonSerdes(Class<T> handledType) { this.handledType = handledType; } @Override public Class<T> handledType() { return handledType; } @Override public String[] accept() { return ACCEPT_PATTERNS; } @Override public String[] contentType() { return CONTENT_TYPE_PATTERNS; } /** * Given a collection class, returns a new instance of it. * * @param collectionType The class of the collection. * @param <C> The type of the collection. * * @return A new instance to the collection. */
// Path: src/main/java/org/turbogwt/net/serialization/client/DeserializationContext.java // public abstract class DeserializationContext { // // private final ContainerFactoryManager containerFactoryManager; // // public DeserializationContext(ContainerFactoryManager containerFactoryManager) { // this.containerFactoryManager = containerFactoryManager; // } // // public <C extends Collection> C getContainerInstance(Class<C> type) { // final Factory<C> factory = containerFactoryManager.getFactory(type); // if (factory == null) // throw new UnableToDeserializeException("Could not get container instance because there's no factory " + // "registered in the requestor."); // return factory.get(); // } // // protected ContainerFactoryManager getContainerFactoryManager() { // return containerFactoryManager; // } // } // // Path: src/main/java/org/turbogwt/net/serialization/client/Serdes.java // public interface Serdes<T> extends Deserializer<T>, Serializer<T> { // // /** // * Method for accessing type of the Object this de/serializer can handle. // * // * @return The class which this de/serializer can de/serialize // */ // @Override // Class<T> handledType(); // } // // Path: src/main/java/org/turbogwt/net/serialization/client/SerializationContext.java // public abstract class SerializationContext { // } // // Path: src/main/java/org/turbogwt/net/serialization/client/UnableToDeserializeException.java // public class UnableToDeserializeException extends SerializationException { // // public UnableToDeserializeException() { // } // // public UnableToDeserializeException(String s) { // super(s); // } // // public UnableToDeserializeException(String s, Throwable throwable) { // super(s, throwable); // } // } // Path: src/main/java/org/turbogwt/net/serialization/client/json/JsonSerdes.java import java.util.Collection; import org.turbogwt.net.serialization.client.DeserializationContext; import org.turbogwt.net.serialization.client.Serdes; import org.turbogwt.net.serialization.client.SerializationContext; import org.turbogwt.net.serialization.client.UnableToDeserializeException; /* * Copyright 2014 Grow Bit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.turbogwt.net.serialization.client.json; /** * Base class for all SerDes that manipulates serialized JSON. * * @param <T> Type of the object to be serialized/deserialized * * @author Danilo Reinert */ public abstract class JsonSerdes<T> implements Serdes<T> { public static String[] ACCEPT_PATTERNS = new String[] { "application/json", "application/javascript" }; public static String[] CONTENT_TYPE_PATTERNS = new String[] { "application/json", "application/javascript" }; private final Class<T> handledType; protected JsonSerdes(Class<T> handledType) { this.handledType = handledType; } @Override public Class<T> handledType() { return handledType; } @Override public String[] accept() { return ACCEPT_PATTERNS; } @Override public String[] contentType() { return CONTENT_TYPE_PATTERNS; } /** * Given a collection class, returns a new instance of it. * * @param collectionType The class of the collection. * @param <C> The type of the collection. * * @return A new instance to the collection. */
public <C extends Collection<T>> C getCollectionInstance(DeserializationContext context, Class<C> collectionType) {
growbit/turbogwt-http
src/main/java/org/turbogwt/net/serialization/client/json/JsonSerdes.java
// Path: src/main/java/org/turbogwt/net/serialization/client/DeserializationContext.java // public abstract class DeserializationContext { // // private final ContainerFactoryManager containerFactoryManager; // // public DeserializationContext(ContainerFactoryManager containerFactoryManager) { // this.containerFactoryManager = containerFactoryManager; // } // // public <C extends Collection> C getContainerInstance(Class<C> type) { // final Factory<C> factory = containerFactoryManager.getFactory(type); // if (factory == null) // throw new UnableToDeserializeException("Could not get container instance because there's no factory " + // "registered in the requestor."); // return factory.get(); // } // // protected ContainerFactoryManager getContainerFactoryManager() { // return containerFactoryManager; // } // } // // Path: src/main/java/org/turbogwt/net/serialization/client/Serdes.java // public interface Serdes<T> extends Deserializer<T>, Serializer<T> { // // /** // * Method for accessing type of the Object this de/serializer can handle. // * // * @return The class which this de/serializer can de/serialize // */ // @Override // Class<T> handledType(); // } // // Path: src/main/java/org/turbogwt/net/serialization/client/SerializationContext.java // public abstract class SerializationContext { // } // // Path: src/main/java/org/turbogwt/net/serialization/client/UnableToDeserializeException.java // public class UnableToDeserializeException extends SerializationException { // // public UnableToDeserializeException() { // } // // public UnableToDeserializeException(String s) { // super(s); // } // // public UnableToDeserializeException(String s, Throwable throwable) { // super(s, throwable); // } // }
import java.util.Collection; import org.turbogwt.net.serialization.client.DeserializationContext; import org.turbogwt.net.serialization.client.Serdes; import org.turbogwt.net.serialization.client.SerializationContext; import org.turbogwt.net.serialization.client.UnableToDeserializeException;
/* * Copyright 2014 Grow Bit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.turbogwt.net.serialization.client.json; /** * Base class for all SerDes that manipulates serialized JSON. * * @param <T> Type of the object to be serialized/deserialized * * @author Danilo Reinert */ public abstract class JsonSerdes<T> implements Serdes<T> { public static String[] ACCEPT_PATTERNS = new String[] { "application/json", "application/javascript" }; public static String[] CONTENT_TYPE_PATTERNS = new String[] { "application/json", "application/javascript" }; private final Class<T> handledType; protected JsonSerdes(Class<T> handledType) { this.handledType = handledType; } @Override public Class<T> handledType() { return handledType; } @Override public String[] accept() { return ACCEPT_PATTERNS; } @Override public String[] contentType() { return CONTENT_TYPE_PATTERNS; } /** * Given a collection class, returns a new instance of it. * * @param collectionType The class of the collection. * @param <C> The type of the collection. * * @return A new instance to the collection. */ public <C extends Collection<T>> C getCollectionInstance(DeserializationContext context, Class<C> collectionType) { final C col = context.getContainerInstance(collectionType); if (col == null)
// Path: src/main/java/org/turbogwt/net/serialization/client/DeserializationContext.java // public abstract class DeserializationContext { // // private final ContainerFactoryManager containerFactoryManager; // // public DeserializationContext(ContainerFactoryManager containerFactoryManager) { // this.containerFactoryManager = containerFactoryManager; // } // // public <C extends Collection> C getContainerInstance(Class<C> type) { // final Factory<C> factory = containerFactoryManager.getFactory(type); // if (factory == null) // throw new UnableToDeserializeException("Could not get container instance because there's no factory " + // "registered in the requestor."); // return factory.get(); // } // // protected ContainerFactoryManager getContainerFactoryManager() { // return containerFactoryManager; // } // } // // Path: src/main/java/org/turbogwt/net/serialization/client/Serdes.java // public interface Serdes<T> extends Deserializer<T>, Serializer<T> { // // /** // * Method for accessing type of the Object this de/serializer can handle. // * // * @return The class which this de/serializer can de/serialize // */ // @Override // Class<T> handledType(); // } // // Path: src/main/java/org/turbogwt/net/serialization/client/SerializationContext.java // public abstract class SerializationContext { // } // // Path: src/main/java/org/turbogwt/net/serialization/client/UnableToDeserializeException.java // public class UnableToDeserializeException extends SerializationException { // // public UnableToDeserializeException() { // } // // public UnableToDeserializeException(String s) { // super(s); // } // // public UnableToDeserializeException(String s, Throwable throwable) { // super(s, throwable); // } // } // Path: src/main/java/org/turbogwt/net/serialization/client/json/JsonSerdes.java import java.util.Collection; import org.turbogwt.net.serialization.client.DeserializationContext; import org.turbogwt.net.serialization.client.Serdes; import org.turbogwt.net.serialization.client.SerializationContext; import org.turbogwt.net.serialization.client.UnableToDeserializeException; /* * Copyright 2014 Grow Bit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.turbogwt.net.serialization.client.json; /** * Base class for all SerDes that manipulates serialized JSON. * * @param <T> Type of the object to be serialized/deserialized * * @author Danilo Reinert */ public abstract class JsonSerdes<T> implements Serdes<T> { public static String[] ACCEPT_PATTERNS = new String[] { "application/json", "application/javascript" }; public static String[] CONTENT_TYPE_PATTERNS = new String[] { "application/json", "application/javascript" }; private final Class<T> handledType; protected JsonSerdes(Class<T> handledType) { this.handledType = handledType; } @Override public Class<T> handledType() { return handledType; } @Override public String[] accept() { return ACCEPT_PATTERNS; } @Override public String[] contentType() { return CONTENT_TYPE_PATTERNS; } /** * Given a collection class, returns a new instance of it. * * @param collectionType The class of the collection. * @param <C> The type of the collection. * * @return A new instance to the collection. */ public <C extends Collection<T>> C getCollectionInstance(DeserializationContext context, Class<C> collectionType) { final C col = context.getContainerInstance(collectionType); if (col == null)
throw new UnableToDeserializeException("Could not instantiate the given collection type.");
growbit/turbogwt-http
src/main/java/org/turbogwt/net/serialization/client/json/JsonSerdes.java
// Path: src/main/java/org/turbogwt/net/serialization/client/DeserializationContext.java // public abstract class DeserializationContext { // // private final ContainerFactoryManager containerFactoryManager; // // public DeserializationContext(ContainerFactoryManager containerFactoryManager) { // this.containerFactoryManager = containerFactoryManager; // } // // public <C extends Collection> C getContainerInstance(Class<C> type) { // final Factory<C> factory = containerFactoryManager.getFactory(type); // if (factory == null) // throw new UnableToDeserializeException("Could not get container instance because there's no factory " + // "registered in the requestor."); // return factory.get(); // } // // protected ContainerFactoryManager getContainerFactoryManager() { // return containerFactoryManager; // } // } // // Path: src/main/java/org/turbogwt/net/serialization/client/Serdes.java // public interface Serdes<T> extends Deserializer<T>, Serializer<T> { // // /** // * Method for accessing type of the Object this de/serializer can handle. // * // * @return The class which this de/serializer can de/serialize // */ // @Override // Class<T> handledType(); // } // // Path: src/main/java/org/turbogwt/net/serialization/client/SerializationContext.java // public abstract class SerializationContext { // } // // Path: src/main/java/org/turbogwt/net/serialization/client/UnableToDeserializeException.java // public class UnableToDeserializeException extends SerializationException { // // public UnableToDeserializeException() { // } // // public UnableToDeserializeException(String s) { // super(s); // } // // public UnableToDeserializeException(String s, Throwable throwable) { // super(s, throwable); // } // }
import java.util.Collection; import org.turbogwt.net.serialization.client.DeserializationContext; import org.turbogwt.net.serialization.client.Serdes; import org.turbogwt.net.serialization.client.SerializationContext; import org.turbogwt.net.serialization.client.UnableToDeserializeException;
/* * Copyright 2014 Grow Bit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.turbogwt.net.serialization.client.json; /** * Base class for all SerDes that manipulates serialized JSON. * * @param <T> Type of the object to be serialized/deserialized * * @author Danilo Reinert */ public abstract class JsonSerdes<T> implements Serdes<T> { public static String[] ACCEPT_PATTERNS = new String[] { "application/json", "application/javascript" }; public static String[] CONTENT_TYPE_PATTERNS = new String[] { "application/json", "application/javascript" }; private final Class<T> handledType; protected JsonSerdes(Class<T> handledType) { this.handledType = handledType; } @Override public Class<T> handledType() { return handledType; } @Override public String[] accept() { return ACCEPT_PATTERNS; } @Override public String[] contentType() { return CONTENT_TYPE_PATTERNS; } /** * Given a collection class, returns a new instance of it. * * @param collectionType The class of the collection. * @param <C> The type of the collection. * * @return A new instance to the collection. */ public <C extends Collection<T>> C getCollectionInstance(DeserializationContext context, Class<C> collectionType) { final C col = context.getContainerInstance(collectionType); if (col == null) throw new UnableToDeserializeException("Could not instantiate the given collection type."); return col; } @Override
// Path: src/main/java/org/turbogwt/net/serialization/client/DeserializationContext.java // public abstract class DeserializationContext { // // private final ContainerFactoryManager containerFactoryManager; // // public DeserializationContext(ContainerFactoryManager containerFactoryManager) { // this.containerFactoryManager = containerFactoryManager; // } // // public <C extends Collection> C getContainerInstance(Class<C> type) { // final Factory<C> factory = containerFactoryManager.getFactory(type); // if (factory == null) // throw new UnableToDeserializeException("Could not get container instance because there's no factory " + // "registered in the requestor."); // return factory.get(); // } // // protected ContainerFactoryManager getContainerFactoryManager() { // return containerFactoryManager; // } // } // // Path: src/main/java/org/turbogwt/net/serialization/client/Serdes.java // public interface Serdes<T> extends Deserializer<T>, Serializer<T> { // // /** // * Method for accessing type of the Object this de/serializer can handle. // * // * @return The class which this de/serializer can de/serialize // */ // @Override // Class<T> handledType(); // } // // Path: src/main/java/org/turbogwt/net/serialization/client/SerializationContext.java // public abstract class SerializationContext { // } // // Path: src/main/java/org/turbogwt/net/serialization/client/UnableToDeserializeException.java // public class UnableToDeserializeException extends SerializationException { // // public UnableToDeserializeException() { // } // // public UnableToDeserializeException(String s) { // super(s); // } // // public UnableToDeserializeException(String s, Throwable throwable) { // super(s, throwable); // } // } // Path: src/main/java/org/turbogwt/net/serialization/client/json/JsonSerdes.java import java.util.Collection; import org.turbogwt.net.serialization.client.DeserializationContext; import org.turbogwt.net.serialization.client.Serdes; import org.turbogwt.net.serialization.client.SerializationContext; import org.turbogwt.net.serialization.client.UnableToDeserializeException; /* * Copyright 2014 Grow Bit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.turbogwt.net.serialization.client.json; /** * Base class for all SerDes that manipulates serialized JSON. * * @param <T> Type of the object to be serialized/deserialized * * @author Danilo Reinert */ public abstract class JsonSerdes<T> implements Serdes<T> { public static String[] ACCEPT_PATTERNS = new String[] { "application/json", "application/javascript" }; public static String[] CONTENT_TYPE_PATTERNS = new String[] { "application/json", "application/javascript" }; private final Class<T> handledType; protected JsonSerdes(Class<T> handledType) { this.handledType = handledType; } @Override public Class<T> handledType() { return handledType; } @Override public String[] accept() { return ACCEPT_PATTERNS; } @Override public String[] contentType() { return CONTENT_TYPE_PATTERNS; } /** * Given a collection class, returns a new instance of it. * * @param collectionType The class of the collection. * @param <C> The type of the collection. * * @return A new instance to the collection. */ public <C extends Collection<T>> C getCollectionInstance(DeserializationContext context, Class<C> collectionType) { final C col = context.getContainerInstance(collectionType); if (col == null) throw new UnableToDeserializeException("Could not instantiate the given collection type."); return col; } @Override
public String serializeFromCollection(Collection<T> c, SerializationContext context) {
growbit/turbogwt-http
src/main/java/org/turbogwt/net/serialization/client/json/JsonBooleanSerdes.java
// Path: src/main/java/org/turbogwt/net/serialization/client/DeserializationContext.java // public abstract class DeserializationContext { // // private final ContainerFactoryManager containerFactoryManager; // // public DeserializationContext(ContainerFactoryManager containerFactoryManager) { // this.containerFactoryManager = containerFactoryManager; // } // // public <C extends Collection> C getContainerInstance(Class<C> type) { // final Factory<C> factory = containerFactoryManager.getFactory(type); // if (factory == null) // throw new UnableToDeserializeException("Could not get container instance because there's no factory " + // "registered in the requestor."); // return factory.get(); // } // // protected ContainerFactoryManager getContainerFactoryManager() { // return containerFactoryManager; // } // } // // Path: src/main/java/org/turbogwt/net/serialization/client/SerializationContext.java // public abstract class SerializationContext { // }
import org.turbogwt.net.serialization.client.DeserializationContext; import org.turbogwt.net.serialization.client.SerializationContext;
/* * Copyright 2014 Grow Bit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.turbogwt.net.serialization.client.json; /** * De/Serializer of JSON booleans. * * @author Danilo Reinert */ public class JsonBooleanSerdes extends JsonValueSerdes<Boolean> { private static JsonBooleanSerdes INSTANCE = new JsonBooleanSerdes(); public JsonBooleanSerdes() { super(Boolean.class); } public static JsonBooleanSerdes getInstance() { return INSTANCE; } @Override
// Path: src/main/java/org/turbogwt/net/serialization/client/DeserializationContext.java // public abstract class DeserializationContext { // // private final ContainerFactoryManager containerFactoryManager; // // public DeserializationContext(ContainerFactoryManager containerFactoryManager) { // this.containerFactoryManager = containerFactoryManager; // } // // public <C extends Collection> C getContainerInstance(Class<C> type) { // final Factory<C> factory = containerFactoryManager.getFactory(type); // if (factory == null) // throw new UnableToDeserializeException("Could not get container instance because there's no factory " + // "registered in the requestor."); // return factory.get(); // } // // protected ContainerFactoryManager getContainerFactoryManager() { // return containerFactoryManager; // } // } // // Path: src/main/java/org/turbogwt/net/serialization/client/SerializationContext.java // public abstract class SerializationContext { // } // Path: src/main/java/org/turbogwt/net/serialization/client/json/JsonBooleanSerdes.java import org.turbogwt.net.serialization.client.DeserializationContext; import org.turbogwt.net.serialization.client.SerializationContext; /* * Copyright 2014 Grow Bit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.turbogwt.net.serialization.client.json; /** * De/Serializer of JSON booleans. * * @author Danilo Reinert */ public class JsonBooleanSerdes extends JsonValueSerdes<Boolean> { private static JsonBooleanSerdes INSTANCE = new JsonBooleanSerdes(); public JsonBooleanSerdes() { super(Boolean.class); } public static JsonBooleanSerdes getInstance() { return INSTANCE; } @Override
public Boolean deserialize(String response, DeserializationContext context) {
growbit/turbogwt-http
src/main/java/org/turbogwt/net/serialization/client/json/JsonBooleanSerdes.java
// Path: src/main/java/org/turbogwt/net/serialization/client/DeserializationContext.java // public abstract class DeserializationContext { // // private final ContainerFactoryManager containerFactoryManager; // // public DeserializationContext(ContainerFactoryManager containerFactoryManager) { // this.containerFactoryManager = containerFactoryManager; // } // // public <C extends Collection> C getContainerInstance(Class<C> type) { // final Factory<C> factory = containerFactoryManager.getFactory(type); // if (factory == null) // throw new UnableToDeserializeException("Could not get container instance because there's no factory " + // "registered in the requestor."); // return factory.get(); // } // // protected ContainerFactoryManager getContainerFactoryManager() { // return containerFactoryManager; // } // } // // Path: src/main/java/org/turbogwt/net/serialization/client/SerializationContext.java // public abstract class SerializationContext { // }
import org.turbogwt.net.serialization.client.DeserializationContext; import org.turbogwt.net.serialization.client.SerializationContext;
/* * Copyright 2014 Grow Bit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.turbogwt.net.serialization.client.json; /** * De/Serializer of JSON booleans. * * @author Danilo Reinert */ public class JsonBooleanSerdes extends JsonValueSerdes<Boolean> { private static JsonBooleanSerdes INSTANCE = new JsonBooleanSerdes(); public JsonBooleanSerdes() { super(Boolean.class); } public static JsonBooleanSerdes getInstance() { return INSTANCE; } @Override public Boolean deserialize(String response, DeserializationContext context) { return Boolean.valueOf(response); } @Override
// Path: src/main/java/org/turbogwt/net/serialization/client/DeserializationContext.java // public abstract class DeserializationContext { // // private final ContainerFactoryManager containerFactoryManager; // // public DeserializationContext(ContainerFactoryManager containerFactoryManager) { // this.containerFactoryManager = containerFactoryManager; // } // // public <C extends Collection> C getContainerInstance(Class<C> type) { // final Factory<C> factory = containerFactoryManager.getFactory(type); // if (factory == null) // throw new UnableToDeserializeException("Could not get container instance because there's no factory " + // "registered in the requestor."); // return factory.get(); // } // // protected ContainerFactoryManager getContainerFactoryManager() { // return containerFactoryManager; // } // } // // Path: src/main/java/org/turbogwt/net/serialization/client/SerializationContext.java // public abstract class SerializationContext { // } // Path: src/main/java/org/turbogwt/net/serialization/client/json/JsonBooleanSerdes.java import org.turbogwt.net.serialization.client.DeserializationContext; import org.turbogwt.net.serialization.client.SerializationContext; /* * Copyright 2014 Grow Bit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.turbogwt.net.serialization.client.json; /** * De/Serializer of JSON booleans. * * @author Danilo Reinert */ public class JsonBooleanSerdes extends JsonValueSerdes<Boolean> { private static JsonBooleanSerdes INSTANCE = new JsonBooleanSerdes(); public JsonBooleanSerdes() { super(Boolean.class); } public static JsonBooleanSerdes getInstance() { return INSTANCE; } @Override public Boolean deserialize(String response, DeserializationContext context) { return Boolean.valueOf(response); } @Override
public String serialize(Boolean b, SerializationContext context) {
growbit/turbogwt-http
src/test/java/org/turbogwt/net/http/client/SerializerAndDeserializerPrecedenceTest.java
// Path: src/main/java/org/turbogwt/net/http/client/header/ContentTypeHeader.java // public class ContentTypeHeader extends SimpleHeaderWithParameter { // // public ContentTypeHeader(String value, Param... params) { // super("Content-Type", value, params); // } // // public ContentTypeHeader(String value) { // super("Content-Type", value); // } // } // // Path: src/test/java/org/turbogwt/net/http/client/mock/ResponseMock.java // public class ResponseMock extends Response { // // private final String text; // private final int statusCode; // private final String statusText; // private final Header[] headers; // // ResponseMock(String text, int statusCode, String statusText, Header[] headers) { // this.text = text; // this.statusCode = statusCode; // this.statusText = statusText; // this.headers = headers; // } // // public static Builder builder() { // return new Builder(); // } // // public static ResponseMock of(String text, int statusCode, String statusText, Header... headers) { // return new ResponseMock(text, statusCode, statusText, headers); // } // // @Override // public String getHeader(String header) { // if (header == null) throw new NullPointerException("Header param cannot be null."); // if (header.isEmpty()) throw new IllegalArgumentException("Header param cannot be empty."); // for (Header h : headers) { // if (h.getName().equals(header)) return h.getValue(); // } // return null; // } // // @Override // public Header[] getHeaders() { // return headers; // } // // @Override // public String getHeadersAsString() { // return Arrays.toString(headers); // } // // @Override // public int getStatusCode() { // return statusCode; // } // // @Override // public String getStatusText() { // return statusText; // } // // @Override // public String getText() { // return text; // } // // /** // * A builder of {@link ResponseMock}. // */ // public static class Builder { // private String text; // private int statusCode; // private String statusText; // private final List<Header> headers = new ArrayList<>(); // // public Builder text(String text) { // this.text = text; // return this; // } // // public Builder statusCode(int statusCode) { // this.statusCode = statusCode; // return this; // } // // public Builder statusText(String statusText) { // this.statusText = statusText; // return this; // } // // public Builder header(final String name, final String value) { // headers.add(new Header() { // @Override // public String getName() { // return name; // } // // @Override // public String getValue() { // return value; // } // // @Override // public String toString() { // return name + " = " + value; // } // }); // return this; // } // // public Builder clearHeaders() { // headers.clear(); // return this; // } // // public ResponseMock build() { // return new ResponseMock(text, statusCode, statusText, (Header[]) headers.toArray()); // } // } // } // // Path: src/test/java/org/turbogwt/net/http/client/mock/ServerStub.java // public class ServerStub implements Server { // // private static Map<String, Response> responseData = new HashMap<>(); // private static Map<String, RequestMock> requestData = new HashMap<>(); // // private static boolean returnSuccess = true; // // public static boolean isReturnSuccess() { // return returnSuccess; // } // // public static void setReturnSuccess(boolean success) { // returnSuccess = success; // } // // public static void responseFor(String uri, Response response) { // responseData.put(uri, response); // } // // public static RequestMock getRequestData(String uri) { // return requestData.get(uri); // } // // public static void triggerPendingRequest() { // ServerConnectionMock.triggerPendingRequest(); // } // // public static void clearStub() { // responseData.clear(); // requestData.clear(); // returnSuccess = true; // } // // static Response getResponseFor(String uri) { // return responseData.get(uri); // } // // static RequestMock setRequestData(String uri, RequestMock requestMock) { // return requestData.put(uri, requestMock); // } // // /** // * Retrieve an instance of {@link org.turbogwt.net.http.client.ServerConnection}. // * // * @return The ServerConnection instance. // */ // @Override // public ServerConnection getConnection() { // return new ServerConnectionMock(); // } // }
import com.google.gwt.core.client.GWT; import com.google.gwt.junit.client.GWTTestCase; import org.turbogwt.core.future.shared.DoneCallback; import org.turbogwt.net.http.client.header.ContentTypeHeader; import org.turbogwt.net.http.client.mock.ResponseMock; import org.turbogwt.net.http.client.mock.ServerStub;
assertFalse(callbackCalled[0]); assertTrue(callbackCalled[1]); } public void testNotMappedDeserializing() { // As TextDeserializer matches */*, this response should be deserialized by it. prepareStub("content-type/not-mapped", serializedResponseAsText); final Requestor requestor = getRequestor(); final boolean[] callbackCalled = new boolean[2]; requestor.request(uri).get(String.class).done(new DoneCallback<String>() { public void onDone(String result) { callbackCalled[1] = true; assertEquals(string, result); } }); ServerStub.triggerPendingRequest(); assertFalse(callbackCalled[0]); assertTrue(callbackCalled[1]); } private Requestor getRequestor() { return GWT.create(Requestor.class); } private void prepareStub(String responseContentType, String serializedResponse) { ServerStub.clearStub();
// Path: src/main/java/org/turbogwt/net/http/client/header/ContentTypeHeader.java // public class ContentTypeHeader extends SimpleHeaderWithParameter { // // public ContentTypeHeader(String value, Param... params) { // super("Content-Type", value, params); // } // // public ContentTypeHeader(String value) { // super("Content-Type", value); // } // } // // Path: src/test/java/org/turbogwt/net/http/client/mock/ResponseMock.java // public class ResponseMock extends Response { // // private final String text; // private final int statusCode; // private final String statusText; // private final Header[] headers; // // ResponseMock(String text, int statusCode, String statusText, Header[] headers) { // this.text = text; // this.statusCode = statusCode; // this.statusText = statusText; // this.headers = headers; // } // // public static Builder builder() { // return new Builder(); // } // // public static ResponseMock of(String text, int statusCode, String statusText, Header... headers) { // return new ResponseMock(text, statusCode, statusText, headers); // } // // @Override // public String getHeader(String header) { // if (header == null) throw new NullPointerException("Header param cannot be null."); // if (header.isEmpty()) throw new IllegalArgumentException("Header param cannot be empty."); // for (Header h : headers) { // if (h.getName().equals(header)) return h.getValue(); // } // return null; // } // // @Override // public Header[] getHeaders() { // return headers; // } // // @Override // public String getHeadersAsString() { // return Arrays.toString(headers); // } // // @Override // public int getStatusCode() { // return statusCode; // } // // @Override // public String getStatusText() { // return statusText; // } // // @Override // public String getText() { // return text; // } // // /** // * A builder of {@link ResponseMock}. // */ // public static class Builder { // private String text; // private int statusCode; // private String statusText; // private final List<Header> headers = new ArrayList<>(); // // public Builder text(String text) { // this.text = text; // return this; // } // // public Builder statusCode(int statusCode) { // this.statusCode = statusCode; // return this; // } // // public Builder statusText(String statusText) { // this.statusText = statusText; // return this; // } // // public Builder header(final String name, final String value) { // headers.add(new Header() { // @Override // public String getName() { // return name; // } // // @Override // public String getValue() { // return value; // } // // @Override // public String toString() { // return name + " = " + value; // } // }); // return this; // } // // public Builder clearHeaders() { // headers.clear(); // return this; // } // // public ResponseMock build() { // return new ResponseMock(text, statusCode, statusText, (Header[]) headers.toArray()); // } // } // } // // Path: src/test/java/org/turbogwt/net/http/client/mock/ServerStub.java // public class ServerStub implements Server { // // private static Map<String, Response> responseData = new HashMap<>(); // private static Map<String, RequestMock> requestData = new HashMap<>(); // // private static boolean returnSuccess = true; // // public static boolean isReturnSuccess() { // return returnSuccess; // } // // public static void setReturnSuccess(boolean success) { // returnSuccess = success; // } // // public static void responseFor(String uri, Response response) { // responseData.put(uri, response); // } // // public static RequestMock getRequestData(String uri) { // return requestData.get(uri); // } // // public static void triggerPendingRequest() { // ServerConnectionMock.triggerPendingRequest(); // } // // public static void clearStub() { // responseData.clear(); // requestData.clear(); // returnSuccess = true; // } // // static Response getResponseFor(String uri) { // return responseData.get(uri); // } // // static RequestMock setRequestData(String uri, RequestMock requestMock) { // return requestData.put(uri, requestMock); // } // // /** // * Retrieve an instance of {@link org.turbogwt.net.http.client.ServerConnection}. // * // * @return The ServerConnection instance. // */ // @Override // public ServerConnection getConnection() { // return new ServerConnectionMock(); // } // } // Path: src/test/java/org/turbogwt/net/http/client/SerializerAndDeserializerPrecedenceTest.java import com.google.gwt.core.client.GWT; import com.google.gwt.junit.client.GWTTestCase; import org.turbogwt.core.future.shared.DoneCallback; import org.turbogwt.net.http.client.header.ContentTypeHeader; import org.turbogwt.net.http.client.mock.ResponseMock; import org.turbogwt.net.http.client.mock.ServerStub; assertFalse(callbackCalled[0]); assertTrue(callbackCalled[1]); } public void testNotMappedDeserializing() { // As TextDeserializer matches */*, this response should be deserialized by it. prepareStub("content-type/not-mapped", serializedResponseAsText); final Requestor requestor = getRequestor(); final boolean[] callbackCalled = new boolean[2]; requestor.request(uri).get(String.class).done(new DoneCallback<String>() { public void onDone(String result) { callbackCalled[1] = true; assertEquals(string, result); } }); ServerStub.triggerPendingRequest(); assertFalse(callbackCalled[0]); assertTrue(callbackCalled[1]); } private Requestor getRequestor() { return GWT.create(Requestor.class); } private void prepareStub(String responseContentType, String serializedResponse) { ServerStub.clearStub();
ServerStub.responseFor(uri, ResponseMock.of(serializedResponse, 200, "OK",
growbit/turbogwt-http
src/test/java/org/turbogwt/net/http/client/SerializerAndDeserializerPrecedenceTest.java
// Path: src/main/java/org/turbogwt/net/http/client/header/ContentTypeHeader.java // public class ContentTypeHeader extends SimpleHeaderWithParameter { // // public ContentTypeHeader(String value, Param... params) { // super("Content-Type", value, params); // } // // public ContentTypeHeader(String value) { // super("Content-Type", value); // } // } // // Path: src/test/java/org/turbogwt/net/http/client/mock/ResponseMock.java // public class ResponseMock extends Response { // // private final String text; // private final int statusCode; // private final String statusText; // private final Header[] headers; // // ResponseMock(String text, int statusCode, String statusText, Header[] headers) { // this.text = text; // this.statusCode = statusCode; // this.statusText = statusText; // this.headers = headers; // } // // public static Builder builder() { // return new Builder(); // } // // public static ResponseMock of(String text, int statusCode, String statusText, Header... headers) { // return new ResponseMock(text, statusCode, statusText, headers); // } // // @Override // public String getHeader(String header) { // if (header == null) throw new NullPointerException("Header param cannot be null."); // if (header.isEmpty()) throw new IllegalArgumentException("Header param cannot be empty."); // for (Header h : headers) { // if (h.getName().equals(header)) return h.getValue(); // } // return null; // } // // @Override // public Header[] getHeaders() { // return headers; // } // // @Override // public String getHeadersAsString() { // return Arrays.toString(headers); // } // // @Override // public int getStatusCode() { // return statusCode; // } // // @Override // public String getStatusText() { // return statusText; // } // // @Override // public String getText() { // return text; // } // // /** // * A builder of {@link ResponseMock}. // */ // public static class Builder { // private String text; // private int statusCode; // private String statusText; // private final List<Header> headers = new ArrayList<>(); // // public Builder text(String text) { // this.text = text; // return this; // } // // public Builder statusCode(int statusCode) { // this.statusCode = statusCode; // return this; // } // // public Builder statusText(String statusText) { // this.statusText = statusText; // return this; // } // // public Builder header(final String name, final String value) { // headers.add(new Header() { // @Override // public String getName() { // return name; // } // // @Override // public String getValue() { // return value; // } // // @Override // public String toString() { // return name + " = " + value; // } // }); // return this; // } // // public Builder clearHeaders() { // headers.clear(); // return this; // } // // public ResponseMock build() { // return new ResponseMock(text, statusCode, statusText, (Header[]) headers.toArray()); // } // } // } // // Path: src/test/java/org/turbogwt/net/http/client/mock/ServerStub.java // public class ServerStub implements Server { // // private static Map<String, Response> responseData = new HashMap<>(); // private static Map<String, RequestMock> requestData = new HashMap<>(); // // private static boolean returnSuccess = true; // // public static boolean isReturnSuccess() { // return returnSuccess; // } // // public static void setReturnSuccess(boolean success) { // returnSuccess = success; // } // // public static void responseFor(String uri, Response response) { // responseData.put(uri, response); // } // // public static RequestMock getRequestData(String uri) { // return requestData.get(uri); // } // // public static void triggerPendingRequest() { // ServerConnectionMock.triggerPendingRequest(); // } // // public static void clearStub() { // responseData.clear(); // requestData.clear(); // returnSuccess = true; // } // // static Response getResponseFor(String uri) { // return responseData.get(uri); // } // // static RequestMock setRequestData(String uri, RequestMock requestMock) { // return requestData.put(uri, requestMock); // } // // /** // * Retrieve an instance of {@link org.turbogwt.net.http.client.ServerConnection}. // * // * @return The ServerConnection instance. // */ // @Override // public ServerConnection getConnection() { // return new ServerConnectionMock(); // } // }
import com.google.gwt.core.client.GWT; import com.google.gwt.junit.client.GWTTestCase; import org.turbogwt.core.future.shared.DoneCallback; import org.turbogwt.net.http.client.header.ContentTypeHeader; import org.turbogwt.net.http.client.mock.ResponseMock; import org.turbogwt.net.http.client.mock.ServerStub;
assertFalse(callbackCalled[0]); assertTrue(callbackCalled[1]); } public void testNotMappedDeserializing() { // As TextDeserializer matches */*, this response should be deserialized by it. prepareStub("content-type/not-mapped", serializedResponseAsText); final Requestor requestor = getRequestor(); final boolean[] callbackCalled = new boolean[2]; requestor.request(uri).get(String.class).done(new DoneCallback<String>() { public void onDone(String result) { callbackCalled[1] = true; assertEquals(string, result); } }); ServerStub.triggerPendingRequest(); assertFalse(callbackCalled[0]); assertTrue(callbackCalled[1]); } private Requestor getRequestor() { return GWT.create(Requestor.class); } private void prepareStub(String responseContentType, String serializedResponse) { ServerStub.clearStub(); ServerStub.responseFor(uri, ResponseMock.of(serializedResponse, 200, "OK",
// Path: src/main/java/org/turbogwt/net/http/client/header/ContentTypeHeader.java // public class ContentTypeHeader extends SimpleHeaderWithParameter { // // public ContentTypeHeader(String value, Param... params) { // super("Content-Type", value, params); // } // // public ContentTypeHeader(String value) { // super("Content-Type", value); // } // } // // Path: src/test/java/org/turbogwt/net/http/client/mock/ResponseMock.java // public class ResponseMock extends Response { // // private final String text; // private final int statusCode; // private final String statusText; // private final Header[] headers; // // ResponseMock(String text, int statusCode, String statusText, Header[] headers) { // this.text = text; // this.statusCode = statusCode; // this.statusText = statusText; // this.headers = headers; // } // // public static Builder builder() { // return new Builder(); // } // // public static ResponseMock of(String text, int statusCode, String statusText, Header... headers) { // return new ResponseMock(text, statusCode, statusText, headers); // } // // @Override // public String getHeader(String header) { // if (header == null) throw new NullPointerException("Header param cannot be null."); // if (header.isEmpty()) throw new IllegalArgumentException("Header param cannot be empty."); // for (Header h : headers) { // if (h.getName().equals(header)) return h.getValue(); // } // return null; // } // // @Override // public Header[] getHeaders() { // return headers; // } // // @Override // public String getHeadersAsString() { // return Arrays.toString(headers); // } // // @Override // public int getStatusCode() { // return statusCode; // } // // @Override // public String getStatusText() { // return statusText; // } // // @Override // public String getText() { // return text; // } // // /** // * A builder of {@link ResponseMock}. // */ // public static class Builder { // private String text; // private int statusCode; // private String statusText; // private final List<Header> headers = new ArrayList<>(); // // public Builder text(String text) { // this.text = text; // return this; // } // // public Builder statusCode(int statusCode) { // this.statusCode = statusCode; // return this; // } // // public Builder statusText(String statusText) { // this.statusText = statusText; // return this; // } // // public Builder header(final String name, final String value) { // headers.add(new Header() { // @Override // public String getName() { // return name; // } // // @Override // public String getValue() { // return value; // } // // @Override // public String toString() { // return name + " = " + value; // } // }); // return this; // } // // public Builder clearHeaders() { // headers.clear(); // return this; // } // // public ResponseMock build() { // return new ResponseMock(text, statusCode, statusText, (Header[]) headers.toArray()); // } // } // } // // Path: src/test/java/org/turbogwt/net/http/client/mock/ServerStub.java // public class ServerStub implements Server { // // private static Map<String, Response> responseData = new HashMap<>(); // private static Map<String, RequestMock> requestData = new HashMap<>(); // // private static boolean returnSuccess = true; // // public static boolean isReturnSuccess() { // return returnSuccess; // } // // public static void setReturnSuccess(boolean success) { // returnSuccess = success; // } // // public static void responseFor(String uri, Response response) { // responseData.put(uri, response); // } // // public static RequestMock getRequestData(String uri) { // return requestData.get(uri); // } // // public static void triggerPendingRequest() { // ServerConnectionMock.triggerPendingRequest(); // } // // public static void clearStub() { // responseData.clear(); // requestData.clear(); // returnSuccess = true; // } // // static Response getResponseFor(String uri) { // return responseData.get(uri); // } // // static RequestMock setRequestData(String uri, RequestMock requestMock) { // return requestData.put(uri, requestMock); // } // // /** // * Retrieve an instance of {@link org.turbogwt.net.http.client.ServerConnection}. // * // * @return The ServerConnection instance. // */ // @Override // public ServerConnection getConnection() { // return new ServerConnectionMock(); // } // } // Path: src/test/java/org/turbogwt/net/http/client/SerializerAndDeserializerPrecedenceTest.java import com.google.gwt.core.client.GWT; import com.google.gwt.junit.client.GWTTestCase; import org.turbogwt.core.future.shared.DoneCallback; import org.turbogwt.net.http.client.header.ContentTypeHeader; import org.turbogwt.net.http.client.mock.ResponseMock; import org.turbogwt.net.http.client.mock.ServerStub; assertFalse(callbackCalled[0]); assertTrue(callbackCalled[1]); } public void testNotMappedDeserializing() { // As TextDeserializer matches */*, this response should be deserialized by it. prepareStub("content-type/not-mapped", serializedResponseAsText); final Requestor requestor = getRequestor(); final boolean[] callbackCalled = new boolean[2]; requestor.request(uri).get(String.class).done(new DoneCallback<String>() { public void onDone(String result) { callbackCalled[1] = true; assertEquals(string, result); } }); ServerStub.triggerPendingRequest(); assertFalse(callbackCalled[0]); assertTrue(callbackCalled[1]); } private Requestor getRequestor() { return GWT.create(Requestor.class); } private void prepareStub(String responseContentType, String serializedResponse) { ServerStub.clearStub(); ServerStub.responseFor(uri, ResponseMock.of(serializedResponse, 200, "OK",
new ContentTypeHeader(responseContentType)));
growbit/turbogwt-http
src/main/java/org/turbogwt/net/serialization/client/misc/VoidSerdes.java
// Path: src/main/java/org/turbogwt/net/serialization/client/DeserializationContext.java // public abstract class DeserializationContext { // // private final ContainerFactoryManager containerFactoryManager; // // public DeserializationContext(ContainerFactoryManager containerFactoryManager) { // this.containerFactoryManager = containerFactoryManager; // } // // public <C extends Collection> C getContainerInstance(Class<C> type) { // final Factory<C> factory = containerFactoryManager.getFactory(type); // if (factory == null) // throw new UnableToDeserializeException("Could not get container instance because there's no factory " + // "registered in the requestor."); // return factory.get(); // } // // protected ContainerFactoryManager getContainerFactoryManager() { // return containerFactoryManager; // } // } // // Path: src/main/java/org/turbogwt/net/serialization/client/Serdes.java // public interface Serdes<T> extends Deserializer<T>, Serializer<T> { // // /** // * Method for accessing type of the Object this de/serializer can handle. // * // * @return The class which this de/serializer can de/serialize // */ // @Override // Class<T> handledType(); // } // // Path: src/main/java/org/turbogwt/net/serialization/client/SerializationContext.java // public abstract class SerializationContext { // }
import java.util.Collection; import org.turbogwt.net.serialization.client.DeserializationContext; import org.turbogwt.net.serialization.client.Serdes; import org.turbogwt.net.serialization.client.SerializationContext;
/* * Copyright 2014 Grow Bit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.turbogwt.net.serialization.client.misc; /** * De/Serializer for Void type. * Returns null for every method. * * @author Danilo Reinert */ public class VoidSerdes implements Serdes<Void> { public static final String[] CONTENT_TYPE_PATTERNS = new String[] {"*/*"}; private static VoidSerdes INSTANCE = new VoidSerdes(); public static VoidSerdes getInstance() { return INSTANCE; } @Override public Class<Void> handledType() { return Void.class; } @Override public String[] contentType() { return CONTENT_TYPE_PATTERNS; } @Override public String[] accept() { return CONTENT_TYPE_PATTERNS; } @Override
// Path: src/main/java/org/turbogwt/net/serialization/client/DeserializationContext.java // public abstract class DeserializationContext { // // private final ContainerFactoryManager containerFactoryManager; // // public DeserializationContext(ContainerFactoryManager containerFactoryManager) { // this.containerFactoryManager = containerFactoryManager; // } // // public <C extends Collection> C getContainerInstance(Class<C> type) { // final Factory<C> factory = containerFactoryManager.getFactory(type); // if (factory == null) // throw new UnableToDeserializeException("Could not get container instance because there's no factory " + // "registered in the requestor."); // return factory.get(); // } // // protected ContainerFactoryManager getContainerFactoryManager() { // return containerFactoryManager; // } // } // // Path: src/main/java/org/turbogwt/net/serialization/client/Serdes.java // public interface Serdes<T> extends Deserializer<T>, Serializer<T> { // // /** // * Method for accessing type of the Object this de/serializer can handle. // * // * @return The class which this de/serializer can de/serialize // */ // @Override // Class<T> handledType(); // } // // Path: src/main/java/org/turbogwt/net/serialization/client/SerializationContext.java // public abstract class SerializationContext { // } // Path: src/main/java/org/turbogwt/net/serialization/client/misc/VoidSerdes.java import java.util.Collection; import org.turbogwt.net.serialization.client.DeserializationContext; import org.turbogwt.net.serialization.client.Serdes; import org.turbogwt.net.serialization.client.SerializationContext; /* * Copyright 2014 Grow Bit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.turbogwt.net.serialization.client.misc; /** * De/Serializer for Void type. * Returns null for every method. * * @author Danilo Reinert */ public class VoidSerdes implements Serdes<Void> { public static final String[] CONTENT_TYPE_PATTERNS = new String[] {"*/*"}; private static VoidSerdes INSTANCE = new VoidSerdes(); public static VoidSerdes getInstance() { return INSTANCE; } @Override public Class<Void> handledType() { return Void.class; } @Override public String[] contentType() { return CONTENT_TYPE_PATTERNS; } @Override public String[] accept() { return CONTENT_TYPE_PATTERNS; } @Override
public Void deserialize(String response, DeserializationContext context) {
growbit/turbogwt-http
src/main/java/org/turbogwt/net/serialization/client/misc/VoidSerdes.java
// Path: src/main/java/org/turbogwt/net/serialization/client/DeserializationContext.java // public abstract class DeserializationContext { // // private final ContainerFactoryManager containerFactoryManager; // // public DeserializationContext(ContainerFactoryManager containerFactoryManager) { // this.containerFactoryManager = containerFactoryManager; // } // // public <C extends Collection> C getContainerInstance(Class<C> type) { // final Factory<C> factory = containerFactoryManager.getFactory(type); // if (factory == null) // throw new UnableToDeserializeException("Could not get container instance because there's no factory " + // "registered in the requestor."); // return factory.get(); // } // // protected ContainerFactoryManager getContainerFactoryManager() { // return containerFactoryManager; // } // } // // Path: src/main/java/org/turbogwt/net/serialization/client/Serdes.java // public interface Serdes<T> extends Deserializer<T>, Serializer<T> { // // /** // * Method for accessing type of the Object this de/serializer can handle. // * // * @return The class which this de/serializer can de/serialize // */ // @Override // Class<T> handledType(); // } // // Path: src/main/java/org/turbogwt/net/serialization/client/SerializationContext.java // public abstract class SerializationContext { // }
import java.util.Collection; import org.turbogwt.net.serialization.client.DeserializationContext; import org.turbogwt.net.serialization.client.Serdes; import org.turbogwt.net.serialization.client.SerializationContext;
/* * Copyright 2014 Grow Bit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.turbogwt.net.serialization.client.misc; /** * De/Serializer for Void type. * Returns null for every method. * * @author Danilo Reinert */ public class VoidSerdes implements Serdes<Void> { public static final String[] CONTENT_TYPE_PATTERNS = new String[] {"*/*"}; private static VoidSerdes INSTANCE = new VoidSerdes(); public static VoidSerdes getInstance() { return INSTANCE; } @Override public Class<Void> handledType() { return Void.class; } @Override public String[] contentType() { return CONTENT_TYPE_PATTERNS; } @Override public String[] accept() { return CONTENT_TYPE_PATTERNS; } @Override public Void deserialize(String response, DeserializationContext context) { return null; } @Override public <C extends Collection<Void>> C deserializeAsCollection(Class<C> collectionType, String response, DeserializationContext context) { return null; } @Override
// Path: src/main/java/org/turbogwt/net/serialization/client/DeserializationContext.java // public abstract class DeserializationContext { // // private final ContainerFactoryManager containerFactoryManager; // // public DeserializationContext(ContainerFactoryManager containerFactoryManager) { // this.containerFactoryManager = containerFactoryManager; // } // // public <C extends Collection> C getContainerInstance(Class<C> type) { // final Factory<C> factory = containerFactoryManager.getFactory(type); // if (factory == null) // throw new UnableToDeserializeException("Could not get container instance because there's no factory " + // "registered in the requestor."); // return factory.get(); // } // // protected ContainerFactoryManager getContainerFactoryManager() { // return containerFactoryManager; // } // } // // Path: src/main/java/org/turbogwt/net/serialization/client/Serdes.java // public interface Serdes<T> extends Deserializer<T>, Serializer<T> { // // /** // * Method for accessing type of the Object this de/serializer can handle. // * // * @return The class which this de/serializer can de/serialize // */ // @Override // Class<T> handledType(); // } // // Path: src/main/java/org/turbogwt/net/serialization/client/SerializationContext.java // public abstract class SerializationContext { // } // Path: src/main/java/org/turbogwt/net/serialization/client/misc/VoidSerdes.java import java.util.Collection; import org.turbogwt.net.serialization.client.DeserializationContext; import org.turbogwt.net.serialization.client.Serdes; import org.turbogwt.net.serialization.client.SerializationContext; /* * Copyright 2014 Grow Bit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.turbogwt.net.serialization.client.misc; /** * De/Serializer for Void type. * Returns null for every method. * * @author Danilo Reinert */ public class VoidSerdes implements Serdes<Void> { public static final String[] CONTENT_TYPE_PATTERNS = new String[] {"*/*"}; private static VoidSerdes INSTANCE = new VoidSerdes(); public static VoidSerdes getInstance() { return INSTANCE; } @Override public Class<Void> handledType() { return Void.class; } @Override public String[] contentType() { return CONTENT_TYPE_PATTERNS; } @Override public String[] accept() { return CONTENT_TYPE_PATTERNS; } @Override public Void deserialize(String response, DeserializationContext context) { return null; } @Override public <C extends Collection<Void>> C deserializeAsCollection(Class<C> collectionType, String response, DeserializationContext context) { return null; } @Override
public String serialize(Void v, SerializationContext context) {
growbit/turbogwt-http
src/main/java/org/turbogwt/net/serialization/client/misc/TextDeserializer.java
// Path: src/main/java/org/turbogwt/net/serialization/client/DeserializationContext.java // public abstract class DeserializationContext { // // private final ContainerFactoryManager containerFactoryManager; // // public DeserializationContext(ContainerFactoryManager containerFactoryManager) { // this.containerFactoryManager = containerFactoryManager; // } // // public <C extends Collection> C getContainerInstance(Class<C> type) { // final Factory<C> factory = containerFactoryManager.getFactory(type); // if (factory == null) // throw new UnableToDeserializeException("Could not get container instance because there's no factory " + // "registered in the requestor."); // return factory.get(); // } // // protected ContainerFactoryManager getContainerFactoryManager() { // return containerFactoryManager; // } // } // // Path: src/main/java/org/turbogwt/net/serialization/client/Deserializer.java // public interface Deserializer<T> { // // /** // * Method for accessing type of the Object this deserializer can handle. // * // * @return The class which this deserializer can deserialize // */ // Class<T> handledType(); // // /** // * Tells the content-type patterns which this deserializer handles. // * <p/> // * // * E.g., a deserializer for JSON can return {"application/json", "application/javascript"}.<br> // * If you want to create a deserializer for any content-type just return "*&#47;*". // * // * @return The content-type patterns handled by this deserializer. // */ // String[] accept(); // // /** // * Deserialize the plain text into an object of type T. // * // * @param response Http response body content // * @param context Context of deserialization // * // * @return The object deserialized // */ // T deserialize(String response, DeserializationContext context); // // /** // * Deserialize the plain text into a collection T. // * <p/> // * // * The collection instance can be retrieved from its {@link org.turbogwt.core.util.shared.Factory}, // * obtained in {@link ContainerFactoryManager#getFactory}.<br> // * The ContainerFactoryManager can be retrieved from {@link DeserializationContext#getContainerInstance(Class)}. // * // * @param collectionType The class of the collection // * @param response Http response body content // * @param context Context of deserialization // * // * @return The object deserialized // */ // <C extends Collection<T>> C deserializeAsCollection(Class<C> collectionType, String response, // DeserializationContext context); // }
import java.util.Collection; import org.turbogwt.net.serialization.client.DeserializationContext; import org.turbogwt.net.serialization.client.Deserializer;
/* * Copyright 2014 Grow Bit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.turbogwt.net.serialization.client.misc; /** * Pass-through deserializer for plain text and generic stuff. * * @author Danilo Reinert */ public class TextDeserializer implements Deserializer<String> { public static String[] ACCEPT_PATTERNS = new String[]{"text/plain", "*/*"}; private static final TextDeserializer INSTANCE = new TextDeserializer(); public static TextDeserializer getInstance() { return INSTANCE; } /** * Method for accessing type of Objects this deserializer can handle. * * @return The class which this deserializer can deserialize */ @Override public Class<String> handledType() { return String.class; } /** * Informs the content type this serializer handle. * * @return The content type handled by this serializer. */ @Override public String[] accept() { return ACCEPT_PATTERNS; } /** * Deserialize the plain text into an object of type T. * * @param response Http response body content * @param context Context of deserialization * * @return The object deserialized */ @Override
// Path: src/main/java/org/turbogwt/net/serialization/client/DeserializationContext.java // public abstract class DeserializationContext { // // private final ContainerFactoryManager containerFactoryManager; // // public DeserializationContext(ContainerFactoryManager containerFactoryManager) { // this.containerFactoryManager = containerFactoryManager; // } // // public <C extends Collection> C getContainerInstance(Class<C> type) { // final Factory<C> factory = containerFactoryManager.getFactory(type); // if (factory == null) // throw new UnableToDeserializeException("Could not get container instance because there's no factory " + // "registered in the requestor."); // return factory.get(); // } // // protected ContainerFactoryManager getContainerFactoryManager() { // return containerFactoryManager; // } // } // // Path: src/main/java/org/turbogwt/net/serialization/client/Deserializer.java // public interface Deserializer<T> { // // /** // * Method for accessing type of the Object this deserializer can handle. // * // * @return The class which this deserializer can deserialize // */ // Class<T> handledType(); // // /** // * Tells the content-type patterns which this deserializer handles. // * <p/> // * // * E.g., a deserializer for JSON can return {"application/json", "application/javascript"}.<br> // * If you want to create a deserializer for any content-type just return "*&#47;*". // * // * @return The content-type patterns handled by this deserializer. // */ // String[] accept(); // // /** // * Deserialize the plain text into an object of type T. // * // * @param response Http response body content // * @param context Context of deserialization // * // * @return The object deserialized // */ // T deserialize(String response, DeserializationContext context); // // /** // * Deserialize the plain text into a collection T. // * <p/> // * // * The collection instance can be retrieved from its {@link org.turbogwt.core.util.shared.Factory}, // * obtained in {@link ContainerFactoryManager#getFactory}.<br> // * The ContainerFactoryManager can be retrieved from {@link DeserializationContext#getContainerInstance(Class)}. // * // * @param collectionType The class of the collection // * @param response Http response body content // * @param context Context of deserialization // * // * @return The object deserialized // */ // <C extends Collection<T>> C deserializeAsCollection(Class<C> collectionType, String response, // DeserializationContext context); // } // Path: src/main/java/org/turbogwt/net/serialization/client/misc/TextDeserializer.java import java.util.Collection; import org.turbogwt.net.serialization.client.DeserializationContext; import org.turbogwt.net.serialization.client.Deserializer; /* * Copyright 2014 Grow Bit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.turbogwt.net.serialization.client.misc; /** * Pass-through deserializer for plain text and generic stuff. * * @author Danilo Reinert */ public class TextDeserializer implements Deserializer<String> { public static String[] ACCEPT_PATTERNS = new String[]{"text/plain", "*/*"}; private static final TextDeserializer INSTANCE = new TextDeserializer(); public static TextDeserializer getInstance() { return INSTANCE; } /** * Method for accessing type of Objects this deserializer can handle. * * @return The class which this deserializer can deserialize */ @Override public Class<String> handledType() { return String.class; } /** * Informs the content type this serializer handle. * * @return The content type handled by this serializer. */ @Override public String[] accept() { return ACCEPT_PATTERNS; } /** * Deserialize the plain text into an object of type T. * * @param response Http response body content * @param context Context of deserialization * * @return The object deserialized */ @Override
public String deserialize(String response, DeserializationContext context) {
growbit/turbogwt-http
src/test/java/org/turbogwt/net/http/client/books/BookXmlSerdes.java
// Path: src/main/java/org/turbogwt/net/serialization/client/DeserializationContext.java // public abstract class DeserializationContext { // // private final ContainerFactoryManager containerFactoryManager; // // public DeserializationContext(ContainerFactoryManager containerFactoryManager) { // this.containerFactoryManager = containerFactoryManager; // } // // public <C extends Collection> C getContainerInstance(Class<C> type) { // final Factory<C> factory = containerFactoryManager.getFactory(type); // if (factory == null) // throw new UnableToDeserializeException("Could not get container instance because there's no factory " + // "registered in the requestor."); // return factory.get(); // } // // protected ContainerFactoryManager getContainerFactoryManager() { // return containerFactoryManager; // } // } // // Path: src/main/java/org/turbogwt/net/serialization/client/Serdes.java // public interface Serdes<T> extends Deserializer<T>, Serializer<T> { // // /** // * Method for accessing type of the Object this de/serializer can handle. // * // * @return The class which this de/serializer can de/serialize // */ // @Override // Class<T> handledType(); // } // // Path: src/main/java/org/turbogwt/net/serialization/client/SerializationContext.java // public abstract class SerializationContext { // } // // Path: src/main/java/org/turbogwt/net/serialization/client/UnableToDeserializeException.java // public class UnableToDeserializeException extends SerializationException { // // public UnableToDeserializeException() { // } // // public UnableToDeserializeException(String s) { // super(s); // } // // public UnableToDeserializeException(String s, Throwable throwable) { // super(s, throwable); // } // }
import com.google.gwt.xml.client.Document; import com.google.gwt.xml.client.NodeList; import com.google.gwt.xml.client.Text; import com.google.gwt.xml.client.XMLParser; import com.google.gwt.xml.client.impl.DOMParseException; import java.util.Collection; import java.util.Collections; import org.turbogwt.net.serialization.client.DeserializationContext; import org.turbogwt.net.serialization.client.Serdes; import org.turbogwt.net.serialization.client.SerializationContext; import org.turbogwt.net.serialization.client.UnableToDeserializeException;
/* * Copyright 2014 Grow Bit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.turbogwt.net.http.client.books; /** * @author Danilo Reinert */ public class BookXmlSerdes implements Serdes<Book> { public static final String[] CONTENT_TYPE_PATTERNS = new String[]{"*/xml", "*/*+xml", "*/xml+*"}; /** * Method for accessing type of Objects this deserializer can handle. * * @return The class which this deserializer can deserialize */ @Override public Class<Book> handledType() { return Book.class; } /** * Informs the content type this serializer serializes. * * @return The content type serialized. */ @Override public String[] contentType() { return CONTENT_TYPE_PATTERNS; } /** * Serialize T to plain text. * * @param book The object to be serialized * @param context Context of the serialization * * @return The object serialized. */ @Override
// Path: src/main/java/org/turbogwt/net/serialization/client/DeserializationContext.java // public abstract class DeserializationContext { // // private final ContainerFactoryManager containerFactoryManager; // // public DeserializationContext(ContainerFactoryManager containerFactoryManager) { // this.containerFactoryManager = containerFactoryManager; // } // // public <C extends Collection> C getContainerInstance(Class<C> type) { // final Factory<C> factory = containerFactoryManager.getFactory(type); // if (factory == null) // throw new UnableToDeserializeException("Could not get container instance because there's no factory " + // "registered in the requestor."); // return factory.get(); // } // // protected ContainerFactoryManager getContainerFactoryManager() { // return containerFactoryManager; // } // } // // Path: src/main/java/org/turbogwt/net/serialization/client/Serdes.java // public interface Serdes<T> extends Deserializer<T>, Serializer<T> { // // /** // * Method for accessing type of the Object this de/serializer can handle. // * // * @return The class which this de/serializer can de/serialize // */ // @Override // Class<T> handledType(); // } // // Path: src/main/java/org/turbogwt/net/serialization/client/SerializationContext.java // public abstract class SerializationContext { // } // // Path: src/main/java/org/turbogwt/net/serialization/client/UnableToDeserializeException.java // public class UnableToDeserializeException extends SerializationException { // // public UnableToDeserializeException() { // } // // public UnableToDeserializeException(String s) { // super(s); // } // // public UnableToDeserializeException(String s, Throwable throwable) { // super(s, throwable); // } // } // Path: src/test/java/org/turbogwt/net/http/client/books/BookXmlSerdes.java import com.google.gwt.xml.client.Document; import com.google.gwt.xml.client.NodeList; import com.google.gwt.xml.client.Text; import com.google.gwt.xml.client.XMLParser; import com.google.gwt.xml.client.impl.DOMParseException; import java.util.Collection; import java.util.Collections; import org.turbogwt.net.serialization.client.DeserializationContext; import org.turbogwt.net.serialization.client.Serdes; import org.turbogwt.net.serialization.client.SerializationContext; import org.turbogwt.net.serialization.client.UnableToDeserializeException; /* * Copyright 2014 Grow Bit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.turbogwt.net.http.client.books; /** * @author Danilo Reinert */ public class BookXmlSerdes implements Serdes<Book> { public static final String[] CONTENT_TYPE_PATTERNS = new String[]{"*/xml", "*/*+xml", "*/xml+*"}; /** * Method for accessing type of Objects this deserializer can handle. * * @return The class which this deserializer can deserialize */ @Override public Class<Book> handledType() { return Book.class; } /** * Informs the content type this serializer serializes. * * @return The content type serialized. */ @Override public String[] contentType() { return CONTENT_TYPE_PATTERNS; } /** * Serialize T to plain text. * * @param book The object to be serialized * @param context Context of the serialization * * @return The object serialized. */ @Override
public String serialize(Book book, SerializationContext context) {
growbit/turbogwt-http
src/test/java/org/turbogwt/net/http/client/books/BookXmlSerdes.java
// Path: src/main/java/org/turbogwt/net/serialization/client/DeserializationContext.java // public abstract class DeserializationContext { // // private final ContainerFactoryManager containerFactoryManager; // // public DeserializationContext(ContainerFactoryManager containerFactoryManager) { // this.containerFactoryManager = containerFactoryManager; // } // // public <C extends Collection> C getContainerInstance(Class<C> type) { // final Factory<C> factory = containerFactoryManager.getFactory(type); // if (factory == null) // throw new UnableToDeserializeException("Could not get container instance because there's no factory " + // "registered in the requestor."); // return factory.get(); // } // // protected ContainerFactoryManager getContainerFactoryManager() { // return containerFactoryManager; // } // } // // Path: src/main/java/org/turbogwt/net/serialization/client/Serdes.java // public interface Serdes<T> extends Deserializer<T>, Serializer<T> { // // /** // * Method for accessing type of the Object this de/serializer can handle. // * // * @return The class which this de/serializer can de/serialize // */ // @Override // Class<T> handledType(); // } // // Path: src/main/java/org/turbogwt/net/serialization/client/SerializationContext.java // public abstract class SerializationContext { // } // // Path: src/main/java/org/turbogwt/net/serialization/client/UnableToDeserializeException.java // public class UnableToDeserializeException extends SerializationException { // // public UnableToDeserializeException() { // } // // public UnableToDeserializeException(String s) { // super(s); // } // // public UnableToDeserializeException(String s, Throwable throwable) { // super(s, throwable); // } // }
import com.google.gwt.xml.client.Document; import com.google.gwt.xml.client.NodeList; import com.google.gwt.xml.client.Text; import com.google.gwt.xml.client.XMLParser; import com.google.gwt.xml.client.impl.DOMParseException; import java.util.Collection; import java.util.Collections; import org.turbogwt.net.serialization.client.DeserializationContext; import org.turbogwt.net.serialization.client.Serdes; import org.turbogwt.net.serialization.client.SerializationContext; import org.turbogwt.net.serialization.client.UnableToDeserializeException;
/* * Copyright 2014 Grow Bit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.turbogwt.net.http.client.books; /** * @author Danilo Reinert */ public class BookXmlSerdes implements Serdes<Book> { public static final String[] CONTENT_TYPE_PATTERNS = new String[]{"*/xml", "*/*+xml", "*/xml+*"}; /** * Method for accessing type of Objects this deserializer can handle. * * @return The class which this deserializer can deserialize */ @Override public Class<Book> handledType() { return Book.class; } /** * Informs the content type this serializer serializes. * * @return The content type serialized. */ @Override public String[] contentType() { return CONTENT_TYPE_PATTERNS; } /** * Serialize T to plain text. * * @param book The object to be serialized * @param context Context of the serialization * * @return The object serialized. */ @Override public String serialize(Book book, SerializationContext context) { StringBuilder xmlBuilder = buildXml(book); return xmlBuilder.toString(); } /** * Serialize a collection of T to plain text. * * @param c The collection of the object to be serialized * @param context Context of the serialization * * @return The object serialized. */ @Override public String serializeFromCollection(Collection<Book> c, SerializationContext context) { StringBuilder xmlBuilder = new StringBuilder("<books>"); for (Book book : c) { xmlBuilder.append(buildXml(book)); } xmlBuilder.append("</books>"); return xmlBuilder.toString(); } /** * Informs the content type this serializer handle. * * @return The content type handled by this serializer. */ @Override public String[] accept() { return CONTENT_TYPE_PATTERNS; } /** * Deserialize the plain text into an object of type T. * * @param response Http response body content * @param context Context of deserialization * * @return The object deserialized */ @Override
// Path: src/main/java/org/turbogwt/net/serialization/client/DeserializationContext.java // public abstract class DeserializationContext { // // private final ContainerFactoryManager containerFactoryManager; // // public DeserializationContext(ContainerFactoryManager containerFactoryManager) { // this.containerFactoryManager = containerFactoryManager; // } // // public <C extends Collection> C getContainerInstance(Class<C> type) { // final Factory<C> factory = containerFactoryManager.getFactory(type); // if (factory == null) // throw new UnableToDeserializeException("Could not get container instance because there's no factory " + // "registered in the requestor."); // return factory.get(); // } // // protected ContainerFactoryManager getContainerFactoryManager() { // return containerFactoryManager; // } // } // // Path: src/main/java/org/turbogwt/net/serialization/client/Serdes.java // public interface Serdes<T> extends Deserializer<T>, Serializer<T> { // // /** // * Method for accessing type of the Object this de/serializer can handle. // * // * @return The class which this de/serializer can de/serialize // */ // @Override // Class<T> handledType(); // } // // Path: src/main/java/org/turbogwt/net/serialization/client/SerializationContext.java // public abstract class SerializationContext { // } // // Path: src/main/java/org/turbogwt/net/serialization/client/UnableToDeserializeException.java // public class UnableToDeserializeException extends SerializationException { // // public UnableToDeserializeException() { // } // // public UnableToDeserializeException(String s) { // super(s); // } // // public UnableToDeserializeException(String s, Throwable throwable) { // super(s, throwable); // } // } // Path: src/test/java/org/turbogwt/net/http/client/books/BookXmlSerdes.java import com.google.gwt.xml.client.Document; import com.google.gwt.xml.client.NodeList; import com.google.gwt.xml.client.Text; import com.google.gwt.xml.client.XMLParser; import com.google.gwt.xml.client.impl.DOMParseException; import java.util.Collection; import java.util.Collections; import org.turbogwt.net.serialization.client.DeserializationContext; import org.turbogwt.net.serialization.client.Serdes; import org.turbogwt.net.serialization.client.SerializationContext; import org.turbogwt.net.serialization.client.UnableToDeserializeException; /* * Copyright 2014 Grow Bit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.turbogwt.net.http.client.books; /** * @author Danilo Reinert */ public class BookXmlSerdes implements Serdes<Book> { public static final String[] CONTENT_TYPE_PATTERNS = new String[]{"*/xml", "*/*+xml", "*/xml+*"}; /** * Method for accessing type of Objects this deserializer can handle. * * @return The class which this deserializer can deserialize */ @Override public Class<Book> handledType() { return Book.class; } /** * Informs the content type this serializer serializes. * * @return The content type serialized. */ @Override public String[] contentType() { return CONTENT_TYPE_PATTERNS; } /** * Serialize T to plain text. * * @param book The object to be serialized * @param context Context of the serialization * * @return The object serialized. */ @Override public String serialize(Book book, SerializationContext context) { StringBuilder xmlBuilder = buildXml(book); return xmlBuilder.toString(); } /** * Serialize a collection of T to plain text. * * @param c The collection of the object to be serialized * @param context Context of the serialization * * @return The object serialized. */ @Override public String serializeFromCollection(Collection<Book> c, SerializationContext context) { StringBuilder xmlBuilder = new StringBuilder("<books>"); for (Book book : c) { xmlBuilder.append(buildXml(book)); } xmlBuilder.append("</books>"); return xmlBuilder.toString(); } /** * Informs the content type this serializer handle. * * @return The content type handled by this serializer. */ @Override public String[] accept() { return CONTENT_TYPE_PATTERNS; } /** * Deserialize the plain text into an object of type T. * * @param response Http response body content * @param context Context of deserialization * * @return The object deserialized */ @Override
public Book deserialize(String response, DeserializationContext context) {
growbit/turbogwt-http
src/test/java/org/turbogwt/net/http/client/books/BookXmlSerdes.java
// Path: src/main/java/org/turbogwt/net/serialization/client/DeserializationContext.java // public abstract class DeserializationContext { // // private final ContainerFactoryManager containerFactoryManager; // // public DeserializationContext(ContainerFactoryManager containerFactoryManager) { // this.containerFactoryManager = containerFactoryManager; // } // // public <C extends Collection> C getContainerInstance(Class<C> type) { // final Factory<C> factory = containerFactoryManager.getFactory(type); // if (factory == null) // throw new UnableToDeserializeException("Could not get container instance because there's no factory " + // "registered in the requestor."); // return factory.get(); // } // // protected ContainerFactoryManager getContainerFactoryManager() { // return containerFactoryManager; // } // } // // Path: src/main/java/org/turbogwt/net/serialization/client/Serdes.java // public interface Serdes<T> extends Deserializer<T>, Serializer<T> { // // /** // * Method for accessing type of the Object this de/serializer can handle. // * // * @return The class which this de/serializer can de/serialize // */ // @Override // Class<T> handledType(); // } // // Path: src/main/java/org/turbogwt/net/serialization/client/SerializationContext.java // public abstract class SerializationContext { // } // // Path: src/main/java/org/turbogwt/net/serialization/client/UnableToDeserializeException.java // public class UnableToDeserializeException extends SerializationException { // // public UnableToDeserializeException() { // } // // public UnableToDeserializeException(String s) { // super(s); // } // // public UnableToDeserializeException(String s, Throwable throwable) { // super(s, throwable); // } // }
import com.google.gwt.xml.client.Document; import com.google.gwt.xml.client.NodeList; import com.google.gwt.xml.client.Text; import com.google.gwt.xml.client.XMLParser; import com.google.gwt.xml.client.impl.DOMParseException; import java.util.Collection; import java.util.Collections; import org.turbogwt.net.serialization.client.DeserializationContext; import org.turbogwt.net.serialization.client.Serdes; import org.turbogwt.net.serialization.client.SerializationContext; import org.turbogwt.net.serialization.client.UnableToDeserializeException;
xmlBuilder.append(buildXml(book)); } xmlBuilder.append("</books>"); return xmlBuilder.toString(); } /** * Informs the content type this serializer handle. * * @return The content type handled by this serializer. */ @Override public String[] accept() { return CONTENT_TYPE_PATTERNS; } /** * Deserialize the plain text into an object of type T. * * @param response Http response body content * @param context Context of deserialization * * @return The object deserialized */ @Override public Book deserialize(String response, DeserializationContext context) { Document xml; try { xml = XMLParser.parse(response); } catch (DOMParseException e) {
// Path: src/main/java/org/turbogwt/net/serialization/client/DeserializationContext.java // public abstract class DeserializationContext { // // private final ContainerFactoryManager containerFactoryManager; // // public DeserializationContext(ContainerFactoryManager containerFactoryManager) { // this.containerFactoryManager = containerFactoryManager; // } // // public <C extends Collection> C getContainerInstance(Class<C> type) { // final Factory<C> factory = containerFactoryManager.getFactory(type); // if (factory == null) // throw new UnableToDeserializeException("Could not get container instance because there's no factory " + // "registered in the requestor."); // return factory.get(); // } // // protected ContainerFactoryManager getContainerFactoryManager() { // return containerFactoryManager; // } // } // // Path: src/main/java/org/turbogwt/net/serialization/client/Serdes.java // public interface Serdes<T> extends Deserializer<T>, Serializer<T> { // // /** // * Method for accessing type of the Object this de/serializer can handle. // * // * @return The class which this de/serializer can de/serialize // */ // @Override // Class<T> handledType(); // } // // Path: src/main/java/org/turbogwt/net/serialization/client/SerializationContext.java // public abstract class SerializationContext { // } // // Path: src/main/java/org/turbogwt/net/serialization/client/UnableToDeserializeException.java // public class UnableToDeserializeException extends SerializationException { // // public UnableToDeserializeException() { // } // // public UnableToDeserializeException(String s) { // super(s); // } // // public UnableToDeserializeException(String s, Throwable throwable) { // super(s, throwable); // } // } // Path: src/test/java/org/turbogwt/net/http/client/books/BookXmlSerdes.java import com.google.gwt.xml.client.Document; import com.google.gwt.xml.client.NodeList; import com.google.gwt.xml.client.Text; import com.google.gwt.xml.client.XMLParser; import com.google.gwt.xml.client.impl.DOMParseException; import java.util.Collection; import java.util.Collections; import org.turbogwt.net.serialization.client.DeserializationContext; import org.turbogwt.net.serialization.client.Serdes; import org.turbogwt.net.serialization.client.SerializationContext; import org.turbogwt.net.serialization.client.UnableToDeserializeException; xmlBuilder.append(buildXml(book)); } xmlBuilder.append("</books>"); return xmlBuilder.toString(); } /** * Informs the content type this serializer handle. * * @return The content type handled by this serializer. */ @Override public String[] accept() { return CONTENT_TYPE_PATTERNS; } /** * Deserialize the plain text into an object of type T. * * @param response Http response body content * @param context Context of deserialization * * @return The object deserialized */ @Override public Book deserialize(String response, DeserializationContext context) { Document xml; try { xml = XMLParser.parse(response); } catch (DOMParseException e) {
throw new UnableToDeserializeException("Could not read response as xml.", e);
growbit/turbogwt-http
src/test/java/org/turbogwt/net/http/client/QualityFactorHeaderTest.java
// Path: src/main/java/org/turbogwt/net/http/client/header/QualityFactorHeader.java // public class QualityFactorHeader extends MultivaluedHeader implements Iterable<QualityFactorHeader.Value> { // // private final Value[] values; // // public QualityFactorHeader(String name, Value... values) { // super(name, (Object[]) values); // this.values = values; // } // // public QualityFactorHeader(String name, String... values) { // super(name, (String[]) values); // this.values = new Value[values.length]; // for (int i = 0; i < values.length; i++) { // String value = values[i]; // this.values[i] = new Value(value); // } // Arrays.sort(values); // } // // public Value[] getQualityFactorValues() { // return values; // } // // @Override // public Iterator<Value> iterator() { // return new JsArrayIterator<>(values); // } // // /** // * Represents a HTTP Header value with relative quality factor associated. // */ // public static class Value implements Comparable<Value> { // // private final double factor; // private final String value; // // public Value(String value) { // this(1, value); // } // // public Value(double factor, String value) throws IllegalArgumentException { // if (factor > 1.0 || factor < 0.0) // throw new IllegalArgumentException("Factor must be between 0 and 1."); // if (value == null || value.isEmpty()) // throw new IllegalArgumentException("Value cannot be empty or null."); // this.factor = factor; // this.value = value; // } // // public double getFactor() { // return factor; // } // // public String getValue() { // return value; // } // // public String toString() { // if (factor == 1) { // return value; // } // return value + "; " + factor; // } // // @Override // public int compareTo(Value value) { // return Double.compare(value.factor, factor); // } // // @Override // public boolean equals(Object o) { // if (this == o) { // return true; // } // if (!(o instanceof Value)) { // return false; // } // // final Value value1 = (Value) o; // // if (Double.compare(value1.factor, factor) != 0) { // return false; // } // if (!value.equals(value1.value)) { // return false; // } // // return true; // } // // @Override // public int hashCode() { // int result; // long temp; // temp = Double.doubleToLongBits(factor); // result = (int) (temp ^ (temp >>> 32)); // result = 31 * result + value.hashCode(); // return result; // } // } // }
import com.google.gwt.junit.client.GWTTestCase; import org.turbogwt.net.http.client.header.QualityFactorHeader;
/* * Copyright 2014 Grow Bit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.turbogwt.net.http.client; /** * @author Danilo Reinert */ public class QualityFactorHeaderTest extends GWTTestCase { @Override public String getModuleName() { return "org.turbogwt.net.http.HttpTest"; } public void testGetValue() { final String expected = "a/b, x/y+z; 0.2, k/l, n/m; 0.6";
// Path: src/main/java/org/turbogwt/net/http/client/header/QualityFactorHeader.java // public class QualityFactorHeader extends MultivaluedHeader implements Iterable<QualityFactorHeader.Value> { // // private final Value[] values; // // public QualityFactorHeader(String name, Value... values) { // super(name, (Object[]) values); // this.values = values; // } // // public QualityFactorHeader(String name, String... values) { // super(name, (String[]) values); // this.values = new Value[values.length]; // for (int i = 0; i < values.length; i++) { // String value = values[i]; // this.values[i] = new Value(value); // } // Arrays.sort(values); // } // // public Value[] getQualityFactorValues() { // return values; // } // // @Override // public Iterator<Value> iterator() { // return new JsArrayIterator<>(values); // } // // /** // * Represents a HTTP Header value with relative quality factor associated. // */ // public static class Value implements Comparable<Value> { // // private final double factor; // private final String value; // // public Value(String value) { // this(1, value); // } // // public Value(double factor, String value) throws IllegalArgumentException { // if (factor > 1.0 || factor < 0.0) // throw new IllegalArgumentException("Factor must be between 0 and 1."); // if (value == null || value.isEmpty()) // throw new IllegalArgumentException("Value cannot be empty or null."); // this.factor = factor; // this.value = value; // } // // public double getFactor() { // return factor; // } // // public String getValue() { // return value; // } // // public String toString() { // if (factor == 1) { // return value; // } // return value + "; " + factor; // } // // @Override // public int compareTo(Value value) { // return Double.compare(value.factor, factor); // } // // @Override // public boolean equals(Object o) { // if (this == o) { // return true; // } // if (!(o instanceof Value)) { // return false; // } // // final Value value1 = (Value) o; // // if (Double.compare(value1.factor, factor) != 0) { // return false; // } // if (!value.equals(value1.value)) { // return false; // } // // return true; // } // // @Override // public int hashCode() { // int result; // long temp; // temp = Double.doubleToLongBits(factor); // result = (int) (temp ^ (temp >>> 32)); // result = 31 * result + value.hashCode(); // return result; // } // } // } // Path: src/test/java/org/turbogwt/net/http/client/QualityFactorHeaderTest.java import com.google.gwt.junit.client.GWTTestCase; import org.turbogwt.net.http.client.header.QualityFactorHeader; /* * Copyright 2014 Grow Bit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.turbogwt.net.http.client; /** * @author Danilo Reinert */ public class QualityFactorHeaderTest extends GWTTestCase { @Override public String getModuleName() { return "org.turbogwt.net.http.HttpTest"; } public void testGetValue() { final String expected = "a/b, x/y+z; 0.2, k/l, n/m; 0.6";
final QualityFactorHeader header = new QualityFactorHeader("name",
growbit/turbogwt-http
src/test/java/org/turbogwt/net/http/client/SimpleHeaderWithParameterTest.java
// Path: src/main/java/org/turbogwt/net/http/client/header/SimpleHeaderWithParameter.java // public class SimpleHeaderWithParameter extends SimpleHeader { // // public SimpleHeaderWithParameter(String name, String value) { // super(name, value); // } // // public SimpleHeaderWithParameter(String name, String value, Param... params) { // super(name, value + paramsToString(params)); // } // // /** // * Parameter of a header value. // */ // public static class Param { // // final String key; // final String value; // // public Param(String key, String value) { // this.key = key; // this.value = value; // } // // @Override // public String toString() { // return "; " + key + '=' + value; // } // } // // private static String paramsToString(Param... params) { // String result = ""; // for (Param param : params) { // result += param.toString(); // } // return result; // } // }
import com.google.gwt.junit.client.GWTTestCase; import org.turbogwt.net.http.client.header.SimpleHeaderWithParameter;
/* * Copyright 2014 Grow Bit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.turbogwt.net.http.client; /** * @author Danilo Reinert */ public class SimpleHeaderWithParameterTest extends GWTTestCase { @Override public String getModuleName() { return "org.turbogwt.net.http.HttpTest"; } public void testGetValue() { final String expected = "text/html; charset=ISO-8859-4";
// Path: src/main/java/org/turbogwt/net/http/client/header/SimpleHeaderWithParameter.java // public class SimpleHeaderWithParameter extends SimpleHeader { // // public SimpleHeaderWithParameter(String name, String value) { // super(name, value); // } // // public SimpleHeaderWithParameter(String name, String value, Param... params) { // super(name, value + paramsToString(params)); // } // // /** // * Parameter of a header value. // */ // public static class Param { // // final String key; // final String value; // // public Param(String key, String value) { // this.key = key; // this.value = value; // } // // @Override // public String toString() { // return "; " + key + '=' + value; // } // } // // private static String paramsToString(Param... params) { // String result = ""; // for (Param param : params) { // result += param.toString(); // } // return result; // } // } // Path: src/test/java/org/turbogwt/net/http/client/SimpleHeaderWithParameterTest.java import com.google.gwt.junit.client.GWTTestCase; import org.turbogwt.net.http.client.header.SimpleHeaderWithParameter; /* * Copyright 2014 Grow Bit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.turbogwt.net.http.client; /** * @author Danilo Reinert */ public class SimpleHeaderWithParameterTest extends GWTTestCase { @Override public String getModuleName() { return "org.turbogwt.net.http.HttpTest"; } public void testGetValue() { final String expected = "text/html; charset=ISO-8859-4";
final SimpleHeaderWithParameter header = new SimpleHeaderWithParameter("Content-Type", "text/html",
growbit/turbogwt-http
src/main/java/org/turbogwt/net/http/client/FormData.java
// Path: src/main/java/org/turbogwt/net/shared/MultivaluedParamComposition.java // public abstract class MultivaluedParamComposition { // // public static final MultivaluedParamComposition REPEATED_PARAM = new RepeatedParamStrategy(); // public static final MultivaluedParamComposition COMMA_SEPARATED_VALUE = new CommaSeparatedValueStrategy(); // // /** // * Construct URI part from gives values. // * // * @param separator the separator of parameters from current URI part // * @param name the parameter name // * @param values the parameter value(s), each object will be converted to a {@code String} using its {@code // * toString()} method. // * // * @return URI part // */ // public abstract String asUriPart(String separator, String name, Object... values); // // /** // * Assert that the value is not null or empty. // * // * @param value the value // * @param message the message to include with any exceptions // * // * @throws IllegalArgumentException if value is null // */ // protected void assertNotNullOrEmpty(String value, String message) throws IllegalArgumentException { // if (value == null || value.length() == 0) { // throw new IllegalArgumentException(message); // } // } // // /** // * This class formats multiple parameters repeating the parameter name. // */ // public static class RepeatedParamStrategy extends MultivaluedParamComposition { // // /** // * Construct encoded URI part from gives values. // * // * @param separator the separator of parameters from current URI part // * @param name the parameter name // * @param values the parameter value(s), each object will be converted to a {@code String} using its {@code // * toString()} method. // * // * @return encoded URI part // */ // @Override // public String asUriPart(String separator, String name, Object... values) { // assertNotNullOrEmpty(name, "Parameter name cannot be null or empty."); // String uriPart = ""; // String sep = ""; // for (Object value : values) { // String strValue = value.toString(); // assertNotNullOrEmpty(strValue, "Parameter value of *" + name // + "* null or empty. You must inform a valid value"); // // uriPart += sep + URL.encodeQueryString(name) + "=" + URL.encodeQueryString(strValue); // sep = separator; // } // return uriPart; // } // } // // /** // * This class formats multiple parameters joining multiple values separated by comma. // */ // public static class CommaSeparatedValueStrategy extends MultivaluedParamComposition { // // /** // * Construct encoded URI part from gives values. // * // * @param separator the separator of parameters from current URI part // * @param name the parameter name // * @param values the parameter value(s), each object will be converted to a {@code String} using its {@code // * toString()} method. // * // * @return encoded URI part // */ // @Override // public String asUriPart(String separator, String name, Object... values) { // assertNotNullOrEmpty(name, "Parameter name cannot be null or empty."); // String uriPart = URL.encodeQueryString(name) + "="; // String sep = ""; // for (Object value : values) { // String strValue = value.toString(); // assertNotNullOrEmpty(strValue, "Parameter value of *" + name // + "* null or empty. You must inform a valid value"); // // uriPart += sep + URL.encodeQueryString(strValue); // sep = ","; // } // return uriPart; // } // } // }
import java.util.Collection; import java.util.Iterator; import java.util.List; import javax.annotation.Nullable; import org.turbogwt.core.collections.client.JsArrayList; import org.turbogwt.core.collections.client.JsMapInteger; import org.turbogwt.net.shared.MultivaluedParamComposition;
/* * Copyright 2014 Grow Bit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.turbogwt.net.http.client; /** * Stores form params and values. * * @author Danilo Reinert */ public class FormData implements Collection<FormParam> { private final List<FormParam> params;
// Path: src/main/java/org/turbogwt/net/shared/MultivaluedParamComposition.java // public abstract class MultivaluedParamComposition { // // public static final MultivaluedParamComposition REPEATED_PARAM = new RepeatedParamStrategy(); // public static final MultivaluedParamComposition COMMA_SEPARATED_VALUE = new CommaSeparatedValueStrategy(); // // /** // * Construct URI part from gives values. // * // * @param separator the separator of parameters from current URI part // * @param name the parameter name // * @param values the parameter value(s), each object will be converted to a {@code String} using its {@code // * toString()} method. // * // * @return URI part // */ // public abstract String asUriPart(String separator, String name, Object... values); // // /** // * Assert that the value is not null or empty. // * // * @param value the value // * @param message the message to include with any exceptions // * // * @throws IllegalArgumentException if value is null // */ // protected void assertNotNullOrEmpty(String value, String message) throws IllegalArgumentException { // if (value == null || value.length() == 0) { // throw new IllegalArgumentException(message); // } // } // // /** // * This class formats multiple parameters repeating the parameter name. // */ // public static class RepeatedParamStrategy extends MultivaluedParamComposition { // // /** // * Construct encoded URI part from gives values. // * // * @param separator the separator of parameters from current URI part // * @param name the parameter name // * @param values the parameter value(s), each object will be converted to a {@code String} using its {@code // * toString()} method. // * // * @return encoded URI part // */ // @Override // public String asUriPart(String separator, String name, Object... values) { // assertNotNullOrEmpty(name, "Parameter name cannot be null or empty."); // String uriPart = ""; // String sep = ""; // for (Object value : values) { // String strValue = value.toString(); // assertNotNullOrEmpty(strValue, "Parameter value of *" + name // + "* null or empty. You must inform a valid value"); // // uriPart += sep + URL.encodeQueryString(name) + "=" + URL.encodeQueryString(strValue); // sep = separator; // } // return uriPart; // } // } // // /** // * This class formats multiple parameters joining multiple values separated by comma. // */ // public static class CommaSeparatedValueStrategy extends MultivaluedParamComposition { // // /** // * Construct encoded URI part from gives values. // * // * @param separator the separator of parameters from current URI part // * @param name the parameter name // * @param values the parameter value(s), each object will be converted to a {@code String} using its {@code // * toString()} method. // * // * @return encoded URI part // */ // @Override // public String asUriPart(String separator, String name, Object... values) { // assertNotNullOrEmpty(name, "Parameter name cannot be null or empty."); // String uriPart = URL.encodeQueryString(name) + "="; // String sep = ""; // for (Object value : values) { // String strValue = value.toString(); // assertNotNullOrEmpty(strValue, "Parameter value of *" + name // + "* null or empty. You must inform a valid value"); // // uriPart += sep + URL.encodeQueryString(strValue); // sep = ","; // } // return uriPart; // } // } // } // Path: src/main/java/org/turbogwt/net/http/client/FormData.java import java.util.Collection; import java.util.Iterator; import java.util.List; import javax.annotation.Nullable; import org.turbogwt.core.collections.client.JsArrayList; import org.turbogwt.core.collections.client.JsMapInteger; import org.turbogwt.net.shared.MultivaluedParamComposition; /* * Copyright 2014 Grow Bit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.turbogwt.net.http.client; /** * Stores form params and values. * * @author Danilo Reinert */ public class FormData implements Collection<FormParam> { private final List<FormParam> params;
private MultivaluedParamComposition multivaluedParamComposition;
growbit/turbogwt-http
src/main/java/org/turbogwt/net/serialization/client/json/JsonObjectSerdes.java
// Path: src/main/java/org/turbogwt/net/serialization/client/DeserializationContext.java // public abstract class DeserializationContext { // // private final ContainerFactoryManager containerFactoryManager; // // public DeserializationContext(ContainerFactoryManager containerFactoryManager) { // this.containerFactoryManager = containerFactoryManager; // } // // public <C extends Collection> C getContainerInstance(Class<C> type) { // final Factory<C> factory = containerFactoryManager.getFactory(type); // if (factory == null) // throw new UnableToDeserializeException("Could not get container instance because there's no factory " + // "registered in the requestor."); // return factory.get(); // } // // protected ContainerFactoryManager getContainerFactoryManager() { // return containerFactoryManager; // } // } // // Path: src/main/java/org/turbogwt/net/serialization/client/SerializationContext.java // public abstract class SerializationContext { // } // // Path: src/main/java/org/turbogwt/net/serialization/client/UnableToDeserializeException.java // public class UnableToDeserializeException extends SerializationException { // // public UnableToDeserializeException() { // } // // public UnableToDeserializeException(String s) { // super(s); // } // // public UnableToDeserializeException(String s, Throwable throwable) { // super(s, throwable); // } // }
import com.google.gwt.core.client.JavaScriptObject; import com.google.gwt.core.client.JsArray; import com.google.gwt.core.client.JsonUtils; import java.util.Collection; import org.turbogwt.core.util.client.Overlays; import org.turbogwt.net.serialization.client.DeserializationContext; import org.turbogwt.net.serialization.client.SerializationContext; import org.turbogwt.net.serialization.client.UnableToDeserializeException;
/* * Copyright 2014 Grow Bit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.turbogwt.net.serialization.client.json; /** * Base class for all SerDes that manipulates serialized JSON objects. * * @param <T> Type of the object to serialize/deserialize. * * @author Danilo Reinert */ public abstract class JsonObjectSerdes<T> extends JsonSerdes<T> { public JsonObjectSerdes(Class<T> handledType) { super(handledType); } /** * Verifies if the deserializer should evaluate the response safely. * <p/> * If this method returns <code>true</code>, then the deserializer will evaluate the response using * {@link com.google.gwt.core.client.JsonUtils#safeEval(String)}, otherwise it will use * {@link com.google.gwt.core.client.JsonUtils#unsafeEval(String)}. * <p/> * If you are completely sure you'll will always receive safe contents, then you can override it * to return <code>false</code> and you'll benefit a faster deserialization. * <p/> * The default implementation is <code>true</code>. * * @return <code>true</code> if you want to evaluate response safely, * or <code>false</code> to evaluate unsafely */ public boolean useSafeEval() { return true; } /** * Recover an instance of T from deserialized JSON. * * @param reader The evaluated response * @param context Context of the deserialization * * @return The object deserialized */
// Path: src/main/java/org/turbogwt/net/serialization/client/DeserializationContext.java // public abstract class DeserializationContext { // // private final ContainerFactoryManager containerFactoryManager; // // public DeserializationContext(ContainerFactoryManager containerFactoryManager) { // this.containerFactoryManager = containerFactoryManager; // } // // public <C extends Collection> C getContainerInstance(Class<C> type) { // final Factory<C> factory = containerFactoryManager.getFactory(type); // if (factory == null) // throw new UnableToDeserializeException("Could not get container instance because there's no factory " + // "registered in the requestor."); // return factory.get(); // } // // protected ContainerFactoryManager getContainerFactoryManager() { // return containerFactoryManager; // } // } // // Path: src/main/java/org/turbogwt/net/serialization/client/SerializationContext.java // public abstract class SerializationContext { // } // // Path: src/main/java/org/turbogwt/net/serialization/client/UnableToDeserializeException.java // public class UnableToDeserializeException extends SerializationException { // // public UnableToDeserializeException() { // } // // public UnableToDeserializeException(String s) { // super(s); // } // // public UnableToDeserializeException(String s, Throwable throwable) { // super(s, throwable); // } // } // Path: src/main/java/org/turbogwt/net/serialization/client/json/JsonObjectSerdes.java import com.google.gwt.core.client.JavaScriptObject; import com.google.gwt.core.client.JsArray; import com.google.gwt.core.client.JsonUtils; import java.util.Collection; import org.turbogwt.core.util.client.Overlays; import org.turbogwt.net.serialization.client.DeserializationContext; import org.turbogwt.net.serialization.client.SerializationContext; import org.turbogwt.net.serialization.client.UnableToDeserializeException; /* * Copyright 2014 Grow Bit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.turbogwt.net.serialization.client.json; /** * Base class for all SerDes that manipulates serialized JSON objects. * * @param <T> Type of the object to serialize/deserialize. * * @author Danilo Reinert */ public abstract class JsonObjectSerdes<T> extends JsonSerdes<T> { public JsonObjectSerdes(Class<T> handledType) { super(handledType); } /** * Verifies if the deserializer should evaluate the response safely. * <p/> * If this method returns <code>true</code>, then the deserializer will evaluate the response using * {@link com.google.gwt.core.client.JsonUtils#safeEval(String)}, otherwise it will use * {@link com.google.gwt.core.client.JsonUtils#unsafeEval(String)}. * <p/> * If you are completely sure you'll will always receive safe contents, then you can override it * to return <code>false</code> and you'll benefit a faster deserialization. * <p/> * The default implementation is <code>true</code>. * * @return <code>true</code> if you want to evaluate response safely, * or <code>false</code> to evaluate unsafely */ public boolean useSafeEval() { return true; } /** * Recover an instance of T from deserialized JSON. * * @param reader The evaluated response * @param context Context of the deserialization * * @return The object deserialized */
public abstract T readJson(JsonRecordReader reader, DeserializationContext context);
growbit/turbogwt-http
src/main/java/org/turbogwt/net/serialization/client/json/JsonObjectSerdes.java
// Path: src/main/java/org/turbogwt/net/serialization/client/DeserializationContext.java // public abstract class DeserializationContext { // // private final ContainerFactoryManager containerFactoryManager; // // public DeserializationContext(ContainerFactoryManager containerFactoryManager) { // this.containerFactoryManager = containerFactoryManager; // } // // public <C extends Collection> C getContainerInstance(Class<C> type) { // final Factory<C> factory = containerFactoryManager.getFactory(type); // if (factory == null) // throw new UnableToDeserializeException("Could not get container instance because there's no factory " + // "registered in the requestor."); // return factory.get(); // } // // protected ContainerFactoryManager getContainerFactoryManager() { // return containerFactoryManager; // } // } // // Path: src/main/java/org/turbogwt/net/serialization/client/SerializationContext.java // public abstract class SerializationContext { // } // // Path: src/main/java/org/turbogwt/net/serialization/client/UnableToDeserializeException.java // public class UnableToDeserializeException extends SerializationException { // // public UnableToDeserializeException() { // } // // public UnableToDeserializeException(String s) { // super(s); // } // // public UnableToDeserializeException(String s, Throwable throwable) { // super(s, throwable); // } // }
import com.google.gwt.core.client.JavaScriptObject; import com.google.gwt.core.client.JsArray; import com.google.gwt.core.client.JsonUtils; import java.util.Collection; import org.turbogwt.core.util.client.Overlays; import org.turbogwt.net.serialization.client.DeserializationContext; import org.turbogwt.net.serialization.client.SerializationContext; import org.turbogwt.net.serialization.client.UnableToDeserializeException;
/* * Copyright 2014 Grow Bit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.turbogwt.net.serialization.client.json; /** * Base class for all SerDes that manipulates serialized JSON objects. * * @param <T> Type of the object to serialize/deserialize. * * @author Danilo Reinert */ public abstract class JsonObjectSerdes<T> extends JsonSerdes<T> { public JsonObjectSerdes(Class<T> handledType) { super(handledType); } /** * Verifies if the deserializer should evaluate the response safely. * <p/> * If this method returns <code>true</code>, then the deserializer will evaluate the response using * {@link com.google.gwt.core.client.JsonUtils#safeEval(String)}, otherwise it will use * {@link com.google.gwt.core.client.JsonUtils#unsafeEval(String)}. * <p/> * If you are completely sure you'll will always receive safe contents, then you can override it * to return <code>false</code> and you'll benefit a faster deserialization. * <p/> * The default implementation is <code>true</code>. * * @return <code>true</code> if you want to evaluate response safely, * or <code>false</code> to evaluate unsafely */ public boolean useSafeEval() { return true; } /** * Recover an instance of T from deserialized JSON. * * @param reader The evaluated response * @param context Context of the deserialization * * @return The object deserialized */ public abstract T readJson(JsonRecordReader reader, DeserializationContext context); /** * Build a JSON using {@link JsonRecordWriter}. * Later this JSON will be serialized using JSON#stringify. * * @param t The object to be serialized * @param writer The serializing JSON * @param context Context of the serialization */
// Path: src/main/java/org/turbogwt/net/serialization/client/DeserializationContext.java // public abstract class DeserializationContext { // // private final ContainerFactoryManager containerFactoryManager; // // public DeserializationContext(ContainerFactoryManager containerFactoryManager) { // this.containerFactoryManager = containerFactoryManager; // } // // public <C extends Collection> C getContainerInstance(Class<C> type) { // final Factory<C> factory = containerFactoryManager.getFactory(type); // if (factory == null) // throw new UnableToDeserializeException("Could not get container instance because there's no factory " + // "registered in the requestor."); // return factory.get(); // } // // protected ContainerFactoryManager getContainerFactoryManager() { // return containerFactoryManager; // } // } // // Path: src/main/java/org/turbogwt/net/serialization/client/SerializationContext.java // public abstract class SerializationContext { // } // // Path: src/main/java/org/turbogwt/net/serialization/client/UnableToDeserializeException.java // public class UnableToDeserializeException extends SerializationException { // // public UnableToDeserializeException() { // } // // public UnableToDeserializeException(String s) { // super(s); // } // // public UnableToDeserializeException(String s, Throwable throwable) { // super(s, throwable); // } // } // Path: src/main/java/org/turbogwt/net/serialization/client/json/JsonObjectSerdes.java import com.google.gwt.core.client.JavaScriptObject; import com.google.gwt.core.client.JsArray; import com.google.gwt.core.client.JsonUtils; import java.util.Collection; import org.turbogwt.core.util.client.Overlays; import org.turbogwt.net.serialization.client.DeserializationContext; import org.turbogwt.net.serialization.client.SerializationContext; import org.turbogwt.net.serialization.client.UnableToDeserializeException; /* * Copyright 2014 Grow Bit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.turbogwt.net.serialization.client.json; /** * Base class for all SerDes that manipulates serialized JSON objects. * * @param <T> Type of the object to serialize/deserialize. * * @author Danilo Reinert */ public abstract class JsonObjectSerdes<T> extends JsonSerdes<T> { public JsonObjectSerdes(Class<T> handledType) { super(handledType); } /** * Verifies if the deserializer should evaluate the response safely. * <p/> * If this method returns <code>true</code>, then the deserializer will evaluate the response using * {@link com.google.gwt.core.client.JsonUtils#safeEval(String)}, otherwise it will use * {@link com.google.gwt.core.client.JsonUtils#unsafeEval(String)}. * <p/> * If you are completely sure you'll will always receive safe contents, then you can override it * to return <code>false</code> and you'll benefit a faster deserialization. * <p/> * The default implementation is <code>true</code>. * * @return <code>true</code> if you want to evaluate response safely, * or <code>false</code> to evaluate unsafely */ public boolean useSafeEval() { return true; } /** * Recover an instance of T from deserialized JSON. * * @param reader The evaluated response * @param context Context of the deserialization * * @return The object deserialized */ public abstract T readJson(JsonRecordReader reader, DeserializationContext context); /** * Build a JSON using {@link JsonRecordWriter}. * Later this JSON will be serialized using JSON#stringify. * * @param t The object to be serialized * @param writer The serializing JSON * @param context Context of the serialization */
public abstract void writeJson(T t, JsonRecordWriter writer, SerializationContext context);
growbit/turbogwt-http
src/main/java/org/turbogwt/net/serialization/client/json/JsonObjectSerdes.java
// Path: src/main/java/org/turbogwt/net/serialization/client/DeserializationContext.java // public abstract class DeserializationContext { // // private final ContainerFactoryManager containerFactoryManager; // // public DeserializationContext(ContainerFactoryManager containerFactoryManager) { // this.containerFactoryManager = containerFactoryManager; // } // // public <C extends Collection> C getContainerInstance(Class<C> type) { // final Factory<C> factory = containerFactoryManager.getFactory(type); // if (factory == null) // throw new UnableToDeserializeException("Could not get container instance because there's no factory " + // "registered in the requestor."); // return factory.get(); // } // // protected ContainerFactoryManager getContainerFactoryManager() { // return containerFactoryManager; // } // } // // Path: src/main/java/org/turbogwt/net/serialization/client/SerializationContext.java // public abstract class SerializationContext { // } // // Path: src/main/java/org/turbogwt/net/serialization/client/UnableToDeserializeException.java // public class UnableToDeserializeException extends SerializationException { // // public UnableToDeserializeException() { // } // // public UnableToDeserializeException(String s) { // super(s); // } // // public UnableToDeserializeException(String s, Throwable throwable) { // super(s, throwable); // } // }
import com.google.gwt.core.client.JavaScriptObject; import com.google.gwt.core.client.JsArray; import com.google.gwt.core.client.JsonUtils; import java.util.Collection; import org.turbogwt.core.util.client.Overlays; import org.turbogwt.net.serialization.client.DeserializationContext; import org.turbogwt.net.serialization.client.SerializationContext; import org.turbogwt.net.serialization.client.UnableToDeserializeException;
/* * Copyright 2014 Grow Bit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.turbogwt.net.serialization.client.json; /** * Base class for all SerDes that manipulates serialized JSON objects. * * @param <T> Type of the object to serialize/deserialize. * * @author Danilo Reinert */ public abstract class JsonObjectSerdes<T> extends JsonSerdes<T> { public JsonObjectSerdes(Class<T> handledType) { super(handledType); } /** * Verifies if the deserializer should evaluate the response safely. * <p/> * If this method returns <code>true</code>, then the deserializer will evaluate the response using * {@link com.google.gwt.core.client.JsonUtils#safeEval(String)}, otherwise it will use * {@link com.google.gwt.core.client.JsonUtils#unsafeEval(String)}. * <p/> * If you are completely sure you'll will always receive safe contents, then you can override it * to return <code>false</code> and you'll benefit a faster deserialization. * <p/> * The default implementation is <code>true</code>. * * @return <code>true</code> if you want to evaluate response safely, * or <code>false</code> to evaluate unsafely */ public boolean useSafeEval() { return true; } /** * Recover an instance of T from deserialized JSON. * * @param reader The evaluated response * @param context Context of the deserialization * * @return The object deserialized */ public abstract T readJson(JsonRecordReader reader, DeserializationContext context); /** * Build a JSON using {@link JsonRecordWriter}. * Later this JSON will be serialized using JSON#stringify. * * @param t The object to be serialized * @param writer The serializing JSON * @param context Context of the serialization */ public abstract void writeJson(T t, JsonRecordWriter writer, SerializationContext context); @Override public T deserialize(String response, DeserializationContext context) { if (!isObject(response))
// Path: src/main/java/org/turbogwt/net/serialization/client/DeserializationContext.java // public abstract class DeserializationContext { // // private final ContainerFactoryManager containerFactoryManager; // // public DeserializationContext(ContainerFactoryManager containerFactoryManager) { // this.containerFactoryManager = containerFactoryManager; // } // // public <C extends Collection> C getContainerInstance(Class<C> type) { // final Factory<C> factory = containerFactoryManager.getFactory(type); // if (factory == null) // throw new UnableToDeserializeException("Could not get container instance because there's no factory " + // "registered in the requestor."); // return factory.get(); // } // // protected ContainerFactoryManager getContainerFactoryManager() { // return containerFactoryManager; // } // } // // Path: src/main/java/org/turbogwt/net/serialization/client/SerializationContext.java // public abstract class SerializationContext { // } // // Path: src/main/java/org/turbogwt/net/serialization/client/UnableToDeserializeException.java // public class UnableToDeserializeException extends SerializationException { // // public UnableToDeserializeException() { // } // // public UnableToDeserializeException(String s) { // super(s); // } // // public UnableToDeserializeException(String s, Throwable throwable) { // super(s, throwable); // } // } // Path: src/main/java/org/turbogwt/net/serialization/client/json/JsonObjectSerdes.java import com.google.gwt.core.client.JavaScriptObject; import com.google.gwt.core.client.JsArray; import com.google.gwt.core.client.JsonUtils; import java.util.Collection; import org.turbogwt.core.util.client.Overlays; import org.turbogwt.net.serialization.client.DeserializationContext; import org.turbogwt.net.serialization.client.SerializationContext; import org.turbogwt.net.serialization.client.UnableToDeserializeException; /* * Copyright 2014 Grow Bit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.turbogwt.net.serialization.client.json; /** * Base class for all SerDes that manipulates serialized JSON objects. * * @param <T> Type of the object to serialize/deserialize. * * @author Danilo Reinert */ public abstract class JsonObjectSerdes<T> extends JsonSerdes<T> { public JsonObjectSerdes(Class<T> handledType) { super(handledType); } /** * Verifies if the deserializer should evaluate the response safely. * <p/> * If this method returns <code>true</code>, then the deserializer will evaluate the response using * {@link com.google.gwt.core.client.JsonUtils#safeEval(String)}, otherwise it will use * {@link com.google.gwt.core.client.JsonUtils#unsafeEval(String)}. * <p/> * If you are completely sure you'll will always receive safe contents, then you can override it * to return <code>false</code> and you'll benefit a faster deserialization. * <p/> * The default implementation is <code>true</code>. * * @return <code>true</code> if you want to evaluate response safely, * or <code>false</code> to evaluate unsafely */ public boolean useSafeEval() { return true; } /** * Recover an instance of T from deserialized JSON. * * @param reader The evaluated response * @param context Context of the deserialization * * @return The object deserialized */ public abstract T readJson(JsonRecordReader reader, DeserializationContext context); /** * Build a JSON using {@link JsonRecordWriter}. * Later this JSON will be serialized using JSON#stringify. * * @param t The object to be serialized * @param writer The serializing JSON * @param context Context of the serialization */ public abstract void writeJson(T t, JsonRecordWriter writer, SerializationContext context); @Override public T deserialize(String response, DeserializationContext context) { if (!isObject(response))
throw new UnableToDeserializeException("Response content is not an object");
growbit/turbogwt-http
src/main/java/org/turbogwt/net/serialization/client/json/OverlaySerdes.java
// Path: src/main/java/org/turbogwt/net/serialization/client/DeserializationContext.java // public abstract class DeserializationContext { // // private final ContainerFactoryManager containerFactoryManager; // // public DeserializationContext(ContainerFactoryManager containerFactoryManager) { // this.containerFactoryManager = containerFactoryManager; // } // // public <C extends Collection> C getContainerInstance(Class<C> type) { // final Factory<C> factory = containerFactoryManager.getFactory(type); // if (factory == null) // throw new UnableToDeserializeException("Could not get container instance because there's no factory " + // "registered in the requestor."); // return factory.get(); // } // // protected ContainerFactoryManager getContainerFactoryManager() { // return containerFactoryManager; // } // } // // Path: src/main/java/org/turbogwt/net/serialization/client/Serdes.java // public interface Serdes<T> extends Deserializer<T>, Serializer<T> { // // /** // * Method for accessing type of the Object this de/serializer can handle. // * // * @return The class which this de/serializer can de/serialize // */ // @Override // Class<T> handledType(); // } // // Path: src/main/java/org/turbogwt/net/serialization/client/SerializationContext.java // public abstract class SerializationContext { // }
import com.google.gwt.core.client.JavaScriptObject; import com.google.gwt.core.client.JsArray; import com.google.gwt.core.client.JsonUtils; import java.util.Collection; import java.util.List; import org.turbogwt.core.collections.client.JsArrayList; import org.turbogwt.core.util.client.Overlays; import org.turbogwt.net.serialization.client.DeserializationContext; import org.turbogwt.net.serialization.client.Serdes; import org.turbogwt.net.serialization.client.SerializationContext;
/* * Copyright 2014 Grow Bit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.turbogwt.net.serialization.client.json; /** * Serializer/Deserializer of Overlay types. * * @param <T> The overlay type of the data to be serialized. * * @author Danilo Reinert */ public class OverlaySerdes<T extends JavaScriptObject> implements Serdes<T> { private static OverlaySerdes<JavaScriptObject> INSTANCE = new OverlaySerdes<>(); @SuppressWarnings("unchecked") public static <O extends JavaScriptObject> OverlaySerdes<O> getInstance() { return (OverlaySerdes<O>) INSTANCE; } @Override @SuppressWarnings("unchecked") public Class<T> handledType() { return (Class<T>) JavaScriptObject.class; } @Override public String[] contentType() { return JsonSerdes.CONTENT_TYPE_PATTERNS; } @Override public String[] accept() { return JsonSerdes.ACCEPT_PATTERNS; } @Override
// Path: src/main/java/org/turbogwt/net/serialization/client/DeserializationContext.java // public abstract class DeserializationContext { // // private final ContainerFactoryManager containerFactoryManager; // // public DeserializationContext(ContainerFactoryManager containerFactoryManager) { // this.containerFactoryManager = containerFactoryManager; // } // // public <C extends Collection> C getContainerInstance(Class<C> type) { // final Factory<C> factory = containerFactoryManager.getFactory(type); // if (factory == null) // throw new UnableToDeserializeException("Could not get container instance because there's no factory " + // "registered in the requestor."); // return factory.get(); // } // // protected ContainerFactoryManager getContainerFactoryManager() { // return containerFactoryManager; // } // } // // Path: src/main/java/org/turbogwt/net/serialization/client/Serdes.java // public interface Serdes<T> extends Deserializer<T>, Serializer<T> { // // /** // * Method for accessing type of the Object this de/serializer can handle. // * // * @return The class which this de/serializer can de/serialize // */ // @Override // Class<T> handledType(); // } // // Path: src/main/java/org/turbogwt/net/serialization/client/SerializationContext.java // public abstract class SerializationContext { // } // Path: src/main/java/org/turbogwt/net/serialization/client/json/OverlaySerdes.java import com.google.gwt.core.client.JavaScriptObject; import com.google.gwt.core.client.JsArray; import com.google.gwt.core.client.JsonUtils; import java.util.Collection; import java.util.List; import org.turbogwt.core.collections.client.JsArrayList; import org.turbogwt.core.util.client.Overlays; import org.turbogwt.net.serialization.client.DeserializationContext; import org.turbogwt.net.serialization.client.Serdes; import org.turbogwt.net.serialization.client.SerializationContext; /* * Copyright 2014 Grow Bit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.turbogwt.net.serialization.client.json; /** * Serializer/Deserializer of Overlay types. * * @param <T> The overlay type of the data to be serialized. * * @author Danilo Reinert */ public class OverlaySerdes<T extends JavaScriptObject> implements Serdes<T> { private static OverlaySerdes<JavaScriptObject> INSTANCE = new OverlaySerdes<>(); @SuppressWarnings("unchecked") public static <O extends JavaScriptObject> OverlaySerdes<O> getInstance() { return (OverlaySerdes<O>) INSTANCE; } @Override @SuppressWarnings("unchecked") public Class<T> handledType() { return (Class<T>) JavaScriptObject.class; } @Override public String[] contentType() { return JsonSerdes.CONTENT_TYPE_PATTERNS; } @Override public String[] accept() { return JsonSerdes.ACCEPT_PATTERNS; } @Override
public T deserialize(String response, DeserializationContext context) {
growbit/turbogwt-http
src/main/java/org/turbogwt/net/serialization/client/json/OverlaySerdes.java
// Path: src/main/java/org/turbogwt/net/serialization/client/DeserializationContext.java // public abstract class DeserializationContext { // // private final ContainerFactoryManager containerFactoryManager; // // public DeserializationContext(ContainerFactoryManager containerFactoryManager) { // this.containerFactoryManager = containerFactoryManager; // } // // public <C extends Collection> C getContainerInstance(Class<C> type) { // final Factory<C> factory = containerFactoryManager.getFactory(type); // if (factory == null) // throw new UnableToDeserializeException("Could not get container instance because there's no factory " + // "registered in the requestor."); // return factory.get(); // } // // protected ContainerFactoryManager getContainerFactoryManager() { // return containerFactoryManager; // } // } // // Path: src/main/java/org/turbogwt/net/serialization/client/Serdes.java // public interface Serdes<T> extends Deserializer<T>, Serializer<T> { // // /** // * Method for accessing type of the Object this de/serializer can handle. // * // * @return The class which this de/serializer can de/serialize // */ // @Override // Class<T> handledType(); // } // // Path: src/main/java/org/turbogwt/net/serialization/client/SerializationContext.java // public abstract class SerializationContext { // }
import com.google.gwt.core.client.JavaScriptObject; import com.google.gwt.core.client.JsArray; import com.google.gwt.core.client.JsonUtils; import java.util.Collection; import java.util.List; import org.turbogwt.core.collections.client.JsArrayList; import org.turbogwt.core.util.client.Overlays; import org.turbogwt.net.serialization.client.DeserializationContext; import org.turbogwt.net.serialization.client.Serdes; import org.turbogwt.net.serialization.client.SerializationContext;
} @Override public String[] accept() { return JsonSerdes.ACCEPT_PATTERNS; } @Override public T deserialize(String response, DeserializationContext context) { return JsonUtils.safeEval(response); } @Override @SuppressWarnings("unchecked") public <C extends Collection<T>> C deserializeAsCollection(Class<C> collectionType, String response, DeserializationContext context) { JsArray<T> jsArray = JsonUtils.safeEval(response); if (collectionType.equals(List.class) || collectionType.equals(Collection.class)) { return (C) new JsArrayList(jsArray); } else { C col = context.getContainerInstance(collectionType); for (int i = 0; i < jsArray.length(); i++) { T t = jsArray.get(i); col.add(t); } return col; } } @Override
// Path: src/main/java/org/turbogwt/net/serialization/client/DeserializationContext.java // public abstract class DeserializationContext { // // private final ContainerFactoryManager containerFactoryManager; // // public DeserializationContext(ContainerFactoryManager containerFactoryManager) { // this.containerFactoryManager = containerFactoryManager; // } // // public <C extends Collection> C getContainerInstance(Class<C> type) { // final Factory<C> factory = containerFactoryManager.getFactory(type); // if (factory == null) // throw new UnableToDeserializeException("Could not get container instance because there's no factory " + // "registered in the requestor."); // return factory.get(); // } // // protected ContainerFactoryManager getContainerFactoryManager() { // return containerFactoryManager; // } // } // // Path: src/main/java/org/turbogwt/net/serialization/client/Serdes.java // public interface Serdes<T> extends Deserializer<T>, Serializer<T> { // // /** // * Method for accessing type of the Object this de/serializer can handle. // * // * @return The class which this de/serializer can de/serialize // */ // @Override // Class<T> handledType(); // } // // Path: src/main/java/org/turbogwt/net/serialization/client/SerializationContext.java // public abstract class SerializationContext { // } // Path: src/main/java/org/turbogwt/net/serialization/client/json/OverlaySerdes.java import com.google.gwt.core.client.JavaScriptObject; import com.google.gwt.core.client.JsArray; import com.google.gwt.core.client.JsonUtils; import java.util.Collection; import java.util.List; import org.turbogwt.core.collections.client.JsArrayList; import org.turbogwt.core.util.client.Overlays; import org.turbogwt.net.serialization.client.DeserializationContext; import org.turbogwt.net.serialization.client.Serdes; import org.turbogwt.net.serialization.client.SerializationContext; } @Override public String[] accept() { return JsonSerdes.ACCEPT_PATTERNS; } @Override public T deserialize(String response, DeserializationContext context) { return JsonUtils.safeEval(response); } @Override @SuppressWarnings("unchecked") public <C extends Collection<T>> C deserializeAsCollection(Class<C> collectionType, String response, DeserializationContext context) { JsArray<T> jsArray = JsonUtils.safeEval(response); if (collectionType.equals(List.class) || collectionType.equals(Collection.class)) { return (C) new JsArrayList(jsArray); } else { C col = context.getContainerInstance(collectionType); for (int i = 0; i < jsArray.length(); i++) { T t = jsArray.get(i); col.add(t); } return col; } } @Override
public String serialize(T t, SerializationContext context) {
growbit/turbogwt-http
src/main/java/org/turbogwt/net/http/client/Requestor.java
// Path: src/main/java/org/turbogwt/net/serialization/client/Deserializer.java // public interface Deserializer<T> { // // /** // * Method for accessing type of the Object this deserializer can handle. // * // * @return The class which this deserializer can deserialize // */ // Class<T> handledType(); // // /** // * Tells the content-type patterns which this deserializer handles. // * <p/> // * // * E.g., a deserializer for JSON can return {"application/json", "application/javascript"}.<br> // * If you want to create a deserializer for any content-type just return "*&#47;*". // * // * @return The content-type patterns handled by this deserializer. // */ // String[] accept(); // // /** // * Deserialize the plain text into an object of type T. // * // * @param response Http response body content // * @param context Context of deserialization // * // * @return The object deserialized // */ // T deserialize(String response, DeserializationContext context); // // /** // * Deserialize the plain text into a collection T. // * <p/> // * // * The collection instance can be retrieved from its {@link org.turbogwt.core.util.shared.Factory}, // * obtained in {@link ContainerFactoryManager#getFactory}.<br> // * The ContainerFactoryManager can be retrieved from {@link DeserializationContext#getContainerInstance(Class)}. // * // * @param collectionType The class of the collection // * @param response Http response body content // * @param context Context of deserialization // * // * @return The object deserialized // */ // <C extends Collection<T>> C deserializeAsCollection(Class<C> collectionType, String response, // DeserializationContext context); // } // // Path: src/main/java/org/turbogwt/net/serialization/client/Serdes.java // public interface Serdes<T> extends Deserializer<T>, Serializer<T> { // // /** // * Method for accessing type of the Object this de/serializer can handle. // * // * @return The class which this de/serializer can de/serialize // */ // @Override // Class<T> handledType(); // } // // Path: src/main/java/org/turbogwt/net/serialization/client/Serializer.java // public interface Serializer<T> { // // /** // * Method for accessing type of the Object this serializer can handle. // * // * @return The class which this serializer can serialize // */ // Class<T> handledType(); // // /** // * Tells the content-type patterns which this serializer handles. // * <p/> // * // * E.g., a serializer for JSON can return {"application/json", "application/javascript"}.<br> // * If you want to create a serializer for any content-type just return "*&#47;*". // * // * @return The content-type patterns handled by this serializer. // */ // String[] contentType(); // // /** // * Serialize T to plain text. // * // * @param t The object to be serialized // * @param context Context of the serialization // * // * @return The object serialized. // */ // String serialize(T t, SerializationContext context); // // /** // * Serialize a collection of T to plain text. // * // * @param c The collection of the object to be serialized // * @param context Context of the serialization // * // * @return The object serialized. // */ // String serializeFromCollection(Collection<T> c, SerializationContext context); // }
import java.util.Collection; import org.turbogwt.core.util.shared.Factory; import org.turbogwt.core.util.shared.Registration; import org.turbogwt.net.serialization.client.Deserializer; import org.turbogwt.net.serialization.client.Serdes; import org.turbogwt.net.serialization.client.Serializer;
/* * Copyright 2014 Grow Bit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.turbogwt.net.http.client; /** * This interface is a configurable {@link Request} factory. * Usually, you will use it as a singleton along your project. * <p/> * * It provides a convenience API for managing/creating HTTP Requests. * <p/> * * You can register {@link RequestFilter}s with #registerRequestFilter, so the are executed over all your requests. * The same for {@link org.turbogwt.net.http.client.ResponseFilter}. * <p/> * * You can register custom {@link org.turbogwt.net.serialization.client.Serializer} with #registerSerializer. * The same for {@link org.turbogwt.net.serialization.client.Deserializer}. * If you want to support both serialization and deserialization for your custom object, * register a {@link org.turbogwt.net.serialization.client.Serdes} with #registerSerdes. * <p/> * * SerDes for {@link String}, {@link Number}, {@link Boolean} * and {@link com.google.gwt.core.client.JavaScriptObject} are already provided. * * @author Danilo Reinert */ public interface Requestor { //=================================================================== // Requestor configuration //=================================================================== void setDefaultContentType(String contentType); String getDefaultContentType();
// Path: src/main/java/org/turbogwt/net/serialization/client/Deserializer.java // public interface Deserializer<T> { // // /** // * Method for accessing type of the Object this deserializer can handle. // * // * @return The class which this deserializer can deserialize // */ // Class<T> handledType(); // // /** // * Tells the content-type patterns which this deserializer handles. // * <p/> // * // * E.g., a deserializer for JSON can return {"application/json", "application/javascript"}.<br> // * If you want to create a deserializer for any content-type just return "*&#47;*". // * // * @return The content-type patterns handled by this deserializer. // */ // String[] accept(); // // /** // * Deserialize the plain text into an object of type T. // * // * @param response Http response body content // * @param context Context of deserialization // * // * @return The object deserialized // */ // T deserialize(String response, DeserializationContext context); // // /** // * Deserialize the plain text into a collection T. // * <p/> // * // * The collection instance can be retrieved from its {@link org.turbogwt.core.util.shared.Factory}, // * obtained in {@link ContainerFactoryManager#getFactory}.<br> // * The ContainerFactoryManager can be retrieved from {@link DeserializationContext#getContainerInstance(Class)}. // * // * @param collectionType The class of the collection // * @param response Http response body content // * @param context Context of deserialization // * // * @return The object deserialized // */ // <C extends Collection<T>> C deserializeAsCollection(Class<C> collectionType, String response, // DeserializationContext context); // } // // Path: src/main/java/org/turbogwt/net/serialization/client/Serdes.java // public interface Serdes<T> extends Deserializer<T>, Serializer<T> { // // /** // * Method for accessing type of the Object this de/serializer can handle. // * // * @return The class which this de/serializer can de/serialize // */ // @Override // Class<T> handledType(); // } // // Path: src/main/java/org/turbogwt/net/serialization/client/Serializer.java // public interface Serializer<T> { // // /** // * Method for accessing type of the Object this serializer can handle. // * // * @return The class which this serializer can serialize // */ // Class<T> handledType(); // // /** // * Tells the content-type patterns which this serializer handles. // * <p/> // * // * E.g., a serializer for JSON can return {"application/json", "application/javascript"}.<br> // * If you want to create a serializer for any content-type just return "*&#47;*". // * // * @return The content-type patterns handled by this serializer. // */ // String[] contentType(); // // /** // * Serialize T to plain text. // * // * @param t The object to be serialized // * @param context Context of the serialization // * // * @return The object serialized. // */ // String serialize(T t, SerializationContext context); // // /** // * Serialize a collection of T to plain text. // * // * @param c The collection of the object to be serialized // * @param context Context of the serialization // * // * @return The object serialized. // */ // String serializeFromCollection(Collection<T> c, SerializationContext context); // } // Path: src/main/java/org/turbogwt/net/http/client/Requestor.java import java.util.Collection; import org.turbogwt.core.util.shared.Factory; import org.turbogwt.core.util.shared.Registration; import org.turbogwt.net.serialization.client.Deserializer; import org.turbogwt.net.serialization.client.Serdes; import org.turbogwt.net.serialization.client.Serializer; /* * Copyright 2014 Grow Bit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.turbogwt.net.http.client; /** * This interface is a configurable {@link Request} factory. * Usually, you will use it as a singleton along your project. * <p/> * * It provides a convenience API for managing/creating HTTP Requests. * <p/> * * You can register {@link RequestFilter}s with #registerRequestFilter, so the are executed over all your requests. * The same for {@link org.turbogwt.net.http.client.ResponseFilter}. * <p/> * * You can register custom {@link org.turbogwt.net.serialization.client.Serializer} with #registerSerializer. * The same for {@link org.turbogwt.net.serialization.client.Deserializer}. * If you want to support both serialization and deserialization for your custom object, * register a {@link org.turbogwt.net.serialization.client.Serdes} with #registerSerdes. * <p/> * * SerDes for {@link String}, {@link Number}, {@link Boolean} * and {@link com.google.gwt.core.client.JavaScriptObject} are already provided. * * @author Danilo Reinert */ public interface Requestor { //=================================================================== // Requestor configuration //=================================================================== void setDefaultContentType(String contentType); String getDefaultContentType();
<T> Deserializer<T> getDeserializer(Class<T> type, String contentType);
growbit/turbogwt-http
src/main/java/org/turbogwt/net/http/client/Requestor.java
// Path: src/main/java/org/turbogwt/net/serialization/client/Deserializer.java // public interface Deserializer<T> { // // /** // * Method for accessing type of the Object this deserializer can handle. // * // * @return The class which this deserializer can deserialize // */ // Class<T> handledType(); // // /** // * Tells the content-type patterns which this deserializer handles. // * <p/> // * // * E.g., a deserializer for JSON can return {"application/json", "application/javascript"}.<br> // * If you want to create a deserializer for any content-type just return "*&#47;*". // * // * @return The content-type patterns handled by this deserializer. // */ // String[] accept(); // // /** // * Deserialize the plain text into an object of type T. // * // * @param response Http response body content // * @param context Context of deserialization // * // * @return The object deserialized // */ // T deserialize(String response, DeserializationContext context); // // /** // * Deserialize the plain text into a collection T. // * <p/> // * // * The collection instance can be retrieved from its {@link org.turbogwt.core.util.shared.Factory}, // * obtained in {@link ContainerFactoryManager#getFactory}.<br> // * The ContainerFactoryManager can be retrieved from {@link DeserializationContext#getContainerInstance(Class)}. // * // * @param collectionType The class of the collection // * @param response Http response body content // * @param context Context of deserialization // * // * @return The object deserialized // */ // <C extends Collection<T>> C deserializeAsCollection(Class<C> collectionType, String response, // DeserializationContext context); // } // // Path: src/main/java/org/turbogwt/net/serialization/client/Serdes.java // public interface Serdes<T> extends Deserializer<T>, Serializer<T> { // // /** // * Method for accessing type of the Object this de/serializer can handle. // * // * @return The class which this de/serializer can de/serialize // */ // @Override // Class<T> handledType(); // } // // Path: src/main/java/org/turbogwt/net/serialization/client/Serializer.java // public interface Serializer<T> { // // /** // * Method for accessing type of the Object this serializer can handle. // * // * @return The class which this serializer can serialize // */ // Class<T> handledType(); // // /** // * Tells the content-type patterns which this serializer handles. // * <p/> // * // * E.g., a serializer for JSON can return {"application/json", "application/javascript"}.<br> // * If you want to create a serializer for any content-type just return "*&#47;*". // * // * @return The content-type patterns handled by this serializer. // */ // String[] contentType(); // // /** // * Serialize T to plain text. // * // * @param t The object to be serialized // * @param context Context of the serialization // * // * @return The object serialized. // */ // String serialize(T t, SerializationContext context); // // /** // * Serialize a collection of T to plain text. // * // * @param c The collection of the object to be serialized // * @param context Context of the serialization // * // * @return The object serialized. // */ // String serializeFromCollection(Collection<T> c, SerializationContext context); // }
import java.util.Collection; import org.turbogwt.core.util.shared.Factory; import org.turbogwt.core.util.shared.Registration; import org.turbogwt.net.serialization.client.Deserializer; import org.turbogwt.net.serialization.client.Serdes; import org.turbogwt.net.serialization.client.Serializer;
/* * Copyright 2014 Grow Bit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.turbogwt.net.http.client; /** * This interface is a configurable {@link Request} factory. * Usually, you will use it as a singleton along your project. * <p/> * * It provides a convenience API for managing/creating HTTP Requests. * <p/> * * You can register {@link RequestFilter}s with #registerRequestFilter, so the are executed over all your requests. * The same for {@link org.turbogwt.net.http.client.ResponseFilter}. * <p/> * * You can register custom {@link org.turbogwt.net.serialization.client.Serializer} with #registerSerializer. * The same for {@link org.turbogwt.net.serialization.client.Deserializer}. * If you want to support both serialization and deserialization for your custom object, * register a {@link org.turbogwt.net.serialization.client.Serdes} with #registerSerdes. * <p/> * * SerDes for {@link String}, {@link Number}, {@link Boolean} * and {@link com.google.gwt.core.client.JavaScriptObject} are already provided. * * @author Danilo Reinert */ public interface Requestor { //=================================================================== // Requestor configuration //=================================================================== void setDefaultContentType(String contentType); String getDefaultContentType(); <T> Deserializer<T> getDeserializer(Class<T> type, String contentType);
// Path: src/main/java/org/turbogwt/net/serialization/client/Deserializer.java // public interface Deserializer<T> { // // /** // * Method for accessing type of the Object this deserializer can handle. // * // * @return The class which this deserializer can deserialize // */ // Class<T> handledType(); // // /** // * Tells the content-type patterns which this deserializer handles. // * <p/> // * // * E.g., a deserializer for JSON can return {"application/json", "application/javascript"}.<br> // * If you want to create a deserializer for any content-type just return "*&#47;*". // * // * @return The content-type patterns handled by this deserializer. // */ // String[] accept(); // // /** // * Deserialize the plain text into an object of type T. // * // * @param response Http response body content // * @param context Context of deserialization // * // * @return The object deserialized // */ // T deserialize(String response, DeserializationContext context); // // /** // * Deserialize the plain text into a collection T. // * <p/> // * // * The collection instance can be retrieved from its {@link org.turbogwt.core.util.shared.Factory}, // * obtained in {@link ContainerFactoryManager#getFactory}.<br> // * The ContainerFactoryManager can be retrieved from {@link DeserializationContext#getContainerInstance(Class)}. // * // * @param collectionType The class of the collection // * @param response Http response body content // * @param context Context of deserialization // * // * @return The object deserialized // */ // <C extends Collection<T>> C deserializeAsCollection(Class<C> collectionType, String response, // DeserializationContext context); // } // // Path: src/main/java/org/turbogwt/net/serialization/client/Serdes.java // public interface Serdes<T> extends Deserializer<T>, Serializer<T> { // // /** // * Method for accessing type of the Object this de/serializer can handle. // * // * @return The class which this de/serializer can de/serialize // */ // @Override // Class<T> handledType(); // } // // Path: src/main/java/org/turbogwt/net/serialization/client/Serializer.java // public interface Serializer<T> { // // /** // * Method for accessing type of the Object this serializer can handle. // * // * @return The class which this serializer can serialize // */ // Class<T> handledType(); // // /** // * Tells the content-type patterns which this serializer handles. // * <p/> // * // * E.g., a serializer for JSON can return {"application/json", "application/javascript"}.<br> // * If you want to create a serializer for any content-type just return "*&#47;*". // * // * @return The content-type patterns handled by this serializer. // */ // String[] contentType(); // // /** // * Serialize T to plain text. // * // * @param t The object to be serialized // * @param context Context of the serialization // * // * @return The object serialized. // */ // String serialize(T t, SerializationContext context); // // /** // * Serialize a collection of T to plain text. // * // * @param c The collection of the object to be serialized // * @param context Context of the serialization // * // * @return The object serialized. // */ // String serializeFromCollection(Collection<T> c, SerializationContext context); // } // Path: src/main/java/org/turbogwt/net/http/client/Requestor.java import java.util.Collection; import org.turbogwt.core.util.shared.Factory; import org.turbogwt.core.util.shared.Registration; import org.turbogwt.net.serialization.client.Deserializer; import org.turbogwt.net.serialization.client.Serdes; import org.turbogwt.net.serialization.client.Serializer; /* * Copyright 2014 Grow Bit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.turbogwt.net.http.client; /** * This interface is a configurable {@link Request} factory. * Usually, you will use it as a singleton along your project. * <p/> * * It provides a convenience API for managing/creating HTTP Requests. * <p/> * * You can register {@link RequestFilter}s with #registerRequestFilter, so the are executed over all your requests. * The same for {@link org.turbogwt.net.http.client.ResponseFilter}. * <p/> * * You can register custom {@link org.turbogwt.net.serialization.client.Serializer} with #registerSerializer. * The same for {@link org.turbogwt.net.serialization.client.Deserializer}. * If you want to support both serialization and deserialization for your custom object, * register a {@link org.turbogwt.net.serialization.client.Serdes} with #registerSerdes. * <p/> * * SerDes for {@link String}, {@link Number}, {@link Boolean} * and {@link com.google.gwt.core.client.JavaScriptObject} are already provided. * * @author Danilo Reinert */ public interface Requestor { //=================================================================== // Requestor configuration //=================================================================== void setDefaultContentType(String contentType); String getDefaultContentType(); <T> Deserializer<T> getDeserializer(Class<T> type, String contentType);
<T> Serializer<T> getSerializer(Class<T> type, String contentType);
growbit/turbogwt-http
src/main/java/org/turbogwt/net/serialization/client/json/JsonNumberSerdes.java
// Path: src/main/java/org/turbogwt/net/serialization/client/DeserializationContext.java // public abstract class DeserializationContext { // // private final ContainerFactoryManager containerFactoryManager; // // public DeserializationContext(ContainerFactoryManager containerFactoryManager) { // this.containerFactoryManager = containerFactoryManager; // } // // public <C extends Collection> C getContainerInstance(Class<C> type) { // final Factory<C> factory = containerFactoryManager.getFactory(type); // if (factory == null) // throw new UnableToDeserializeException("Could not get container instance because there's no factory " + // "registered in the requestor."); // return factory.get(); // } // // protected ContainerFactoryManager getContainerFactoryManager() { // return containerFactoryManager; // } // } // // Path: src/main/java/org/turbogwt/net/serialization/client/SerializationContext.java // public abstract class SerializationContext { // } // // Path: src/main/java/org/turbogwt/net/serialization/client/UnableToDeserializeException.java // public class UnableToDeserializeException extends SerializationException { // // public UnableToDeserializeException() { // } // // public UnableToDeserializeException(String s) { // super(s); // } // // public UnableToDeserializeException(String s, Throwable throwable) { // super(s, throwable); // } // }
import org.turbogwt.net.serialization.client.DeserializationContext; import org.turbogwt.net.serialization.client.SerializationContext; import org.turbogwt.net.serialization.client.UnableToDeserializeException;
/* * Copyright 2014 Grow Bit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.turbogwt.net.serialization.client.json; /** * De/Serializer of JSON numbers. * * @author Danilo Reinert */ public class JsonNumberSerdes extends JsonValueSerdes<Number> { private static JsonNumberSerdes INSTANCE = new JsonNumberSerdes(); public JsonNumberSerdes() { super(Number.class); } public static JsonNumberSerdes getInstance() { return INSTANCE; } @Override
// Path: src/main/java/org/turbogwt/net/serialization/client/DeserializationContext.java // public abstract class DeserializationContext { // // private final ContainerFactoryManager containerFactoryManager; // // public DeserializationContext(ContainerFactoryManager containerFactoryManager) { // this.containerFactoryManager = containerFactoryManager; // } // // public <C extends Collection> C getContainerInstance(Class<C> type) { // final Factory<C> factory = containerFactoryManager.getFactory(type); // if (factory == null) // throw new UnableToDeserializeException("Could not get container instance because there's no factory " + // "registered in the requestor."); // return factory.get(); // } // // protected ContainerFactoryManager getContainerFactoryManager() { // return containerFactoryManager; // } // } // // Path: src/main/java/org/turbogwt/net/serialization/client/SerializationContext.java // public abstract class SerializationContext { // } // // Path: src/main/java/org/turbogwt/net/serialization/client/UnableToDeserializeException.java // public class UnableToDeserializeException extends SerializationException { // // public UnableToDeserializeException() { // } // // public UnableToDeserializeException(String s) { // super(s); // } // // public UnableToDeserializeException(String s, Throwable throwable) { // super(s, throwable); // } // } // Path: src/main/java/org/turbogwt/net/serialization/client/json/JsonNumberSerdes.java import org.turbogwt.net.serialization.client.DeserializationContext; import org.turbogwt.net.serialization.client.SerializationContext; import org.turbogwt.net.serialization.client.UnableToDeserializeException; /* * Copyright 2014 Grow Bit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.turbogwt.net.serialization.client.json; /** * De/Serializer of JSON numbers. * * @author Danilo Reinert */ public class JsonNumberSerdes extends JsonValueSerdes<Number> { private static JsonNumberSerdes INSTANCE = new JsonNumberSerdes(); public JsonNumberSerdes() { super(Number.class); } public static JsonNumberSerdes getInstance() { return INSTANCE; } @Override
public Number deserialize(String response, DeserializationContext context) {
growbit/turbogwt-http
src/main/java/org/turbogwt/net/serialization/client/json/JsonNumberSerdes.java
// Path: src/main/java/org/turbogwt/net/serialization/client/DeserializationContext.java // public abstract class DeserializationContext { // // private final ContainerFactoryManager containerFactoryManager; // // public DeserializationContext(ContainerFactoryManager containerFactoryManager) { // this.containerFactoryManager = containerFactoryManager; // } // // public <C extends Collection> C getContainerInstance(Class<C> type) { // final Factory<C> factory = containerFactoryManager.getFactory(type); // if (factory == null) // throw new UnableToDeserializeException("Could not get container instance because there's no factory " + // "registered in the requestor."); // return factory.get(); // } // // protected ContainerFactoryManager getContainerFactoryManager() { // return containerFactoryManager; // } // } // // Path: src/main/java/org/turbogwt/net/serialization/client/SerializationContext.java // public abstract class SerializationContext { // } // // Path: src/main/java/org/turbogwt/net/serialization/client/UnableToDeserializeException.java // public class UnableToDeserializeException extends SerializationException { // // public UnableToDeserializeException() { // } // // public UnableToDeserializeException(String s) { // super(s); // } // // public UnableToDeserializeException(String s, Throwable throwable) { // super(s, throwable); // } // }
import org.turbogwt.net.serialization.client.DeserializationContext; import org.turbogwt.net.serialization.client.SerializationContext; import org.turbogwt.net.serialization.client.UnableToDeserializeException;
/* * Copyright 2014 Grow Bit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.turbogwt.net.serialization.client.json; /** * De/Serializer of JSON numbers. * * @author Danilo Reinert */ public class JsonNumberSerdes extends JsonValueSerdes<Number> { private static JsonNumberSerdes INSTANCE = new JsonNumberSerdes(); public JsonNumberSerdes() { super(Number.class); } public static JsonNumberSerdes getInstance() { return INSTANCE; } @Override public Number deserialize(String response, DeserializationContext context) { try { if (response.contains(".")) { return Double.valueOf(response); } try { return Integer.valueOf(response); } catch (NumberFormatException e) { return Long.valueOf(response); } } catch (NumberFormatException e) {
// Path: src/main/java/org/turbogwt/net/serialization/client/DeserializationContext.java // public abstract class DeserializationContext { // // private final ContainerFactoryManager containerFactoryManager; // // public DeserializationContext(ContainerFactoryManager containerFactoryManager) { // this.containerFactoryManager = containerFactoryManager; // } // // public <C extends Collection> C getContainerInstance(Class<C> type) { // final Factory<C> factory = containerFactoryManager.getFactory(type); // if (factory == null) // throw new UnableToDeserializeException("Could not get container instance because there's no factory " + // "registered in the requestor."); // return factory.get(); // } // // protected ContainerFactoryManager getContainerFactoryManager() { // return containerFactoryManager; // } // } // // Path: src/main/java/org/turbogwt/net/serialization/client/SerializationContext.java // public abstract class SerializationContext { // } // // Path: src/main/java/org/turbogwt/net/serialization/client/UnableToDeserializeException.java // public class UnableToDeserializeException extends SerializationException { // // public UnableToDeserializeException() { // } // // public UnableToDeserializeException(String s) { // super(s); // } // // public UnableToDeserializeException(String s, Throwable throwable) { // super(s, throwable); // } // } // Path: src/main/java/org/turbogwt/net/serialization/client/json/JsonNumberSerdes.java import org.turbogwt.net.serialization.client.DeserializationContext; import org.turbogwt.net.serialization.client.SerializationContext; import org.turbogwt.net.serialization.client.UnableToDeserializeException; /* * Copyright 2014 Grow Bit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.turbogwt.net.serialization.client.json; /** * De/Serializer of JSON numbers. * * @author Danilo Reinert */ public class JsonNumberSerdes extends JsonValueSerdes<Number> { private static JsonNumberSerdes INSTANCE = new JsonNumberSerdes(); public JsonNumberSerdes() { super(Number.class); } public static JsonNumberSerdes getInstance() { return INSTANCE; } @Override public Number deserialize(String response, DeserializationContext context) { try { if (response.contains(".")) { return Double.valueOf(response); } try { return Integer.valueOf(response); } catch (NumberFormatException e) { return Long.valueOf(response); } } catch (NumberFormatException e) {
throw new UnableToDeserializeException("Could not deserialize response as number.");
growbit/turbogwt-http
src/main/java/org/turbogwt/net/serialization/client/json/JsonNumberSerdes.java
// Path: src/main/java/org/turbogwt/net/serialization/client/DeserializationContext.java // public abstract class DeserializationContext { // // private final ContainerFactoryManager containerFactoryManager; // // public DeserializationContext(ContainerFactoryManager containerFactoryManager) { // this.containerFactoryManager = containerFactoryManager; // } // // public <C extends Collection> C getContainerInstance(Class<C> type) { // final Factory<C> factory = containerFactoryManager.getFactory(type); // if (factory == null) // throw new UnableToDeserializeException("Could not get container instance because there's no factory " + // "registered in the requestor."); // return factory.get(); // } // // protected ContainerFactoryManager getContainerFactoryManager() { // return containerFactoryManager; // } // } // // Path: src/main/java/org/turbogwt/net/serialization/client/SerializationContext.java // public abstract class SerializationContext { // } // // Path: src/main/java/org/turbogwt/net/serialization/client/UnableToDeserializeException.java // public class UnableToDeserializeException extends SerializationException { // // public UnableToDeserializeException() { // } // // public UnableToDeserializeException(String s) { // super(s); // } // // public UnableToDeserializeException(String s, Throwable throwable) { // super(s, throwable); // } // }
import org.turbogwt.net.serialization.client.DeserializationContext; import org.turbogwt.net.serialization.client.SerializationContext; import org.turbogwt.net.serialization.client.UnableToDeserializeException;
/* * Copyright 2014 Grow Bit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.turbogwt.net.serialization.client.json; /** * De/Serializer of JSON numbers. * * @author Danilo Reinert */ public class JsonNumberSerdes extends JsonValueSerdes<Number> { private static JsonNumberSerdes INSTANCE = new JsonNumberSerdes(); public JsonNumberSerdes() { super(Number.class); } public static JsonNumberSerdes getInstance() { return INSTANCE; } @Override public Number deserialize(String response, DeserializationContext context) { try { if (response.contains(".")) { return Double.valueOf(response); } try { return Integer.valueOf(response); } catch (NumberFormatException e) { return Long.valueOf(response); } } catch (NumberFormatException e) { throw new UnableToDeserializeException("Could not deserialize response as number."); } } @Override
// Path: src/main/java/org/turbogwt/net/serialization/client/DeserializationContext.java // public abstract class DeserializationContext { // // private final ContainerFactoryManager containerFactoryManager; // // public DeserializationContext(ContainerFactoryManager containerFactoryManager) { // this.containerFactoryManager = containerFactoryManager; // } // // public <C extends Collection> C getContainerInstance(Class<C> type) { // final Factory<C> factory = containerFactoryManager.getFactory(type); // if (factory == null) // throw new UnableToDeserializeException("Could not get container instance because there's no factory " + // "registered in the requestor."); // return factory.get(); // } // // protected ContainerFactoryManager getContainerFactoryManager() { // return containerFactoryManager; // } // } // // Path: src/main/java/org/turbogwt/net/serialization/client/SerializationContext.java // public abstract class SerializationContext { // } // // Path: src/main/java/org/turbogwt/net/serialization/client/UnableToDeserializeException.java // public class UnableToDeserializeException extends SerializationException { // // public UnableToDeserializeException() { // } // // public UnableToDeserializeException(String s) { // super(s); // } // // public UnableToDeserializeException(String s, Throwable throwable) { // super(s, throwable); // } // } // Path: src/main/java/org/turbogwt/net/serialization/client/json/JsonNumberSerdes.java import org.turbogwt.net.serialization.client.DeserializationContext; import org.turbogwt.net.serialization.client.SerializationContext; import org.turbogwt.net.serialization.client.UnableToDeserializeException; /* * Copyright 2014 Grow Bit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.turbogwt.net.serialization.client.json; /** * De/Serializer of JSON numbers. * * @author Danilo Reinert */ public class JsonNumberSerdes extends JsonValueSerdes<Number> { private static JsonNumberSerdes INSTANCE = new JsonNumberSerdes(); public JsonNumberSerdes() { super(Number.class); } public static JsonNumberSerdes getInstance() { return INSTANCE; } @Override public Number deserialize(String response, DeserializationContext context) { try { if (response.contains(".")) { return Double.valueOf(response); } try { return Integer.valueOf(response); } catch (NumberFormatException e) { return Long.valueOf(response); } } catch (NumberFormatException e) { throw new UnableToDeserializeException("Could not deserialize response as number."); } } @Override
public String serialize(Number n, SerializationContext context) {
growbit/turbogwt-http
src/test/java/org/turbogwt/net/NetGwtTestSuite.java
// Path: src/test/java/org/turbogwt/net/client/UriBuilderTest.java // public class UriBuilderTest extends GWTTestCase { // // @Override // public String getModuleName() { // return "org.turbogwt.net.NetTest"; // } // // public void testBasicFlow() { // String expected = "http://user:pwd@localhost:8888/server/root/resource;class=2;class=5;class=6" + // "/child;group=A;subGroup=A.1;subGroup=A.2?age=12&name=Aa&name=Zz#first"; // // String uri = UriBuilder.newInstance() // .scheme("http") // .user("user") // .password("pwd") // .host("localhost") // .port(8888) // .path("server") // .segment("root", "resource") // .matrixParam("class", 2, 5, 6) // .segment("child") // .matrixParam("group", "A") // .matrixParam("subGroup", "A.1", "A.2") // .queryParam("age", 12) // .queryParam("name", "Aa", "Zz") // .fragment("first") // .build().toString(); // // assertEquals(expected, uri); // } // // public void testCommaSeparatedStrategy() { // String expected = "/server/root;class=2,5,6" + // "/child;group=A;subGroup=A.1,A.2?age=12&name=Aa,Zz#first"; // // String uri = UriBuilder.fromPath("server") // .multivaluedParamComposition(MultivaluedParamComposition.COMMA_SEPARATED_VALUE) // .segment("root") // .matrixParam("class", 2, 5, 6) // .segment("child") // .matrixParam("group", "A") // .matrixParam("subGroup", "A.1", "A.2") // .queryParam("age", 12) // .queryParam("name", "Aa", "Zz") // .fragment("first") // .build().toString(); // // assertEquals(expected, uri); // } // // public void testTemplateParams() { // String expected = "http://user:pwd@localhost:8888/server/root/any;class=2;class=5;class=6" + // "/child;group=A;subGroup=A.1;subGroup=A.2?age=12&name=Aa&name=Zz#firstserver"; // // String uri = UriBuilder.newInstance() // .scheme("http") // .user("user") // .password("pwd") // .host("localhost") // .port(8888) // .path("{a}/{b}") // .segment("{c}") // .matrixParam("class", 2, 5, 6) // .segment("child") // .matrixParam("group", "A") // .matrixParam("subGroup", "A.1", "A.2") // .queryParam("age", 12) // .queryParam("name", "Aa", "Zz") // .fragment("{d}{a}") // .build("server", "root", "any", "first").toString(); // // assertEquals(expected, uri); // } // // public void testInsufficientTemplateParams() { // try { // assertNull(UriBuilder.newInstance() // .path("{a}/{b}") // .segment("{c}") // .fragment("{d}{a}") // .build("server", "root", "any").toString()); // } catch (UriBuilderException e) { // assertNotNull(e); // } // } // }
import com.google.gwt.junit.tools.GWTTestSuite; import junit.framework.Test; import org.turbogwt.net.client.UriBuilderTest;
/* * Copyright 2014 Grow Bit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.turbogwt.net; /** * @author Danilo Reinert */ public class NetGwtTestSuite { public static Test suite() { GWTTestSuite suite = new GWTTestSuite("Net Core Test Suite");
// Path: src/test/java/org/turbogwt/net/client/UriBuilderTest.java // public class UriBuilderTest extends GWTTestCase { // // @Override // public String getModuleName() { // return "org.turbogwt.net.NetTest"; // } // // public void testBasicFlow() { // String expected = "http://user:pwd@localhost:8888/server/root/resource;class=2;class=5;class=6" + // "/child;group=A;subGroup=A.1;subGroup=A.2?age=12&name=Aa&name=Zz#first"; // // String uri = UriBuilder.newInstance() // .scheme("http") // .user("user") // .password("pwd") // .host("localhost") // .port(8888) // .path("server") // .segment("root", "resource") // .matrixParam("class", 2, 5, 6) // .segment("child") // .matrixParam("group", "A") // .matrixParam("subGroup", "A.1", "A.2") // .queryParam("age", 12) // .queryParam("name", "Aa", "Zz") // .fragment("first") // .build().toString(); // // assertEquals(expected, uri); // } // // public void testCommaSeparatedStrategy() { // String expected = "/server/root;class=2,5,6" + // "/child;group=A;subGroup=A.1,A.2?age=12&name=Aa,Zz#first"; // // String uri = UriBuilder.fromPath("server") // .multivaluedParamComposition(MultivaluedParamComposition.COMMA_SEPARATED_VALUE) // .segment("root") // .matrixParam("class", 2, 5, 6) // .segment("child") // .matrixParam("group", "A") // .matrixParam("subGroup", "A.1", "A.2") // .queryParam("age", 12) // .queryParam("name", "Aa", "Zz") // .fragment("first") // .build().toString(); // // assertEquals(expected, uri); // } // // public void testTemplateParams() { // String expected = "http://user:pwd@localhost:8888/server/root/any;class=2;class=5;class=6" + // "/child;group=A;subGroup=A.1;subGroup=A.2?age=12&name=Aa&name=Zz#firstserver"; // // String uri = UriBuilder.newInstance() // .scheme("http") // .user("user") // .password("pwd") // .host("localhost") // .port(8888) // .path("{a}/{b}") // .segment("{c}") // .matrixParam("class", 2, 5, 6) // .segment("child") // .matrixParam("group", "A") // .matrixParam("subGroup", "A.1", "A.2") // .queryParam("age", 12) // .queryParam("name", "Aa", "Zz") // .fragment("{d}{a}") // .build("server", "root", "any", "first").toString(); // // assertEquals(expected, uri); // } // // public void testInsufficientTemplateParams() { // try { // assertNull(UriBuilder.newInstance() // .path("{a}/{b}") // .segment("{c}") // .fragment("{d}{a}") // .build("server", "root", "any").toString()); // } catch (UriBuilderException e) { // assertNotNull(e); // } // } // } // Path: src/test/java/org/turbogwt/net/NetGwtTestSuite.java import com.google.gwt.junit.tools.GWTTestSuite; import junit.framework.Test; import org.turbogwt.net.client.UriBuilderTest; /* * Copyright 2014 Grow Bit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.turbogwt.net; /** * @author Danilo Reinert */ public class NetGwtTestSuite { public static Test suite() { GWTTestSuite suite = new GWTTestSuite("Net Core Test Suite");
suite.addTestSuite(UriBuilderTest.class);
growbit/turbogwt-http
src/main/java/org/turbogwt/net/http/client/RequestDispatcher.java
// Path: src/main/java/org/turbogwt/net/http/client/header/AcceptHeader.java // public class AcceptHeader extends QualityFactorHeader { // // public AcceptHeader(Value... values) { // super("Accept", values); // } // // public AcceptHeader(String... values) { // super("Accept", values); // } // }
import com.google.gwt.http.client.Header; import java.util.Collection; import org.turbogwt.net.http.client.header.AcceptHeader;
/* * Copyright 2014 Grow Bit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.turbogwt.net.http.client; /** * A {@link Request} with dispatching capabilities. */ public interface RequestDispatcher extends Request { @Override RequestDispatcher contentType(String contentType); @Override RequestDispatcher accept(String contentType); @Override
// Path: src/main/java/org/turbogwt/net/http/client/header/AcceptHeader.java // public class AcceptHeader extends QualityFactorHeader { // // public AcceptHeader(Value... values) { // super("Accept", values); // } // // public AcceptHeader(String... values) { // super("Accept", values); // } // } // Path: src/main/java/org/turbogwt/net/http/client/RequestDispatcher.java import com.google.gwt.http.client.Header; import java.util.Collection; import org.turbogwt.net.http.client.header.AcceptHeader; /* * Copyright 2014 Grow Bit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.turbogwt.net.http.client; /** * A {@link Request} with dispatching capabilities. */ public interface RequestDispatcher extends Request { @Override RequestDispatcher contentType(String contentType); @Override RequestDispatcher accept(String contentType); @Override
RequestDispatcher accept(AcceptHeader acceptHeader);
growbit/turbogwt-http
src/test/java/org/turbogwt/net/http/client/mock/ServerStub.java
// Path: src/main/java/org/turbogwt/net/http/client/Server.java // public interface Server { // // /** // * Retrieve an instance of {@link ServerConnection}. // * // * @return The ServerConnection instance. // */ // ServerConnection getConnection(); // } // // Path: src/main/java/org/turbogwt/net/http/client/ServerConnection.java // public interface ServerConnection { // // void sendRequest(RequestBuilder.Method method, String url, String data, RequestCallback callback) // throws RequestException; // // void sendRequest(int timeout, @Nullable String user, @Nullable String password, @Nullable Headers headers, // RequestBuilder.Method method, String url, String data, RequestCallback callback) // throws RequestException; // }
import com.google.gwt.http.client.Response; import java.util.HashMap; import java.util.Map; import org.turbogwt.net.http.client.Server; import org.turbogwt.net.http.client.ServerConnection;
} public static RequestMock getRequestData(String uri) { return requestData.get(uri); } public static void triggerPendingRequest() { ServerConnectionMock.triggerPendingRequest(); } public static void clearStub() { responseData.clear(); requestData.clear(); returnSuccess = true; } static Response getResponseFor(String uri) { return responseData.get(uri); } static RequestMock setRequestData(String uri, RequestMock requestMock) { return requestData.put(uri, requestMock); } /** * Retrieve an instance of {@link org.turbogwt.net.http.client.ServerConnection}. * * @return The ServerConnection instance. */ @Override
// Path: src/main/java/org/turbogwt/net/http/client/Server.java // public interface Server { // // /** // * Retrieve an instance of {@link ServerConnection}. // * // * @return The ServerConnection instance. // */ // ServerConnection getConnection(); // } // // Path: src/main/java/org/turbogwt/net/http/client/ServerConnection.java // public interface ServerConnection { // // void sendRequest(RequestBuilder.Method method, String url, String data, RequestCallback callback) // throws RequestException; // // void sendRequest(int timeout, @Nullable String user, @Nullable String password, @Nullable Headers headers, // RequestBuilder.Method method, String url, String data, RequestCallback callback) // throws RequestException; // } // Path: src/test/java/org/turbogwt/net/http/client/mock/ServerStub.java import com.google.gwt.http.client.Response; import java.util.HashMap; import java.util.Map; import org.turbogwt.net.http.client.Server; import org.turbogwt.net.http.client.ServerConnection; } public static RequestMock getRequestData(String uri) { return requestData.get(uri); } public static void triggerPendingRequest() { ServerConnectionMock.triggerPendingRequest(); } public static void clearStub() { responseData.clear(); requestData.clear(); returnSuccess = true; } static Response getResponseFor(String uri) { return responseData.get(uri); } static RequestMock setRequestData(String uri, RequestMock requestMock) { return requestData.put(uri, requestMock); } /** * Retrieve an instance of {@link org.turbogwt.net.http.client.ServerConnection}. * * @return The ServerConnection instance. */ @Override
public ServerConnection getConnection() {
growbit/turbogwt-http
src/main/java/org/turbogwt/net/http/client/Request.java
// Path: src/main/java/org/turbogwt/net/http/client/header/AcceptHeader.java // public class AcceptHeader extends QualityFactorHeader { // // public AcceptHeader(Value... values) { // super("Accept", values); // } // // public AcceptHeader(String... values) { // super("Accept", values); // } // }
import com.google.gwt.http.client.Header; import org.turbogwt.net.http.client.header.AcceptHeader;
/* * Copyright 2014 Grow Bit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.turbogwt.net.http.client; /** * This type provides fluent style request building. * * @author Danilo Reinert */ public interface Request { /** * Set the content type of this request. * * @param contentType The content type of this request * * @return the updated Request */ Request contentType(String contentType); /** * Set the content type accepted for the response. * * @param contentType The content type accepted for the response * * @return the updated Request */ Request accept(String contentType); /** * Set the Accept header of the request. * * @param acceptHeader The accept header of the request. * * @return the updated Request */
// Path: src/main/java/org/turbogwt/net/http/client/header/AcceptHeader.java // public class AcceptHeader extends QualityFactorHeader { // // public AcceptHeader(Value... values) { // super("Accept", values); // } // // public AcceptHeader(String... values) { // super("Accept", values); // } // } // Path: src/main/java/org/turbogwt/net/http/client/Request.java import com.google.gwt.http.client.Header; import org.turbogwt.net.http.client.header.AcceptHeader; /* * Copyright 2014 Grow Bit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.turbogwt.net.http.client; /** * This type provides fluent style request building. * * @author Danilo Reinert */ public interface Request { /** * Set the content type of this request. * * @param contentType The content type of this request * * @return the updated Request */ Request contentType(String contentType); /** * Set the content type accepted for the response. * * @param contentType The content type accepted for the response * * @return the updated Request */ Request accept(String contentType); /** * Set the Accept header of the request. * * @param acceptHeader The accept header of the request. * * @return the updated Request */
Request accept(AcceptHeader acceptHeader);
growbit/turbogwt-http
src/main/java/org/turbogwt/net/serialization/client/json/JsonStringSerdes.java
// Path: src/main/java/org/turbogwt/net/serialization/client/DeserializationContext.java // public abstract class DeserializationContext { // // private final ContainerFactoryManager containerFactoryManager; // // public DeserializationContext(ContainerFactoryManager containerFactoryManager) { // this.containerFactoryManager = containerFactoryManager; // } // // public <C extends Collection> C getContainerInstance(Class<C> type) { // final Factory<C> factory = containerFactoryManager.getFactory(type); // if (factory == null) // throw new UnableToDeserializeException("Could not get container instance because there's no factory " + // "registered in the requestor."); // return factory.get(); // } // // protected ContainerFactoryManager getContainerFactoryManager() { // return containerFactoryManager; // } // } // // Path: src/main/java/org/turbogwt/net/serialization/client/SerializationContext.java // public abstract class SerializationContext { // }
import org.turbogwt.net.serialization.client.DeserializationContext; import org.turbogwt.net.serialization.client.SerializationContext;
/* * Copyright 2014 Grow Bit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.turbogwt.net.serialization.client.json; /** * De/Serializer of JSON strings. * * @author Danilo Reinert */ public class JsonStringSerdes extends JsonValueSerdes<String> { private static JsonStringSerdes INSTANCE = new JsonStringSerdes(); public JsonStringSerdes() { super(String.class); } public static JsonStringSerdes getInstance() { return INSTANCE; } @Override
// Path: src/main/java/org/turbogwt/net/serialization/client/DeserializationContext.java // public abstract class DeserializationContext { // // private final ContainerFactoryManager containerFactoryManager; // // public DeserializationContext(ContainerFactoryManager containerFactoryManager) { // this.containerFactoryManager = containerFactoryManager; // } // // public <C extends Collection> C getContainerInstance(Class<C> type) { // final Factory<C> factory = containerFactoryManager.getFactory(type); // if (factory == null) // throw new UnableToDeserializeException("Could not get container instance because there's no factory " + // "registered in the requestor."); // return factory.get(); // } // // protected ContainerFactoryManager getContainerFactoryManager() { // return containerFactoryManager; // } // } // // Path: src/main/java/org/turbogwt/net/serialization/client/SerializationContext.java // public abstract class SerializationContext { // } // Path: src/main/java/org/turbogwt/net/serialization/client/json/JsonStringSerdes.java import org.turbogwt.net.serialization.client.DeserializationContext; import org.turbogwt.net.serialization.client.SerializationContext; /* * Copyright 2014 Grow Bit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.turbogwt.net.serialization.client.json; /** * De/Serializer of JSON strings. * * @author Danilo Reinert */ public class JsonStringSerdes extends JsonValueSerdes<String> { private static JsonStringSerdes INSTANCE = new JsonStringSerdes(); public JsonStringSerdes() { super(String.class); } public static JsonStringSerdes getInstance() { return INSTANCE; } @Override
public String deserialize(String response, DeserializationContext context) {
growbit/turbogwt-http
src/main/java/org/turbogwt/net/serialization/client/json/JsonStringSerdes.java
// Path: src/main/java/org/turbogwt/net/serialization/client/DeserializationContext.java // public abstract class DeserializationContext { // // private final ContainerFactoryManager containerFactoryManager; // // public DeserializationContext(ContainerFactoryManager containerFactoryManager) { // this.containerFactoryManager = containerFactoryManager; // } // // public <C extends Collection> C getContainerInstance(Class<C> type) { // final Factory<C> factory = containerFactoryManager.getFactory(type); // if (factory == null) // throw new UnableToDeserializeException("Could not get container instance because there's no factory " + // "registered in the requestor."); // return factory.get(); // } // // protected ContainerFactoryManager getContainerFactoryManager() { // return containerFactoryManager; // } // } // // Path: src/main/java/org/turbogwt/net/serialization/client/SerializationContext.java // public abstract class SerializationContext { // }
import org.turbogwt.net.serialization.client.DeserializationContext; import org.turbogwt.net.serialization.client.SerializationContext;
/* * Copyright 2014 Grow Bit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.turbogwt.net.serialization.client.json; /** * De/Serializer of JSON strings. * * @author Danilo Reinert */ public class JsonStringSerdes extends JsonValueSerdes<String> { private static JsonStringSerdes INSTANCE = new JsonStringSerdes(); public JsonStringSerdes() { super(String.class); } public static JsonStringSerdes getInstance() { return INSTANCE; } @Override public String deserialize(String response, DeserializationContext context) { return response.substring(1, response.length() - 1); } @Override
// Path: src/main/java/org/turbogwt/net/serialization/client/DeserializationContext.java // public abstract class DeserializationContext { // // private final ContainerFactoryManager containerFactoryManager; // // public DeserializationContext(ContainerFactoryManager containerFactoryManager) { // this.containerFactoryManager = containerFactoryManager; // } // // public <C extends Collection> C getContainerInstance(Class<C> type) { // final Factory<C> factory = containerFactoryManager.getFactory(type); // if (factory == null) // throw new UnableToDeserializeException("Could not get container instance because there's no factory " + // "registered in the requestor."); // return factory.get(); // } // // protected ContainerFactoryManager getContainerFactoryManager() { // return containerFactoryManager; // } // } // // Path: src/main/java/org/turbogwt/net/serialization/client/SerializationContext.java // public abstract class SerializationContext { // } // Path: src/main/java/org/turbogwt/net/serialization/client/json/JsonStringSerdes.java import org.turbogwt.net.serialization.client.DeserializationContext; import org.turbogwt.net.serialization.client.SerializationContext; /* * Copyright 2014 Grow Bit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.turbogwt.net.serialization.client.json; /** * De/Serializer of JSON strings. * * @author Danilo Reinert */ public class JsonStringSerdes extends JsonValueSerdes<String> { private static JsonStringSerdes INSTANCE = new JsonStringSerdes(); public JsonStringSerdes() { super(String.class); } public static JsonStringSerdes getInstance() { return INSTANCE; } @Override public String deserialize(String response, DeserializationContext context) { return response.substring(1, response.length() - 1); } @Override
public String serialize(String s, SerializationContext context) {
growbit/turbogwt-http
src/test/java/org/turbogwt/net/http/client/MultipleHeaderTest.java
// Path: src/main/java/org/turbogwt/net/http/client/header/MultivaluedHeader.java // public class MultivaluedHeader extends Header { // // private final String name; // private final String value; // private final String[] values; // // protected MultivaluedHeader(String name, Object... values) { // this.name = name; // this.values = new String[values.length]; // for (int i = 0; i < values.length; i++) { // Object v = values[i]; // this.values[i] = v.toString(); // } // this.value = mountValue(this.values); // } // // public MultivaluedHeader(String name, String... values) { // this.name = name; // this.values = values; // this.value = mountValue(values); // } // // /** // * Returns the name of the HTTP header. // * // * @return name of the HTTP header // */ // @Override // public String getName() { // return name; // } // // /** // * Returns the value of the HTTP header. // * // * @return value of the HTTP header // */ // @Override // public String getValue() { // return value; // } // // /** // * Returns the values of the HTTP header. // * // * @return values of the HTTP header // */ // public String[] getValues() { // return values; // } // // protected String mountValue(String[] values) { // String mountedValue = ""; // String separator = ""; // for (String v : values) { // mountedValue += separator + v; // separator = ", "; // } // return mountedValue; // } // }
import com.google.gwt.junit.client.GWTTestCase; import org.turbogwt.net.http.client.header.MultivaluedHeader;
/* * Copyright 2014 Grow Bit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.turbogwt.net.http.client; /** * @author Danilo Reinert */ public class MultipleHeaderTest extends GWTTestCase { @Override public String getModuleName() { return "org.turbogwt.net.http.HttpTest"; } public void testGetValue() { final String expected = "a/b, x/y+z";
// Path: src/main/java/org/turbogwt/net/http/client/header/MultivaluedHeader.java // public class MultivaluedHeader extends Header { // // private final String name; // private final String value; // private final String[] values; // // protected MultivaluedHeader(String name, Object... values) { // this.name = name; // this.values = new String[values.length]; // for (int i = 0; i < values.length; i++) { // Object v = values[i]; // this.values[i] = v.toString(); // } // this.value = mountValue(this.values); // } // // public MultivaluedHeader(String name, String... values) { // this.name = name; // this.values = values; // this.value = mountValue(values); // } // // /** // * Returns the name of the HTTP header. // * // * @return name of the HTTP header // */ // @Override // public String getName() { // return name; // } // // /** // * Returns the value of the HTTP header. // * // * @return value of the HTTP header // */ // @Override // public String getValue() { // return value; // } // // /** // * Returns the values of the HTTP header. // * // * @return values of the HTTP header // */ // public String[] getValues() { // return values; // } // // protected String mountValue(String[] values) { // String mountedValue = ""; // String separator = ""; // for (String v : values) { // mountedValue += separator + v; // separator = ", "; // } // return mountedValue; // } // } // Path: src/test/java/org/turbogwt/net/http/client/MultipleHeaderTest.java import com.google.gwt.junit.client.GWTTestCase; import org.turbogwt.net.http.client.header.MultivaluedHeader; /* * Copyright 2014 Grow Bit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.turbogwt.net.http.client; /** * @author Danilo Reinert */ public class MultipleHeaderTest extends GWTTestCase { @Override public String getModuleName() { return "org.turbogwt.net.http.HttpTest"; } public void testGetValue() { final String expected = "a/b, x/y+z";
final MultivaluedHeader header = new MultivaluedHeader("name", "a/b", "x/y+z");
growbit/turbogwt-http
src/main/java/org/turbogwt/net/serialization/client/json/JsonValueSerdes.java
// Path: src/main/java/org/turbogwt/net/serialization/client/DeserializationContext.java // public abstract class DeserializationContext { // // private final ContainerFactoryManager containerFactoryManager; // // public DeserializationContext(ContainerFactoryManager containerFactoryManager) { // this.containerFactoryManager = containerFactoryManager; // } // // public <C extends Collection> C getContainerInstance(Class<C> type) { // final Factory<C> factory = containerFactoryManager.getFactory(type); // if (factory == null) // throw new UnableToDeserializeException("Could not get container instance because there's no factory " + // "registered in the requestor."); // return factory.get(); // } // // protected ContainerFactoryManager getContainerFactoryManager() { // return containerFactoryManager; // } // } // // Path: src/main/java/org/turbogwt/net/serialization/client/UnableToDeserializeException.java // public class UnableToDeserializeException extends SerializationException { // // public UnableToDeserializeException() { // } // // public UnableToDeserializeException(String s) { // super(s); // } // // public UnableToDeserializeException(String s, Throwable throwable) { // super(s, throwable); // } // }
import java.util.Collection; import org.turbogwt.net.serialization.client.DeserializationContext; import org.turbogwt.net.serialization.client.UnableToDeserializeException;
/* * Copyright 2014 Grow Bit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.turbogwt.net.serialization.client.json; /** * Base class for all SerDes that manipulates serialized JSON simple values. * * @param <T> Type of the object to serialize/deserialize * * @author Danilo Reinert */ public abstract class JsonValueSerdes<T> extends JsonSerdes<T> { public JsonValueSerdes(Class<T> handledType) { super(handledType); } @Override public <C extends Collection<T>> C deserializeAsCollection(Class<C> collectionType, String response,
// Path: src/main/java/org/turbogwt/net/serialization/client/DeserializationContext.java // public abstract class DeserializationContext { // // private final ContainerFactoryManager containerFactoryManager; // // public DeserializationContext(ContainerFactoryManager containerFactoryManager) { // this.containerFactoryManager = containerFactoryManager; // } // // public <C extends Collection> C getContainerInstance(Class<C> type) { // final Factory<C> factory = containerFactoryManager.getFactory(type); // if (factory == null) // throw new UnableToDeserializeException("Could not get container instance because there's no factory " + // "registered in the requestor."); // return factory.get(); // } // // protected ContainerFactoryManager getContainerFactoryManager() { // return containerFactoryManager; // } // } // // Path: src/main/java/org/turbogwt/net/serialization/client/UnableToDeserializeException.java // public class UnableToDeserializeException extends SerializationException { // // public UnableToDeserializeException() { // } // // public UnableToDeserializeException(String s) { // super(s); // } // // public UnableToDeserializeException(String s, Throwable throwable) { // super(s, throwable); // } // } // Path: src/main/java/org/turbogwt/net/serialization/client/json/JsonValueSerdes.java import java.util.Collection; import org.turbogwt.net.serialization.client.DeserializationContext; import org.turbogwt.net.serialization.client.UnableToDeserializeException; /* * Copyright 2014 Grow Bit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.turbogwt.net.serialization.client.json; /** * Base class for all SerDes that manipulates serialized JSON simple values. * * @param <T> Type of the object to serialize/deserialize * * @author Danilo Reinert */ public abstract class JsonValueSerdes<T> extends JsonSerdes<T> { public JsonValueSerdes(Class<T> handledType) { super(handledType); } @Override public <C extends Collection<T>> C deserializeAsCollection(Class<C> collectionType, String response,
DeserializationContext context) {
growbit/turbogwt-http
src/main/java/org/turbogwt/net/serialization/client/json/JsonValueSerdes.java
// Path: src/main/java/org/turbogwt/net/serialization/client/DeserializationContext.java // public abstract class DeserializationContext { // // private final ContainerFactoryManager containerFactoryManager; // // public DeserializationContext(ContainerFactoryManager containerFactoryManager) { // this.containerFactoryManager = containerFactoryManager; // } // // public <C extends Collection> C getContainerInstance(Class<C> type) { // final Factory<C> factory = containerFactoryManager.getFactory(type); // if (factory == null) // throw new UnableToDeserializeException("Could not get container instance because there's no factory " + // "registered in the requestor."); // return factory.get(); // } // // protected ContainerFactoryManager getContainerFactoryManager() { // return containerFactoryManager; // } // } // // Path: src/main/java/org/turbogwt/net/serialization/client/UnableToDeserializeException.java // public class UnableToDeserializeException extends SerializationException { // // public UnableToDeserializeException() { // } // // public UnableToDeserializeException(String s) { // super(s); // } // // public UnableToDeserializeException(String s, Throwable throwable) { // super(s, throwable); // } // }
import java.util.Collection; import org.turbogwt.net.serialization.client.DeserializationContext; import org.turbogwt.net.serialization.client.UnableToDeserializeException;
/* * Copyright 2014 Grow Bit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.turbogwt.net.serialization.client.json; /** * Base class for all SerDes that manipulates serialized JSON simple values. * * @param <T> Type of the object to serialize/deserialize * * @author Danilo Reinert */ public abstract class JsonValueSerdes<T> extends JsonSerdes<T> { public JsonValueSerdes(Class<T> handledType) { super(handledType); } @Override public <C extends Collection<T>> C deserializeAsCollection(Class<C> collectionType, String response, DeserializationContext context) { final String trimmedResponse = response.trim();
// Path: src/main/java/org/turbogwt/net/serialization/client/DeserializationContext.java // public abstract class DeserializationContext { // // private final ContainerFactoryManager containerFactoryManager; // // public DeserializationContext(ContainerFactoryManager containerFactoryManager) { // this.containerFactoryManager = containerFactoryManager; // } // // public <C extends Collection> C getContainerInstance(Class<C> type) { // final Factory<C> factory = containerFactoryManager.getFactory(type); // if (factory == null) // throw new UnableToDeserializeException("Could not get container instance because there's no factory " + // "registered in the requestor."); // return factory.get(); // } // // protected ContainerFactoryManager getContainerFactoryManager() { // return containerFactoryManager; // } // } // // Path: src/main/java/org/turbogwt/net/serialization/client/UnableToDeserializeException.java // public class UnableToDeserializeException extends SerializationException { // // public UnableToDeserializeException() { // } // // public UnableToDeserializeException(String s) { // super(s); // } // // public UnableToDeserializeException(String s, Throwable throwable) { // super(s, throwable); // } // } // Path: src/main/java/org/turbogwt/net/serialization/client/json/JsonValueSerdes.java import java.util.Collection; import org.turbogwt.net.serialization.client.DeserializationContext; import org.turbogwt.net.serialization.client.UnableToDeserializeException; /* * Copyright 2014 Grow Bit * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.turbogwt.net.serialization.client.json; /** * Base class for all SerDes that manipulates serialized JSON simple values. * * @param <T> Type of the object to serialize/deserialize * * @author Danilo Reinert */ public abstract class JsonValueSerdes<T> extends JsonSerdes<T> { public JsonValueSerdes(Class<T> handledType) { super(handledType); } @Override public <C extends Collection<T>> C deserializeAsCollection(Class<C> collectionType, String response, DeserializationContext context) { final String trimmedResponse = response.trim();
if (!isArray(trimmedResponse)) throw new UnableToDeserializeException("Response content is not an array.");
wetneb/MorozParser
src/graphexpr/ProducerExpr.java
// Path: src/pregroup/SimpleType.java // public class SimpleType // { // private String base; // private int exp; // // public SimpleType(String bt, int e) // { // base = bt; // exp = e; // } // // public boolean isUnit() // { // return base.equals("1"); // } // // //! Generalized Contraction rule // public boolean gcon(SimpleType a, PartialComparator<String> c) // { // return // (a.exp == this.exp + 1) && // ((c.lessThan(this.base, a.base) && this.exp % 2 == 0) || // (c.lessThan(a.base, this.base) && this.exp % 2 != 0)); // } // // //! Left adjoint of the type // public SimpleType left() // { // SimpleType adj = new SimpleType(base, exp); // adj.exp--; // return adj; // } // // //! Right adjoint of the type // public SimpleType right() // { // SimpleType adj = new SimpleType(base, exp); // adj.exp++; // return adj; // } // // public boolean isProductive() // { // return (exp % 2 == 0); // } // // public String toString() // { // if(exp == 0) // return base; // // return base + "^{" + exp + "}"; // } // // public String toLatex() // { // if(exp == 0) // return base; // String output = base + "^{"; // if(exp > 0) // { // for(int i = 0; i < exp; i++) // output += "r"; // } // else // for(int i = 0; i > exp; i--) // output += "l"; // return (output+"}"); // } // // public String getBase() // { // return base; // } // }
import pregroup.SimpleType;
package graphexpr; public class ProducerExpr extends GraphExpr implements Cloneable {
// Path: src/pregroup/SimpleType.java // public class SimpleType // { // private String base; // private int exp; // // public SimpleType(String bt, int e) // { // base = bt; // exp = e; // } // // public boolean isUnit() // { // return base.equals("1"); // } // // //! Generalized Contraction rule // public boolean gcon(SimpleType a, PartialComparator<String> c) // { // return // (a.exp == this.exp + 1) && // ((c.lessThan(this.base, a.base) && this.exp % 2 == 0) || // (c.lessThan(a.base, this.base) && this.exp % 2 != 0)); // } // // //! Left adjoint of the type // public SimpleType left() // { // SimpleType adj = new SimpleType(base, exp); // adj.exp--; // return adj; // } // // //! Right adjoint of the type // public SimpleType right() // { // SimpleType adj = new SimpleType(base, exp); // adj.exp++; // return adj; // } // // public boolean isProductive() // { // return (exp % 2 == 0); // } // // public String toString() // { // if(exp == 0) // return base; // // return base + "^{" + exp + "}"; // } // // public String toLatex() // { // if(exp == 0) // return base; // String output = base + "^{"; // if(exp > 0) // { // for(int i = 0; i < exp; i++) // output += "r"; // } // else // for(int i = 0; i > exp; i--) // output += "l"; // return (output+"}"); // } // // public String getBase() // { // return base; // } // } // Path: src/graphexpr/ProducerExpr.java import pregroup.SimpleType; package graphexpr; public class ProducerExpr extends GraphExpr implements Cloneable {
public SimpleType type;
wetneb/MorozParser
src/graphexpr/TripleVarExpr.java
// Path: src/util/NotFoundException.java // public class NotFoundException extends Exception // { // private static final long serialVersionUID = 1L; // public final int i; // public NotFoundException(int id) { i = id; } // }
import java.util.HashMap; import util.NotFoundException;
package graphexpr; public class TripleVarExpr extends StmtExpr { public int id; public TripleVarExpr(int i) { id = i; } public void shift(HashMap<Integer, Integer> map, String name)
// Path: src/util/NotFoundException.java // public class NotFoundException extends Exception // { // private static final long serialVersionUID = 1L; // public final int i; // public NotFoundException(int id) { i = id; } // } // Path: src/graphexpr/TripleVarExpr.java import java.util.HashMap; import util.NotFoundException; package graphexpr; public class TripleVarExpr extends StmtExpr { public int id; public TripleVarExpr(int i) { id = i; } public void shift(HashMap<Integer, Integer> map, String name)
throws NotFoundException
wetneb/MorozParser
src/graphexpr/ExprResolver.java
// Path: src/pregroup/TypeLink.java // public class TypeLink // { // public int start; // public int end; // // public TypeLink(int s, int e) // { // start = s; // end = e; // } // // public String toString() // { // return "("+start+","+end+")"; // } // } // // Path: src/pregroup/TypeReduction.java // public class TypeReduction extends ArrayList<TypeLink> // { // private static final long serialVersionUID = 1L; // // //! Create an empty type reduction // public static TypeReduction empty() // { // return new TypeReduction(); // } // // //! Add a new link to an existing reduction // public TypeReduction link(int s, int e) // { // TypeReduction res = new TypeReduction(); // for(TypeLink l : this) // res.add(l); // res.add(new TypeLink(s,e)); // return res; // } // // //! Makes the union of two type reductions (supposed disjoint) // public static TypeReduction union(TypeReduction lhs, TypeReduction rhs) // { // TypeReduction res = new TypeReduction(); // for(TypeLink l : lhs) // res.add(l); // for(TypeLink l : rhs) // res.add(l); // return res; // } // // public String toString() // { // String res = ""; // for(TypeLink l : this) // res += l.toString() + " "; // return res; // } // } // // Path: src/rdf/GraphString.java // public class GraphString extends PhraseString // { // private static final long serialVersionUID = 1L; // // private HashMap<Integer, PatternExpr> patterns; // // public GraphString(SemanticLexicon lex, List<Pair<String,String>> sen, TypeString target) throws UnknownTagException, TypeException // { // this(lex.graphExprs(sen), sen, target); // } // // public GraphString(SemanticLexicon lex, List<Pair<String,String>> sen, SimpleType target) throws UnknownTagException, TypeException // { // this(lex.graphExprs(sen), sen, new TypeString(target)); // } // // public PatternExpr getPattern(int index) // { // return patterns.get(index); // } // // public void shiftPattern(HashMap<Integer, Integer> map, int idx, String name) throws NotFoundException // { // PatternExpr p = getPattern(idx); // p.shift(map, name); // patterns.put(idx, p); // } // // public GraphString(List<List<List<GraphExpr>>> lst, List<Pair<String,String>> sen, TypeString target) throws TypeException // { // //! TODO Redesign this method : separate HashMap generation and type string generation // patterns = new HashMap<Integer, PatternExpr>(); // int widx = 0; // for(List<List<GraphExpr>> candidates : lst) // { // HashMap<Integer,Integer> map = new HashMap<Integer,Integer>(); // // if(candidates.size() == 1 && candidates.get(0).size() == 1 && candidates.get(0).get(0).getType().isUnit()) // continue; // // addLB(); // addStar(); // for(List<GraphExpr> type : candidates) // { // int idx = this.size(); // // TypeString str = new TypeString(); // for(GraphExpr ge : type) // { // if(ge.isConsumer()) // { // ConsumerExpr c = (ConsumerExpr)ge; // map.put(c.var, idx); // } // idx++; // } // // idx = this.size(); // for(GraphExpr ge : type) // { // if(ge.isProducer()) // { // ProducerExpr p = (ProducerExpr) ge; // try { // p.pattern.shift(map, sen.get(widx).getLeft()); // } catch(NotFoundException e) // { // throw new TypeException("Invalid pattern \""+p.pattern.toString()+ // "\": variable "+e.i+" is undefined."); // } // patterns.put(idx,p.pattern); // } // str.add(ge.getType()); // idx++; // } // // addType(str); // addStar(); // } // // addRB(); // widx++; // } // // //! Add the candidate // addLB(); // addStar(); // addType(target.right()); // } // // }
import java.util.HashMap; import pregroup.TypeLink; import pregroup.TypeReduction; import rdf.GraphString;
package graphexpr; public class ExprResolver extends HashMap<Integer, PatternExpr> { private static final long serialVersionUID = 1L; private int entrypoint;
// Path: src/pregroup/TypeLink.java // public class TypeLink // { // public int start; // public int end; // // public TypeLink(int s, int e) // { // start = s; // end = e; // } // // public String toString() // { // return "("+start+","+end+")"; // } // } // // Path: src/pregroup/TypeReduction.java // public class TypeReduction extends ArrayList<TypeLink> // { // private static final long serialVersionUID = 1L; // // //! Create an empty type reduction // public static TypeReduction empty() // { // return new TypeReduction(); // } // // //! Add a new link to an existing reduction // public TypeReduction link(int s, int e) // { // TypeReduction res = new TypeReduction(); // for(TypeLink l : this) // res.add(l); // res.add(new TypeLink(s,e)); // return res; // } // // //! Makes the union of two type reductions (supposed disjoint) // public static TypeReduction union(TypeReduction lhs, TypeReduction rhs) // { // TypeReduction res = new TypeReduction(); // for(TypeLink l : lhs) // res.add(l); // for(TypeLink l : rhs) // res.add(l); // return res; // } // // public String toString() // { // String res = ""; // for(TypeLink l : this) // res += l.toString() + " "; // return res; // } // } // // Path: src/rdf/GraphString.java // public class GraphString extends PhraseString // { // private static final long serialVersionUID = 1L; // // private HashMap<Integer, PatternExpr> patterns; // // public GraphString(SemanticLexicon lex, List<Pair<String,String>> sen, TypeString target) throws UnknownTagException, TypeException // { // this(lex.graphExprs(sen), sen, target); // } // // public GraphString(SemanticLexicon lex, List<Pair<String,String>> sen, SimpleType target) throws UnknownTagException, TypeException // { // this(lex.graphExprs(sen), sen, new TypeString(target)); // } // // public PatternExpr getPattern(int index) // { // return patterns.get(index); // } // // public void shiftPattern(HashMap<Integer, Integer> map, int idx, String name) throws NotFoundException // { // PatternExpr p = getPattern(idx); // p.shift(map, name); // patterns.put(idx, p); // } // // public GraphString(List<List<List<GraphExpr>>> lst, List<Pair<String,String>> sen, TypeString target) throws TypeException // { // //! TODO Redesign this method : separate HashMap generation and type string generation // patterns = new HashMap<Integer, PatternExpr>(); // int widx = 0; // for(List<List<GraphExpr>> candidates : lst) // { // HashMap<Integer,Integer> map = new HashMap<Integer,Integer>(); // // if(candidates.size() == 1 && candidates.get(0).size() == 1 && candidates.get(0).get(0).getType().isUnit()) // continue; // // addLB(); // addStar(); // for(List<GraphExpr> type : candidates) // { // int idx = this.size(); // // TypeString str = new TypeString(); // for(GraphExpr ge : type) // { // if(ge.isConsumer()) // { // ConsumerExpr c = (ConsumerExpr)ge; // map.put(c.var, idx); // } // idx++; // } // // idx = this.size(); // for(GraphExpr ge : type) // { // if(ge.isProducer()) // { // ProducerExpr p = (ProducerExpr) ge; // try { // p.pattern.shift(map, sen.get(widx).getLeft()); // } catch(NotFoundException e) // { // throw new TypeException("Invalid pattern \""+p.pattern.toString()+ // "\": variable "+e.i+" is undefined."); // } // patterns.put(idx,p.pattern); // } // str.add(ge.getType()); // idx++; // } // // addType(str); // addStar(); // } // // addRB(); // widx++; // } // // //! Add the candidate // addLB(); // addStar(); // addType(target.right()); // } // // } // Path: src/graphexpr/ExprResolver.java import java.util.HashMap; import pregroup.TypeLink; import pregroup.TypeReduction; import rdf.GraphString; package graphexpr; public class ExprResolver extends HashMap<Integer, PatternExpr> { private static final long serialVersionUID = 1L; private int entrypoint;
public ExprResolver(GraphString phr, TypeReduction red)
wetneb/MorozParser
src/graphexpr/ExprResolver.java
// Path: src/pregroup/TypeLink.java // public class TypeLink // { // public int start; // public int end; // // public TypeLink(int s, int e) // { // start = s; // end = e; // } // // public String toString() // { // return "("+start+","+end+")"; // } // } // // Path: src/pregroup/TypeReduction.java // public class TypeReduction extends ArrayList<TypeLink> // { // private static final long serialVersionUID = 1L; // // //! Create an empty type reduction // public static TypeReduction empty() // { // return new TypeReduction(); // } // // //! Add a new link to an existing reduction // public TypeReduction link(int s, int e) // { // TypeReduction res = new TypeReduction(); // for(TypeLink l : this) // res.add(l); // res.add(new TypeLink(s,e)); // return res; // } // // //! Makes the union of two type reductions (supposed disjoint) // public static TypeReduction union(TypeReduction lhs, TypeReduction rhs) // { // TypeReduction res = new TypeReduction(); // for(TypeLink l : lhs) // res.add(l); // for(TypeLink l : rhs) // res.add(l); // return res; // } // // public String toString() // { // String res = ""; // for(TypeLink l : this) // res += l.toString() + " "; // return res; // } // } // // Path: src/rdf/GraphString.java // public class GraphString extends PhraseString // { // private static final long serialVersionUID = 1L; // // private HashMap<Integer, PatternExpr> patterns; // // public GraphString(SemanticLexicon lex, List<Pair<String,String>> sen, TypeString target) throws UnknownTagException, TypeException // { // this(lex.graphExprs(sen), sen, target); // } // // public GraphString(SemanticLexicon lex, List<Pair<String,String>> sen, SimpleType target) throws UnknownTagException, TypeException // { // this(lex.graphExprs(sen), sen, new TypeString(target)); // } // // public PatternExpr getPattern(int index) // { // return patterns.get(index); // } // // public void shiftPattern(HashMap<Integer, Integer> map, int idx, String name) throws NotFoundException // { // PatternExpr p = getPattern(idx); // p.shift(map, name); // patterns.put(idx, p); // } // // public GraphString(List<List<List<GraphExpr>>> lst, List<Pair<String,String>> sen, TypeString target) throws TypeException // { // //! TODO Redesign this method : separate HashMap generation and type string generation // patterns = new HashMap<Integer, PatternExpr>(); // int widx = 0; // for(List<List<GraphExpr>> candidates : lst) // { // HashMap<Integer,Integer> map = new HashMap<Integer,Integer>(); // // if(candidates.size() == 1 && candidates.get(0).size() == 1 && candidates.get(0).get(0).getType().isUnit()) // continue; // // addLB(); // addStar(); // for(List<GraphExpr> type : candidates) // { // int idx = this.size(); // // TypeString str = new TypeString(); // for(GraphExpr ge : type) // { // if(ge.isConsumer()) // { // ConsumerExpr c = (ConsumerExpr)ge; // map.put(c.var, idx); // } // idx++; // } // // idx = this.size(); // for(GraphExpr ge : type) // { // if(ge.isProducer()) // { // ProducerExpr p = (ProducerExpr) ge; // try { // p.pattern.shift(map, sen.get(widx).getLeft()); // } catch(NotFoundException e) // { // throw new TypeException("Invalid pattern \""+p.pattern.toString()+ // "\": variable "+e.i+" is undefined."); // } // patterns.put(idx,p.pattern); // } // str.add(ge.getType()); // idx++; // } // // addType(str); // addStar(); // } // // addRB(); // widx++; // } // // //! Add the candidate // addLB(); // addStar(); // addType(target.right()); // } // // }
import java.util.HashMap; import pregroup.TypeLink; import pregroup.TypeReduction; import rdf.GraphString;
package graphexpr; public class ExprResolver extends HashMap<Integer, PatternExpr> { private static final long serialVersionUID = 1L; private int entrypoint;
// Path: src/pregroup/TypeLink.java // public class TypeLink // { // public int start; // public int end; // // public TypeLink(int s, int e) // { // start = s; // end = e; // } // // public String toString() // { // return "("+start+","+end+")"; // } // } // // Path: src/pregroup/TypeReduction.java // public class TypeReduction extends ArrayList<TypeLink> // { // private static final long serialVersionUID = 1L; // // //! Create an empty type reduction // public static TypeReduction empty() // { // return new TypeReduction(); // } // // //! Add a new link to an existing reduction // public TypeReduction link(int s, int e) // { // TypeReduction res = new TypeReduction(); // for(TypeLink l : this) // res.add(l); // res.add(new TypeLink(s,e)); // return res; // } // // //! Makes the union of two type reductions (supposed disjoint) // public static TypeReduction union(TypeReduction lhs, TypeReduction rhs) // { // TypeReduction res = new TypeReduction(); // for(TypeLink l : lhs) // res.add(l); // for(TypeLink l : rhs) // res.add(l); // return res; // } // // public String toString() // { // String res = ""; // for(TypeLink l : this) // res += l.toString() + " "; // return res; // } // } // // Path: src/rdf/GraphString.java // public class GraphString extends PhraseString // { // private static final long serialVersionUID = 1L; // // private HashMap<Integer, PatternExpr> patterns; // // public GraphString(SemanticLexicon lex, List<Pair<String,String>> sen, TypeString target) throws UnknownTagException, TypeException // { // this(lex.graphExprs(sen), sen, target); // } // // public GraphString(SemanticLexicon lex, List<Pair<String,String>> sen, SimpleType target) throws UnknownTagException, TypeException // { // this(lex.graphExprs(sen), sen, new TypeString(target)); // } // // public PatternExpr getPattern(int index) // { // return patterns.get(index); // } // // public void shiftPattern(HashMap<Integer, Integer> map, int idx, String name) throws NotFoundException // { // PatternExpr p = getPattern(idx); // p.shift(map, name); // patterns.put(idx, p); // } // // public GraphString(List<List<List<GraphExpr>>> lst, List<Pair<String,String>> sen, TypeString target) throws TypeException // { // //! TODO Redesign this method : separate HashMap generation and type string generation // patterns = new HashMap<Integer, PatternExpr>(); // int widx = 0; // for(List<List<GraphExpr>> candidates : lst) // { // HashMap<Integer,Integer> map = new HashMap<Integer,Integer>(); // // if(candidates.size() == 1 && candidates.get(0).size() == 1 && candidates.get(0).get(0).getType().isUnit()) // continue; // // addLB(); // addStar(); // for(List<GraphExpr> type : candidates) // { // int idx = this.size(); // // TypeString str = new TypeString(); // for(GraphExpr ge : type) // { // if(ge.isConsumer()) // { // ConsumerExpr c = (ConsumerExpr)ge; // map.put(c.var, idx); // } // idx++; // } // // idx = this.size(); // for(GraphExpr ge : type) // { // if(ge.isProducer()) // { // ProducerExpr p = (ProducerExpr) ge; // try { // p.pattern.shift(map, sen.get(widx).getLeft()); // } catch(NotFoundException e) // { // throw new TypeException("Invalid pattern \""+p.pattern.toString()+ // "\": variable "+e.i+" is undefined."); // } // patterns.put(idx,p.pattern); // } // str.add(ge.getType()); // idx++; // } // // addType(str); // addStar(); // } // // addRB(); // widx++; // } // // //! Add the candidate // addLB(); // addStar(); // addType(target.right()); // } // // } // Path: src/graphexpr/ExprResolver.java import java.util.HashMap; import pregroup.TypeLink; import pregroup.TypeReduction; import rdf.GraphString; package graphexpr; public class ExprResolver extends HashMap<Integer, PatternExpr> { private static final long serialVersionUID = 1L; private int entrypoint;
public ExprResolver(GraphString phr, TypeReduction red)
wetneb/MorozParser
src/graphexpr/ExprResolver.java
// Path: src/pregroup/TypeLink.java // public class TypeLink // { // public int start; // public int end; // // public TypeLink(int s, int e) // { // start = s; // end = e; // } // // public String toString() // { // return "("+start+","+end+")"; // } // } // // Path: src/pregroup/TypeReduction.java // public class TypeReduction extends ArrayList<TypeLink> // { // private static final long serialVersionUID = 1L; // // //! Create an empty type reduction // public static TypeReduction empty() // { // return new TypeReduction(); // } // // //! Add a new link to an existing reduction // public TypeReduction link(int s, int e) // { // TypeReduction res = new TypeReduction(); // for(TypeLink l : this) // res.add(l); // res.add(new TypeLink(s,e)); // return res; // } // // //! Makes the union of two type reductions (supposed disjoint) // public static TypeReduction union(TypeReduction lhs, TypeReduction rhs) // { // TypeReduction res = new TypeReduction(); // for(TypeLink l : lhs) // res.add(l); // for(TypeLink l : rhs) // res.add(l); // return res; // } // // public String toString() // { // String res = ""; // for(TypeLink l : this) // res += l.toString() + " "; // return res; // } // } // // Path: src/rdf/GraphString.java // public class GraphString extends PhraseString // { // private static final long serialVersionUID = 1L; // // private HashMap<Integer, PatternExpr> patterns; // // public GraphString(SemanticLexicon lex, List<Pair<String,String>> sen, TypeString target) throws UnknownTagException, TypeException // { // this(lex.graphExprs(sen), sen, target); // } // // public GraphString(SemanticLexicon lex, List<Pair<String,String>> sen, SimpleType target) throws UnknownTagException, TypeException // { // this(lex.graphExprs(sen), sen, new TypeString(target)); // } // // public PatternExpr getPattern(int index) // { // return patterns.get(index); // } // // public void shiftPattern(HashMap<Integer, Integer> map, int idx, String name) throws NotFoundException // { // PatternExpr p = getPattern(idx); // p.shift(map, name); // patterns.put(idx, p); // } // // public GraphString(List<List<List<GraphExpr>>> lst, List<Pair<String,String>> sen, TypeString target) throws TypeException // { // //! TODO Redesign this method : separate HashMap generation and type string generation // patterns = new HashMap<Integer, PatternExpr>(); // int widx = 0; // for(List<List<GraphExpr>> candidates : lst) // { // HashMap<Integer,Integer> map = new HashMap<Integer,Integer>(); // // if(candidates.size() == 1 && candidates.get(0).size() == 1 && candidates.get(0).get(0).getType().isUnit()) // continue; // // addLB(); // addStar(); // for(List<GraphExpr> type : candidates) // { // int idx = this.size(); // // TypeString str = new TypeString(); // for(GraphExpr ge : type) // { // if(ge.isConsumer()) // { // ConsumerExpr c = (ConsumerExpr)ge; // map.put(c.var, idx); // } // idx++; // } // // idx = this.size(); // for(GraphExpr ge : type) // { // if(ge.isProducer()) // { // ProducerExpr p = (ProducerExpr) ge; // try { // p.pattern.shift(map, sen.get(widx).getLeft()); // } catch(NotFoundException e) // { // throw new TypeException("Invalid pattern \""+p.pattern.toString()+ // "\": variable "+e.i+" is undefined."); // } // patterns.put(idx,p.pattern); // } // str.add(ge.getType()); // idx++; // } // // addType(str); // addStar(); // } // // addRB(); // widx++; // } // // //! Add the candidate // addLB(); // addStar(); // addType(target.right()); // } // // }
import java.util.HashMap; import pregroup.TypeLink; import pregroup.TypeReduction; import rdf.GraphString;
package graphexpr; public class ExprResolver extends HashMap<Integer, PatternExpr> { private static final long serialVersionUID = 1L; private int entrypoint; public ExprResolver(GraphString phr, TypeReduction red) { super();
// Path: src/pregroup/TypeLink.java // public class TypeLink // { // public int start; // public int end; // // public TypeLink(int s, int e) // { // start = s; // end = e; // } // // public String toString() // { // return "("+start+","+end+")"; // } // } // // Path: src/pregroup/TypeReduction.java // public class TypeReduction extends ArrayList<TypeLink> // { // private static final long serialVersionUID = 1L; // // //! Create an empty type reduction // public static TypeReduction empty() // { // return new TypeReduction(); // } // // //! Add a new link to an existing reduction // public TypeReduction link(int s, int e) // { // TypeReduction res = new TypeReduction(); // for(TypeLink l : this) // res.add(l); // res.add(new TypeLink(s,e)); // return res; // } // // //! Makes the union of two type reductions (supposed disjoint) // public static TypeReduction union(TypeReduction lhs, TypeReduction rhs) // { // TypeReduction res = new TypeReduction(); // for(TypeLink l : lhs) // res.add(l); // for(TypeLink l : rhs) // res.add(l); // return res; // } // // public String toString() // { // String res = ""; // for(TypeLink l : this) // res += l.toString() + " "; // return res; // } // } // // Path: src/rdf/GraphString.java // public class GraphString extends PhraseString // { // private static final long serialVersionUID = 1L; // // private HashMap<Integer, PatternExpr> patterns; // // public GraphString(SemanticLexicon lex, List<Pair<String,String>> sen, TypeString target) throws UnknownTagException, TypeException // { // this(lex.graphExprs(sen), sen, target); // } // // public GraphString(SemanticLexicon lex, List<Pair<String,String>> sen, SimpleType target) throws UnknownTagException, TypeException // { // this(lex.graphExprs(sen), sen, new TypeString(target)); // } // // public PatternExpr getPattern(int index) // { // return patterns.get(index); // } // // public void shiftPattern(HashMap<Integer, Integer> map, int idx, String name) throws NotFoundException // { // PatternExpr p = getPattern(idx); // p.shift(map, name); // patterns.put(idx, p); // } // // public GraphString(List<List<List<GraphExpr>>> lst, List<Pair<String,String>> sen, TypeString target) throws TypeException // { // //! TODO Redesign this method : separate HashMap generation and type string generation // patterns = new HashMap<Integer, PatternExpr>(); // int widx = 0; // for(List<List<GraphExpr>> candidates : lst) // { // HashMap<Integer,Integer> map = new HashMap<Integer,Integer>(); // // if(candidates.size() == 1 && candidates.get(0).size() == 1 && candidates.get(0).get(0).getType().isUnit()) // continue; // // addLB(); // addStar(); // for(List<GraphExpr> type : candidates) // { // int idx = this.size(); // // TypeString str = new TypeString(); // for(GraphExpr ge : type) // { // if(ge.isConsumer()) // { // ConsumerExpr c = (ConsumerExpr)ge; // map.put(c.var, idx); // } // idx++; // } // // idx = this.size(); // for(GraphExpr ge : type) // { // if(ge.isProducer()) // { // ProducerExpr p = (ProducerExpr) ge; // try { // p.pattern.shift(map, sen.get(widx).getLeft()); // } catch(NotFoundException e) // { // throw new TypeException("Invalid pattern \""+p.pattern.toString()+ // "\": variable "+e.i+" is undefined."); // } // patterns.put(idx,p.pattern); // } // str.add(ge.getType()); // idx++; // } // // addType(str); // addStar(); // } // // addRB(); // widx++; // } // // //! Add the candidate // addLB(); // addStar(); // addType(target.right()); // } // // } // Path: src/graphexpr/ExprResolver.java import java.util.HashMap; import pregroup.TypeLink; import pregroup.TypeReduction; import rdf.GraphString; package graphexpr; public class ExprResolver extends HashMap<Integer, PatternExpr> { private static final long serialVersionUID = 1L; private int entrypoint; public ExprResolver(GraphString phr, TypeReduction red) { super();
for(TypeLink link : red)
wetneb/MorozParser
src/app/SimpleTokenizer.java
// Path: src/util/TokenizerException.java // public class TokenizerException extends IOException // { // private static final long serialVersionUID = 1L; // public final String what; // public TokenizerException(String s) { what = s; } // }
import java.util.ArrayList; import java.util.List; import java.io.StringReader; import java.io.IOException; import util.TokenizerException;
zzInput = zzBufferL[zzCurrentPosL++]; } } int zzNext = zzTransL[ zzRowMapL[zzState] + zzCMapL[zzInput] ]; if (zzNext == -1) break zzForAction; zzState = zzNext; int zzAttributes = zzAttrL[zzState]; if ( (zzAttributes & 1) == 1 ) { zzAction = zzState; zzMarkedPosL = zzCurrentPosL; if ( (zzAttributes & 8) == 8 ) break zzForAction; } } } // store back cached position zzMarkedPos = zzMarkedPosL; switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) { case 1: { return yytext(); } case 4: break; case 3: { /* ignore */ } case 5: break; case 2:
// Path: src/util/TokenizerException.java // public class TokenizerException extends IOException // { // private static final long serialVersionUID = 1L; // public final String what; // public TokenizerException(String s) { what = s; } // } // Path: src/app/SimpleTokenizer.java import java.util.ArrayList; import java.util.List; import java.io.StringReader; import java.io.IOException; import util.TokenizerException; zzInput = zzBufferL[zzCurrentPosL++]; } } int zzNext = zzTransL[ zzRowMapL[zzState] + zzCMapL[zzInput] ]; if (zzNext == -1) break zzForAction; zzState = zzNext; int zzAttributes = zzAttrL[zzState]; if ( (zzAttributes & 1) == 1 ) { zzAction = zzState; zzMarkedPosL = zzCurrentPosL; if ( (zzAttributes & 8) == 8 ) break zzForAction; } } } // store back cached position zzMarkedPos = zzMarkedPosL; switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) { case 1: { return yytext(); } case 4: break; case 3: { /* ignore */ } case 5: break; case 2:
{ throw new TokenizerException(yytext());
wetneb/MorozParser
src/latex/TikzReduction.java
// Path: src/pregroup/PhraseString.java // public class PhraseString extends Vector<PhraseElem> // { // private static final long serialVersionUID = 1L; // // // Construct an empty phrase string // public PhraseString() // { // // } // // // Construct from a list of words, a lexicon and a target type // public PhraseString(Lexicon lex, List<Pair<String,String>> lst, TypeString target) // { // this(lex.types(lst), target); // } // // // Construct from a list of type candidates and a target type // public PhraseString(List<List<TypeString>> lst, TypeString target) // { // for(List<TypeString> candidates : lst) // { // addLB(); // addStar(); // for(TypeString type : candidates) // { // addType(type); // addStar(); // } // // addRB(); // } // // //! Add the candidate // addLB(); // addStar(); // addType(target.right()); // } // // public PhraseString(Lexicon lex, List<Pair<String,String>> sentence, // SimpleType target) { // this(lex,sentence,new TypeString(target)); // } // // // public String toString() // { // String res = ""; // for(PhraseElem e : this) // { // res += e.toString(); // } // return res; // } // // protected void addLB() // { // this.add(new LBElem()); // } // // protected void addRB() // { // this.add(new RBElem()); // } // // protected void addStar() // { // this.add(new StarElem()); // } // // private void addType(SimpleType t) // { // TypeElem elem = new TypeElem(); // elem.val = t; // add(elem); // } // // protected void addType(TypeString lst) // { // for(SimpleType t : lst) // addType(t); // } // } // // Path: src/pregroup/TypeLink.java // public class TypeLink // { // public int start; // public int end; // // public TypeLink(int s, int e) // { // start = s; // end = e; // } // // public String toString() // { // return "("+start+","+end+")"; // } // } // // Path: src/pregroup/TypeReduction.java // public class TypeReduction extends ArrayList<TypeLink> // { // private static final long serialVersionUID = 1L; // // //! Create an empty type reduction // public static TypeReduction empty() // { // return new TypeReduction(); // } // // //! Add a new link to an existing reduction // public TypeReduction link(int s, int e) // { // TypeReduction res = new TypeReduction(); // for(TypeLink l : this) // res.add(l); // res.add(new TypeLink(s,e)); // return res; // } // // //! Makes the union of two type reductions (supposed disjoint) // public static TypeReduction union(TypeReduction lhs, TypeReduction rhs) // { // TypeReduction res = new TypeReduction(); // for(TypeLink l : lhs) // res.add(l); // for(TypeLink l : rhs) // res.add(l); // return res; // } // // public String toString() // { // String res = ""; // for(TypeLink l : this) // res += l.toString() + " "; // return res; // } // }
import java.util.List; import pregroup.PhraseString; import pregroup.TypeLink; import pregroup.TypeReduction;
package latex; //! Creates a TikZ output from a parsing reduction public class TikzReduction { private static final String tikzHeader = "\\begin{tikzpicture}[\n"+ "every node/.style={%\n"+ "text height=1.5ex," + "text depth=0.25ex,"+ "}]\n"+ "% Diagram generated by http://github.com/wetneb/MorozParser"+ "\n\n"; private static final String tikzFooter = "\n\\end{tikzpicture}\n"; //! Vertical space between the types and the links below them private static final double distToTypes = 0.25; //! Horizontal space between two simple types in the same word private static final double typeSpacing = 0.4; //! Horizontal space between the types of two words private static final double wordSpacing = 1.1; //! Vertical space between the original words and their types private static final double textDistance = 0.5;
// Path: src/pregroup/PhraseString.java // public class PhraseString extends Vector<PhraseElem> // { // private static final long serialVersionUID = 1L; // // // Construct an empty phrase string // public PhraseString() // { // // } // // // Construct from a list of words, a lexicon and a target type // public PhraseString(Lexicon lex, List<Pair<String,String>> lst, TypeString target) // { // this(lex.types(lst), target); // } // // // Construct from a list of type candidates and a target type // public PhraseString(List<List<TypeString>> lst, TypeString target) // { // for(List<TypeString> candidates : lst) // { // addLB(); // addStar(); // for(TypeString type : candidates) // { // addType(type); // addStar(); // } // // addRB(); // } // // //! Add the candidate // addLB(); // addStar(); // addType(target.right()); // } // // public PhraseString(Lexicon lex, List<Pair<String,String>> sentence, // SimpleType target) { // this(lex,sentence,new TypeString(target)); // } // // // public String toString() // { // String res = ""; // for(PhraseElem e : this) // { // res += e.toString(); // } // return res; // } // // protected void addLB() // { // this.add(new LBElem()); // } // // protected void addRB() // { // this.add(new RBElem()); // } // // protected void addStar() // { // this.add(new StarElem()); // } // // private void addType(SimpleType t) // { // TypeElem elem = new TypeElem(); // elem.val = t; // add(elem); // } // // protected void addType(TypeString lst) // { // for(SimpleType t : lst) // addType(t); // } // } // // Path: src/pregroup/TypeLink.java // public class TypeLink // { // public int start; // public int end; // // public TypeLink(int s, int e) // { // start = s; // end = e; // } // // public String toString() // { // return "("+start+","+end+")"; // } // } // // Path: src/pregroup/TypeReduction.java // public class TypeReduction extends ArrayList<TypeLink> // { // private static final long serialVersionUID = 1L; // // //! Create an empty type reduction // public static TypeReduction empty() // { // return new TypeReduction(); // } // // //! Add a new link to an existing reduction // public TypeReduction link(int s, int e) // { // TypeReduction res = new TypeReduction(); // for(TypeLink l : this) // res.add(l); // res.add(new TypeLink(s,e)); // return res; // } // // //! Makes the union of two type reductions (supposed disjoint) // public static TypeReduction union(TypeReduction lhs, TypeReduction rhs) // { // TypeReduction res = new TypeReduction(); // for(TypeLink l : lhs) // res.add(l); // for(TypeLink l : rhs) // res.add(l); // return res; // } // // public String toString() // { // String res = ""; // for(TypeLink l : this) // res += l.toString() + " "; // return res; // } // } // Path: src/latex/TikzReduction.java import java.util.List; import pregroup.PhraseString; import pregroup.TypeLink; import pregroup.TypeReduction; package latex; //! Creates a TikZ output from a parsing reduction public class TikzReduction { private static final String tikzHeader = "\\begin{tikzpicture}[\n"+ "every node/.style={%\n"+ "text height=1.5ex," + "text depth=0.25ex,"+ "}]\n"+ "% Diagram generated by http://github.com/wetneb/MorozParser"+ "\n\n"; private static final String tikzFooter = "\n\\end{tikzpicture}\n"; //! Vertical space between the types and the links below them private static final double distToTypes = 0.25; //! Horizontal space between two simple types in the same word private static final double typeSpacing = 0.4; //! Horizontal space between the types of two words private static final double wordSpacing = 1.1; //! Vertical space between the original words and their types private static final double textDistance = 0.5;
public static String draw(PhraseString phrase, List<String> words, TypeReduction red)
wetneb/MorozParser
src/latex/TikzReduction.java
// Path: src/pregroup/PhraseString.java // public class PhraseString extends Vector<PhraseElem> // { // private static final long serialVersionUID = 1L; // // // Construct an empty phrase string // public PhraseString() // { // // } // // // Construct from a list of words, a lexicon and a target type // public PhraseString(Lexicon lex, List<Pair<String,String>> lst, TypeString target) // { // this(lex.types(lst), target); // } // // // Construct from a list of type candidates and a target type // public PhraseString(List<List<TypeString>> lst, TypeString target) // { // for(List<TypeString> candidates : lst) // { // addLB(); // addStar(); // for(TypeString type : candidates) // { // addType(type); // addStar(); // } // // addRB(); // } // // //! Add the candidate // addLB(); // addStar(); // addType(target.right()); // } // // public PhraseString(Lexicon lex, List<Pair<String,String>> sentence, // SimpleType target) { // this(lex,sentence,new TypeString(target)); // } // // // public String toString() // { // String res = ""; // for(PhraseElem e : this) // { // res += e.toString(); // } // return res; // } // // protected void addLB() // { // this.add(new LBElem()); // } // // protected void addRB() // { // this.add(new RBElem()); // } // // protected void addStar() // { // this.add(new StarElem()); // } // // private void addType(SimpleType t) // { // TypeElem elem = new TypeElem(); // elem.val = t; // add(elem); // } // // protected void addType(TypeString lst) // { // for(SimpleType t : lst) // addType(t); // } // } // // Path: src/pregroup/TypeLink.java // public class TypeLink // { // public int start; // public int end; // // public TypeLink(int s, int e) // { // start = s; // end = e; // } // // public String toString() // { // return "("+start+","+end+")"; // } // } // // Path: src/pregroup/TypeReduction.java // public class TypeReduction extends ArrayList<TypeLink> // { // private static final long serialVersionUID = 1L; // // //! Create an empty type reduction // public static TypeReduction empty() // { // return new TypeReduction(); // } // // //! Add a new link to an existing reduction // public TypeReduction link(int s, int e) // { // TypeReduction res = new TypeReduction(); // for(TypeLink l : this) // res.add(l); // res.add(new TypeLink(s,e)); // return res; // } // // //! Makes the union of two type reductions (supposed disjoint) // public static TypeReduction union(TypeReduction lhs, TypeReduction rhs) // { // TypeReduction res = new TypeReduction(); // for(TypeLink l : lhs) // res.add(l); // for(TypeLink l : rhs) // res.add(l); // return res; // } // // public String toString() // { // String res = ""; // for(TypeLink l : this) // res += l.toString() + " "; // return res; // } // }
import java.util.List; import pregroup.PhraseString; import pregroup.TypeLink; import pregroup.TypeReduction;
package latex; //! Creates a TikZ output from a parsing reduction public class TikzReduction { private static final String tikzHeader = "\\begin{tikzpicture}[\n"+ "every node/.style={%\n"+ "text height=1.5ex," + "text depth=0.25ex,"+ "}]\n"+ "% Diagram generated by http://github.com/wetneb/MorozParser"+ "\n\n"; private static final String tikzFooter = "\n\\end{tikzpicture}\n"; //! Vertical space between the types and the links below them private static final double distToTypes = 0.25; //! Horizontal space between two simple types in the same word private static final double typeSpacing = 0.4; //! Horizontal space between the types of two words private static final double wordSpacing = 1.1; //! Vertical space between the original words and their types private static final double textDistance = 0.5;
// Path: src/pregroup/PhraseString.java // public class PhraseString extends Vector<PhraseElem> // { // private static final long serialVersionUID = 1L; // // // Construct an empty phrase string // public PhraseString() // { // // } // // // Construct from a list of words, a lexicon and a target type // public PhraseString(Lexicon lex, List<Pair<String,String>> lst, TypeString target) // { // this(lex.types(lst), target); // } // // // Construct from a list of type candidates and a target type // public PhraseString(List<List<TypeString>> lst, TypeString target) // { // for(List<TypeString> candidates : lst) // { // addLB(); // addStar(); // for(TypeString type : candidates) // { // addType(type); // addStar(); // } // // addRB(); // } // // //! Add the candidate // addLB(); // addStar(); // addType(target.right()); // } // // public PhraseString(Lexicon lex, List<Pair<String,String>> sentence, // SimpleType target) { // this(lex,sentence,new TypeString(target)); // } // // // public String toString() // { // String res = ""; // for(PhraseElem e : this) // { // res += e.toString(); // } // return res; // } // // protected void addLB() // { // this.add(new LBElem()); // } // // protected void addRB() // { // this.add(new RBElem()); // } // // protected void addStar() // { // this.add(new StarElem()); // } // // private void addType(SimpleType t) // { // TypeElem elem = new TypeElem(); // elem.val = t; // add(elem); // } // // protected void addType(TypeString lst) // { // for(SimpleType t : lst) // addType(t); // } // } // // Path: src/pregroup/TypeLink.java // public class TypeLink // { // public int start; // public int end; // // public TypeLink(int s, int e) // { // start = s; // end = e; // } // // public String toString() // { // return "("+start+","+end+")"; // } // } // // Path: src/pregroup/TypeReduction.java // public class TypeReduction extends ArrayList<TypeLink> // { // private static final long serialVersionUID = 1L; // // //! Create an empty type reduction // public static TypeReduction empty() // { // return new TypeReduction(); // } // // //! Add a new link to an existing reduction // public TypeReduction link(int s, int e) // { // TypeReduction res = new TypeReduction(); // for(TypeLink l : this) // res.add(l); // res.add(new TypeLink(s,e)); // return res; // } // // //! Makes the union of two type reductions (supposed disjoint) // public static TypeReduction union(TypeReduction lhs, TypeReduction rhs) // { // TypeReduction res = new TypeReduction(); // for(TypeLink l : lhs) // res.add(l); // for(TypeLink l : rhs) // res.add(l); // return res; // } // // public String toString() // { // String res = ""; // for(TypeLink l : this) // res += l.toString() + " "; // return res; // } // } // Path: src/latex/TikzReduction.java import java.util.List; import pregroup.PhraseString; import pregroup.TypeLink; import pregroup.TypeReduction; package latex; //! Creates a TikZ output from a parsing reduction public class TikzReduction { private static final String tikzHeader = "\\begin{tikzpicture}[\n"+ "every node/.style={%\n"+ "text height=1.5ex," + "text depth=0.25ex,"+ "}]\n"+ "% Diagram generated by http://github.com/wetneb/MorozParser"+ "\n\n"; private static final String tikzFooter = "\n\\end{tikzpicture}\n"; //! Vertical space between the types and the links below them private static final double distToTypes = 0.25; //! Horizontal space between two simple types in the same word private static final double typeSpacing = 0.4; //! Horizontal space between the types of two words private static final double wordSpacing = 1.1; //! Vertical space between the original words and their types private static final double textDistance = 0.5;
public static String draw(PhraseString phrase, List<String> words, TypeReduction red)
wetneb/MorozParser
src/latex/TikzReduction.java
// Path: src/pregroup/PhraseString.java // public class PhraseString extends Vector<PhraseElem> // { // private static final long serialVersionUID = 1L; // // // Construct an empty phrase string // public PhraseString() // { // // } // // // Construct from a list of words, a lexicon and a target type // public PhraseString(Lexicon lex, List<Pair<String,String>> lst, TypeString target) // { // this(lex.types(lst), target); // } // // // Construct from a list of type candidates and a target type // public PhraseString(List<List<TypeString>> lst, TypeString target) // { // for(List<TypeString> candidates : lst) // { // addLB(); // addStar(); // for(TypeString type : candidates) // { // addType(type); // addStar(); // } // // addRB(); // } // // //! Add the candidate // addLB(); // addStar(); // addType(target.right()); // } // // public PhraseString(Lexicon lex, List<Pair<String,String>> sentence, // SimpleType target) { // this(lex,sentence,new TypeString(target)); // } // // // public String toString() // { // String res = ""; // for(PhraseElem e : this) // { // res += e.toString(); // } // return res; // } // // protected void addLB() // { // this.add(new LBElem()); // } // // protected void addRB() // { // this.add(new RBElem()); // } // // protected void addStar() // { // this.add(new StarElem()); // } // // private void addType(SimpleType t) // { // TypeElem elem = new TypeElem(); // elem.val = t; // add(elem); // } // // protected void addType(TypeString lst) // { // for(SimpleType t : lst) // addType(t); // } // } // // Path: src/pregroup/TypeLink.java // public class TypeLink // { // public int start; // public int end; // // public TypeLink(int s, int e) // { // start = s; // end = e; // } // // public String toString() // { // return "("+start+","+end+")"; // } // } // // Path: src/pregroup/TypeReduction.java // public class TypeReduction extends ArrayList<TypeLink> // { // private static final long serialVersionUID = 1L; // // //! Create an empty type reduction // public static TypeReduction empty() // { // return new TypeReduction(); // } // // //! Add a new link to an existing reduction // public TypeReduction link(int s, int e) // { // TypeReduction res = new TypeReduction(); // for(TypeLink l : this) // res.add(l); // res.add(new TypeLink(s,e)); // return res; // } // // //! Makes the union of two type reductions (supposed disjoint) // public static TypeReduction union(TypeReduction lhs, TypeReduction rhs) // { // TypeReduction res = new TypeReduction(); // for(TypeLink l : lhs) // res.add(l); // for(TypeLink l : rhs) // res.add(l); // return res; // } // // public String toString() // { // String res = ""; // for(TypeLink l : this) // res += l.toString() + " "; // return res; // } // }
import java.util.List; import pregroup.PhraseString; import pregroup.TypeLink; import pregroup.TypeReduction;
package latex; //! Creates a TikZ output from a parsing reduction public class TikzReduction { private static final String tikzHeader = "\\begin{tikzpicture}[\n"+ "every node/.style={%\n"+ "text height=1.5ex," + "text depth=0.25ex,"+ "}]\n"+ "% Diagram generated by http://github.com/wetneb/MorozParser"+ "\n\n"; private static final String tikzFooter = "\n\\end{tikzpicture}\n"; //! Vertical space between the types and the links below them private static final double distToTypes = 0.25; //! Horizontal space between two simple types in the same word private static final double typeSpacing = 0.4; //! Horizontal space between the types of two words private static final double wordSpacing = 1.1; //! Vertical space between the original words and their types private static final double textDistance = 0.5; public static String draw(PhraseString phrase, List<String> words, TypeReduction red) { int n = phrase.size(); double[] pos = new double[n]; boolean[] used = new boolean[n]; String output = tikzHeader; //! Compute the used types for(int i = 0; i < n; i++) used[i] = false;
// Path: src/pregroup/PhraseString.java // public class PhraseString extends Vector<PhraseElem> // { // private static final long serialVersionUID = 1L; // // // Construct an empty phrase string // public PhraseString() // { // // } // // // Construct from a list of words, a lexicon and a target type // public PhraseString(Lexicon lex, List<Pair<String,String>> lst, TypeString target) // { // this(lex.types(lst), target); // } // // // Construct from a list of type candidates and a target type // public PhraseString(List<List<TypeString>> lst, TypeString target) // { // for(List<TypeString> candidates : lst) // { // addLB(); // addStar(); // for(TypeString type : candidates) // { // addType(type); // addStar(); // } // // addRB(); // } // // //! Add the candidate // addLB(); // addStar(); // addType(target.right()); // } // // public PhraseString(Lexicon lex, List<Pair<String,String>> sentence, // SimpleType target) { // this(lex,sentence,new TypeString(target)); // } // // // public String toString() // { // String res = ""; // for(PhraseElem e : this) // { // res += e.toString(); // } // return res; // } // // protected void addLB() // { // this.add(new LBElem()); // } // // protected void addRB() // { // this.add(new RBElem()); // } // // protected void addStar() // { // this.add(new StarElem()); // } // // private void addType(SimpleType t) // { // TypeElem elem = new TypeElem(); // elem.val = t; // add(elem); // } // // protected void addType(TypeString lst) // { // for(SimpleType t : lst) // addType(t); // } // } // // Path: src/pregroup/TypeLink.java // public class TypeLink // { // public int start; // public int end; // // public TypeLink(int s, int e) // { // start = s; // end = e; // } // // public String toString() // { // return "("+start+","+end+")"; // } // } // // Path: src/pregroup/TypeReduction.java // public class TypeReduction extends ArrayList<TypeLink> // { // private static final long serialVersionUID = 1L; // // //! Create an empty type reduction // public static TypeReduction empty() // { // return new TypeReduction(); // } // // //! Add a new link to an existing reduction // public TypeReduction link(int s, int e) // { // TypeReduction res = new TypeReduction(); // for(TypeLink l : this) // res.add(l); // res.add(new TypeLink(s,e)); // return res; // } // // //! Makes the union of two type reductions (supposed disjoint) // public static TypeReduction union(TypeReduction lhs, TypeReduction rhs) // { // TypeReduction res = new TypeReduction(); // for(TypeLink l : lhs) // res.add(l); // for(TypeLink l : rhs) // res.add(l); // return res; // } // // public String toString() // { // String res = ""; // for(TypeLink l : this) // res += l.toString() + " "; // return res; // } // } // Path: src/latex/TikzReduction.java import java.util.List; import pregroup.PhraseString; import pregroup.TypeLink; import pregroup.TypeReduction; package latex; //! Creates a TikZ output from a parsing reduction public class TikzReduction { private static final String tikzHeader = "\\begin{tikzpicture}[\n"+ "every node/.style={%\n"+ "text height=1.5ex," + "text depth=0.25ex,"+ "}]\n"+ "% Diagram generated by http://github.com/wetneb/MorozParser"+ "\n\n"; private static final String tikzFooter = "\n\\end{tikzpicture}\n"; //! Vertical space between the types and the links below them private static final double distToTypes = 0.25; //! Horizontal space between two simple types in the same word private static final double typeSpacing = 0.4; //! Horizontal space between the types of two words private static final double wordSpacing = 1.1; //! Vertical space between the original words and their types private static final double textDistance = 0.5; public static String draw(PhraseString phrase, List<String> words, TypeReduction red) { int n = phrase.size(); double[] pos = new double[n]; boolean[] used = new boolean[n]; String output = tikzHeader; //! Compute the used types for(int i = 0; i < n; i++) used[i] = false;
for(TypeLink l : red)
wetneb/MorozParser
src/graphexpr/NodeVarExpr.java
// Path: src/util/NotFoundException.java // public class NotFoundException extends Exception // { // private static final long serialVersionUID = 1L; // public final int i; // public NotFoundException(int id) { i = id; } // }
import java.util.HashMap; import util.NotFoundException;
package graphexpr; public class NodeVarExpr extends NodeExpr implements Cloneable { public int id; public NodeVarExpr(int i) { id = i; }
// Path: src/util/NotFoundException.java // public class NotFoundException extends Exception // { // private static final long serialVersionUID = 1L; // public final int i; // public NotFoundException(int id) { i = id; } // } // Path: src/graphexpr/NodeVarExpr.java import java.util.HashMap; import util.NotFoundException; package graphexpr; public class NodeVarExpr extends NodeExpr implements Cloneable { public int id; public NodeVarExpr(int i) { id = i; }
public void shift(HashMap<Integer, Integer> map, String name) throws NotFoundException
wetneb/MorozParser
src/graphexpr/GraphExpr.java
// Path: src/pregroup/SimpleType.java // public class SimpleType // { // private String base; // private int exp; // // public SimpleType(String bt, int e) // { // base = bt; // exp = e; // } // // public boolean isUnit() // { // return base.equals("1"); // } // // //! Generalized Contraction rule // public boolean gcon(SimpleType a, PartialComparator<String> c) // { // return // (a.exp == this.exp + 1) && // ((c.lessThan(this.base, a.base) && this.exp % 2 == 0) || // (c.lessThan(a.base, this.base) && this.exp % 2 != 0)); // } // // //! Left adjoint of the type // public SimpleType left() // { // SimpleType adj = new SimpleType(base, exp); // adj.exp--; // return adj; // } // // //! Right adjoint of the type // public SimpleType right() // { // SimpleType adj = new SimpleType(base, exp); // adj.exp++; // return adj; // } // // public boolean isProductive() // { // return (exp % 2 == 0); // } // // public String toString() // { // if(exp == 0) // return base; // // return base + "^{" + exp + "}"; // } // // public String toLatex() // { // if(exp == 0) // return base; // String output = base + "^{"; // if(exp > 0) // { // for(int i = 0; i < exp; i++) // output += "r"; // } // else // for(int i = 0; i > exp; i--) // output += "l"; // return (output+"}"); // } // // public String getBase() // { // return base; // } // }
import pregroup.SimpleType;
package graphexpr; public abstract class GraphExpr implements Cloneable { public boolean isProducer() { return (this instanceof ProducerExpr); } public boolean isConsumer() { return (this instanceof ConsumerExpr); }
// Path: src/pregroup/SimpleType.java // public class SimpleType // { // private String base; // private int exp; // // public SimpleType(String bt, int e) // { // base = bt; // exp = e; // } // // public boolean isUnit() // { // return base.equals("1"); // } // // //! Generalized Contraction rule // public boolean gcon(SimpleType a, PartialComparator<String> c) // { // return // (a.exp == this.exp + 1) && // ((c.lessThan(this.base, a.base) && this.exp % 2 == 0) || // (c.lessThan(a.base, this.base) && this.exp % 2 != 0)); // } // // //! Left adjoint of the type // public SimpleType left() // { // SimpleType adj = new SimpleType(base, exp); // adj.exp--; // return adj; // } // // //! Right adjoint of the type // public SimpleType right() // { // SimpleType adj = new SimpleType(base, exp); // adj.exp++; // return adj; // } // // public boolean isProductive() // { // return (exp % 2 == 0); // } // // public String toString() // { // if(exp == 0) // return base; // // return base + "^{" + exp + "}"; // } // // public String toLatex() // { // if(exp == 0) // return base; // String output = base + "^{"; // if(exp > 0) // { // for(int i = 0; i < exp; i++) // output += "r"; // } // else // for(int i = 0; i > exp; i--) // output += "l"; // return (output+"}"); // } // // public String getBase() // { // return base; // } // } // Path: src/graphexpr/GraphExpr.java import pregroup.SimpleType; package graphexpr; public abstract class GraphExpr implements Cloneable { public boolean isProducer() { return (this instanceof ProducerExpr); } public boolean isConsumer() { return (this instanceof ConsumerExpr); }
public abstract SimpleType getType();
wetneb/MorozParser
src/graphexpr/MorphExpr.java
// Path: src/util/NotFoundException.java // public class NotFoundException extends Exception // { // private static final long serialVersionUID = 1L; // public final int i; // public NotFoundException(int id) { i = id; } // }
import java.util.HashMap; import util.NotFoundException;
package graphexpr; public class MorphExpr extends NodeExpr { public boolean isReify; public StmtExpr triple; public MorphExpr(boolean reify, StmtExpr t) { isReify = reify; triple = t; } public String toString() { if(isReify) return "reify("+triple.toString()+")"; else return "qlify("+triple.toString()+")"; } public Object clone() { return new MorphExpr(isReify, (StmtExpr) triple.clone()); } public void shift(HashMap<Integer, Integer> map, String name)
// Path: src/util/NotFoundException.java // public class NotFoundException extends Exception // { // private static final long serialVersionUID = 1L; // public final int i; // public NotFoundException(int id) { i = id; } // } // Path: src/graphexpr/MorphExpr.java import java.util.HashMap; import util.NotFoundException; package graphexpr; public class MorphExpr extends NodeExpr { public boolean isReify; public StmtExpr triple; public MorphExpr(boolean reify, StmtExpr t) { isReify = reify; triple = t; } public String toString() { if(isReify) return "reify("+triple.toString()+")"; else return "qlify("+triple.toString()+")"; } public Object clone() { return new MorphExpr(isReify, (StmtExpr) triple.clone()); } public void shift(HashMap<Integer, Integer> map, String name)
throws NotFoundException
wetneb/MorozParser
src/xmllexicon/SimpleTypeParser.java
// Path: src/pregroup/PartialComparator.java // public interface PartialComparator<T> // { // public boolean lessThan(T lhs, T rhs); // } // // Path: src/pregroup/TypeString.java // public class TypeString extends ArrayList<SimpleType> // { // private static final long serialVersionUID = 1L; // // //! Construct an empty type string // public TypeString() // { // // } // // //! Construct a type string from a simple type (makes a singleton) // public TypeString(SimpleType s) // { // this.add(s); // } // // //! Add a simple type // public boolean add(String base, int exp) // { // this.add(new SimpleType(base, exp)); // return true; // } // // //! Compute the left adjoint // public TypeString left() // { // TypeString result = new TypeString(); // // for(SimpleType s : this) // result.add(0, s.left()); // // return result; // } // // //! Compute the right adjoint // public TypeString right() // { // TypeString result = new TypeString(); // // for(SimpleType s : this) // result.add(0, s.right()); // // return result; // } // // //! Print the type as a string // public String toString() // { // String res = ""; // // for(SimpleType s : this) // res = res + s.toString(); // // return res; // } // }
import java.io.IOException; import java.io.StringReader; import pregroup.PartialComparator; import pregroup.TypeString;
package xmllexicon; public class SimpleTypeParser {
// Path: src/pregroup/PartialComparator.java // public interface PartialComparator<T> // { // public boolean lessThan(T lhs, T rhs); // } // // Path: src/pregroup/TypeString.java // public class TypeString extends ArrayList<SimpleType> // { // private static final long serialVersionUID = 1L; // // //! Construct an empty type string // public TypeString() // { // // } // // //! Construct a type string from a simple type (makes a singleton) // public TypeString(SimpleType s) // { // this.add(s); // } // // //! Add a simple type // public boolean add(String base, int exp) // { // this.add(new SimpleType(base, exp)); // return true; // } // // //! Compute the left adjoint // public TypeString left() // { // TypeString result = new TypeString(); // // for(SimpleType s : this) // result.add(0, s.left()); // // return result; // } // // //! Compute the right adjoint // public TypeString right() // { // TypeString result = new TypeString(); // // for(SimpleType s : this) // result.add(0, s.right()); // // return result; // } // // //! Print the type as a string // public String toString() // { // String res = ""; // // for(SimpleType s : this) // res = res + s.toString(); // // return res; // } // } // Path: src/xmllexicon/SimpleTypeParser.java import java.io.IOException; import java.io.StringReader; import pregroup.PartialComparator; import pregroup.TypeString; package xmllexicon; public class SimpleTypeParser {
static TypeString parse(String input)
wetneb/MorozParser
src/graphexpr/TripleExpr.java
// Path: src/util/NotFoundException.java // public class NotFoundException extends Exception // { // private static final long serialVersionUID = 1L; // public final int i; // public NotFoundException(int id) { i = id; } // }
import java.util.HashMap; import util.NotFoundException;
package graphexpr; public class TripleExpr extends StmtExpr implements Cloneable { public NodeExpr subj; public NodeExpr prop; public NodeExpr obj; public TripleExpr(NodeExpr s, NodeExpr p, NodeExpr o) { subj = s; prop = p; obj = o; }
// Path: src/util/NotFoundException.java // public class NotFoundException extends Exception // { // private static final long serialVersionUID = 1L; // public final int i; // public NotFoundException(int id) { i = id; } // } // Path: src/graphexpr/TripleExpr.java import java.util.HashMap; import util.NotFoundException; package graphexpr; public class TripleExpr extends StmtExpr implements Cloneable { public NodeExpr subj; public NodeExpr prop; public NodeExpr obj; public TripleExpr(NodeExpr s, NodeExpr p, NodeExpr o) { subj = s; prop = p; obj = o; }
public void shift(HashMap<Integer,Integer> map, String name) throws NotFoundException
wetneb/MorozParser
src/xmllexicon/TagLexicon.java
// Path: src/pregroup/TypeString.java // public class TypeString extends ArrayList<SimpleType> // { // private static final long serialVersionUID = 1L; // // //! Construct an empty type string // public TypeString() // { // // } // // //! Construct a type string from a simple type (makes a singleton) // public TypeString(SimpleType s) // { // this.add(s); // } // // //! Add a simple type // public boolean add(String base, int exp) // { // this.add(new SimpleType(base, exp)); // return true; // } // // //! Compute the left adjoint // public TypeString left() // { // TypeString result = new TypeString(); // // for(SimpleType s : this) // result.add(0, s.left()); // // return result; // } // // //! Compute the right adjoint // public TypeString right() // { // TypeString result = new TypeString(); // // for(SimpleType s : this) // result.add(0, s.right()); // // return result; // } // // //! Print the type as a string // public String toString() // { // String res = ""; // // for(SimpleType s : this) // res = res + s.toString(); // // return res; // } // } // // Path: src/tagging/StanfordTagger.java // public class StanfordTagger // { // private MaxentTagger tagger = null; // // public StanfordTagger() // { // // } // // public void load(String path) // { // tagger = new MaxentTagger(path); // } // // public List<Pair<String,String>> tagSentence(List<String> sentence) // { // List<Pair<String,String>> result = new ArrayList<Pair<String,String>>(); // List<Word> inputSentence = new ArrayList<Word>(); // for(String word : sentence) // inputSentence.add(new Word(word)); // // List<TaggedWord> taggedSentence = tagger.tagSentence(inputSentence); // for(TaggedWord tw : taggedSentence) // result.add(Pair.of(tw.word(), tw.tag())); // // return result; // } // }
import java.util.List; import pregroup.TypeString; import tagging.StanfordTagger;
package xmllexicon; public class TagLexicon extends XmlLexicon { private static final long serialVersionUID = 1L;
// Path: src/pregroup/TypeString.java // public class TypeString extends ArrayList<SimpleType> // { // private static final long serialVersionUID = 1L; // // //! Construct an empty type string // public TypeString() // { // // } // // //! Construct a type string from a simple type (makes a singleton) // public TypeString(SimpleType s) // { // this.add(s); // } // // //! Add a simple type // public boolean add(String base, int exp) // { // this.add(new SimpleType(base, exp)); // return true; // } // // //! Compute the left adjoint // public TypeString left() // { // TypeString result = new TypeString(); // // for(SimpleType s : this) // result.add(0, s.left()); // // return result; // } // // //! Compute the right adjoint // public TypeString right() // { // TypeString result = new TypeString(); // // for(SimpleType s : this) // result.add(0, s.right()); // // return result; // } // // //! Print the type as a string // public String toString() // { // String res = ""; // // for(SimpleType s : this) // res = res + s.toString(); // // return res; // } // } // // Path: src/tagging/StanfordTagger.java // public class StanfordTagger // { // private MaxentTagger tagger = null; // // public StanfordTagger() // { // // } // // public void load(String path) // { // tagger = new MaxentTagger(path); // } // // public List<Pair<String,String>> tagSentence(List<String> sentence) // { // List<Pair<String,String>> result = new ArrayList<Pair<String,String>>(); // List<Word> inputSentence = new ArrayList<Word>(); // for(String word : sentence) // inputSentence.add(new Word(word)); // // List<TaggedWord> taggedSentence = tagger.tagSentence(inputSentence); // for(TaggedWord tw : taggedSentence) // result.add(Pair.of(tw.word(), tw.tag())); // // return result; // } // } // Path: src/xmllexicon/TagLexicon.java import java.util.List; import pregroup.TypeString; import tagging.StanfordTagger; package xmllexicon; public class TagLexicon extends XmlLexicon { private static final long serialVersionUID = 1L;
public List<List<TypeString>> types(List<String> sentence, StanfordTagger tagger)
wetneb/MorozParser
src/xmllexicon/TagLexicon.java
// Path: src/pregroup/TypeString.java // public class TypeString extends ArrayList<SimpleType> // { // private static final long serialVersionUID = 1L; // // //! Construct an empty type string // public TypeString() // { // // } // // //! Construct a type string from a simple type (makes a singleton) // public TypeString(SimpleType s) // { // this.add(s); // } // // //! Add a simple type // public boolean add(String base, int exp) // { // this.add(new SimpleType(base, exp)); // return true; // } // // //! Compute the left adjoint // public TypeString left() // { // TypeString result = new TypeString(); // // for(SimpleType s : this) // result.add(0, s.left()); // // return result; // } // // //! Compute the right adjoint // public TypeString right() // { // TypeString result = new TypeString(); // // for(SimpleType s : this) // result.add(0, s.right()); // // return result; // } // // //! Print the type as a string // public String toString() // { // String res = ""; // // for(SimpleType s : this) // res = res + s.toString(); // // return res; // } // } // // Path: src/tagging/StanfordTagger.java // public class StanfordTagger // { // private MaxentTagger tagger = null; // // public StanfordTagger() // { // // } // // public void load(String path) // { // tagger = new MaxentTagger(path); // } // // public List<Pair<String,String>> tagSentence(List<String> sentence) // { // List<Pair<String,String>> result = new ArrayList<Pair<String,String>>(); // List<Word> inputSentence = new ArrayList<Word>(); // for(String word : sentence) // inputSentence.add(new Word(word)); // // List<TaggedWord> taggedSentence = tagger.tagSentence(inputSentence); // for(TaggedWord tw : taggedSentence) // result.add(Pair.of(tw.word(), tw.tag())); // // return result; // } // }
import java.util.List; import pregroup.TypeString; import tagging.StanfordTagger;
package xmllexicon; public class TagLexicon extends XmlLexicon { private static final long serialVersionUID = 1L;
// Path: src/pregroup/TypeString.java // public class TypeString extends ArrayList<SimpleType> // { // private static final long serialVersionUID = 1L; // // //! Construct an empty type string // public TypeString() // { // // } // // //! Construct a type string from a simple type (makes a singleton) // public TypeString(SimpleType s) // { // this.add(s); // } // // //! Add a simple type // public boolean add(String base, int exp) // { // this.add(new SimpleType(base, exp)); // return true; // } // // //! Compute the left adjoint // public TypeString left() // { // TypeString result = new TypeString(); // // for(SimpleType s : this) // result.add(0, s.left()); // // return result; // } // // //! Compute the right adjoint // public TypeString right() // { // TypeString result = new TypeString(); // // for(SimpleType s : this) // result.add(0, s.right()); // // return result; // } // // //! Print the type as a string // public String toString() // { // String res = ""; // // for(SimpleType s : this) // res = res + s.toString(); // // return res; // } // } // // Path: src/tagging/StanfordTagger.java // public class StanfordTagger // { // private MaxentTagger tagger = null; // // public StanfordTagger() // { // // } // // public void load(String path) // { // tagger = new MaxentTagger(path); // } // // public List<Pair<String,String>> tagSentence(List<String> sentence) // { // List<Pair<String,String>> result = new ArrayList<Pair<String,String>>(); // List<Word> inputSentence = new ArrayList<Word>(); // for(String word : sentence) // inputSentence.add(new Word(word)); // // List<TaggedWord> taggedSentence = tagger.tagSentence(inputSentence); // for(TaggedWord tw : taggedSentence) // result.add(Pair.of(tw.word(), tw.tag())); // // return result; // } // } // Path: src/xmllexicon/TagLexicon.java import java.util.List; import pregroup.TypeString; import tagging.StanfordTagger; package xmllexicon; public class TagLexicon extends XmlLexicon { private static final long serialVersionUID = 1L;
public List<List<TypeString>> types(List<String> sentence, StanfordTagger tagger)
wetneb/MorozParser
src/graphexpr/ConsumerExpr.java
// Path: src/pregroup/SimpleType.java // public class SimpleType // { // private String base; // private int exp; // // public SimpleType(String bt, int e) // { // base = bt; // exp = e; // } // // public boolean isUnit() // { // return base.equals("1"); // } // // //! Generalized Contraction rule // public boolean gcon(SimpleType a, PartialComparator<String> c) // { // return // (a.exp == this.exp + 1) && // ((c.lessThan(this.base, a.base) && this.exp % 2 == 0) || // (c.lessThan(a.base, this.base) && this.exp % 2 != 0)); // } // // //! Left adjoint of the type // public SimpleType left() // { // SimpleType adj = new SimpleType(base, exp); // adj.exp--; // return adj; // } // // //! Right adjoint of the type // public SimpleType right() // { // SimpleType adj = new SimpleType(base, exp); // adj.exp++; // return adj; // } // // public boolean isProductive() // { // return (exp % 2 == 0); // } // // public String toString() // { // if(exp == 0) // return base; // // return base + "^{" + exp + "}"; // } // // public String toLatex() // { // if(exp == 0) // return base; // String output = base + "^{"; // if(exp > 0) // { // for(int i = 0; i < exp; i++) // output += "r"; // } // else // for(int i = 0; i > exp; i--) // output += "l"; // return (output+"}"); // } // // public String getBase() // { // return base; // } // }
import pregroup.SimpleType;
package graphexpr; public class ConsumerExpr extends GraphExpr {
// Path: src/pregroup/SimpleType.java // public class SimpleType // { // private String base; // private int exp; // // public SimpleType(String bt, int e) // { // base = bt; // exp = e; // } // // public boolean isUnit() // { // return base.equals("1"); // } // // //! Generalized Contraction rule // public boolean gcon(SimpleType a, PartialComparator<String> c) // { // return // (a.exp == this.exp + 1) && // ((c.lessThan(this.base, a.base) && this.exp % 2 == 0) || // (c.lessThan(a.base, this.base) && this.exp % 2 != 0)); // } // // //! Left adjoint of the type // public SimpleType left() // { // SimpleType adj = new SimpleType(base, exp); // adj.exp--; // return adj; // } // // //! Right adjoint of the type // public SimpleType right() // { // SimpleType adj = new SimpleType(base, exp); // adj.exp++; // return adj; // } // // public boolean isProductive() // { // return (exp % 2 == 0); // } // // public String toString() // { // if(exp == 0) // return base; // // return base + "^{" + exp + "}"; // } // // public String toLatex() // { // if(exp == 0) // return base; // String output = base + "^{"; // if(exp > 0) // { // for(int i = 0; i < exp; i++) // output += "r"; // } // else // for(int i = 0; i > exp; i--) // output += "l"; // return (output+"}"); // } // // public String getBase() // { // return base; // } // } // Path: src/graphexpr/ConsumerExpr.java import pregroup.SimpleType; package graphexpr; public class ConsumerExpr extends GraphExpr {
public SimpleType type;
wetneb/MorozParser
src/xmllexicon/TypeRelations.java
// Path: src/pregroup/PartialComparator.java // public interface PartialComparator<T> // { // public boolean lessThan(T lhs, T rhs); // }
import java.util.ArrayList; import java.util.List; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlType; import pregroup.PartialComparator;
// // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // Any modifications to this file will be lost upon recompilation of the source schema. // Generated on: 2013.06.26 at 01:04:00 PM CEST // package xmllexicon; /** * <p>Java class for TypeRelations complex type. * * <p>The following schema fragment specifies the expected content contained within this class. * * <pre> * &lt;complexType name="TypeRelations"> * &lt;complexContent> * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> * &lt;sequence> * &lt;element name="rel" type="{}TypeRel" maxOccurs="unbounded"/> * &lt;/sequence> * &lt;/restriction> * &lt;/complexContent> * &lt;/complexType> * </pre> * * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "TypeRelations", propOrder = { "rel" })
// Path: src/pregroup/PartialComparator.java // public interface PartialComparator<T> // { // public boolean lessThan(T lhs, T rhs); // } // Path: src/xmllexicon/TypeRelations.java import java.util.ArrayList; import java.util.List; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlType; import pregroup.PartialComparator; // // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 // See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> // Any modifications to this file will be lost upon recompilation of the source schema. // Generated on: 2013.06.26 at 01:04:00 PM CEST // package xmllexicon; /** * <p>Java class for TypeRelations complex type. * * <p>The following schema fragment specifies the expected content contained within this class. * * <pre> * &lt;complexType name="TypeRelations"> * &lt;complexContent> * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> * &lt;sequence> * &lt;element name="rel" type="{}TypeRel" maxOccurs="unbounded"/> * &lt;/sequence> * &lt;/restriction> * &lt;/complexContent> * &lt;/complexType> * </pre> * * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "TypeRelations", propOrder = { "rel" })
public class TypeRelations implements PartialComparator<String> {
wetneb/MorozParser
src/graphexpr/PatternExpr.java
// Path: src/util/NotFoundException.java // public class NotFoundException extends Exception // { // private static final long serialVersionUID = 1L; // public final int i; // public NotFoundException(int id) { i = id; } // }
import java.util.HashMap; import util.NotFoundException;
package graphexpr; public abstract class PatternExpr implements Cloneable { public boolean isNode() { return (this instanceof NodeExpr); } public boolean isStmt() { return (this instanceof StmtExpr); }
// Path: src/util/NotFoundException.java // public class NotFoundException extends Exception // { // private static final long serialVersionUID = 1L; // public final int i; // public NotFoundException(int id) { i = id; } // } // Path: src/graphexpr/PatternExpr.java import java.util.HashMap; import util.NotFoundException; package graphexpr; public abstract class PatternExpr implements Cloneable { public boolean isNode() { return (this instanceof NodeExpr); } public boolean isStmt() { return (this instanceof StmtExpr); }
public abstract void shift(HashMap<Integer,Integer> map, String name) throws NotFoundException;
wetneb/MorozParser
src/xmllexicon/XmlLexicon.java
// Path: src/pregroup/Lexicon.java // public interface Lexicon // { // //! Retrieve the list of types for a given sentence // public List<List<TypeString>> types(List<Pair<String,String>> sentence); // // //! Retrieve a comparator for the basic types // public PartialComparator<String> getComparator(); // } // // Path: src/pregroup/PartialComparator.java // public interface PartialComparator<T> // { // public boolean lessThan(T lhs, T rhs); // } // // Path: src/pregroup/TypeString.java // public class TypeString extends ArrayList<SimpleType> // { // private static final long serialVersionUID = 1L; // // //! Construct an empty type string // public TypeString() // { // // } // // //! Construct a type string from a simple type (makes a singleton) // public TypeString(SimpleType s) // { // this.add(s); // } // // //! Add a simple type // public boolean add(String base, int exp) // { // this.add(new SimpleType(base, exp)); // return true; // } // // //! Compute the left adjoint // public TypeString left() // { // TypeString result = new TypeString(); // // for(SimpleType s : this) // result.add(0, s.left()); // // return result; // } // // //! Compute the right adjoint // public TypeString right() // { // TypeString result = new TypeString(); // // for(SimpleType s : this) // result.add(0, s.right()); // // return result; // } // // //! Print the type as a string // public String toString() // { // String res = ""; // // for(SimpleType s : this) // res = res + s.toString(); // // return res; // } // }
import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.io.FileInputStream; import java.io.IOException; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBElement; import javax.xml.bind.JAXBException; import javax.xml.bind.Unmarshaller; import org.apache.commons.lang3.tuple.Pair; import pregroup.Lexicon; import pregroup.PartialComparator; import pregroup.TypeString;
package xmllexicon; public class XmlLexicon implements Lexicon {
// Path: src/pregroup/Lexicon.java // public interface Lexicon // { // //! Retrieve the list of types for a given sentence // public List<List<TypeString>> types(List<Pair<String,String>> sentence); // // //! Retrieve a comparator for the basic types // public PartialComparator<String> getComparator(); // } // // Path: src/pregroup/PartialComparator.java // public interface PartialComparator<T> // { // public boolean lessThan(T lhs, T rhs); // } // // Path: src/pregroup/TypeString.java // public class TypeString extends ArrayList<SimpleType> // { // private static final long serialVersionUID = 1L; // // //! Construct an empty type string // public TypeString() // { // // } // // //! Construct a type string from a simple type (makes a singleton) // public TypeString(SimpleType s) // { // this.add(s); // } // // //! Add a simple type // public boolean add(String base, int exp) // { // this.add(new SimpleType(base, exp)); // return true; // } // // //! Compute the left adjoint // public TypeString left() // { // TypeString result = new TypeString(); // // for(SimpleType s : this) // result.add(0, s.left()); // // return result; // } // // //! Compute the right adjoint // public TypeString right() // { // TypeString result = new TypeString(); // // for(SimpleType s : this) // result.add(0, s.right()); // // return result; // } // // //! Print the type as a string // public String toString() // { // String res = ""; // // for(SimpleType s : this) // res = res + s.toString(); // // return res; // } // } // Path: src/xmllexicon/XmlLexicon.java import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.io.FileInputStream; import java.io.IOException; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBElement; import javax.xml.bind.JAXBException; import javax.xml.bind.Unmarshaller; import org.apache.commons.lang3.tuple.Pair; import pregroup.Lexicon; import pregroup.PartialComparator; import pregroup.TypeString; package xmllexicon; public class XmlLexicon implements Lexicon {
private HashMap<String, List<TypeString>> mFromTag;
wetneb/MorozParser
src/xmllexicon/XmlLexicon.java
// Path: src/pregroup/Lexicon.java // public interface Lexicon // { // //! Retrieve the list of types for a given sentence // public List<List<TypeString>> types(List<Pair<String,String>> sentence); // // //! Retrieve a comparator for the basic types // public PartialComparator<String> getComparator(); // } // // Path: src/pregroup/PartialComparator.java // public interface PartialComparator<T> // { // public boolean lessThan(T lhs, T rhs); // } // // Path: src/pregroup/TypeString.java // public class TypeString extends ArrayList<SimpleType> // { // private static final long serialVersionUID = 1L; // // //! Construct an empty type string // public TypeString() // { // // } // // //! Construct a type string from a simple type (makes a singleton) // public TypeString(SimpleType s) // { // this.add(s); // } // // //! Add a simple type // public boolean add(String base, int exp) // { // this.add(new SimpleType(base, exp)); // return true; // } // // //! Compute the left adjoint // public TypeString left() // { // TypeString result = new TypeString(); // // for(SimpleType s : this) // result.add(0, s.left()); // // return result; // } // // //! Compute the right adjoint // public TypeString right() // { // TypeString result = new TypeString(); // // for(SimpleType s : this) // result.add(0, s.right()); // // return result; // } // // //! Print the type as a string // public String toString() // { // String res = ""; // // for(SimpleType s : this) // res = res + s.toString(); // // return res; // } // }
import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.io.FileInputStream; import java.io.IOException; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBElement; import javax.xml.bind.JAXBException; import javax.xml.bind.Unmarshaller; import org.apache.commons.lang3.tuple.Pair; import pregroup.Lexicon; import pregroup.PartialComparator; import pregroup.TypeString;
RawLexicon rl = (RawLexicon)lexicon.getValue(); Entries entries = rl.getEntries(); rels = rl.getRelations(); //! TODO : add error handling ! (if entries.getEntry() is null (when there's no <entries>) for(EntryType ent : entries.getEntry()) { String form = ent.getForm(); String tag = ent.getTag(); List<String> rawTypes = ent.getType(); List<TypeString> res = new ArrayList<TypeString>(); for(String rt : rawTypes) res.add(SimpleTypeParser.parse(rt)); if(form != "" && form != null) mFromForm.put(form, res); else mFromTag.put(tag, res); } } catch (JAXBException je) { je.printStackTrace(); } catch (IOException ioe) { ioe.printStackTrace(); } }
// Path: src/pregroup/Lexicon.java // public interface Lexicon // { // //! Retrieve the list of types for a given sentence // public List<List<TypeString>> types(List<Pair<String,String>> sentence); // // //! Retrieve a comparator for the basic types // public PartialComparator<String> getComparator(); // } // // Path: src/pregroup/PartialComparator.java // public interface PartialComparator<T> // { // public boolean lessThan(T lhs, T rhs); // } // // Path: src/pregroup/TypeString.java // public class TypeString extends ArrayList<SimpleType> // { // private static final long serialVersionUID = 1L; // // //! Construct an empty type string // public TypeString() // { // // } // // //! Construct a type string from a simple type (makes a singleton) // public TypeString(SimpleType s) // { // this.add(s); // } // // //! Add a simple type // public boolean add(String base, int exp) // { // this.add(new SimpleType(base, exp)); // return true; // } // // //! Compute the left adjoint // public TypeString left() // { // TypeString result = new TypeString(); // // for(SimpleType s : this) // result.add(0, s.left()); // // return result; // } // // //! Compute the right adjoint // public TypeString right() // { // TypeString result = new TypeString(); // // for(SimpleType s : this) // result.add(0, s.right()); // // return result; // } // // //! Print the type as a string // public String toString() // { // String res = ""; // // for(SimpleType s : this) // res = res + s.toString(); // // return res; // } // } // Path: src/xmllexicon/XmlLexicon.java import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.io.FileInputStream; import java.io.IOException; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBElement; import javax.xml.bind.JAXBException; import javax.xml.bind.Unmarshaller; import org.apache.commons.lang3.tuple.Pair; import pregroup.Lexicon; import pregroup.PartialComparator; import pregroup.TypeString; RawLexicon rl = (RawLexicon)lexicon.getValue(); Entries entries = rl.getEntries(); rels = rl.getRelations(); //! TODO : add error handling ! (if entries.getEntry() is null (when there's no <entries>) for(EntryType ent : entries.getEntry()) { String form = ent.getForm(); String tag = ent.getTag(); List<String> rawTypes = ent.getType(); List<TypeString> res = new ArrayList<TypeString>(); for(String rt : rawTypes) res.add(SimpleTypeParser.parse(rt)); if(form != "" && form != null) mFromForm.put(form, res); else mFromTag.put(tag, res); } } catch (JAXBException je) { je.printStackTrace(); } catch (IOException ioe) { ioe.printStackTrace(); } }
public PartialComparator<String> getComparator()
alfa-laboratory/colibri-ui
src/main/java/ru/colibri/ui/steps/general/TextFieldSteps.java
// Path: src/main/java/ru/colibri/ui/core/steps/AbsSteps.java // @Log // public abstract class AbsSteps extends Steps implements InitializingBean { // // private static final int TIMEOUT = 7; // private int currentTimeout; // // @Autowired // protected TestContext testContext; // // @Autowired // protected AppiumDriver driver; // // @Autowired(required = false) // protected IFinder finder; // // @Autowired // protected IPageProvider pageProvider; // // @Autowired // protected DriversSettings driverSettings; // // protected IPage getCurrentPage() { // return pageProvider.getCurrentPage(); // } // // @Override // public void afterPropertiesSet() throws Exception { // log.info(String.format("Bean %s loaded", this.getClass().getSimpleName())); // } // // protected DriversSettings getDriversSettings() { // return driverSettings; // } // // protected WebElement getWebElementByName(String elementName) { // IElement element = getCurrentPage().getElementByName(elementName); // return finder.findWebElement(element); // } // // protected void decreaseImplicitlyWait() { // decreaseImplicitlyWait(TIMEOUT); // } // // protected void decreaseImplicitlyWait(int timeout) { // currentTimeout = getDriversSettings().getImplicitlyWaitInSeconds(); // driver.manage().timeouts().implicitlyWait(timeout, TimeUnit.SECONDS); // } // // protected void increaseImplicitlyWait() { // driver.manage().timeouts().implicitlyWait(currentTimeout, TimeUnit.SECONDS); // } // } // // Path: src/main/java/ru/colibri/ui/settings/general/PropertyUtils.java // @Slf4j // @Service // public class PropertyUtils { // private final static Pattern propertyPattern = compile("(#)([A-Za-z0-9_-]+?)(#)"); // // @Autowired // private AppSettings appSettings; // // public static Properties readProperty(String... filePaths) { // Properties props = new Properties(); // for (String path : filePaths) { // try (InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream(path), UTF_8)) { // props.load(inputStreamReader); // } catch (IOException e) { // throw new RuntimeException("Ошибка загрузки настроек драйвера: ", e); // } // } // return props; // } // // public String injectProperties(String text) { // Map<String, String> userProfile = appSettings.getUserProfile(); // Matcher matcher = propertyPattern.matcher(text); // if (!matcher.find()) { // return text; // } // String propertyKey = matcher.group(2); // String propertyValue = userProfile.get(propertyKey); // if (propertyValue == null) { // log.error("Couldn't find property {} for user {}", propertyKey, System.getenv().getOrDefault(ColibriStartFlags.USER, "user not defined")); // return text; // } // return matcher.replaceAll(propertyValue); // } // }
import lombok.extern.java.Log; import org.jbehave.core.annotations.Named; import org.jbehave.core.annotations.When; import org.openqa.selenium.By; import org.openqa.selenium.Keys; import org.openqa.selenium.WebDriverException; import org.openqa.selenium.WebElement; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import ru.colibri.ui.core.steps.AbsSteps; import ru.colibri.ui.settings.general.PropertyUtils; import ru.yandex.qatools.allure.annotations.Step; import java.util.List; import java.util.logging.Level;
package ru.colibri.ui.steps.general; @Log @Component
// Path: src/main/java/ru/colibri/ui/core/steps/AbsSteps.java // @Log // public abstract class AbsSteps extends Steps implements InitializingBean { // // private static final int TIMEOUT = 7; // private int currentTimeout; // // @Autowired // protected TestContext testContext; // // @Autowired // protected AppiumDriver driver; // // @Autowired(required = false) // protected IFinder finder; // // @Autowired // protected IPageProvider pageProvider; // // @Autowired // protected DriversSettings driverSettings; // // protected IPage getCurrentPage() { // return pageProvider.getCurrentPage(); // } // // @Override // public void afterPropertiesSet() throws Exception { // log.info(String.format("Bean %s loaded", this.getClass().getSimpleName())); // } // // protected DriversSettings getDriversSettings() { // return driverSettings; // } // // protected WebElement getWebElementByName(String elementName) { // IElement element = getCurrentPage().getElementByName(elementName); // return finder.findWebElement(element); // } // // protected void decreaseImplicitlyWait() { // decreaseImplicitlyWait(TIMEOUT); // } // // protected void decreaseImplicitlyWait(int timeout) { // currentTimeout = getDriversSettings().getImplicitlyWaitInSeconds(); // driver.manage().timeouts().implicitlyWait(timeout, TimeUnit.SECONDS); // } // // protected void increaseImplicitlyWait() { // driver.manage().timeouts().implicitlyWait(currentTimeout, TimeUnit.SECONDS); // } // } // // Path: src/main/java/ru/colibri/ui/settings/general/PropertyUtils.java // @Slf4j // @Service // public class PropertyUtils { // private final static Pattern propertyPattern = compile("(#)([A-Za-z0-9_-]+?)(#)"); // // @Autowired // private AppSettings appSettings; // // public static Properties readProperty(String... filePaths) { // Properties props = new Properties(); // for (String path : filePaths) { // try (InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream(path), UTF_8)) { // props.load(inputStreamReader); // } catch (IOException e) { // throw new RuntimeException("Ошибка загрузки настроек драйвера: ", e); // } // } // return props; // } // // public String injectProperties(String text) { // Map<String, String> userProfile = appSettings.getUserProfile(); // Matcher matcher = propertyPattern.matcher(text); // if (!matcher.find()) { // return text; // } // String propertyKey = matcher.group(2); // String propertyValue = userProfile.get(propertyKey); // if (propertyValue == null) { // log.error("Couldn't find property {} for user {}", propertyKey, System.getenv().getOrDefault(ColibriStartFlags.USER, "user not defined")); // return text; // } // return matcher.replaceAll(propertyValue); // } // } // Path: src/main/java/ru/colibri/ui/steps/general/TextFieldSteps.java import lombok.extern.java.Log; import org.jbehave.core.annotations.Named; import org.jbehave.core.annotations.When; import org.openqa.selenium.By; import org.openqa.selenium.Keys; import org.openqa.selenium.WebDriverException; import org.openqa.selenium.WebElement; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import ru.colibri.ui.core.steps.AbsSteps; import ru.colibri.ui.settings.general.PropertyUtils; import ru.yandex.qatools.allure.annotations.Step; import java.util.List; import java.util.logging.Level; package ru.colibri.ui.steps.general; @Log @Component
public class TextFieldSteps extends AbsSteps {
alfa-laboratory/colibri-ui
src/main/java/ru/colibri/ui/steps/general/TextFieldSteps.java
// Path: src/main/java/ru/colibri/ui/core/steps/AbsSteps.java // @Log // public abstract class AbsSteps extends Steps implements InitializingBean { // // private static final int TIMEOUT = 7; // private int currentTimeout; // // @Autowired // protected TestContext testContext; // // @Autowired // protected AppiumDriver driver; // // @Autowired(required = false) // protected IFinder finder; // // @Autowired // protected IPageProvider pageProvider; // // @Autowired // protected DriversSettings driverSettings; // // protected IPage getCurrentPage() { // return pageProvider.getCurrentPage(); // } // // @Override // public void afterPropertiesSet() throws Exception { // log.info(String.format("Bean %s loaded", this.getClass().getSimpleName())); // } // // protected DriversSettings getDriversSettings() { // return driverSettings; // } // // protected WebElement getWebElementByName(String elementName) { // IElement element = getCurrentPage().getElementByName(elementName); // return finder.findWebElement(element); // } // // protected void decreaseImplicitlyWait() { // decreaseImplicitlyWait(TIMEOUT); // } // // protected void decreaseImplicitlyWait(int timeout) { // currentTimeout = getDriversSettings().getImplicitlyWaitInSeconds(); // driver.manage().timeouts().implicitlyWait(timeout, TimeUnit.SECONDS); // } // // protected void increaseImplicitlyWait() { // driver.manage().timeouts().implicitlyWait(currentTimeout, TimeUnit.SECONDS); // } // } // // Path: src/main/java/ru/colibri/ui/settings/general/PropertyUtils.java // @Slf4j // @Service // public class PropertyUtils { // private final static Pattern propertyPattern = compile("(#)([A-Za-z0-9_-]+?)(#)"); // // @Autowired // private AppSettings appSettings; // // public static Properties readProperty(String... filePaths) { // Properties props = new Properties(); // for (String path : filePaths) { // try (InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream(path), UTF_8)) { // props.load(inputStreamReader); // } catch (IOException e) { // throw new RuntimeException("Ошибка загрузки настроек драйвера: ", e); // } // } // return props; // } // // public String injectProperties(String text) { // Map<String, String> userProfile = appSettings.getUserProfile(); // Matcher matcher = propertyPattern.matcher(text); // if (!matcher.find()) { // return text; // } // String propertyKey = matcher.group(2); // String propertyValue = userProfile.get(propertyKey); // if (propertyValue == null) { // log.error("Couldn't find property {} for user {}", propertyKey, System.getenv().getOrDefault(ColibriStartFlags.USER, "user not defined")); // return text; // } // return matcher.replaceAll(propertyValue); // } // }
import lombok.extern.java.Log; import org.jbehave.core.annotations.Named; import org.jbehave.core.annotations.When; import org.openqa.selenium.By; import org.openqa.selenium.Keys; import org.openqa.selenium.WebDriverException; import org.openqa.selenium.WebElement; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import ru.colibri.ui.core.steps.AbsSteps; import ru.colibri.ui.settings.general.PropertyUtils; import ru.yandex.qatools.allure.annotations.Step; import java.util.List; import java.util.logging.Level;
package ru.colibri.ui.steps.general; @Log @Component public class TextFieldSteps extends AbsSteps { @Autowired
// Path: src/main/java/ru/colibri/ui/core/steps/AbsSteps.java // @Log // public abstract class AbsSteps extends Steps implements InitializingBean { // // private static final int TIMEOUT = 7; // private int currentTimeout; // // @Autowired // protected TestContext testContext; // // @Autowired // protected AppiumDriver driver; // // @Autowired(required = false) // protected IFinder finder; // // @Autowired // protected IPageProvider pageProvider; // // @Autowired // protected DriversSettings driverSettings; // // protected IPage getCurrentPage() { // return pageProvider.getCurrentPage(); // } // // @Override // public void afterPropertiesSet() throws Exception { // log.info(String.format("Bean %s loaded", this.getClass().getSimpleName())); // } // // protected DriversSettings getDriversSettings() { // return driverSettings; // } // // protected WebElement getWebElementByName(String elementName) { // IElement element = getCurrentPage().getElementByName(elementName); // return finder.findWebElement(element); // } // // protected void decreaseImplicitlyWait() { // decreaseImplicitlyWait(TIMEOUT); // } // // protected void decreaseImplicitlyWait(int timeout) { // currentTimeout = getDriversSettings().getImplicitlyWaitInSeconds(); // driver.manage().timeouts().implicitlyWait(timeout, TimeUnit.SECONDS); // } // // protected void increaseImplicitlyWait() { // driver.manage().timeouts().implicitlyWait(currentTimeout, TimeUnit.SECONDS); // } // } // // Path: src/main/java/ru/colibri/ui/settings/general/PropertyUtils.java // @Slf4j // @Service // public class PropertyUtils { // private final static Pattern propertyPattern = compile("(#)([A-Za-z0-9_-]+?)(#)"); // // @Autowired // private AppSettings appSettings; // // public static Properties readProperty(String... filePaths) { // Properties props = new Properties(); // for (String path : filePaths) { // try (InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream(path), UTF_8)) { // props.load(inputStreamReader); // } catch (IOException e) { // throw new RuntimeException("Ошибка загрузки настроек драйвера: ", e); // } // } // return props; // } // // public String injectProperties(String text) { // Map<String, String> userProfile = appSettings.getUserProfile(); // Matcher matcher = propertyPattern.matcher(text); // if (!matcher.find()) { // return text; // } // String propertyKey = matcher.group(2); // String propertyValue = userProfile.get(propertyKey); // if (propertyValue == null) { // log.error("Couldn't find property {} for user {}", propertyKey, System.getenv().getOrDefault(ColibriStartFlags.USER, "user not defined")); // return text; // } // return matcher.replaceAll(propertyValue); // } // } // Path: src/main/java/ru/colibri/ui/steps/general/TextFieldSteps.java import lombok.extern.java.Log; import org.jbehave.core.annotations.Named; import org.jbehave.core.annotations.When; import org.openqa.selenium.By; import org.openqa.selenium.Keys; import org.openqa.selenium.WebDriverException; import org.openqa.selenium.WebElement; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import ru.colibri.ui.core.steps.AbsSteps; import ru.colibri.ui.settings.general.PropertyUtils; import ru.yandex.qatools.allure.annotations.Step; import java.util.List; import java.util.logging.Level; package ru.colibri.ui.steps.general; @Log @Component public class TextFieldSteps extends AbsSteps { @Autowired
private PropertyUtils propertyUtils;
alfa-laboratory/colibri-ui
src/main/java/ru/colibri/ui/steps/general/ScrollSteps.java
// Path: src/main/java/ru/colibri/ui/core/fields/IElement.java // public interface IElement { // String getName(); // // String getContentDesc(); // // String getId(); // // String getText(); // // String getXpath(); // // String getNSPredicate(); // // boolean isSpecific(); // } // // Path: src/main/java/ru/colibri/ui/core/steps/AbsSteps.java // @Log // public abstract class AbsSteps extends Steps implements InitializingBean { // // private static final int TIMEOUT = 7; // private int currentTimeout; // // @Autowired // protected TestContext testContext; // // @Autowired // protected AppiumDriver driver; // // @Autowired(required = false) // protected IFinder finder; // // @Autowired // protected IPageProvider pageProvider; // // @Autowired // protected DriversSettings driverSettings; // // protected IPage getCurrentPage() { // return pageProvider.getCurrentPage(); // } // // @Override // public void afterPropertiesSet() throws Exception { // log.info(String.format("Bean %s loaded", this.getClass().getSimpleName())); // } // // protected DriversSettings getDriversSettings() { // return driverSettings; // } // // protected WebElement getWebElementByName(String elementName) { // IElement element = getCurrentPage().getElementByName(elementName); // return finder.findWebElement(element); // } // // protected void decreaseImplicitlyWait() { // decreaseImplicitlyWait(TIMEOUT); // } // // protected void decreaseImplicitlyWait(int timeout) { // currentTimeout = getDriversSettings().getImplicitlyWaitInSeconds(); // driver.manage().timeouts().implicitlyWait(timeout, TimeUnit.SECONDS); // } // // protected void increaseImplicitlyWait() { // driver.manage().timeouts().implicitlyWait(currentTimeout, TimeUnit.SECONDS); // } // }
import org.jbehave.core.annotations.Named; import org.jbehave.core.annotations.When; import org.springframework.stereotype.Component; import ru.colibri.ui.core.fields.IElement; import ru.colibri.ui.core.steps.AbsSteps;
package ru.colibri.ui.steps.general; @Component public class ScrollSteps extends AbsSteps { @When("скролл внутри \"$targetListName\" до \"$toElementName\"") public void scrollTo(@Named("$targetListName") String targetListName, @Named("$toElementName") String toElementName) {
// Path: src/main/java/ru/colibri/ui/core/fields/IElement.java // public interface IElement { // String getName(); // // String getContentDesc(); // // String getId(); // // String getText(); // // String getXpath(); // // String getNSPredicate(); // // boolean isSpecific(); // } // // Path: src/main/java/ru/colibri/ui/core/steps/AbsSteps.java // @Log // public abstract class AbsSteps extends Steps implements InitializingBean { // // private static final int TIMEOUT = 7; // private int currentTimeout; // // @Autowired // protected TestContext testContext; // // @Autowired // protected AppiumDriver driver; // // @Autowired(required = false) // protected IFinder finder; // // @Autowired // protected IPageProvider pageProvider; // // @Autowired // protected DriversSettings driverSettings; // // protected IPage getCurrentPage() { // return pageProvider.getCurrentPage(); // } // // @Override // public void afterPropertiesSet() throws Exception { // log.info(String.format("Bean %s loaded", this.getClass().getSimpleName())); // } // // protected DriversSettings getDriversSettings() { // return driverSettings; // } // // protected WebElement getWebElementByName(String elementName) { // IElement element = getCurrentPage().getElementByName(elementName); // return finder.findWebElement(element); // } // // protected void decreaseImplicitlyWait() { // decreaseImplicitlyWait(TIMEOUT); // } // // protected void decreaseImplicitlyWait(int timeout) { // currentTimeout = getDriversSettings().getImplicitlyWaitInSeconds(); // driver.manage().timeouts().implicitlyWait(timeout, TimeUnit.SECONDS); // } // // protected void increaseImplicitlyWait() { // driver.manage().timeouts().implicitlyWait(currentTimeout, TimeUnit.SECONDS); // } // } // Path: src/main/java/ru/colibri/ui/steps/general/ScrollSteps.java import org.jbehave.core.annotations.Named; import org.jbehave.core.annotations.When; import org.springframework.stereotype.Component; import ru.colibri.ui.core.fields.IElement; import ru.colibri.ui.core.steps.AbsSteps; package ru.colibri.ui.steps.general; @Component public class ScrollSteps extends AbsSteps { @When("скролл внутри \"$targetListName\" до \"$toElementName\"") public void scrollTo(@Named("$targetListName") String targetListName, @Named("$toElementName") String toElementName) {
IElement elementList = getCurrentPage().getElementByName(targetListName);
alfa-laboratory/colibri-ui
src/main/java/ru/colibri/ui/settings/android/AndroidPageProvider.java
// Path: src/main/java/ru/colibri/ui/core/contexts/TestContext.java // @Component // @Getter // @Setter // public class TestContext { // private String currentPageName; // private Map<String, String> context = new HashMap<>(); // } // // Path: src/main/java/ru/colibri/ui/core/pages/AbsPageProvider.java // @ToString // public abstract class AbsPageProvider implements IPageProvider { // // @Autowired // protected AppiumDriver driver; // // protected HashMap<String, IPage> pagesByName; // protected HashMap<String, IPage> pagesByID; // // public AbsPageProvider() { // pagesByName = new HashMap<>(); // pagesByID = new HashMap<>(); // } // // public void addPageObject(IPage pageObject) throws PageNameAlreadyUsedException { // String systemId = pageObject.getSystemId().toLowerCase(); // if (!systemId.isEmpty() && pagesByID.containsKey(systemId)) { // throw new PageNameAlreadyUsedException(systemId); // } // String name = pageObject.getName().toLowerCase(); // if (!name.isEmpty() && pagesByName.containsKey(name)) { // throw new PageNameAlreadyUsedException(name); // } // pagesByName.put(name, pageObject); // pagesByID.put(systemId, pageObject); // } // // public IPage getPageByName(String pageName) { // return getIPage(pagesByName, pageName); // } // // public IPage getPageById(String pageId) { // return getIPage(pagesByID, pageId); // } // // private IPage getIPage(HashMap<String, IPage> pages, String pageName) { // IPage result = pages.get(pageName.toLowerCase()); // if (result == null) { // throw new NoPageFoundException(pageName); // } // return result; // } // // @Override // public void addPagesObject(List<IPage> pages) { // pages.forEach(this::addPageObject); // } // } // // Path: src/main/java/ru/colibri/ui/core/pages/IPage.java // public interface IPage { // String getName(); // // String getSystemId(); // // List<IElement> getSpecificElements(); // // IElement getElementByName(String name); // // void addElement(IElement element); // } // // Path: src/main/java/ru/colibri/ui/core/settings/AppSettings.java // @Getter // @Builder // @ToString // @EqualsAndHashCode // public class AppSettings { // private final String packageName; // private final String startPageId; // private final boolean activityUse; // private final Map<String, String> userProfile; // }
import io.appium.java_client.android.AndroidDriver; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Component; import ru.colibri.ui.core.contexts.TestContext; import ru.colibri.ui.core.pages.AbsPageProvider; import ru.colibri.ui.core.pages.IPage; import ru.colibri.ui.core.settings.AppSettings;
package ru.colibri.ui.settings.android; @Component @Qualifier("android")
// Path: src/main/java/ru/colibri/ui/core/contexts/TestContext.java // @Component // @Getter // @Setter // public class TestContext { // private String currentPageName; // private Map<String, String> context = new HashMap<>(); // } // // Path: src/main/java/ru/colibri/ui/core/pages/AbsPageProvider.java // @ToString // public abstract class AbsPageProvider implements IPageProvider { // // @Autowired // protected AppiumDriver driver; // // protected HashMap<String, IPage> pagesByName; // protected HashMap<String, IPage> pagesByID; // // public AbsPageProvider() { // pagesByName = new HashMap<>(); // pagesByID = new HashMap<>(); // } // // public void addPageObject(IPage pageObject) throws PageNameAlreadyUsedException { // String systemId = pageObject.getSystemId().toLowerCase(); // if (!systemId.isEmpty() && pagesByID.containsKey(systemId)) { // throw new PageNameAlreadyUsedException(systemId); // } // String name = pageObject.getName().toLowerCase(); // if (!name.isEmpty() && pagesByName.containsKey(name)) { // throw new PageNameAlreadyUsedException(name); // } // pagesByName.put(name, pageObject); // pagesByID.put(systemId, pageObject); // } // // public IPage getPageByName(String pageName) { // return getIPage(pagesByName, pageName); // } // // public IPage getPageById(String pageId) { // return getIPage(pagesByID, pageId); // } // // private IPage getIPage(HashMap<String, IPage> pages, String pageName) { // IPage result = pages.get(pageName.toLowerCase()); // if (result == null) { // throw new NoPageFoundException(pageName); // } // return result; // } // // @Override // public void addPagesObject(List<IPage> pages) { // pages.forEach(this::addPageObject); // } // } // // Path: src/main/java/ru/colibri/ui/core/pages/IPage.java // public interface IPage { // String getName(); // // String getSystemId(); // // List<IElement> getSpecificElements(); // // IElement getElementByName(String name); // // void addElement(IElement element); // } // // Path: src/main/java/ru/colibri/ui/core/settings/AppSettings.java // @Getter // @Builder // @ToString // @EqualsAndHashCode // public class AppSettings { // private final String packageName; // private final String startPageId; // private final boolean activityUse; // private final Map<String, String> userProfile; // } // Path: src/main/java/ru/colibri/ui/settings/android/AndroidPageProvider.java import io.appium.java_client.android.AndroidDriver; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Component; import ru.colibri.ui.core.contexts.TestContext; import ru.colibri.ui.core.pages.AbsPageProvider; import ru.colibri.ui.core.pages.IPage; import ru.colibri.ui.core.settings.AppSettings; package ru.colibri.ui.settings.android; @Component @Qualifier("android")
public class AndroidPageProvider extends AbsPageProvider {
alfa-laboratory/colibri-ui
src/main/java/ru/colibri/ui/settings/android/AndroidPageProvider.java
// Path: src/main/java/ru/colibri/ui/core/contexts/TestContext.java // @Component // @Getter // @Setter // public class TestContext { // private String currentPageName; // private Map<String, String> context = new HashMap<>(); // } // // Path: src/main/java/ru/colibri/ui/core/pages/AbsPageProvider.java // @ToString // public abstract class AbsPageProvider implements IPageProvider { // // @Autowired // protected AppiumDriver driver; // // protected HashMap<String, IPage> pagesByName; // protected HashMap<String, IPage> pagesByID; // // public AbsPageProvider() { // pagesByName = new HashMap<>(); // pagesByID = new HashMap<>(); // } // // public void addPageObject(IPage pageObject) throws PageNameAlreadyUsedException { // String systemId = pageObject.getSystemId().toLowerCase(); // if (!systemId.isEmpty() && pagesByID.containsKey(systemId)) { // throw new PageNameAlreadyUsedException(systemId); // } // String name = pageObject.getName().toLowerCase(); // if (!name.isEmpty() && pagesByName.containsKey(name)) { // throw new PageNameAlreadyUsedException(name); // } // pagesByName.put(name, pageObject); // pagesByID.put(systemId, pageObject); // } // // public IPage getPageByName(String pageName) { // return getIPage(pagesByName, pageName); // } // // public IPage getPageById(String pageId) { // return getIPage(pagesByID, pageId); // } // // private IPage getIPage(HashMap<String, IPage> pages, String pageName) { // IPage result = pages.get(pageName.toLowerCase()); // if (result == null) { // throw new NoPageFoundException(pageName); // } // return result; // } // // @Override // public void addPagesObject(List<IPage> pages) { // pages.forEach(this::addPageObject); // } // } // // Path: src/main/java/ru/colibri/ui/core/pages/IPage.java // public interface IPage { // String getName(); // // String getSystemId(); // // List<IElement> getSpecificElements(); // // IElement getElementByName(String name); // // void addElement(IElement element); // } // // Path: src/main/java/ru/colibri/ui/core/settings/AppSettings.java // @Getter // @Builder // @ToString // @EqualsAndHashCode // public class AppSettings { // private final String packageName; // private final String startPageId; // private final boolean activityUse; // private final Map<String, String> userProfile; // }
import io.appium.java_client.android.AndroidDriver; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Component; import ru.colibri.ui.core.contexts.TestContext; import ru.colibri.ui.core.pages.AbsPageProvider; import ru.colibri.ui.core.pages.IPage; import ru.colibri.ui.core.settings.AppSettings;
package ru.colibri.ui.settings.android; @Component @Qualifier("android") public class AndroidPageProvider extends AbsPageProvider { @Autowired
// Path: src/main/java/ru/colibri/ui/core/contexts/TestContext.java // @Component // @Getter // @Setter // public class TestContext { // private String currentPageName; // private Map<String, String> context = new HashMap<>(); // } // // Path: src/main/java/ru/colibri/ui/core/pages/AbsPageProvider.java // @ToString // public abstract class AbsPageProvider implements IPageProvider { // // @Autowired // protected AppiumDriver driver; // // protected HashMap<String, IPage> pagesByName; // protected HashMap<String, IPage> pagesByID; // // public AbsPageProvider() { // pagesByName = new HashMap<>(); // pagesByID = new HashMap<>(); // } // // public void addPageObject(IPage pageObject) throws PageNameAlreadyUsedException { // String systemId = pageObject.getSystemId().toLowerCase(); // if (!systemId.isEmpty() && pagesByID.containsKey(systemId)) { // throw new PageNameAlreadyUsedException(systemId); // } // String name = pageObject.getName().toLowerCase(); // if (!name.isEmpty() && pagesByName.containsKey(name)) { // throw new PageNameAlreadyUsedException(name); // } // pagesByName.put(name, pageObject); // pagesByID.put(systemId, pageObject); // } // // public IPage getPageByName(String pageName) { // return getIPage(pagesByName, pageName); // } // // public IPage getPageById(String pageId) { // return getIPage(pagesByID, pageId); // } // // private IPage getIPage(HashMap<String, IPage> pages, String pageName) { // IPage result = pages.get(pageName.toLowerCase()); // if (result == null) { // throw new NoPageFoundException(pageName); // } // return result; // } // // @Override // public void addPagesObject(List<IPage> pages) { // pages.forEach(this::addPageObject); // } // } // // Path: src/main/java/ru/colibri/ui/core/pages/IPage.java // public interface IPage { // String getName(); // // String getSystemId(); // // List<IElement> getSpecificElements(); // // IElement getElementByName(String name); // // void addElement(IElement element); // } // // Path: src/main/java/ru/colibri/ui/core/settings/AppSettings.java // @Getter // @Builder // @ToString // @EqualsAndHashCode // public class AppSettings { // private final String packageName; // private final String startPageId; // private final boolean activityUse; // private final Map<String, String> userProfile; // } // Path: src/main/java/ru/colibri/ui/settings/android/AndroidPageProvider.java import io.appium.java_client.android.AndroidDriver; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Component; import ru.colibri.ui.core.contexts.TestContext; import ru.colibri.ui.core.pages.AbsPageProvider; import ru.colibri.ui.core.pages.IPage; import ru.colibri.ui.core.settings.AppSettings; package ru.colibri.ui.settings.android; @Component @Qualifier("android") public class AndroidPageProvider extends AbsPageProvider { @Autowired
private AppSettings appSettings;
alfa-laboratory/colibri-ui
src/main/java/ru/colibri/ui/settings/android/AndroidPageProvider.java
// Path: src/main/java/ru/colibri/ui/core/contexts/TestContext.java // @Component // @Getter // @Setter // public class TestContext { // private String currentPageName; // private Map<String, String> context = new HashMap<>(); // } // // Path: src/main/java/ru/colibri/ui/core/pages/AbsPageProvider.java // @ToString // public abstract class AbsPageProvider implements IPageProvider { // // @Autowired // protected AppiumDriver driver; // // protected HashMap<String, IPage> pagesByName; // protected HashMap<String, IPage> pagesByID; // // public AbsPageProvider() { // pagesByName = new HashMap<>(); // pagesByID = new HashMap<>(); // } // // public void addPageObject(IPage pageObject) throws PageNameAlreadyUsedException { // String systemId = pageObject.getSystemId().toLowerCase(); // if (!systemId.isEmpty() && pagesByID.containsKey(systemId)) { // throw new PageNameAlreadyUsedException(systemId); // } // String name = pageObject.getName().toLowerCase(); // if (!name.isEmpty() && pagesByName.containsKey(name)) { // throw new PageNameAlreadyUsedException(name); // } // pagesByName.put(name, pageObject); // pagesByID.put(systemId, pageObject); // } // // public IPage getPageByName(String pageName) { // return getIPage(pagesByName, pageName); // } // // public IPage getPageById(String pageId) { // return getIPage(pagesByID, pageId); // } // // private IPage getIPage(HashMap<String, IPage> pages, String pageName) { // IPage result = pages.get(pageName.toLowerCase()); // if (result == null) { // throw new NoPageFoundException(pageName); // } // return result; // } // // @Override // public void addPagesObject(List<IPage> pages) { // pages.forEach(this::addPageObject); // } // } // // Path: src/main/java/ru/colibri/ui/core/pages/IPage.java // public interface IPage { // String getName(); // // String getSystemId(); // // List<IElement> getSpecificElements(); // // IElement getElementByName(String name); // // void addElement(IElement element); // } // // Path: src/main/java/ru/colibri/ui/core/settings/AppSettings.java // @Getter // @Builder // @ToString // @EqualsAndHashCode // public class AppSettings { // private final String packageName; // private final String startPageId; // private final boolean activityUse; // private final Map<String, String> userProfile; // }
import io.appium.java_client.android.AndroidDriver; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Component; import ru.colibri.ui.core.contexts.TestContext; import ru.colibri.ui.core.pages.AbsPageProvider; import ru.colibri.ui.core.pages.IPage; import ru.colibri.ui.core.settings.AppSettings;
package ru.colibri.ui.settings.android; @Component @Qualifier("android") public class AndroidPageProvider extends AbsPageProvider { @Autowired private AppSettings appSettings; @Autowired
// Path: src/main/java/ru/colibri/ui/core/contexts/TestContext.java // @Component // @Getter // @Setter // public class TestContext { // private String currentPageName; // private Map<String, String> context = new HashMap<>(); // } // // Path: src/main/java/ru/colibri/ui/core/pages/AbsPageProvider.java // @ToString // public abstract class AbsPageProvider implements IPageProvider { // // @Autowired // protected AppiumDriver driver; // // protected HashMap<String, IPage> pagesByName; // protected HashMap<String, IPage> pagesByID; // // public AbsPageProvider() { // pagesByName = new HashMap<>(); // pagesByID = new HashMap<>(); // } // // public void addPageObject(IPage pageObject) throws PageNameAlreadyUsedException { // String systemId = pageObject.getSystemId().toLowerCase(); // if (!systemId.isEmpty() && pagesByID.containsKey(systemId)) { // throw new PageNameAlreadyUsedException(systemId); // } // String name = pageObject.getName().toLowerCase(); // if (!name.isEmpty() && pagesByName.containsKey(name)) { // throw new PageNameAlreadyUsedException(name); // } // pagesByName.put(name, pageObject); // pagesByID.put(systemId, pageObject); // } // // public IPage getPageByName(String pageName) { // return getIPage(pagesByName, pageName); // } // // public IPage getPageById(String pageId) { // return getIPage(pagesByID, pageId); // } // // private IPage getIPage(HashMap<String, IPage> pages, String pageName) { // IPage result = pages.get(pageName.toLowerCase()); // if (result == null) { // throw new NoPageFoundException(pageName); // } // return result; // } // // @Override // public void addPagesObject(List<IPage> pages) { // pages.forEach(this::addPageObject); // } // } // // Path: src/main/java/ru/colibri/ui/core/pages/IPage.java // public interface IPage { // String getName(); // // String getSystemId(); // // List<IElement> getSpecificElements(); // // IElement getElementByName(String name); // // void addElement(IElement element); // } // // Path: src/main/java/ru/colibri/ui/core/settings/AppSettings.java // @Getter // @Builder // @ToString // @EqualsAndHashCode // public class AppSettings { // private final String packageName; // private final String startPageId; // private final boolean activityUse; // private final Map<String, String> userProfile; // } // Path: src/main/java/ru/colibri/ui/settings/android/AndroidPageProvider.java import io.appium.java_client.android.AndroidDriver; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Component; import ru.colibri.ui.core.contexts.TestContext; import ru.colibri.ui.core.pages.AbsPageProvider; import ru.colibri.ui.core.pages.IPage; import ru.colibri.ui.core.settings.AppSettings; package ru.colibri.ui.settings.android; @Component @Qualifier("android") public class AndroidPageProvider extends AbsPageProvider { @Autowired private AppSettings appSettings; @Autowired
private TestContext testContext;
alfa-laboratory/colibri-ui
src/main/java/ru/colibri/ui/settings/android/AndroidPageProvider.java
// Path: src/main/java/ru/colibri/ui/core/contexts/TestContext.java // @Component // @Getter // @Setter // public class TestContext { // private String currentPageName; // private Map<String, String> context = new HashMap<>(); // } // // Path: src/main/java/ru/colibri/ui/core/pages/AbsPageProvider.java // @ToString // public abstract class AbsPageProvider implements IPageProvider { // // @Autowired // protected AppiumDriver driver; // // protected HashMap<String, IPage> pagesByName; // protected HashMap<String, IPage> pagesByID; // // public AbsPageProvider() { // pagesByName = new HashMap<>(); // pagesByID = new HashMap<>(); // } // // public void addPageObject(IPage pageObject) throws PageNameAlreadyUsedException { // String systemId = pageObject.getSystemId().toLowerCase(); // if (!systemId.isEmpty() && pagesByID.containsKey(systemId)) { // throw new PageNameAlreadyUsedException(systemId); // } // String name = pageObject.getName().toLowerCase(); // if (!name.isEmpty() && pagesByName.containsKey(name)) { // throw new PageNameAlreadyUsedException(name); // } // pagesByName.put(name, pageObject); // pagesByID.put(systemId, pageObject); // } // // public IPage getPageByName(String pageName) { // return getIPage(pagesByName, pageName); // } // // public IPage getPageById(String pageId) { // return getIPage(pagesByID, pageId); // } // // private IPage getIPage(HashMap<String, IPage> pages, String pageName) { // IPage result = pages.get(pageName.toLowerCase()); // if (result == null) { // throw new NoPageFoundException(pageName); // } // return result; // } // // @Override // public void addPagesObject(List<IPage> pages) { // pages.forEach(this::addPageObject); // } // } // // Path: src/main/java/ru/colibri/ui/core/pages/IPage.java // public interface IPage { // String getName(); // // String getSystemId(); // // List<IElement> getSpecificElements(); // // IElement getElementByName(String name); // // void addElement(IElement element); // } // // Path: src/main/java/ru/colibri/ui/core/settings/AppSettings.java // @Getter // @Builder // @ToString // @EqualsAndHashCode // public class AppSettings { // private final String packageName; // private final String startPageId; // private final boolean activityUse; // private final Map<String, String> userProfile; // }
import io.appium.java_client.android.AndroidDriver; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Component; import ru.colibri.ui.core.contexts.TestContext; import ru.colibri.ui.core.pages.AbsPageProvider; import ru.colibri.ui.core.pages.IPage; import ru.colibri.ui.core.settings.AppSettings;
package ru.colibri.ui.settings.android; @Component @Qualifier("android") public class AndroidPageProvider extends AbsPageProvider { @Autowired private AppSettings appSettings; @Autowired private TestContext testContext; @Override
// Path: src/main/java/ru/colibri/ui/core/contexts/TestContext.java // @Component // @Getter // @Setter // public class TestContext { // private String currentPageName; // private Map<String, String> context = new HashMap<>(); // } // // Path: src/main/java/ru/colibri/ui/core/pages/AbsPageProvider.java // @ToString // public abstract class AbsPageProvider implements IPageProvider { // // @Autowired // protected AppiumDriver driver; // // protected HashMap<String, IPage> pagesByName; // protected HashMap<String, IPage> pagesByID; // // public AbsPageProvider() { // pagesByName = new HashMap<>(); // pagesByID = new HashMap<>(); // } // // public void addPageObject(IPage pageObject) throws PageNameAlreadyUsedException { // String systemId = pageObject.getSystemId().toLowerCase(); // if (!systemId.isEmpty() && pagesByID.containsKey(systemId)) { // throw new PageNameAlreadyUsedException(systemId); // } // String name = pageObject.getName().toLowerCase(); // if (!name.isEmpty() && pagesByName.containsKey(name)) { // throw new PageNameAlreadyUsedException(name); // } // pagesByName.put(name, pageObject); // pagesByID.put(systemId, pageObject); // } // // public IPage getPageByName(String pageName) { // return getIPage(pagesByName, pageName); // } // // public IPage getPageById(String pageId) { // return getIPage(pagesByID, pageId); // } // // private IPage getIPage(HashMap<String, IPage> pages, String pageName) { // IPage result = pages.get(pageName.toLowerCase()); // if (result == null) { // throw new NoPageFoundException(pageName); // } // return result; // } // // @Override // public void addPagesObject(List<IPage> pages) { // pages.forEach(this::addPageObject); // } // } // // Path: src/main/java/ru/colibri/ui/core/pages/IPage.java // public interface IPage { // String getName(); // // String getSystemId(); // // List<IElement> getSpecificElements(); // // IElement getElementByName(String name); // // void addElement(IElement element); // } // // Path: src/main/java/ru/colibri/ui/core/settings/AppSettings.java // @Getter // @Builder // @ToString // @EqualsAndHashCode // public class AppSettings { // private final String packageName; // private final String startPageId; // private final boolean activityUse; // private final Map<String, String> userProfile; // } // Path: src/main/java/ru/colibri/ui/settings/android/AndroidPageProvider.java import io.appium.java_client.android.AndroidDriver; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Component; import ru.colibri.ui.core.contexts.TestContext; import ru.colibri.ui.core.pages.AbsPageProvider; import ru.colibri.ui.core.pages.IPage; import ru.colibri.ui.core.settings.AppSettings; package ru.colibri.ui.settings.android; @Component @Qualifier("android") public class AndroidPageProvider extends AbsPageProvider { @Autowired private AppSettings appSettings; @Autowired private TestContext testContext; @Override
public IPage getCurrentPage() {