proj_name stringclasses 131
values | relative_path stringlengths 30 228 | class_name stringlengths 1 68 | func_name stringlengths 1 48 | masked_class stringlengths 78 9.82k | func_body stringlengths 46 9.61k | len_input int64 29 2.01k | len_output int64 14 1.94k | total int64 55 2.05k | relevant_context stringlengths 0 38.4k |
|---|---|---|---|---|---|---|---|---|---|
pagehelper_Mybatis-PageHelper | Mybatis-PageHelper/src/main/java/com/github/pagehelper/dialect/helper/SqlServerDialect.java | SqlServerDialect | getPageSql | class SqlServerDialect extends AbstractHelperDialect {
protected SqlServerSqlParser sqlServerSqlParser;
protected Cache<String, String> CACHE_COUNTSQL;
protected Cache<String, String> CACHE_PAGESQL;
protected ReplaceSql replaceSql;
@Override
public String getCountSql(MappedStatement ... |
//处理pageKey
pageKey.update(page.getStartRow());
pageKey.update(page.getPageSize());
String cacheSql = CACHE_PAGESQL.get(sql);
if (cacheSql == null) {
cacheSql = sql;
cacheSql = replaceSql.replace(cacheSql);
cacheSql = sqlServerSqlParser.conver... | 965 | 211 | 1,176 | <methods>public non-sealed void <init>() ,public void afterAll() ,public boolean afterCount(long, java.lang.Object, org.apache.ibatis.session.RowBounds) ,public java.lang.Object afterPage(List#RAW, java.lang.Object, org.apache.ibatis.session.RowBounds) ,public boolean beforeCount(org.apache.ibatis.mapping.MappedStateme... |
pagehelper_Mybatis-PageHelper | Mybatis-PageHelper/src/main/java/com/github/pagehelper/dialect/rowbounds/Db2RowBoundsDialect.java | Db2RowBoundsDialect | getPageSql | class Db2RowBoundsDialect extends AbstractRowBoundsDialect {
@Override
public String getPageSql(String sql, RowBounds rowBounds, CacheKey pageKey) {<FILL_FUNCTION_BODY>}
} |
int startRow = rowBounds.getOffset() + 1;
int endRow = rowBounds.getOffset() + rowBounds.getLimit();
StringBuilder sqlBuilder = new StringBuilder(sql.length() + 120);
sqlBuilder.append("SELECT * FROM (SELECT TMP_PAGE.*,ROWNUMBER() OVER() AS PAGEHELPER_ROW_ID FROM ( \n");
sqlBuil... | 60 | 199 | 259 | <methods>public non-sealed void <init>() ,public void afterAll() ,public boolean afterCount(long, java.lang.Object, org.apache.ibatis.session.RowBounds) ,public java.lang.Object afterPage(List#RAW, java.lang.Object, org.apache.ibatis.session.RowBounds) ,public boolean beforeCount(org.apache.ibatis.mapping.MappedStateme... |
pagehelper_Mybatis-PageHelper | Mybatis-PageHelper/src/main/java/com/github/pagehelper/dialect/rowbounds/HerdDBRowBoundsDialect.java | HerdDBRowBoundsDialect | getPageSql | class HerdDBRowBoundsDialect extends AbstractRowBoundsDialect {
@Override
public String getPageSql(String sql, RowBounds rowBounds, CacheKey pageKey) {<FILL_FUNCTION_BODY>}
} |
StringBuilder sqlBuilder = new StringBuilder(sql.length() + 14);
sqlBuilder.append(sql);
if (rowBounds.getOffset() == 0) {
sqlBuilder.append("\n LIMIT ");
sqlBuilder.append(rowBounds.getLimit());
} else {
sqlBuilder.append("\n LIMIT ");
sq... | 60 | 155 | 215 | <methods>public non-sealed void <init>() ,public void afterAll() ,public boolean afterCount(long, java.lang.Object, org.apache.ibatis.session.RowBounds) ,public java.lang.Object afterPage(List#RAW, java.lang.Object, org.apache.ibatis.session.RowBounds) ,public boolean beforeCount(org.apache.ibatis.mapping.MappedStateme... |
pagehelper_Mybatis-PageHelper | Mybatis-PageHelper/src/main/java/com/github/pagehelper/dialect/rowbounds/HsqldbRowBoundsDialect.java | HsqldbRowBoundsDialect | getPageSql | class HsqldbRowBoundsDialect extends AbstractRowBoundsDialect {
@Override
public String getPageSql(String sql, RowBounds rowBounds, CacheKey pageKey) {<FILL_FUNCTION_BODY>}
} |
StringBuilder sqlBuilder = new StringBuilder(sql.length() + 20);
sqlBuilder.append(sql);
if (rowBounds.getLimit() > 0) {
sqlBuilder.append("\n LIMIT ");
sqlBuilder.append(rowBounds.getLimit());
pageKey.update(rowBounds.getLimit());
}
if (rowBo... | 60 | 146 | 206 | <methods>public non-sealed void <init>() ,public void afterAll() ,public boolean afterCount(long, java.lang.Object, org.apache.ibatis.session.RowBounds) ,public java.lang.Object afterPage(List#RAW, java.lang.Object, org.apache.ibatis.session.RowBounds) ,public boolean beforeCount(org.apache.ibatis.mapping.MappedStateme... |
pagehelper_Mybatis-PageHelper | Mybatis-PageHelper/src/main/java/com/github/pagehelper/dialect/rowbounds/InformixRowBoundsDialect.java | InformixRowBoundsDialect | getPageSql | class InformixRowBoundsDialect extends AbstractRowBoundsDialect {
@Override
public String getPageSql(String sql, RowBounds rowBounds, CacheKey pageKey) {<FILL_FUNCTION_BODY>}
} |
StringBuilder sqlBuilder = new StringBuilder(sql.length() + 40);
sqlBuilder.append("SELECT ");
if (rowBounds.getOffset() > 0) {
sqlBuilder.append(" SKIP ");
sqlBuilder.append(rowBounds.getOffset());
pageKey.update(rowBounds.getOffset());
}
if ... | 59 | 181 | 240 | <methods>public non-sealed void <init>() ,public void afterAll() ,public boolean afterCount(long, java.lang.Object, org.apache.ibatis.session.RowBounds) ,public java.lang.Object afterPage(List#RAW, java.lang.Object, org.apache.ibatis.session.RowBounds) ,public boolean beforeCount(org.apache.ibatis.mapping.MappedStateme... |
pagehelper_Mybatis-PageHelper | Mybatis-PageHelper/src/main/java/com/github/pagehelper/dialect/rowbounds/MySqlRowBoundsDialect.java | MySqlRowBoundsDialect | getPageSql | class MySqlRowBoundsDialect extends AbstractRowBoundsDialect {
@Override
public String getPageSql(String sql, RowBounds rowBounds, CacheKey pageKey) {<FILL_FUNCTION_BODY>}
} |
StringBuilder sqlBuilder = new StringBuilder(sql.length() + 14);
sqlBuilder.append(sql);
if (rowBounds.getOffset() == 0) {
sqlBuilder.append("\n LIMIT ");
sqlBuilder.append(rowBounds.getLimit());
} else {
sqlBuilder.append("\n LIMIT ");
sq... | 59 | 155 | 214 | <methods>public non-sealed void <init>() ,public void afterAll() ,public boolean afterCount(long, java.lang.Object, org.apache.ibatis.session.RowBounds) ,public java.lang.Object afterPage(List#RAW, java.lang.Object, org.apache.ibatis.session.RowBounds) ,public boolean beforeCount(org.apache.ibatis.mapping.MappedStateme... |
pagehelper_Mybatis-PageHelper | Mybatis-PageHelper/src/main/java/com/github/pagehelper/dialect/rowbounds/OracleRowBoundsDialect.java | OracleRowBoundsDialect | getPageSql | class OracleRowBoundsDialect extends AbstractRowBoundsDialect {
@Override
public String getPageSql(String sql, RowBounds rowBounds, CacheKey pageKey) {<FILL_FUNCTION_BODY>}
} |
int startRow = rowBounds.getOffset();
int endRow = rowBounds.getOffset() + rowBounds.getLimit();
StringBuilder sqlBuilder = new StringBuilder(sql.length() + 120);
if (startRow > 0) {
sqlBuilder.append("SELECT * FROM ( ");
}
if (endRow > 0) {
sqlBu... | 58 | 262 | 320 | <methods>public non-sealed void <init>() ,public void afterAll() ,public boolean afterCount(long, java.lang.Object, org.apache.ibatis.session.RowBounds) ,public java.lang.Object afterPage(List#RAW, java.lang.Object, org.apache.ibatis.session.RowBounds) ,public boolean beforeCount(org.apache.ibatis.mapping.MappedStateme... |
pagehelper_Mybatis-PageHelper | Mybatis-PageHelper/src/main/java/com/github/pagehelper/dialect/rowbounds/PostgreSqlRowBoundsDialect.java | PostgreSqlRowBoundsDialect | getPageSql | class PostgreSqlRowBoundsDialect extends AbstractRowBoundsDialect {
/**
* 构建 <a href="https://www.postgresql.org/docs/current/queries-limit.html">PostgreSQL</a>分页查询语句
*/
@Override
public String getPageSql(String sql, RowBounds rowBounds, CacheKey pageKey) {<FILL_FUNCTION_BODY>}
} |
StringBuilder sqlStr = new StringBuilder(sql.length() + 17);
sqlStr.append(sql);
if (rowBounds.getOffset() == 0) {
sqlStr.append(" LIMIT ");
sqlStr.append(rowBounds.getLimit());
} else {
sqlStr.append(" LIMIT ");
sqlStr.append(rowBounds.ge... | 110 | 154 | 264 | <methods>public non-sealed void <init>() ,public void afterAll() ,public boolean afterCount(long, java.lang.Object, org.apache.ibatis.session.RowBounds) ,public java.lang.Object afterPage(List#RAW, java.lang.Object, org.apache.ibatis.session.RowBounds) ,public boolean beforeCount(org.apache.ibatis.mapping.MappedStateme... |
pagehelper_Mybatis-PageHelper | Mybatis-PageHelper/src/main/java/com/github/pagehelper/dialect/rowbounds/SqlServer2012RowBoundsDialect.java | SqlServer2012RowBoundsDialect | getPageSql | class SqlServer2012RowBoundsDialect extends SqlServerRowBoundsDialect {
@Override
public String getPageSql(String sql, RowBounds rowBounds, CacheKey pageKey) {<FILL_FUNCTION_BODY>}
} |
StringBuilder sqlBuilder = new StringBuilder(sql.length() + 14);
sqlBuilder.append(sql);
sqlBuilder.append("\n OFFSET ");
sqlBuilder.append(rowBounds.getOffset());
sqlBuilder.append(" ROWS ");
pageKey.update(rowBounds.getOffset());
sqlBuilder.append(" FETCH NEXT ... | 64 | 138 | 202 | <methods>public non-sealed void <init>() ,public java.lang.String getCountSql(org.apache.ibatis.mapping.MappedStatement, org.apache.ibatis.mapping.BoundSql, java.lang.Object, org.apache.ibatis.session.RowBounds, org.apache.ibatis.cache.CacheKey) ,public java.lang.String getPageSql(java.lang.String, org.apache.ibatis.se... |
pagehelper_Mybatis-PageHelper | Mybatis-PageHelper/src/main/java/com/github/pagehelper/dialect/rowbounds/SqlServerRowBoundsDialect.java | SqlServerRowBoundsDialect | setProperties | class SqlServerRowBoundsDialect extends AbstractRowBoundsDialect {
protected SqlServerSqlParser sqlServerSqlParser;
protected ReplaceSql replaceSql;
@Override
public String getCountSql(MappedStatement ms, BoundSql boundSql, Object parameterObject, RowBounds rowBounds, CacheKey countKey) {
... |
super.setProperties(properties);
this.sqlServerSqlParser = ClassUtil.newInstance(properties.getProperty("sqlServerSqlParser"), SqlServerSqlParser.class, properties, DefaultSqlServerSqlParser::new);
String replaceSql = properties.getProperty("replaceSql");
if (StringUtil.isEmpty(replaceS... | 336 | 167 | 503 | <methods>public non-sealed void <init>() ,public void afterAll() ,public boolean afterCount(long, java.lang.Object, org.apache.ibatis.session.RowBounds) ,public java.lang.Object afterPage(List#RAW, java.lang.Object, org.apache.ibatis.session.RowBounds) ,public boolean beforeCount(org.apache.ibatis.mapping.MappedStateme... |
pagehelper_Mybatis-PageHelper | Mybatis-PageHelper/src/main/java/com/github/pagehelper/page/PageBoundSqlInterceptors.java | PageBoundSqlInterceptors | setProperties | class PageBoundSqlInterceptors {
private BoundSqlInterceptor.Chain chain;
public void setProperties(Properties properties) {<FILL_FUNCTION_BODY>}
public BoundSqlInterceptor.Chain getChain() {
return chain;
}
} |
//初始化 boundSqlInterceptorChain
String boundSqlInterceptorStr = properties.getProperty("boundSqlInterceptors");
if (StringUtil.isNotEmpty(boundSqlInterceptorStr)) {
String[] boundSqlInterceptors = boundSqlInterceptorStr.split("[;|,]");
List<BoundSqlInterceptor> list = new... | 73 | 185 | 258 | <no_super_class> |
pagehelper_Mybatis-PageHelper | Mybatis-PageHelper/src/main/java/com/github/pagehelper/page/PageMethod.java | PageMethod | startPage | class PageMethod {
protected static final ThreadLocal<Page> LOCAL_PAGE = new ThreadLocal<Page>();
protected static boolean DEFAULT_COUNT = true;
/**
* 设置 Page 参数
*
* @param page
*/
public static void setLocalPage(Page page) {
LOCAL_PAGE.set(page);
}
... |
Page<E> page = PageObjectUtil.getPageFromObject(params, true);
//当已经执行过orderBy的时候
Page<E> oldPage = getLocalPage();
if (oldPage != null && oldPage.isOrderByOnly()) {
page.setOrderBy(oldPage.getOrderBy());
}
setLocalPage(page);
return page;
| 1,422 | 97 | 1,519 | <no_super_class> |
pagehelper_Mybatis-PageHelper | Mybatis-PageHelper/src/main/java/com/github/pagehelper/page/PageParams.java | PageParams | getPage | class PageParams {
/**
* RowBounds参数offset作为PageNum使用 - 默认不使用
*/
protected boolean offsetAsPageNum = false;
/**
* RowBounds是否进行count查询 - 默认不查询
*/
protected boolean rowBoundsWithCount = false;
/**
* 当设置为true的时候,如果pagesize设置为0(或RowBounds的limit=0),就不执行分页,返回全部结果
... |
Page page = PageHelper.getLocalPage();
if (page == null) {
if (rowBounds != RowBounds.DEFAULT) {
if (offsetAsPageNum) {
page = new Page(rowBounds.getOffset(), rowBounds.getLimit(), rowBoundsWithCount);
} else {
page = n... | 991 | 466 | 1,457 | <no_super_class> |
pagehelper_Mybatis-PageHelper | Mybatis-PageHelper/src/main/java/com/github/pagehelper/parser/SqlParserUtil.java | SqlParserUtil | parse | class SqlParserUtil {
private static final SqlParser SQL_PARSER;
static {
SqlParser temp = null;
ServiceLoader<SqlParser> loader = ServiceLoader.load(SqlParser.class);
for (SqlParser sqlParser : loader) {
temp = sqlParser;
break;
}
if (temp == nu... |
try {
return SQL_PARSER.parse(statementReader);
} catch (JSQLParserException | ParseException e) {
throw new RuntimeException(e);
}
| 141 | 48 | 189 | <no_super_class> |
pagehelper_Mybatis-PageHelper | Mybatis-PageHelper/src/main/java/com/github/pagehelper/parser/defaults/DefaultOrderBySqlParser.java | DefaultOrderBySqlParser | converToOrderBySql | class DefaultOrderBySqlParser implements OrderBySqlParser {
private static final Log log = LogFactory.getLog(DefaultOrderBySqlParser.class);
/**
* convert to order by sql
*
* @param sql
* @param orderBy
* @return
*/
@Override
public String converToOrderBySql(String sql, St... |
//解析SQL
Statement stmt = null;
try {
stmt = SqlParserUtil.parse(sql);
Select select = (Select) stmt;
//处理body-去最外层order by
List<OrderByElement> orderByElements = extraOrderBy(select);
String defaultOrderBy = PlainSelect.orderByToString... | 263 | 221 | 484 | <no_super_class> |
pagehelper_Mybatis-PageHelper | Mybatis-PageHelper/src/main/java/com/github/pagehelper/util/ClassUtil.java | ClassUtil | newInstance | class ClassUtil {
/**
* 支持配置和SPI,优先级:配置类 > SPI > 默认值
*
* @param classStr 配置串,可空
* @param spi SPI 接口
* @param properties 配置属性
* @param defaultSupplier 默认值
*/
@SuppressWarnings("unchecked")
public static <T> T newInstance(String classStr, Class<T> sp... |
try {
T instance = cls.newInstance();
if (instance instanceof PageProperties) {
((PageProperties) instance).setProperties(properties);
}
return instance;
} catch (Exception e) {
throw new PageException(e);
}
| 549 | 70 | 619 | <no_super_class> |
pagehelper_Mybatis-PageHelper | Mybatis-PageHelper/src/main/java/com/github/pagehelper/util/ExecutorUtil.java | ExecutorUtil | executeAutoCount | class ExecutorUtil {
private static Field additionalParametersField;
private static Field providerMethodArgumentNamesField;
static {
try {
additionalParametersField = BoundSql.class.getDeclaredField("additionalParameters");
additionalParametersField.setAccessible(true);
... |
Map<String, Object> additionalParameters = getAdditionalParameter(boundSql);
//创建 count 查询的缓存 key
CacheKey countKey = executor.createCacheKey(countMs, parameter, RowBounds.DEFAULT, boundSql);
//调用方言获取 count sql
String countSql = dialect.getCountSql(countMs, boundSql, parameter, ... | 1,511 | 392 | 1,903 | <no_super_class> |
pagehelper_Mybatis-PageHelper | Mybatis-PageHelper/src/main/java/com/github/pagehelper/util/MSUtils.java | MSUtils | newCountMappedStatement | class MSUtils {
private static final List<ResultMapping> EMPTY_RESULTMAPPING = new ArrayList<ResultMapping>(0);
/**
* 新建count查询的MappedStatement
*
* @param ms
* @param newMsId
* @return
*/
public static MappedStatement newCountMappedStatement(MappedStatement ms, String newMsId)... |
MappedStatement.Builder builder = new MappedStatement.Builder(ms.getConfiguration(), newMsId, ms.getSqlSource(), ms.getSqlCommandType());
builder.resource(ms.getResource());
builder.fetchSize(ms.getFetchSize());
builder.statementType(ms.getStatementType());
builder.keyGenerator(... | 114 | 372 | 486 | <no_super_class> |
pagehelper_Mybatis-PageHelper | Mybatis-PageHelper/src/main/java/com/github/pagehelper/util/MetaObjectUtil.java | MetaObjectUtil | forObject | class MetaObjectUtil {
public static Method method;
static {
try {
// 高版本中的 MetaObject.forObject 有 4 个参数,低版本是 1 个
//先判断当前使用的是否为高版本
Class.forName("org.apache.ibatis.reflection.ReflectorFactory");
// 下面这个 MetaObjectWithReflectCache 带反射的缓存信息
Clas... |
try {
return (MetaObject) method.invoke(null, object);
} catch (Exception e) {
throw new PageException(e);
}
| 342 | 43 | 385 | <no_super_class> |
pagehelper_Mybatis-PageHelper | Mybatis-PageHelper/src/main/java/com/github/pagehelper/util/MetaObjectWithReflectCache.java | MetaObjectWithReflectCache | forObject | class MetaObjectWithReflectCache {
public static final ObjectFactory DEFAULT_OBJECT_FACTORY = new DefaultObjectFactory();
public static final ObjectWrapperFactory DEFAULT_OBJECT_WRAPPER_FACTORY = new DefaultObjectWrapperFactory();
public static final ReflectorFactory DEFAULT_REFLECTOR_FACTORY = new DefaultR... |
try {
return MetaObject.forObject(object, DEFAULT_OBJECT_FACTORY, DEFAULT_OBJECT_WRAPPER_FACTORY, DEFAULT_REFLECTOR_FACTORY);
} catch (Exception e) {
throw new PageException(e);
}
| 114 | 72 | 186 | <no_super_class> |
pagehelper_Mybatis-PageHelper | Mybatis-PageHelper/src/main/java/com/github/pagehelper/util/PageObjectUtil.java | PageObjectUtil | getPageFromObject | class PageObjectUtil {
//request获取方法
protected static Boolean hasRequest;
protected static Class<?> requestClass;
protected static Method getParameterMap;
protected static Map<String, String> PARAMS = new HashMap<String, String>(6, 1);
static {
try {
requestClass = ClassUtil... |
if (params == null) {
throw new PageException("unable to get paginated query parameters!");
}
if(params instanceof IPage){
IPage pageParams = (IPage) params;
Page page = null;
if(pageParams.getPageNum() != null && pageParams.getPageSize() != null)... | 637 | 827 | 1,464 | <no_super_class> |
pagehelper_Mybatis-PageHelper | Mybatis-PageHelper/src/main/java/com/github/pagehelper/util/SqlSafeUtil.java | SqlSafeUtil | check | class SqlSafeUtil {
/**
* SQL语法检查正则:符合两个关键字(有先后顺序)才算匹配
* <p>
* 参考: mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/toolkit/sql/SqlInjectionUtils.java
*/
private static final Pattern SQL_SYNTAX_PATTERN = Pattern.compile("(insert|delete|update|select|create|drop|truncate|grant|a... |
if (value == null) {
return false;
}
// 不允许使用任何函数(不能出现括号),否则无法检测后面这个注入 order by id,if(1=2,1,(sleep(100)));
return value.contains("(") || SQL_COMMENT_PATTERN.matcher(value).find() || SQL_SYNTAX_PATTERN.matcher(value).find();
| 414 | 110 | 524 | <no_super_class> |
pagehelper_Mybatis-PageHelper | Mybatis-PageHelper/src/main/java/com/github/pagehelper/util/StackTraceUtil.java | StackTraceUtil | current | class StackTraceUtil {
/**
* 当前方法堆栈信息
*/
public static String current() {<FILL_FUNCTION_BODY>}
} |
Exception exception = new Exception("Stack information when setting pagination parameters");
StringWriter writer = new StringWriter();
exception.printStackTrace(new PrintWriter(writer));
return writer.toString();
| 46 | 50 | 96 | <no_super_class> |
pagehelper_Mybatis-PageHelper | Mybatis-PageHelper/src/main/java/com/github/pagehelper/util/StringUtil.java | StringUtil | isEmpty | class StringUtil {
public static boolean isEmpty(String str) {<FILL_FUNCTION_BODY>}
public static boolean isNotEmpty(String str) {
return !isEmpty(str);
}
} |
if (str == null || str.length() == 0) {
return true;
}
return false;
| 57 | 32 | 89 | <no_super_class> |
luxiaoxun_NettyRpc | NettyRpc/netty-rpc-client/src/main/java/com/netty/rpc/client/RpcClient.java | RpcClient | setApplicationContext | class RpcClient implements ApplicationContextAware, DisposableBean {
private static final Logger logger = LoggerFactory.getLogger(RpcClient.class);
private ServiceDiscovery serviceDiscovery;
private static ThreadPoolExecutor threadPoolExecutor = ThreadPoolUtil.createThreadPool(RpcClient.class.getSimpleNam... |
String[] beanNames = applicationContext.getBeanDefinitionNames();
for (String beanName : beanNames) {
Object bean = applicationContext.getBean(beanName);
Field[] fields = bean.getClass().getDeclaredFields();
try {
for (Field field : fields) {
... | 380 | 189 | 569 | <no_super_class> |
luxiaoxun_NettyRpc | NettyRpc/netty-rpc-client/src/main/java/com/netty/rpc/client/connect/ConnectionManager.java | SingletonHolder | run | class SingletonHolder {
private static final ConnectionManager instance = new ConnectionManager();
}
public static ConnectionManager getInstance() {
return SingletonHolder.instance;
}
public void updateConnectedServer(List<RpcProtocol> serviceList) {
// Now using 2 collections ... |
Bootstrap b = new Bootstrap();
b.group(eventLoopGroup)
.channel(NioSocketChannel.class)
.handler(new RpcClientInitializer());
ChannelFuture channelFuture = b.connect(remotePeer);
channelFuture.addListener(n... | 876 | 224 | 1,100 | <no_super_class> |
luxiaoxun_NettyRpc | NettyRpc/netty-rpc-client/src/main/java/com/netty/rpc/client/discovery/ServiceDiscovery.java | ServiceDiscovery | getServiceAndUpdateServer | class ServiceDiscovery {
private static final Logger logger = LoggerFactory.getLogger(ServiceDiscovery.class);
private CuratorClient curatorClient;
public ServiceDiscovery(String registryAddress) {
this.curatorClient = new CuratorClient(registryAddress);
discoveryService();
}
priva... |
String path = childData.getPath();
String data = new String(childData.getData(), StandardCharsets.UTF_8);
logger.info("Child data updated, path:{},type:{},data:{},", path, type, data);
RpcProtocol rpcProtocol = RpcProtocol.fromJson(data);
updateConnectedServer(rpcProtocol, type... | 791 | 96 | 887 | <no_super_class> |
luxiaoxun_NettyRpc | NettyRpc/netty-rpc-client/src/main/java/com/netty/rpc/client/handler/RpcClientHandler.java | RpcClientHandler | channelRead0 | class RpcClientHandler extends SimpleChannelInboundHandler<RpcResponse> {
private static final Logger logger = LoggerFactory.getLogger(RpcClientHandler.class);
private ConcurrentHashMap<String, RpcFuture> pendingRPC = new ConcurrentHashMap<>();
private volatile Channel channel;
private SocketAddress re... |
String requestId = response.getRequestId();
logger.debug("Receive response: " + requestId);
RpcFuture rpcFuture = pendingRPC.get(requestId);
if (rpcFuture != null) {
pendingRPC.remove(requestId);
rpcFuture.done(response);
} else {
logger.warn(... | 644 | 107 | 751 | <no_super_class> |
luxiaoxun_NettyRpc | NettyRpc/netty-rpc-client/src/main/java/com/netty/rpc/client/handler/RpcClientInitializer.java | RpcClientInitializer | initChannel | class RpcClientInitializer extends ChannelInitializer<SocketChannel> {
@Override
protected void initChannel(SocketChannel socketChannel) throws Exception {<FILL_FUNCTION_BODY>}
} |
// Serializer serializer = ProtostuffSerializer.class.newInstance();
// Serializer serializer = HessianSerializer.class.newInstance();
Serializer serializer = KryoSerializer.class.newInstance();
ChannelPipeline cp = socketChannel.pipeline();
cp.addLast(new IdleStateHandler(0, 0, B... | 49 | 194 | 243 | <no_super_class> |
luxiaoxun_NettyRpc | NettyRpc/netty-rpc-client/src/main/java/com/netty/rpc/client/handler/RpcFuture.java | Sync | tryRelease | class Sync extends AbstractQueuedSynchronizer {
private static final long serialVersionUID = 1L;
//future status
private final int done = 1;
private final int pending = 0;
@Override
protected boolean tryAcquire(int arg) {
return getState() == done;
}... |
if (getState() == pending) {
if (compareAndSetState(pending, done)) {
return true;
} else {
return false;
}
} else {
return true;
}
| 130 | 59 | 189 | <no_super_class> |
luxiaoxun_NettyRpc | NettyRpc/netty-rpc-client/src/main/java/com/netty/rpc/client/proxy/ObjectProxy.java | ObjectProxy | call | class ObjectProxy<T, P> implements InvocationHandler, RpcService<T, P, SerializableFunction<T>> {
private static final Logger logger = LoggerFactory.getLogger(ObjectProxy.class);
private Class<T> clazz;
private String version;
public ObjectProxy(Class<T> clazz, String version) {
this.clazz = cl... |
String serviceKey = ServiceUtil.makeServiceKey(this.clazz.getName(), version);
RpcClientHandler handler = ConnectionManager.getInstance().chooseHandler(serviceKey);
RpcRequest request = createRequest(this.clazz.getName(), tSerializableFunction.getName(), args);
RpcFuture rpcFuture = han... | 1,215 | 93 | 1,308 | <no_super_class> |
luxiaoxun_NettyRpc | NettyRpc/netty-rpc-client/src/main/java/com/netty/rpc/client/route/RpcLoadBalance.java | RpcLoadBalance | getServiceMap | class RpcLoadBalance {
// Service map: group by service name
protected Map<String, List<RpcProtocol>> getServiceMap(Map<RpcProtocol, RpcClientHandler> connectedServerNodes) {<FILL_FUNCTION_BODY>}
// Route the connection for service key
public abstract RpcProtocol route(String serviceKey, Map<RpcProtoco... |
Map<String, List<RpcProtocol>> serviceMap = new HashedMap<>();
if (connectedServerNodes != null && connectedServerNodes.size() > 0) {
for (RpcProtocol rpcProtocol : connectedServerNodes.keySet()) {
for (RpcServiceInfo serviceInfo : rpcProtocol.getServiceInfoList()) {
... | 106 | 204 | 310 | <no_super_class> |
luxiaoxun_NettyRpc | NettyRpc/netty-rpc-client/src/main/java/com/netty/rpc/client/route/impl/RpcLoadBalanceConsistentHash.java | RpcLoadBalanceConsistentHash | route | class RpcLoadBalanceConsistentHash extends RpcLoadBalance {
public RpcProtocol doRoute(String serviceKey, List<RpcProtocol> addressList) {
int index = Hashing.consistentHash(serviceKey.hashCode(), addressList.size());
return addressList.get(index);
}
@Override
public RpcProtocol route(... |
Map<String, List<RpcProtocol>> serviceMap = getServiceMap(connectedServerNodes);
List<RpcProtocol> addressList = serviceMap.get(serviceKey);
if (addressList != null && addressList.size() > 0) {
return doRoute(serviceKey, addressList);
} else {
throw new Exception... | 125 | 102 | 227 | <methods>public non-sealed void <init>() ,public abstract com.netty.rpc.protocol.RpcProtocol route(java.lang.String, Map<com.netty.rpc.protocol.RpcProtocol,com.netty.rpc.client.handler.RpcClientHandler>) throws java.lang.Exception<variables> |
luxiaoxun_NettyRpc | NettyRpc/netty-rpc-client/src/main/java/com/netty/rpc/client/route/impl/RpcLoadBalanceLFU.java | RpcLoadBalanceLFU | doRoute | class RpcLoadBalanceLFU extends RpcLoadBalance {
private ConcurrentMap<String, HashMap<RpcProtocol, Integer>> jobLfuMap = new ConcurrentHashMap<String, HashMap<RpcProtocol, Integer>>();
private long CACHE_VALID_TIME = 0;
public RpcProtocol doRoute(String serviceKey, List<RpcProtocol> addressList) {<FILL_FU... |
// cache clear
if (System.currentTimeMillis() > CACHE_VALID_TIME) {
jobLfuMap.clear();
CACHE_VALID_TIME = System.currentTimeMillis() + 1000 * 60 * 60 * 24;
}
// lfu item init
HashMap<RpcProtocol, Integer> lfuItemMap = jobLfuMap.get(serviceKey);
i... | 248 | 574 | 822 | <methods>public non-sealed void <init>() ,public abstract com.netty.rpc.protocol.RpcProtocol route(java.lang.String, Map<com.netty.rpc.protocol.RpcProtocol,com.netty.rpc.client.handler.RpcClientHandler>) throws java.lang.Exception<variables> |
luxiaoxun_NettyRpc | NettyRpc/netty-rpc-client/src/main/java/com/netty/rpc/client/route/impl/RpcLoadBalanceLRU.java | RpcLoadBalanceLRU | removeEldestEntry | class RpcLoadBalanceLRU extends RpcLoadBalance {
private ConcurrentMap<String, LinkedHashMap<RpcProtocol, RpcProtocol>> jobLRUMap =
new ConcurrentHashMap<String, LinkedHashMap<RpcProtocol, RpcProtocol>>();
private long CACHE_VALID_TIME = 0;
public RpcProtocol doRoute(String serviceKey, List<Rpc... |
if (super.size() > 1000) {
return true;
} else {
return false;
}
| 820 | 36 | 856 | <methods>public non-sealed void <init>() ,public abstract com.netty.rpc.protocol.RpcProtocol route(java.lang.String, Map<com.netty.rpc.protocol.RpcProtocol,com.netty.rpc.client.handler.RpcClientHandler>) throws java.lang.Exception<variables> |
luxiaoxun_NettyRpc | NettyRpc/netty-rpc-client/src/main/java/com/netty/rpc/client/route/impl/RpcLoadBalanceRandom.java | RpcLoadBalanceRandom | route | class RpcLoadBalanceRandom extends RpcLoadBalance {
private Random random = new Random();
public RpcProtocol doRoute(List<RpcProtocol> addressList) {
int size = addressList.size();
// Random
return addressList.get(random.nextInt(size));
}
@Override
public RpcProtocol route(... |
Map<String, List<RpcProtocol>> serviceMap = getServiceMap(connectedServerNodes);
List<RpcProtocol> addressList = serviceMap.get(serviceKey);
if (addressList != null && addressList.size() > 0) {
return doRoute(addressList);
} else {
throw new Exception("Can not fi... | 125 | 99 | 224 | <methods>public non-sealed void <init>() ,public abstract com.netty.rpc.protocol.RpcProtocol route(java.lang.String, Map<com.netty.rpc.protocol.RpcProtocol,com.netty.rpc.client.handler.RpcClientHandler>) throws java.lang.Exception<variables> |
luxiaoxun_NettyRpc | NettyRpc/netty-rpc-client/src/main/java/com/netty/rpc/client/route/impl/RpcLoadBalanceRoundRobin.java | RpcLoadBalanceRoundRobin | route | class RpcLoadBalanceRoundRobin extends RpcLoadBalance {
private AtomicInteger roundRobin = new AtomicInteger(0);
public RpcProtocol doRoute(List<RpcProtocol> addressList) {
int size = addressList.size();
// Round robin
int index = (roundRobin.getAndAdd(1) + size) % size;
return ... |
Map<String, List<RpcProtocol>> serviceMap = getServiceMap(connectedServerNodes);
List<RpcProtocol> addressList = serviceMap.get(serviceKey);
if (addressList != null && addressList.size() > 0) {
return doRoute(addressList);
} else {
throw new Exception("Can not fi... | 155 | 99 | 254 | <methods>public non-sealed void <init>() ,public abstract com.netty.rpc.protocol.RpcProtocol route(java.lang.String, Map<com.netty.rpc.protocol.RpcProtocol,com.netty.rpc.client.handler.RpcClientHandler>) throws java.lang.Exception<variables> |
luxiaoxun_NettyRpc | NettyRpc/netty-rpc-common/src/main/java/com/netty/rpc/codec/RpcDecoder.java | RpcDecoder | decode | class RpcDecoder extends ByteToMessageDecoder {
private static final Logger logger = LoggerFactory.getLogger(RpcDecoder.class);
private Class<?> genericClass;
private Serializer serializer;
public RpcDecoder(Class<?> genericClass, Serializer serializer) {
this.genericClass = genericClass;
... |
if (in.readableBytes() < 4) {
return;
}
in.markReaderIndex();
int dataLength = in.readInt();
if (in.readableBytes() < dataLength) {
in.resetReaderIndex();
return;
}
byte[] data = new byte[dataLength];
in.readBytes(data)... | 145 | 157 | 302 | <no_super_class> |
luxiaoxun_NettyRpc | NettyRpc/netty-rpc-common/src/main/java/com/netty/rpc/codec/RpcEncoder.java | RpcEncoder | encode | class RpcEncoder extends MessageToByteEncoder {
private static final Logger logger = LoggerFactory.getLogger(RpcEncoder.class);
private Class<?> genericClass;
private Serializer serializer;
public RpcEncoder(Class<?> genericClass, Serializer serializer) {
this.genericClass = genericClass;
... |
if (genericClass.isInstance(in)) {
try {
byte[] data = serializer.serialize(in);
out.writeInt(data.length);
out.writeBytes(data);
} catch (Exception ex) {
logger.error("Encode error: " + ex.toString());
}
... | 139 | 85 | 224 | <no_super_class> |
luxiaoxun_NettyRpc | NettyRpc/netty-rpc-common/src/main/java/com/netty/rpc/protocol/RpcProtocol.java | RpcProtocol | isListEquals | class RpcProtocol implements Serializable {
private static final long serialVersionUID = -1102180003395190700L;
// service host
private String host;
// service port
private int port;
// service info list
private List<RpcServiceInfo> serviceInfoList;
public String toJson() {
Stri... |
if (thisList == null && thatList == null) {
return true;
}
if ((thisList == null && thatList != null)
|| (thisList != null && thatList == null)
|| (thisList.size() != thatList.size())) {
return false;
}
return thisList.cont... | 499 | 103 | 602 | <no_super_class> |
luxiaoxun_NettyRpc | NettyRpc/netty-rpc-common/src/main/java/com/netty/rpc/protocol/RpcServiceInfo.java | RpcServiceInfo | equals | class RpcServiceInfo implements Serializable {
// interface name
private String serviceName;
// service version
private String version;
public String getServiceName() {
return serviceName;
}
public void setServiceName(String serviceName) {
this.serviceName = serviceName;
... |
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
RpcServiceInfo that = (RpcServiceInfo) o;
return Objects.equals(serviceName, that.serviceName) &&
Objects.equals(version, that.version);
| 230 | 81 | 311 | <no_super_class> |
luxiaoxun_NettyRpc | NettyRpc/netty-rpc-common/src/main/java/com/netty/rpc/serializer/hessian/Hessian1Serializer.java | Hessian1Serializer | serialize | class Hessian1Serializer extends Serializer {
@Override
public <T> byte[] serialize(T obj) {<FILL_FUNCTION_BODY>}
@Override
public <T> Object deserialize(byte[] bytes, Class<T> clazz) {
ByteArrayInputStream is = new ByteArrayInputStream(bytes);
HessianInput hi = new HessianInput(is);
... |
ByteArrayOutputStream os = new ByteArrayOutputStream();
HessianOutput ho = new HessianOutput(os);
try {
ho.writeObject(obj);
ho.flush();
byte[] result = os.toByteArray();
return result;
} catch (IOException e) {
throw new Runti... | 214 | 155 | 369 | <methods>public non-sealed void <init>() ,public abstract java.lang.Object deserialize(byte[], Class<T>) ,public abstract byte[] serialize(T) <variables> |
luxiaoxun_NettyRpc | NettyRpc/netty-rpc-common/src/main/java/com/netty/rpc/serializer/hessian/HessianSerializer.java | HessianSerializer | deserialize | class HessianSerializer extends Serializer {
@Override
public <T> byte[] serialize(T obj) {
ByteArrayOutputStream os = new ByteArrayOutputStream();
Hessian2Output ho = new Hessian2Output(os);
try {
ho.writeObject(obj);
ho.flush();
byte[] result = os.t... |
ByteArrayInputStream is = new ByteArrayInputStream(bytes);
Hessian2Input hi = new Hessian2Input(is);
try {
Object result = hi.readObject();
return result;
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
try {
... | 231 | 142 | 373 | <methods>public non-sealed void <init>() ,public abstract java.lang.Object deserialize(byte[], Class<T>) ,public abstract byte[] serialize(T) <variables> |
luxiaoxun_NettyRpc | NettyRpc/netty-rpc-common/src/main/java/com/netty/rpc/serializer/kryo/KryoPoolFactory.java | KryoPoolFactory | create | class KryoPoolFactory {
private static volatile KryoPoolFactory poolFactory = null;
private KryoFactory factory = new KryoFactory() {
@Override
public Kryo create() {<FILL_FUNCTION_BODY>}
};
private KryoPool pool = new KryoPool.Builder(factory).build();
private KryoPoolFactory() {... |
Kryo kryo = new Kryo();
kryo.setReferences(false);
kryo.register(RpcRequest.class);
kryo.register(RpcResponse.class);
Kryo.DefaultInstantiatorStrategy strategy = (Kryo.DefaultInstantiatorStrategy) kryo.getInstantiatorStrategy();
strategy.setFallba... | 210 | 119 | 329 | <no_super_class> |
luxiaoxun_NettyRpc | NettyRpc/netty-rpc-common/src/main/java/com/netty/rpc/serializer/kryo/KryoSerializer.java | KryoSerializer | deserialize | class KryoSerializer extends Serializer {
private KryoPool pool = KryoPoolFactory.getKryoPoolInstance();
@Override
public <T> byte[] serialize(T obj) {
Kryo kryo = pool.borrow();
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
Output out = new Output(byteA... |
Kryo kryo = pool.borrow();
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(bytes);
Input in = new Input(byteArrayInputStream);
try {
Object result = kryo.readObject(in, clazz);
in.close();
return result;
} catch (Exception... | 240 | 146 | 386 | <methods>public non-sealed void <init>() ,public abstract java.lang.Object deserialize(byte[], Class<T>) ,public abstract byte[] serialize(T) <variables> |
luxiaoxun_NettyRpc | NettyRpc/netty-rpc-common/src/main/java/com/netty/rpc/serializer/protostuff/ProtostuffSerializer.java | ProtostuffSerializer | deserialize | class ProtostuffSerializer extends Serializer {
private Map<Class<?>, Schema<?>> cachedSchema = new ConcurrentHashMap<>();
private Objenesis objenesis = new ObjenesisStd(true);
@SuppressWarnings("unchecked")
private <T> Schema<T> getSchema(Class<T> cls) {
// for thread-safe
return (Sch... |
try {
T message = (T) objenesis.newInstance(clazz);
Schema<T> schema = getSchema(clazz);
ProtostuffIOUtil.mergeFrom(bytes, message, schema);
return message;
} catch (Exception e) {
throw new IllegalStateException(e.getMessage(), e);
}
... | 311 | 89 | 400 | <methods>public non-sealed void <init>() ,public abstract java.lang.Object deserialize(byte[], Class<T>) ,public abstract byte[] serialize(T) <variables> |
luxiaoxun_NettyRpc | NettyRpc/netty-rpc-common/src/main/java/com/netty/rpc/util/JsonUtil.java | JsonUtil | jsonToObjectHashMap | class JsonUtil {
private static ObjectMapper objMapper = new ObjectMapper();
static {
SimpleDateFormat dateFormat = new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss");
objMapper.setDateFormat(dateFormat);
objMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
... |
type obj = null;
JavaType javaType = objMapper.getTypeFactory().constructParametricType(HashMap.class, keyClass, valueClass);
try {
obj = objMapper.readValue(json, javaType);
} catch (IOException e) {
throw new IllegalStateException(e.getMessage(), e);
}
... | 790 | 91 | 881 | <no_super_class> |
luxiaoxun_NettyRpc | NettyRpc/netty-rpc-common/src/main/java/com/netty/rpc/util/SerializationUtil.java | SerializationUtil | serialize | class SerializationUtil {
private static Map<Class<?>, Schema<?>> cachedSchema = new ConcurrentHashMap<>();
private static Objenesis objenesis = new ObjenesisStd(true);
private SerializationUtil() {
}
@SuppressWarnings("unchecked")
private static <T> Schema<T> getSchema(Class<T> cls) {
// ... |
Class<T> cls = (Class<T>) obj.getClass();
LinkedBuffer buffer = LinkedBuffer.allocate(LinkedBuffer.DEFAULT_BUFFER_SIZE);
try {
Schema<T> schema = getSchema(cls);
return ProtostuffIOUtil.toByteArray(obj, schema, buffer);
} catch (Exception e) {
throw n... | 428 | 121 | 549 | <no_super_class> |
luxiaoxun_NettyRpc | NettyRpc/netty-rpc-common/src/main/java/com/netty/rpc/util/ServiceUtil.java | ServiceUtil | makeServiceKey | class ServiceUtil {
public static final String SERVICE_CONCAT_TOKEN = "#";
public static String makeServiceKey(String interfaceName, String version) {<FILL_FUNCTION_BODY>}
} |
String serviceKey = interfaceName;
if (version != null && version.trim().length() > 0) {
serviceKey += SERVICE_CONCAT_TOKEN.concat(version);
}
return serviceKey;
| 55 | 59 | 114 | <no_super_class> |
luxiaoxun_NettyRpc | NettyRpc/netty-rpc-common/src/main/java/com/netty/rpc/util/ThreadPoolUtil.java | ThreadPoolUtil | newThread | class ThreadPoolUtil {
public static ThreadPoolExecutor createThreadPool(final String name, int corePoolSize, int maxPoolSize) {
ThreadPoolExecutor serverHandlerPool = new ThreadPoolExecutor(
corePoolSize,
maxPoolSize,
60L,
TimeUnit.SECONDS,
... |
return new Thread(r, "netty-rpc-" + name + "-" + r.hashCode());
| 150 | 29 | 179 | <no_super_class> |
luxiaoxun_NettyRpc | NettyRpc/netty-rpc-common/src/main/java/com/netty/rpc/zookeeper/CuratorClient.java | CuratorClient | watchPathChildrenNode | class CuratorClient {
private CuratorFramework client;
public CuratorClient(String connectString, String namespace, int sessionTimeout, int connectionTimeout) {
client = CuratorFrameworkFactory.builder().namespace(namespace).connectString(connectString)
.sessionTimeoutMs(sessionTimeout)... |
PathChildrenCache pathChildrenCache = new PathChildrenCache(client, path, true);
//BUILD_INITIAL_CACHE 代表使用同步的方式进行缓存初始化。
pathChildrenCache.start(PathChildrenCache.StartMode.BUILD_INITIAL_CACHE);
pathChildrenCache.getListenable().addListener(listener);
| 606 | 91 | 697 | <no_super_class> |
luxiaoxun_NettyRpc | NettyRpc/netty-rpc-server/src/main/java/com/netty/rpc/server/RpcServer.java | RpcServer | setApplicationContext | class RpcServer extends NettyServer implements ApplicationContextAware, InitializingBean, DisposableBean {
public RpcServer(String serverAddress, String registryAddress) {
super(serverAddress, registryAddress);
}
@Override
public void setApplicationContext(ApplicationContext ctx) throws BeansEx... |
Map<String, Object> serviceBeanMap = ctx.getBeansWithAnnotation(NettyRpcService.class);
if (MapUtils.isNotEmpty(serviceBeanMap)) {
for (Object serviceBean : serviceBeanMap.values()) {
NettyRpcService nettyRpcService = serviceBean.getClass().getAnnotation(NettyRpcService.clas... | 135 | 142 | 277 | <methods>public void <init>(java.lang.String, java.lang.String) ,public void addService(java.lang.String, java.lang.String, java.lang.Object) ,public void start() ,public void stop() <variables>private static final Logger logger,private java.lang.String serverAddress,private Map<java.lang.String,java.lang.Object> servi... |
luxiaoxun_NettyRpc | NettyRpc/netty-rpc-server/src/main/java/com/netty/rpc/server/core/NettyServer.java | NettyServer | start | class NettyServer extends Server {
private static final Logger logger = LoggerFactory.getLogger(NettyServer.class);
private Thread thread;
private String serverAddress;
private ServiceRegistry serviceRegistry;
private Map<String, Object> serviceMap = new HashMap<>();
public NettyServer(String ... |
thread = new Thread(new Runnable() {
ThreadPoolExecutor threadPoolExecutor = ThreadPoolUtil.createThreadPool(
NettyServer.class.getSimpleName(), 16, 32);
@Override
public void run() {
EventLoopGroup bossGroup = new NioEventLoopGroup();
... | 263 | 438 | 701 | <methods>public non-sealed void <init>() ,public abstract void start() throws java.lang.Exception,public abstract void stop() throws java.lang.Exception<variables> |
luxiaoxun_NettyRpc | NettyRpc/netty-rpc-server/src/main/java/com/netty/rpc/server/core/RpcServerHandler.java | RpcServerHandler | run | class RpcServerHandler extends SimpleChannelInboundHandler<RpcRequest> {
private static final Logger logger = LoggerFactory.getLogger(RpcServerHandler.class);
private final Map<String, Object> handlerMap;
private final ThreadPoolExecutor serverHandlerPool;
public RpcServerHandler(Map<String, Object> ... |
logger.info("Receive request " + request.getRequestId());
RpcResponse response = new RpcResponse();
response.setRequestId(request.getRequestId());
try {
Object result = handle(request);
response.setResult(result);
... | 800 | 169 | 969 | <no_super_class> |
luxiaoxun_NettyRpc | NettyRpc/netty-rpc-server/src/main/java/com/netty/rpc/server/core/RpcServerInitializer.java | RpcServerInitializer | initChannel | class RpcServerInitializer extends ChannelInitializer<SocketChannel> {
private Map<String, Object> handlerMap;
private ThreadPoolExecutor threadPoolExecutor;
public RpcServerInitializer(Map<String, Object> handlerMap, ThreadPoolExecutor threadPoolExecutor) {
this.handlerMap = handlerMap;
th... |
// Serializer serializer = ProtostuffSerializer.class.newInstance();
// Serializer serializer = HessianSerializer.class.newInstance();
Serializer serializer = KryoSerializer.class.newInstance();
ChannelPipeline cp = channel.pipeline();
cp.addLast(new IdleStateHandler(0, 0, Beat.BE... | 123 | 200 | 323 | <no_super_class> |
luxiaoxun_NettyRpc | NettyRpc/netty-rpc-server/src/main/java/com/netty/rpc/server/registry/ServiceRegistry.java | ServiceRegistry | registerService | class ServiceRegistry {
private static final Logger logger = LoggerFactory.getLogger(ServiceRegistry.class);
private CuratorClient curatorClient;
private List<String> pathList = new ArrayList<>();
public ServiceRegistry(String registryAddress) {
this.curatorClient = new CuratorClient(registryA... |
// Register service info
List<RpcServiceInfo> serviceInfoList = new ArrayList<>();
for (String key : serviceMap.keySet()) {
String[] serviceInfo = key.split(ServiceUtil.SERVICE_CONCAT_TOKEN);
if (serviceInfo.length > 0) {
RpcServiceInfo rpcServiceInfo = n... | 221 | 499 | 720 | <no_super_class> |
LibrePDF_OpenPDF | OpenPDF/openpdf/src/main/java/com/lowagie/bouncycastle/BouncyCastleHelper.java | BouncyCastleHelper | getEnvelopedData | class BouncyCastleHelper {
public static void checkCertificateEncodingOrThrowException(Certificate certificate) {
// OJO...
try {
new X509CertificateHolder(certificate.getEncoded());
} catch (CertificateEncodingException | IOException f) {
throw new ExceptionConverte... |
byte[] envelopedData = null;
for (PdfObject recipient : recipients.getElements()) {
strings.remove(recipient);
try {
CMSEnvelopedData data = new CMSEnvelopedData(recipient.getBytes());
final Collection<RecipientInformation> recipientInformations ... | 161 | 288 | 449 | <no_super_class> |
LibrePDF_OpenPDF | OpenPDF/openpdf/src/main/java/com/lowagie/text/Anchor.java | Anchor | getUrl | class Anchor extends Phrase {
// constant
private static final long serialVersionUID = -852278536049236911L;
// membervariables
/**
* This is the name of the <CODE>Anchor</CODE>.
*/
protected String name = null;
/**
* This is the reference of the <CODE>Anchor</CODE>.
*/
... |
try {
return new URL(reference);
} catch (MalformedURLException mue) {
return null;
}
| 1,769 | 36 | 1,805 | <methods>public void <init>() ,public void <init>(com.lowagie.text.Phrase) ,public void <init>(float) ,public void <init>(com.lowagie.text.Chunk) ,public void <init>(float, com.lowagie.text.Chunk) ,public void <init>(java.lang.String) ,public void <init>(java.lang.String, com.lowagie.text.Font) ,public void <init>(floa... |
LibrePDF_OpenPDF | OpenPDF/openpdf/src/main/java/com/lowagie/text/ChapterAutoNumber.java | ChapterAutoNumber | addSection | class ChapterAutoNumber extends Chapter {
// constant
private static final long serialVersionUID = -9217457637987854167L;
/**
* Is the chapter number already set?
*
* @since 2.1.4
*/
protected boolean numberSet = false;
/**
* Create a new object.
*
* @param para... |
if (isAddedCompletely()) {
throw new IllegalStateException(
MessageLocalization.getComposedMessage("this.largeelement.has.already.been.added.to.the.document"));
}
return addSection(title, 2);
| 532 | 66 | 598 | <methods>public void <init>(int) ,public void <init>(com.lowagie.text.Paragraph, int) ,public void <init>(java.lang.String, int) ,public boolean isNestable() ,public int type() <variables>private static final long serialVersionUID |
LibrePDF_OpenPDF | OpenPDF/openpdf/src/main/java/com/lowagie/text/ExceptionConverter.java | ExceptionConverter | convertException | class ExceptionConverter extends RuntimeException {
private static final long serialVersionUID = 8657630363395849399L;
/**
* we keep a handle to the wrapped exception
*/
private Exception ex;
/**
* prefix for the exception
*/
private String prefix;
/**
* Construct a Ru... |
if (ex instanceof RuntimeException) {
return (RuntimeException) ex;
}
return new ExceptionConverter(ex);
| 775 | 34 | 809 | <methods>public void <init>() ,public void <init>(java.lang.String) ,public void <init>(java.lang.Throwable) ,public void <init>(java.lang.String, java.lang.Throwable) <variables>static final long serialVersionUID |
LibrePDF_OpenPDF | OpenPDF/openpdf/src/main/java/com/lowagie/text/GreekList.java | GreekList | add | class GreekList extends List {
// constructors
/**
* Initialization
*/
public GreekList() {
super(true);
setGreekFont();
}
/**
* Initialization
*
* @param symbolIndent indent
*/
public GreekList(int symbolIndent) {
super(true, symbolIndent... |
if (o instanceof ListItem) {
ListItem item = (ListItem) o;
Chunk chunk = new Chunk(preSymbol, symbol.getFont());
chunk.append(GreekAlphabetFactory.getString(first + list.size(), lowercase));
chunk.append(postSymbol);
item.setListSymbol(chunk);
... | 452 | 191 | 643 | <methods>public void <init>() ,public void <init>(float) ,public void <init>(boolean) ,public void <init>(boolean, boolean) ,public void <init>(boolean, float) ,public void <init>(boolean, boolean, float) ,public boolean add(com.lowagie.text.Element) ,public boolean add(com.lowagie.text.List) ,public boolean add(java.l... |
LibrePDF_OpenPDF | OpenPDF/openpdf/src/main/java/com/lowagie/text/HeaderFooter.java | HeaderFooter | paragraph | class HeaderFooter extends Rectangle {
// membervariables
/**
* Does the page contain a pagenumber?
*/
private boolean numbered;
/**
* This is the <CODE>Phrase</CODE> that comes before the pagenumber.
*/
private Phrase before = null;
/**
* This is number of the page.... |
Paragraph paragraph;
if (before != null) {
paragraph = new Paragraph(before.getLeading());
paragraph.add(before);
// Adding a Paragraph to another Paraghraph adds a newline that needs to be removed in headers and footers
if (before instanceof Paragraph
... | 1,566 | 267 | 1,833 | <methods>public void <init>(float, float, float, float) ,public void <init>(float, float) ,public void <init>(float, float, float, float, int) ,public void <init>(float, float, int) ,public void <init>(com.lowagie.text.Rectangle) ,public void cloneNonPositionParameters(com.lowagie.text.Rectangle) ,public void disableBo... |
LibrePDF_OpenPDF | OpenPDF/openpdf/src/main/java/com/lowagie/text/ImageLoader.java | ImageLoader | getPngImage | class ImageLoader {
/**
* Creates an Image from a PNG image file in an URL.
*
* @param url url of the image
* @return an object of type <code>Image</code>
*/
public static Image getPngImage(URL url) {<FILL_FUNCTION_BODY>}
public static Image getGifImage(URL url) {
try (Inp... |
try (InputStream is = url.openStream()) {
BufferedImage bufferedImage = ImageIO.read(is);
return Image.getInstance(bufferedImage, null, false);
} catch (Exception e) {
throw new ExceptionConverter(e);
}
| 1,142 | 68 | 1,210 | <no_super_class> |
LibrePDF_OpenPDF | OpenPDF/openpdf/src/main/java/com/lowagie/text/ImgWMF.java | ImgWMF | readWMF | class ImgWMF extends Image {
// Constructors
ImgWMF(Image image) {
super(image);
}
/**
* Constructs an <CODE>ImgWMF</CODE>-object, using an <VAR>url</VAR>.
*
* @param url the <CODE>URL</CODE> where the image can be found
* @throws BadElementException on error
* @throw... |
setTemplateData(template);
template.setWidth(getWidth());
template.setHeight(getHeight());
InputStream is = null;
try {
if (rawData == null) {
is = url.openStream();
} else {
is = new java.io.ByteArrayInputStream(rawData);
... | 894 | 136 | 1,030 | <methods>public void <init>(java.net.URL) ,public float getAbsoluteX() ,public float getAbsoluteY() ,public com.lowagie.text.pdf.PdfDictionary getAdditional() ,public int getAlignment() ,public java.lang.String getAlt() ,public com.lowagie.text.Annotation getAnnotation() ,public int getBpc() ,public int getColorspace()... |
LibrePDF_OpenPDF | OpenPDF/openpdf/src/main/java/com/lowagie/text/Jpeg2000.java | Jpeg2000 | processParameters | class Jpeg2000 extends Image {
// public static final membervariables
public static final int JP2_JP = 0x6a502020;
public static final int JP2_IHDR = 0x69686472;
public static final int JPIP_JPIP = 0x6a706970;
public static final int JP2_FTYP = 0x66747970;
public static final int JP2_JP2H = 0... |
type = JPEG2000;
originalType = ORIGINAL_JPEG2000;
inp = null;
try {
String errorID;
if (rawData == null) {
inp = url.openStream();
errorID = url.toString();
} else {
inp = new java.io.ByteArrayInputStre... | 1,053 | 817 | 1,870 | <methods>public void <init>(java.net.URL) ,public float getAbsoluteX() ,public float getAbsoluteY() ,public com.lowagie.text.pdf.PdfDictionary getAdditional() ,public int getAlignment() ,public java.lang.String getAlt() ,public com.lowagie.text.Annotation getAnnotation() ,public int getBpc() ,public int getColorspace()... |
LibrePDF_OpenPDF | OpenPDF/openpdf/src/main/java/com/lowagie/text/ListItem.java | ListItem | setIndentationLeft | class ListItem extends Paragraph {
// constants
private static final long serialVersionUID = 1970670787169329006L;
// member variables
/**
* this is the symbol that will precede the listitem.
*
* @since 5.0 used to be private
*/
protected Chunk symbol;
// constructors
... |
if (autoindent) {
setIndentationLeft(getListSymbol().getWidthPoint());
} else {
setIndentationLeft(indentation);
}
| 1,155 | 46 | 1,201 | <methods>public void <init>() ,public void <init>(float) ,public void <init>(com.lowagie.text.Chunk) ,public void <init>(float, com.lowagie.text.Chunk) ,public void <init>(java.lang.String) ,public void <init>(java.lang.String, com.lowagie.text.Font) ,public void <init>(float, java.lang.String) ,public void <init>(floa... |
LibrePDF_OpenPDF | OpenPDF/openpdf/src/main/java/com/lowagie/text/MarkedObject.java | MarkedObject | process | class MarkedObject implements Element {
/**
* The element that is wrapped in a MarkedObject.
*/
protected Element element;
/**
* Contains extra markupAttributes
*/
protected Properties markupAttributes = new Properties();
/**
* This constructor is for internal use only.
... |
try {
return listener.add(element);
} catch (DocumentException de) {
return false;
}
| 595 | 34 | 629 | <no_super_class> |
LibrePDF_OpenPDF | OpenPDF/openpdf/src/main/java/com/lowagie/text/Meta.java | Meta | process | class Meta implements Element {
// membervariables
/**
* This is the type of Meta-information this object contains.
*/
private int type;
/**
* This is the content of the Meta-information.
*/
private StringBuffer content;
// constructors
/**
* Constructs a <CODE>... |
try {
return listener.add(this);
} catch (DocumentException de) {
return false;
}
| 1,143 | 34 | 1,177 | <no_super_class> |
LibrePDF_OpenPDF | OpenPDF/openpdf/src/main/java/com/lowagie/text/RomanList.java | RomanList | add | class RomanList extends List {
// constructors
/**
* Initialization
*/
public RomanList() {
super(true);
}
/**
* Initialization
*
* @param symbolIndent indent
*/
public RomanList(int symbolIndent) {
super(true, symbolIndent);
}
/**
*... |
if (o instanceof ListItem) {
ListItem item = (ListItem) o;
Chunk chunk;
chunk = new Chunk(preSymbol, symbol.getFont());
chunk.append(RomanNumberFactory.getString(first + list.size(), lowercase));
chunk.append(postSymbol);
item.setListSymbo... | 351 | 194 | 545 | <methods>public void <init>() ,public void <init>(float) ,public void <init>(boolean) ,public void <init>(boolean, boolean) ,public void <init>(boolean, float) ,public void <init>(boolean, boolean, float) ,public boolean add(com.lowagie.text.Element) ,public boolean add(com.lowagie.text.List) ,public boolean add(java.l... |
LibrePDF_OpenPDF | OpenPDF/openpdf/src/main/java/com/lowagie/text/SpecialSymbol.java | SpecialSymbol | getCorrespondingSymbol | class SpecialSymbol {
/**
* Returns the first occurrence of a special symbol in a <CODE>String</CODE>.
*
* @param string a <CODE>String</CODE>
* @return an index of -1 if no special symbol was found
*/
public static int index(String string) {
int length = string.length();
... |
switch (c) {
case 913:
return 'A'; // ALFA
case 914:
return 'B'; // BETA
case 915:
return 'G'; // GAMMA
case 916:
return 'D'; // DELTA
case 917:
return 'E'; // EPSILON
... | 411 | 864 | 1,275 | <no_super_class> |
LibrePDF_OpenPDF | OpenPDF/openpdf/src/main/java/com/lowagie/text/ZapfDingbatsList.java | ZapfDingbatsList | add | class ZapfDingbatsList extends List {
/**
* char-number in zapfdingbats
*/
protected int zn;
/**
* Creates a ZapfDingbatsList
*
* @param zn a char-number
*/
public ZapfDingbatsList(int zn) {
super(true);
this.zn = zn;
float fontsize = symbol.getFon... |
if (o instanceof ListItem) {
ListItem item = (ListItem) o;
Chunk chunk = new Chunk(preSymbol, symbol.getFont());
chunk.append(String.valueOf((char) zn));
chunk.append(postSymbol);
item.setListSymbol(chunk);
item.setIndentationLeft(symbolIn... | 582 | 184 | 766 | <methods>public void <init>() ,public void <init>(float) ,public void <init>(boolean) ,public void <init>(boolean, boolean) ,public void <init>(boolean, float) ,public void <init>(boolean, boolean, float) ,public boolean add(com.lowagie.text.Element) ,public boolean add(com.lowagie.text.List) ,public boolean add(java.l... |
LibrePDF_OpenPDF | OpenPDF/openpdf/src/main/java/com/lowagie/text/ZapfDingbatsNumberList.java | ZapfDingbatsNumberList | add | class ZapfDingbatsNumberList extends List {
/**
* which type
*/
protected int type;
/**
* Creates a ZapdDingbatsNumberList
*
* @param type the type of list
*/
public ZapfDingbatsNumberList(int type) {
super(true);
this.type = type;
float fontsize =... |
if (o instanceof ListItem) {
ListItem item = (ListItem) o;
Chunk chunk = new Chunk(preSymbol, symbol.getFont());
switch (type) {
case 0:
chunk.append(String.valueOf((char) (first + list.size() + 171)));
break;
... | 568 | 312 | 880 | <methods>public void <init>() ,public void <init>(float) ,public void <init>(boolean) ,public void <init>(boolean, boolean) ,public void <init>(boolean, float) ,public void <init>(boolean, boolean, float) ,public boolean add(com.lowagie.text.Element) ,public boolean add(com.lowagie.text.List) ,public boolean add(java.l... |
LibrePDF_OpenPDF | OpenPDF/openpdf/src/main/java/com/lowagie/text/error_messages/MessageLocalization.java | MessageLocalization | getLanguageMessages | class MessageLocalization {
private static final String BASE_PATH = "com/lowagie/text/error_messages/";
private static Map<String, String> defaultLanguage = new HashMap<>();
private static Map<String, String> currentLanguage;
static {
try {
defaultLanguage = getLanguageMessages("en... |
if (language == null) {
throw new IllegalArgumentException("The language cannot be null.");
}
InputStream is = null;
try {
String file;
if (country != null) {
file = language + "_" + country + ".lng";
} else {
... | 1,651 | 271 | 1,922 | <no_super_class> |
LibrePDF_OpenPDF | OpenPDF/openpdf/src/main/java/com/lowagie/text/factories/GreekAlphabetFactory.java | GreekAlphabetFactory | getString | class GreekAlphabetFactory {
/**
* Changes an int into a lower case Greek letter combination.
*
* @param index the original number
* @return the letter combination
*/
public static final String getString(int index) {
return getString(index, true);
}
/**
* Changes ... |
if (index < 1) {
return "";
}
index--;
int bytes = 1;
int start = 0;
int symbols = 24;
while (index >= symbols + start) {
bytes++;
start += symbols;
symbols *= 24;
}
int c = index - start;
... | 305 | 220 | 525 | <no_super_class> |
LibrePDF_OpenPDF | OpenPDF/openpdf/src/main/java/com/lowagie/text/factories/RomanAlphabetFactory.java | RomanAlphabetFactory | getString | class RomanAlphabetFactory {
/**
* Translates a positive integer (not equal to zero) into a String using the letters 'a' to 'z'; 1 = a, 2 = b, ...,
* 26 = z, 27 = aa, 28 = ab,...
*
* @param index the integer to translate
* @return the lowercase String representing the integer
*/
p... |
if (index < 1) {
throw new NumberFormatException(MessageLocalization.getComposedMessage(
"you.can.t.translate.a.negative.number.into.an.alphabetical.value"));
}
index--;
int bytes = 1;
int start = 0;
int symbols = 26;
while (index... | 541 | 192 | 733 | <no_super_class> |
LibrePDF_OpenPDF | OpenPDF/openpdf/src/main/java/com/lowagie/text/factories/RomanNumberFactory.java | RomanNumberFactory | getString | class RomanNumberFactory {
/**
* Array with Roman digits.
*/
private static final RomanDigit[] roman = {
new RomanDigit('m', 1000, false),
new RomanDigit('d', 500, false),
new RomanDigit('c', 100, true),
new RomanDigit('l', 50, false),
new R... |
StringBuilder buf = new StringBuilder();
// lower than 0 ? Add minus
if (index < 0) {
buf.append('-');
index = -index;
}
// greater than 3000
if (index > 3000) {
buf.append('|');
buf.append(getString(index / 1000));
... | 666 | 391 | 1,057 | <no_super_class> |
LibrePDF_OpenPDF | OpenPDF/openpdf/src/main/java/com/lowagie/text/html/HtmlEncoder.java | HtmlEncoder | encode | class HtmlEncoder {
// membervariables
/**
* List with the HTML translation of all the characters.
*/
private static final String[] htmlCode = new String[256];
static {
for (int i = 0; i < 10; i++) {
htmlCode[i] = "�" + i + ";";
}
for (int i = 10; i <... |
int n = string.length();
char character;
StringBuilder buffer = new StringBuilder();
// loop over all the characters of the String.
for (int i = 0; i < n; i++) {
character = string.charAt(i);
// the Htmlcode of these characters are added to a StringBuffer... | 1,022 | 158 | 1,180 | <no_super_class> |
LibrePDF_OpenPDF | OpenPDF/openpdf/src/main/java/com/lowagie/text/html/HtmlParser.java | HtmlParser | go | class HtmlParser extends XmlParser {
/**
* Parses a given file that validates with the iText DTD and writes the content to a document.
*
* @param document the document the parser will write to
* @param is the InputSource with the content
*/
public static void parse(DocListener d... |
try {
parser.parse(is, new SAXmyHtmlHandler(document));
} catch (SAXException | IOException se) {
throw new ExceptionConverter(se);
}
| 846 | 49 | 895 | <methods>public void <init>() ,public void go(com.lowagie.text.DocListener, org.xml.sax.InputSource) ,public void go(com.lowagie.text.DocListener, org.xml.sax.InputSource, java.lang.String) ,public void go(com.lowagie.text.DocListener, org.xml.sax.InputSource, java.io.InputStream) ,public void go(com.lowagie.text.DocLi... |
LibrePDF_OpenPDF | OpenPDF/openpdf/src/main/java/com/lowagie/text/html/HtmlPeer.java | HtmlPeer | getAttributes | class HtmlPeer extends XmlPeer {
/**
* Creates a XmlPeer.
*
* @param name the iText name of the tag
* @param alias the Html name of the tag
*/
public HtmlPeer(String name, String alias) {
super(name, alias.toLowerCase());
}
/**
* Sets an alias for an attribute.
... |
Properties attributes = new Properties();
attributes.putAll(attributeValues);
if (defaultContent != null) {
attributes.put(ElementTags.ITEXT, defaultContent);
}
if (attrs != null) {
String attribute, value;
for (int i = 0; i < attrs.getLength(... | 232 | 142 | 374 | <methods>public void <init>(java.lang.String, java.lang.String) ,public void addAlias(java.lang.String, java.lang.String) ,public void addValue(java.lang.String, java.lang.String) ,public java.lang.String getAlias() ,public java.util.Properties getAttributes(org.xml.sax.Attributes) ,public java.util.Properties getDefau... |
LibrePDF_OpenPDF | OpenPDF/openpdf/src/main/java/com/lowagie/text/html/SAXmyHtmlHandler.java | SAXmyHtmlHandler | startElement | class SAXmyHtmlHandler extends SAXiTextHandler<HtmlPeer> {
// SAXmyHandler
/**
* These are the properties of the body section.
*/
private final Properties bodyAttributes = new Properties();
/**
* This is the status of the table border.
*/
private boolean tableBorder = false;
/... |
// super.handleStartingTags is replaced with handleStartingTags
// suggestion by Vu Ngoc Tan/Hop
String lowerCaseName = name.toLowerCase();
if (HtmlTagMap.isHtml(lowerCaseName)) {
// we do nothing
return;
}
if (HtmlTagMap.isHead(lowerCaseName)) {
... | 1,072 | 966 | 2,038 | <methods>public void <init>(com.lowagie.text.DocListener) ,public void <init>(com.lowagie.text.DocListener, Map<java.lang.String,com.lowagie.text.html.HtmlPeer>, com.lowagie.text.pdf.BaseFont) ,public void <init>(com.lowagie.text.DocListener, Map<java.lang.String,com.lowagie.text.html.HtmlPeer>) ,public void characters... |
LibrePDF_OpenPDF | OpenPDF/openpdf/src/main/java/com/lowagie/text/html/simpleparser/ChainedProperties.java | ChainedProperties | addToChain | class ChainedProperties {
public final static int[] fontSizes = {8, 10, 12, 14, 18, 24, 36};
/**
* Will be replaced with types alternative
*/
public ArrayList<Object[]> chain = new ArrayList<>();
/**
* Creates a new instance of ChainedProperties
*/
public ChainedProperties() {... |
// adjust the font size
String value = prop.get(ElementTags.SIZE);
if (value != null) {
if (value.endsWith("pt")) {
prop.put(ElementTags.SIZE, value.substring(0,
value.length() - 2));
} else {
int s = 0;
... | 621 | 373 | 994 | <no_super_class> |
LibrePDF_OpenPDF | OpenPDF/openpdf/src/main/java/com/lowagie/text/html/simpleparser/IncTable.java | IncTable | addCol | class IncTable {
private Map<String, String> props = new HashMap<>();
private List<List<PdfPCell>> rows = new ArrayList<>();
private List<PdfPCell> cols;
public IncTable(Map<String, String> props) {
this.props.putAll(props);
}
public void addCol(PdfPCell cell) {<FILL_FUNCTION_BODY>}
... |
if (cols == null) {
cols = new ArrayList<>();
}
cols.add(cell);
| 522 | 34 | 556 | <no_super_class> |
LibrePDF_OpenPDF | OpenPDF/openpdf/src/main/java/com/lowagie/text/html/simpleparser/StyleSheet.java | StyleSheet | applyStyle | class StyleSheet {
private final Map<String, Map<String, String>> classMap = new HashMap<>();
private final Map<String, Map<String, String>> tagMap = new HashMap<>();
public void applyStyle(String tag, Map<String, String> props) {<FILL_FUNCTION_BODY>}
public void loadStyle(String style, Map<String, S... |
Map<String, String> map = tagMap.get(tag.toLowerCase());
if (map != null) {
Map<String, String> temp = new HashMap<>(map);
temp.putAll(props);
props.putAll(temp);
}
String cm = props.get(Markup.HTML_ATTR_CSS_CLASS);
if (cm == null) {
... | 302 | 193 | 495 | <no_super_class> |
LibrePDF_OpenPDF | OpenPDF/openpdf/src/main/java/com/lowagie/text/pdf/AsianFontMapper.java | AsianFontMapper | awtToPdf | class AsianFontMapper extends DefaultFontMapper {
public static final String ChineseSimplifiedFont = "STSong-Light";
public static final String ChineseSimplifiedEncoding_H = "UniGB-UCS2-H";
public static final String ChineseSimplifiedEncoding_V = "UniGB-UCS2-V";
public static final String ChineseTradi... |
try {
BaseFontParameters p = getBaseFontParameters(font.getFontName());
if (p != null) {
return BaseFont.createFont(p.fontName, p.encoding, p.embedded, p.cached, p.ttfAfm, p.pfb);
} else {
return BaseFont.createFont(defaultFont, encoding, true... | 507 | 125 | 632 | <methods>public non-sealed void <init>() ,public com.lowagie.text.pdf.BaseFont awtToPdf(java.awt.Font) ,public HashMap<java.lang.String,java.lang.String> getAliases() ,public com.lowagie.text.pdf.DefaultFontMapper.BaseFontParameters getBaseFontParameters(java.lang.String) ,public HashMap<java.lang.String,com.lowagie.te... |
LibrePDF_OpenPDF | OpenPDF/openpdf/src/main/java/com/lowagie/text/pdf/BarcodeDatamatrix.java | Placement | corner1 | class Placement {
private static final Map<Integer, short[]> cache = new HashMap<>();
private int nrow;
private int ncol;
private short[] array;
private Placement() {
}
static short[] doPlacement(int nrow, int ncol) {
Integer key = nrow * 1000 + nco... |
module(nrow - 1, 0, chr, 0);
module(nrow - 1, 1, chr, 1);
module(nrow - 1, 2, chr, 2);
module(0, ncol - 2, chr, 3);
module(0, ncol - 1, chr, 4);
module(1, ncol - 1, chr, 5);
module(2, ncol - 1, chr, 6);
module(3, ncol - 1, ... | 1,679 | 150 | 1,829 | <no_super_class> |
LibrePDF_OpenPDF | OpenPDF/openpdf/src/main/java/com/lowagie/text/pdf/BarcodeEANSUPP.java | BarcodeEANSUPP | placeBarcode | class BarcodeEANSUPP extends Barcode {
/**
* The barcode with the EAN/UPC.
*/
protected Barcode ean;
/**
* The barcode with the supplemental.
*/
protected Barcode supp;
/**
* Creates new combined barcode.
*
* @param ean the EAN/UPC barcode
* @param supp the... |
if (supp.getFont() != null) {
supp.setBarHeight(ean.getBarHeight() + supp.getBaseline() - supp.getFont()
.getFontDescriptor(BaseFont.CAPHEIGHT, supp.getSize()));
} else {
supp.setBarHeight(ean.getBarHeight());
}
Rectangle eanR = ean.getBarcode... | 1,069 | 228 | 1,297 | <methods>public non-sealed void <init>() ,public abstract java.awt.Image createAwtImage(java.awt.Color, java.awt.Color) ,public com.lowagie.text.Image createImageWithBarcode(com.lowagie.text.pdf.PdfContentByte, java.awt.Color, java.awt.Color) ,public com.lowagie.text.pdf.PdfTemplate createTemplateWithBarcode(com.lowagi... |
LibrePDF_OpenPDF | OpenPDF/openpdf/src/main/java/com/lowagie/text/pdf/CMYKColor.java | CMYKColor | hashCode | class CMYKColor extends ExtendedColor {
private static final long serialVersionUID = 5940378778276468452L;
float cyan;
float magenta;
float yellow;
float black;
/**
* Constructs a CMYK Color based on 4 color values (values are integers from 0 to 255).
*
* @param intCyan cyan ... |
return Float.floatToIntBits(cyan)
^ Float.floatToIntBits(magenta)
^ Float.floatToIntBits(yellow)
^ Float.floatToIntBits(black)
^ Float.floatToIntBits(getAlpha())
;
| 1,095 | 80 | 1,175 | <methods>public void <init>(int) ,public void <init>(int, float, float, float) ,public void <init>(int, float, float, float, float) ,public static int getType(java.awt.Color) ,public int getType() <variables>public static final int MAX_COLOR_VALUE,public static final float MAX_FLOAT_COLOR_VALUE,public static final floa... |
LibrePDF_OpenPDF | OpenPDF/openpdf/src/main/java/com/lowagie/text/pdf/DefaultSplitCharacter.java | DefaultSplitCharacter | isSplitCharacter | class DefaultSplitCharacter implements SplitCharacter {
/**
* An instance of the default SplitCharacter.
*/
public static final SplitCharacter DEFAULT = new DefaultSplitCharacter();
/**
* Checks if a character can be used to split a <CODE>PdfString</CODE>.
* <p>
* for the moment e... |
char c = getCurrentCharacter(current, cc, ck);
if (c <= ' ' || c == '-' || c == '\u2010') {
return true;
}
if (c < 0x2002) {
return false;
}
return c <= 0x200b
|| c >= 0x2e80 && c < 0xd7a0
|| c >= 0xf900 && c < 0xfb... | 398 | 158 | 556 | <no_super_class> |
LibrePDF_OpenPDF | OpenPDF/openpdf/src/main/java/com/lowagie/text/pdf/EnumerateTTC.java | EnumerateTTC | findNames | class EnumerateTTC extends TrueTypeFont {
/**
* OpenType fonts that contain TrueType outlines should use the value of 0x00010000 for the sfntVersion. OpenType
* fonts containing CFF data (version 1 or 2) should use 0x4F54544F ('OTTO', when re-interpreted as a Tag) for
* sfntVersion.
* <p>
... |
tables = new HashMap<>();
try {
String mainTag = readStandardString(4);
if (!mainTag.equals("ttcf")) {
throw new DocumentException(
MessageLocalization.getComposedMessage("1.is.not.a.valid.ttc.file", fileName));
}
... | 419 | 508 | 927 | <methods>public java.lang.String[][] getAllNameEntries() ,public java.lang.String[] getCodePagesSupported() ,public java.lang.String[][] getFamilyFontName() ,public float getFontDescriptor(int, float) ,public java.lang.String[][] getFullFontName() ,public com.lowagie.text.pdf.PdfStream getFullFontStream() throws java.i... |
LibrePDF_OpenPDF | OpenPDF/openpdf/src/main/java/com/lowagie/text/pdf/ExtendedColor.java | ExtendedColor | normalize | class ExtendedColor extends Color {
/**
* a type of extended color.
*/
public static final int TYPE_RGB = 0;
/**
* a type of extended color.
*/
public static final int TYPE_GRAY = 1;
/**
* a type of extended color.
*/
public static final int TYPE_CMYK = 2;
/**
... |
if (value < 0f) {
return 0f;
}
if (value > MAX_FLOAT_COLOR_VALUE) {
return MAX_FLOAT_COLOR_VALUE;
}
return value;
| 917 | 61 | 978 | <methods>public void <init>(int) ,public void <init>(int, boolean) ,public void <init>(int, int, int) ,public void <init>(float, float, float) ,public void <init>(java.awt.color.ColorSpace, float[], float) ,public void <init>(int, int, int, int) ,public void <init>(float, float, float, float) ,public static int HSBtoRG... |
LibrePDF_OpenPDF | OpenPDF/openpdf/src/main/java/com/lowagie/text/pdf/FdfReader.java | FdfReader | readPdf | class FdfReader extends PdfReader {
PdfName encoding;
private Map<String, PdfDictionary> fields;
private String fileSpec;
/**
* Reads an FDF form.
*
* @param filename the file name of the form
* @throws IOException on error
*/
public FdfReader(String filename) throws IOExc... |
fields = new HashMap<>();
try {
tokens.checkFdfHeader();
rebuildXref();
readDocObj();
} finally {
try {
tokens.close();
} catch (Exception e) {
// empty on purpose
}
}
readFie... | 1,462 | 78 | 1,540 | <methods>public void <init>(java.lang.String) throws java.io.IOException,public void <init>(java.lang.String, byte[]) throws java.io.IOException,public void <init>(byte[]) throws java.io.IOException,public void <init>(byte[], byte[]) throws java.io.IOException,public void <init>(java.lang.String, java.security.cert.Cer... |
LibrePDF_OpenPDF | OpenPDF/openpdf/src/main/java/com/lowagie/text/pdf/FontSelector.java | FontSelector | process | class FontSelector {
protected ArrayList<Font> fonts = new ArrayList<>();
public FontSelector() {
FontFactory.register("font-fallback/LiberationSans-Regular.ttf", "sans");
Font font = FontFactory.getFont("sans", BaseFont.IDENTITY_H);
fonts.add(font);
}
/**
* change the co... |
int fsize = fonts.size();
char[] cc = text.toCharArray();
int len = cc.length;
StringBuilder sb = new StringBuilder();
Font font = null;
int lastidx = -1;
Phrase ret = new Phrase();
for (int k = 0; k < len; ++k) {
char c = cc[k];
i... | 488 | 577 | 1,065 | <no_super_class> |
LibrePDF_OpenPDF | OpenPDF/openpdf/src/main/java/com/lowagie/text/pdf/FopGlyphProcessor.java | FopGlyphProcessor | convertToBytesWithGlyphs | class FopGlyphProcessor {
private static boolean isFopSupported;
static {
try {
Class.forName("org.apache.fop.complexscripts.util.GlyphSequence");
isFopSupported = true;
} catch (ClassNotFoundException e) {
isFopSupported = false;
}
}
public... |
TrueTypeFontUnicode ttu = (TrueTypeFontUnicode) font;
IntBuffer charBuffer = IntBuffer.allocate(text.length());
IntBuffer glyphBuffer = IntBuffer.allocate(text.length());
int textLength = text.length();
for (char c : text.toCharArray()) {
int[] metrics = ttu.getMetri... | 176 | 544 | 720 | <no_super_class> |
LibrePDF_OpenPDF | OpenPDF/openpdf/src/main/java/com/lowagie/text/pdf/GrayColor.java | GrayColor | equals | class GrayColor extends ExtendedColor {
public static final GrayColor GRAYBLACK = new GrayColor(0);
public static final GrayColor GRAYWHITE = new GrayColor(MAX_FLOAT_COLOR_VALUE);
private static final long serialVersionUID = -6571835680819282746L;
private float gray;
public GrayColor(int intGray) ... |
return obj instanceof GrayColor && ((GrayColor) obj).gray == this.gray;
| 350 | 24 | 374 | <methods>public void <init>(int) ,public void <init>(int, float, float, float) ,public void <init>(int, float, float, float, float) ,public static int getType(java.awt.Color) ,public int getType() <variables>public static final int MAX_COLOR_VALUE,public static final float MAX_FLOAT_COLOR_VALUE,public static final floa... |
LibrePDF_OpenPDF | OpenPDF/openpdf/src/main/java/com/lowagie/text/pdf/HyphenationAuto.java | HyphenationAuto | getHyphenatedWordPre | class HyphenationAuto implements HyphenationEvent {
/**
* The hyphenator engine.
*/
protected Hyphenator hyphenator;
/**
* The second part of the hyphenated word.
*/
protected String post;
/**
* Creates a new hyphenation instance usable in <CODE>Chunk</CODE>.
*
*... |
post = word;
String hyphen = getHyphenSymbol();
float hyphenWidth = font.getWidthPoint(hyphen, fontSize);
if (hyphenWidth > remainingWidth) {
return "";
}
Hyphenation hyphenation = hyphenator.hyphenate(word);
if (hyphenation == null) {
ret... | 533 | 232 | 765 | <no_super_class> |
LibrePDF_OpenPDF | OpenPDF/openpdf/src/main/java/com/lowagie/text/pdf/LZWDecoder.java | LZWDecoder | addStringToTable | class LZWDecoder {
byte[][] stringTable;
byte[] data = null;
OutputStream uncompData;
int tableIndex, bitsToGet = 9;
int bytePointer, bitPointer;
int nextData = 0;
int nextBits = 0;
int[] andTable = {
511,
1023,
2047,
4095
};
pub... |
int length = oldString.length;
byte[] string = new byte[length + 1];
System.arraycopy(oldString, 0, string, 0, length);
string[length] = newString;
// Add this new String to the table
stringTable[tableIndex++] = string;
if (tableIndex == 511) {
bits... | 1,368 | 152 | 1,520 | <no_super_class> |
LibrePDF_OpenPDF | OpenPDF/openpdf/src/main/java/com/lowagie/text/pdf/MappedRandomAccessFile.java | MappedRandomAccessFile | cleanJava11 | class MappedRandomAccessFile implements AutoCloseable {
private MappedByteBuffer mappedByteBuffer = null;
private FileChannel channel = null;
/**
* Constructs a new MappedRandomAccessFile instance
*
* @param filename String
* @param mode String r, w or rw
* @throws FileNotFoun... |
Boolean success = Boolean.FALSE;
try {
MethodHandles.Lookup lookup = MethodHandles.lookup();
Class<?> unsafeClass = Class.forName("sun.misc.Unsafe");
MethodHandle methodHandle = lookup.findStatic(unsafeClass, "getUnsafe", MethodType.methodType(unsafeClass));
... | 1,176 | 185 | 1,361 | <no_super_class> |
LibrePDF_OpenPDF | OpenPDF/openpdf/src/main/java/com/lowagie/text/pdf/OcspClientBouncyCastle.java | OcspClientBouncyCastle | generateOCSPRequest | class OcspClientBouncyCastle implements OcspClient {
/**
* root certificate
*/
private final X509Certificate rootCert;
/**
* check certificate
*/
private final X509Certificate checkCert;
/**
* OCSP URL
*/
private final String url;
/**
* HTTP proxy used to ... |
// Add provider BC
Provider prov = new org.bouncycastle.jce.provider.BouncyCastleProvider();
Security.addProvider(prov);
// Generate the id for the certificate we are looking for
// OJO... Modificacion de
// Felix--------------------------------------------------
... | 1,101 | 549 | 1,650 | <no_super_class> |
LibrePDF_OpenPDF | OpenPDF/openpdf/src/main/java/com/lowagie/text/pdf/OutputStreamEncryption.java | OutputStreamEncryption | write | class OutputStreamEncryption extends OutputStream {
private static final int AES_128 = 4;
private static final int AES_256_V3 = 6;
protected OutputStream out;
protected ARCFOUREncryption arcfour;
protected AESCipher cipher;
private byte[] sb = new byte[1];
private boolean aes;
private b... |
if (aes) {
byte[] b2 = cipher.update(b, off, len);
if (b2 == null || b2.length == 0) {
return;
}
out.write(b2, 0, b2.length);
} else {
byte[] b2 = new byte[Math.min(len, 4192)];
while (len > 0) {
int... | 1,619 | 186 | 1,805 | <methods>public void <init>() ,public void close() throws java.io.IOException,public void flush() throws java.io.IOException,public static java.io.OutputStream nullOutputStream() ,public abstract void write(int) throws java.io.IOException,public void write(byte[]) throws java.io.IOException,public void write(byte[], in... |
LibrePDF_OpenPDF | OpenPDF/openpdf/src/main/java/com/lowagie/text/pdf/PRAcroForm.java | PRAcroForm | iterateFields | class PRAcroForm extends PdfDictionary {
ArrayList<FieldInformation> fields;
ArrayList<PdfDictionary> stack;
HashMap<String, FieldInformation> fieldByName;
PdfReader reader;
/**
* Constructor
*
* @param reader reader of the input file
*/
public PRAcroForm(PdfReader reader) ... |
for (PdfObject pdfObject : fieldlist.getElements()) {
PRIndirectReference ref = (PRIndirectReference) pdfObject;
PdfDictionary dict = (PdfDictionary) PdfReader.getPdfObjectRelease(ref);
// if we are not a field dictionary, pass our parent's values
PRIndirectRefe... | 1,092 | 528 | 1,620 | <methods>public void <init>() ,public void <init>(com.lowagie.text.pdf.PdfName) ,public void clear() ,public boolean contains(com.lowagie.text.pdf.PdfName) ,public com.lowagie.text.pdf.PdfObject get(com.lowagie.text.pdf.PdfName) ,public com.lowagie.text.pdf.PdfArray getAsArray(com.lowagie.text.pdf.PdfName) ,public com.... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.