/** * Appends method name to existing path. */ protected void append(final String methodName) { if (path.length() != 0) { path += StringPool.DOT; } if (methodName.startsWith(StringPool.LEFT_SQ_BRACKET)) { path = StringUtil.substring(path, 0, -1); } path += methodName; }
public Class convert(Object value) { if (value == null) { return null; } if (value.getClass() == Class.class) { return (Class) value; } try { String className = value.toString().trim(); if (className.endsWith(".class")) { className = StringUtil.substring(className, 0, -6); } return ClassLoaderUtil.loadClass(className); } catch (ClassNotFoundException cnfex) { throw new TypeConversionException(value, cnfex); } }
public DbEntityColumnDescriptor( final DbEntityDescriptor ded, final String columnName, final String fieldName, final Class fieldType, final boolean isId, final Class<? extends SqlType> sqlTypeClass) { this.dbEntityDescriptor = ded; this.propertyName = fieldName; this.propertyType = fieldType; this.isId = isId; this.sqlTypeClass = sqlTypeClass; this.columnNameForQuery = columnName; if (StringUtil.detectQuoteChar(columnNameForQuery) != 0) { this.columnName = StringUtil.substring(columnNameForQuery, 1, -1); } else { this.columnName = columnNameForQuery; } }
@Override public Class convert(final Object value) { if (value == null) { return null; } if (value.getClass() == Class.class) { return (Class) value; } try { String className = value.toString().trim(); if (className.endsWith(".class")) { className = StringUtil.substring(className, 0, -6); } return ClassLoaderUtil.loadClass(className); } catch (ClassNotFoundException cnfex) { throw new TypeConversionException(value, cnfex); } }
String packageActionPath = delta == 0 ? StringPool.EMPTY : StringUtil.substring(actionPackage, - delta - 1, 0);
mapping = StringUtil.substring(mapping, 0, -1);
/** * Removes starting and ending single or double quotes. */ public static String removeQuotes(String string) { if ( (startsWithChar(string, '\'') && endsWithChar(string, '\'')) || (startsWithChar(string, '"') && endsWithChar(string, '"')) ) { return substring(string, 1, -1); } return string; }
@Test void testSubstring() { assertEquals("2", StringUtil.substring("123", 1, 2)); assertEquals("23", StringUtil.substring("123", 1, 2000)); assertEquals("123", StringUtil.substring("123", -1000, 2000)); assertEquals("", StringUtil.substring("123", 1, 1)); assertEquals("2", StringUtil.substring("123", 1, -1)); assertEquals("", StringUtil.substring("123", 1, -2)); assertEquals("", StringUtil.substring("123", 2, -1)); assertEquals("2", StringUtil.substring("123", -2, -1)); assertEquals("23", StringUtil.substring("123", -2, 0)); assertEquals("AbCdE", StringUtil.substring("AbCdEf", 0, -1)); assertEquals("dEf", StringUtil.substring("AbCdEf", -3, 0)); assertEquals("dE", StringUtil.substring("AbCdEf", -3, -1)); assertEquals("AbCdE", StringUtil.substring("AbCdEf", -3000, -1)); assertEquals("", StringUtil.substring("AbCdEf", 1000, 2000)); }
providerName = StringUtil.substring(providerName, 0, -8);
public DbEntityDescriptor( final Class<E> type, final String schemaName, final TableNamingStrategy tableNamingStrategy, final ColumnNamingStrategy columnNamingStrategy) { this.type = type; this.entityName = type.getSimpleName(); this.isAnnotated = DbMetaUtil.resolveIsAnnotated(type); this.schemaName = DbMetaUtil.resolveSchemaName(type, schemaName); this.columnNamingStrategy = columnNamingStrategy; this.mappedTypes = DbMetaUtil.resolveMappedTypes(type); this.tableNameForQuery = DbMetaUtil.resolveTableName(type, tableNamingStrategy); if (StringUtil.detectQuoteChar(tableNameForQuery) != 0) { this.tableName = StringUtil.substring(tableNameForQuery, 1, -1); } else { this.tableName = tableNameForQuery; } }
/** * Removes starting and ending single or double quotes. */ public static String removeQuotes(final String string) { if ( (startsWithChar(string, '\'') && endsWithChar(string, '\'')) || (startsWithChar(string, '"') && endsWithChar(string, '"')) || (startsWithChar(string, '`') && endsWithChar(string, '`')) ) { return substring(string, 1, -1); } return string; }
assertEquals(Foo.class.getName() + ProxettaNames.proxyClassNameSuffix, StringUtil.substring(foo.getClass().getName(), 0, -1)); assertEquals(Foo.class.getName() + ProxettaNames.proxyClassNameSuffix, StringUtil.substring(foo.getClass().getName(), 0, -1)); assertEquals(Foo.class.getName() + "$$Ppp", StringUtil.substring(foo.getClass().getName(), 0, -1));
@Test void testUploadWithMonitor() throws IOException { EchoTestServer echoTestServer = new EchoTestServer(); File file = FileUtil.createTempFile(); file.deleteOnExit(); FileUtil.writeString(file, StringUtil.repeat('A', 1024)); final StringBuilder sb = new StringBuilder(); HttpResponse response = HttpRequest .post("http://localhost:8081/hello") .form("id", "12") .form("file", file) .monitor(new HttpProgressListener() { @Override public void transferred(int len) { sb.append(":" + len); } }) .send(); assertEquals(200, response.statusCode()); assertEquals("OK", response.statusPhrase()); echoTestServer.stop(); file.delete(); assertEquals(":0:512:1024:148", StringUtil.substring(sb.toString(), 0, -1)); }
/** * Appends method name to existing path. */ protected void append(final String methodName) { if (path.length() != 0) { path += StringPool.DOT; } if (methodName.startsWith(StringPool.LEFT_SQ_BRACKET)) { path = StringUtil.substring(path, 0, -1); } path += methodName; }
public DbEntityColumnDescriptor( final DbEntityDescriptor ded, final String columnName, final String fieldName, final Class fieldType, final boolean isId, final Class<? extends SqlType> sqlTypeClass) { this.dbEntityDescriptor = ded; this.propertyName = fieldName; this.propertyType = fieldType; this.isId = isId; this.sqlTypeClass = sqlTypeClass; this.columnNameForQuery = columnName; if (StringUtil.detectQuoteChar(columnNameForQuery) != 0) { this.columnName = StringUtil.substring(columnNameForQuery, 1, -1); } else { this.columnName = columnNameForQuery; } }
@Override public Class convert(final Object value) { if (value == null) { return null; } if (value.getClass() == Class.class) { return (Class) value; } try { String className = value.toString().trim(); if (className.endsWith(".class")) { className = StringUtil.substring(className, 0, -6); } return ClassLoaderUtil.loadClass(className); } catch (ClassNotFoundException cnfex) { throw new TypeConversionException(value, cnfex); } }
providerName = StringUtil.substring(providerName, 0, -8);
public DbEntityDescriptor( final Class<E> type, final String schemaName, final TableNamingStrategy tableNamingStrategy, final ColumnNamingStrategy columnNamingStrategy) { this.type = type; this.entityName = type.getSimpleName(); this.isAnnotated = DbMetaUtil.resolveIsAnnotated(type); this.schemaName = DbMetaUtil.resolveSchemaName(type, schemaName); this.columnNamingStrategy = columnNamingStrategy; this.mappedTypes = DbMetaUtil.resolveMappedTypes(type); this.tableNameForQuery = DbMetaUtil.resolveTableName(type, tableNamingStrategy); if (StringUtil.detectQuoteChar(tableNameForQuery) != 0) { this.tableName = StringUtil.substring(tableNameForQuery, 1, -1); } else { this.tableName = tableNameForQuery; } }
/** * Removes starting and ending single or double quotes. */ public static String removeQuotes(final String string) { if ( (startsWithChar(string, '\'') && endsWithChar(string, '\'')) || (startsWithChar(string, '"') && endsWithChar(string, '"')) || (startsWithChar(string, '`') && endsWithChar(string, '`')) ) { return substring(string, 1, -1); } return string; }