CPD Results
The following document contains the results of PMD's CPD 7.7.0.
Duplications
| File |
Line |
| com\ibatis\sqlmap\engine\cache\fifo\FifoCacheController.java |
45 |
| com\ibatis\sqlmap\engine\cache\lru\LruCacheController.java |
45 |
public FifoCacheController() {
this.cacheSize = 100;
this.cache = Collections.synchronizedMap(new HashMap());
this.keyList = Collections.synchronizedList(new LinkedList());
}
/**
* Gets the cache size.
*
* @return the cache size
*/
public int getCacheSize() {
return cacheSize;
}
/**
* Sets the cache size.
*
* @param cacheSize
* the new cache size
*/
public void setCacheSize(int cacheSize) {
this.cacheSize = cacheSize;
}
/**
* Configures the cache
*
* @param props
* Optionally can contain properties [reference-type=WEAK|SOFT|STRONG]
*/
public void setProperties(Properties props) {
String size = props.getProperty("cache-size");
if (size == null) {
size = props.getProperty("size");
}
if (size != null) {
cacheSize = Integer.parseInt(size);
}
}
/**
* Add an object to the cache
*
* @param cacheModel
* The cacheModel
* @param key
* The key of the object to be cached
* @param value
* The object to be cached
*/
public void putObject(CacheModel cacheModel, Object key, Object value) {
cache.put(key, value);
keyList.add(key);
if (keyList.size() > cacheSize) {
try {
Object oldestKey = keyList.remove(0);
cache.remove(oldestKey);
} catch (IndexOutOfBoundsException e) {
// ignore
}
}
}
/**
* Get an object out of the cache.
*
* @param cacheModel
* The cache model
* @param key
* The key of the object to be returned
*
* @return The cached object (or null)
*/
public Object getObject(CacheModel cacheModel, Object key) { |
| File |
Line |
| com\ibatis\common\xml\NodeletParser.java |
196 |
| com\ibatis\common\xml\NodeletParser.java |
247 |
private Document createDocument(Reader reader)
throws ParserConfigurationException, FactoryConfigurationError, SAXException, IOException {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
factory.setFeature("http://xml.org/sax/features/external-general-entities", false);
factory.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_SCHEMA, "");
factory.setValidating(validation);
factory.setNamespaceAware(false);
factory.setIgnoringComments(true);
factory.setIgnoringElementContentWhitespace(false);
factory.setCoalescing(false);
factory.setExpandEntityReferences(false);
DocumentBuilder builder = factory.newDocumentBuilder();
builder.setEntityResolver(entityResolver);
builder.setErrorHandler(new ErrorHandler() {
public void error(SAXParseException exception) throws SAXException {
throw exception;
}
public void fatalError(SAXParseException exception) throws SAXException {
throw exception;
}
public void warning(SAXParseException exception) throws SAXException {
}
});
return builder.parse(new InputSource(reader)); |
| File |
Line |
| com\ibatis\common\jdbc\logging\PreparedStatementLogProxy.java |
82 |
| com\ibatis\common\jdbc\logging\StatementLogProxy.java |
66 |
} else if ("getResultSet".equals(method.getName())) {
ResultSet rs = (ResultSet) method.invoke(statement, params);
if (rs != null) {
return ResultSetLogProxy.newInstance(rs);
} else {
return null;
}
} else if ("equals".equals(method.getName())) {
Object ps = params[0];
if (ps instanceof Proxy) {
return new Boolean(proxy == ps);
}
return new Boolean(false);
} else if ("hashCode".equals(method.getName())) {
return Integer.valueOf(proxy.hashCode());
} else {
return method.invoke(statement, params);
}
} catch (Throwable t) {
throw ClassInfo.unwrapThrowable(t);
}
}
/**
* Creates a logging version of a PreparedStatement.
*
* @param stmt
* - the statement
* @param sql
* - the sql statement
*
* @return - the proxy
*/
public static PreparedStatement newInstance(PreparedStatement stmt, String sql) { |
| File |
Line |
| com\ibatis\sqlmap\engine\type\ObjectTypeHandler.java |
29 |
| com\ibatis\sqlmap\engine\type\UnknownTypeHandler.java |
47 |
ps.setObject(i, parameter);
}
public Object getResult(ResultSet rs, String columnName) throws SQLException {
Object object = rs.getObject(columnName);
if (rs.wasNull()) {
return null;
} else {
return object;
}
}
public Object getResult(ResultSet rs, int columnIndex) throws SQLException {
Object object = rs.getObject(columnIndex);
if (rs.wasNull()) {
return null;
} else {
return object;
}
}
public Object getResult(CallableStatement cs, int columnIndex) throws SQLException {
Object object = cs.getObject(columnIndex);
if (cs.wasNull()) {
return null;
} else {
return object;
}
}
public Object valueOf(String s) {
return s;
} |
| File |
Line |
| com\ibatis\sqlmap\engine\builder\xml\SqlMapParser.java |
341 |
| com\ibatis\sqlmap\engine\builder\xml\SqlMapParser.java |
398 |
+ "' (must be a TypeHandler or TypeHandlerCallback implementation).");
Object typeHandlerImpl = null;
try {
if (callback != null && callback.length() > 0) {
callback = state.getConfig().getTypeHandlerFactory().resolveAlias(callback);
typeHandlerImpl = Resources.instantiate(callback);
}
} catch (Exception e) {
throw new RuntimeException("Error occurred during custom type handler configuration. Cause: " + e, e);
}
Integer columnIndex = null;
if (columnIndexProp != null) {
try {
columnIndex = Integer.valueOf(columnIndexProp);
} catch (Exception e) {
throw new RuntimeException("Error parsing column index. Cause: " + e, e);
}
}
state.getResultConfig().addResultMapping(propertyName, columnName, columnIndex, javaClass, jdbcType, nullValue, |
| File |
Line |
| com\ibatis\common\beans\ComplexBeanProbe.java |
84 |
| com\ibatis\common\beans\ComplexBeanProbe.java |
122 |
type = getClassPropertyTypeForSetter((Class) object, name);
} else if (object instanceof Map) {
Map map = (Map) object;
Object value = map.get(name);
if (value == null) {
type = Object.class;
} else {
type = value.getClass();
}
} else {
if (name.indexOf('.') > -1) {
StringTokenizer parser = new StringTokenizer(name, ".");
while (parser.hasMoreTokens()) {
name = parser.nextToken();
type = ClassInfo.getInstance(type).getSetterType(name); |