本文整理汇总了Java中org.teiid.core.util.StringUtil类的典型用法代码示例。如果您正苦于以下问题:Java StringUtil类的具体用法?Java StringUtil怎么用?Java StringUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StringUtil类属于org.teiid.core.util包,在下文中一共展示了StringUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: log
import org.teiid.core.util.StringUtil; //导入依赖的package包/类
public void log(int level, String context, Throwable t, Object... msg) {
Logger logger = getLogger(context);
Level javaLevel = convertLevel(level);
if (msg.length == 0) {
logger.log(javaLevel, null, t);
}
else if (msg.length == 1 && !(msg[0] instanceof String)) {
String msgStr = StringUtil.toString(msg, " ", false); //$NON-NLS-1$
LogRecord record = new LogRecord(javaLevel, msgStr);
record.setParameters(msg);
record.setThrown(t);
record.setLoggerName(context);
logger.log(record);
}
else {
logger.log(javaLevel, StringUtil.toString(msg, " ", false), t); //$NON-NLS-1$
}
}
示例2: setDatatype
import org.teiid.core.util.StringUtil; //导入依赖的package包/类
public void setDatatype(Datatype datatype, boolean copyAttributes, int arrayDimensions) {
this.datatype = datatype;
this.arrayDimensions = arrayDimensions;
if (datatype != null) {
this.datatypeUUID = this.datatype.getUUID();
this.runtimeType = this.datatype.getRuntimeTypeName();
if (arrayDimensions > 0) {
this.runtimeType += StringUtil.join(Collections.nCopies(arrayDimensions, "[]"), ""); //$NON-NLS-1$ //$NON-NLS-2$
}
if (copyAttributes) {
this.radix = this.datatype.getRadix();
this.length = this.datatype.getLength();
this.precision = this.datatype.getPrecision();
this.scale = this.datatype.getScale();
this.nullType = this.datatype.getNullType();
}
}
}
示例3: addNamespace
import org.teiid.core.util.StringUtil; //导入依赖的package包/类
public void addNamespace(String prefix, String uri) {
if (uri == null || uri.indexOf('}') != -1) {
throw new MetadataException(DataPlugin.Event.TEIID60018, DataPlugin.Util.gs(DataPlugin.Event.TEIID60018, uri));
}
if (StringUtil.startsWithIgnoreCase(prefix, TEIID_RESERVED)) {
String validURI = BUILTIN_NAMESPACES.get(prefix);
if (validURI == null || !uri.equals(validURI)) {
throw new MetadataException(DataPlugin.Event.TEIID60017, DataPlugin.Util.gs(DataPlugin.Event.TEIID60017, prefix));
}
}
if (this.namespaces == null) {
this.namespaces = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER);
}
this.namespaces.put(prefix, uri);
}
示例4: matchesPartialName
import org.teiid.core.util.StringUtil; //导入依赖的package包/类
protected boolean matchesPartialName(String partialGroupName, String name, Schema schema) {
if (!StringUtil.endsWithIgnoreCase(name, partialGroupName)) {
return false;
}
int schemaMatch = partialGroupName.length() - name.length();
if (schemaMatch > 0) {
if (schemaMatch != schema.getName().length() + 1
|| !StringUtil.startsWithIgnoreCase(partialGroupName, schema.getName())
|| partialGroupName.charAt(schemaMatch + 1) != '.') {
return false;
}
} else if (schemaMatch < 0 && name.charAt(-schemaMatch - 1) != '.') {
return false;
}
return true;
}
示例5: getGroupsForPartialName
import org.teiid.core.util.StringUtil; //导入依赖的package包/类
@Override
public Collection getGroupsForPartialName(String partialGroupName)
throws TeiidComponentException, QueryMetadataException {
Collection groups = super.getGroupsForPartialName(partialGroupName);
ArrayList<String> allGroups = new ArrayList<String>(groups);
for (Map.Entry<String, TempMetadataID> entry : tempStore.getData().entrySet()) {
String name = entry.getKey();
if (StringUtil.endsWithIgnoreCase(name, partialGroupName)
//don't want to match tables by anything less than the full name,
//since this should be a temp or a global temp and in the latter case there's a real metadata entry
//alternatively we could check to see if the name is already in the result list
&& (name.length() == partialGroupName.length() || (entry.getValue().getMetadataType() != Type.TEMP && name.length() > partialGroupName.length() && name.charAt(name.length() - partialGroupName.length() - 1) == '.'))) {
allGroups.add(name);
}
}
return allGroups;
}
示例6: equals
import org.teiid.core.util.StringUtil; //导入依赖的package包/类
/**
* Compare two queries for equality. Blocks will only evaluate to equal if
* they are IDENTICAL: statements in the block are equal and are in the same order.
* @param obj Other object
* @return True if equal
*/
public boolean equals(Object obj) {
// Quick same object test
if(this == obj) {
return true;
}
// Quick fail tests
if(!(obj instanceof Block)) {
return false;
}
Block other = (Block)obj;
// Compare the statements on the block
return this.atomic == other.atomic
&& StringUtil.equalsIgnoreCase(label, other.label)
&& EquivalenceUtil.areEqual(getStatements(), other.getStatements())
&& EquivalenceUtil.areEqual(exceptionGroup, other.exceptionGroup)
&& EquivalenceUtil.areEqual(exceptionStatements, exceptionStatements);
}
示例7: equals
import org.teiid.core.util.StringUtil; //导入依赖的package包/类
/**
* Compare two WhileStatements for equality. They will only evaluate to equal if
* they are IDENTICAL: the block is same and the condition on is same.
* @param obj Other object
* @return True if equal
*/
public boolean equals(Object obj) {
// Quick same object test
if(this == obj) {
return true;
}
// Quick fail tests
if(!(obj instanceof WhileStatement)) {
return false;
}
WhileStatement other = (WhileStatement) obj;
return
// Compare the condition
EquivalenceUtil.areEqual(getCondition(), other.getCondition()) &&
// Compare the if block
EquivalenceUtil.areEqual(whileBlock, other.whileBlock)
&& StringUtil.equalsIgnoreCase(this.label, other.label);
}
示例8: equals
import org.teiid.core.util.StringUtil; //导入依赖的package包/类
/**
* Compare two LoopStatements for equality. They will only evaluate to equal if
* they are IDENTICAL: the blocks is same, the query is same, and the cursor name is same.
* @param obj Other object
* @return True if equal
*/
public boolean equals(Object obj) {
// Quick same object test
if(this == obj) {
return true;
}
// Quick fail tests
if(!(obj instanceof LoopStatement)) {
return false;
}
LoopStatement other = (LoopStatement) obj;
return
// Compare the query
EquivalenceUtil.areEqual(query, other.query) &&
// Compare the if block
EquivalenceUtil.areEqual(loopBlock, other.loopBlock) &&
// Compare the else block
EquivalenceUtil.areEqual(cursorName, other.cursorName)
&& StringUtil.equalsIgnoreCase(this.label, other.label);
}
示例9: escapeSinglePart
import org.teiid.core.util.StringUtil; //导入依赖的package包/类
public static String escapeSinglePart( String part ) {
if (isReservedWord(part)) {
return ID_ESCAPE_CHAR + part + ID_ESCAPE_CHAR;
}
boolean escape = true;
char start = part.charAt(0);
if (start == '#' || start == '@' || StringUtil.isLetter(start)) {
escape = false;
for (int i = 1; !escape && i < part.length(); i++) {
char c = part.charAt(i);
escape = !StringUtil.isLetterOrDigit(c) && c != '_';
}
}
if (escape) {
return ID_ESCAPE_CHAR + escapeStringValue(part, "\"") + ID_ESCAPE_CHAR; //$NON-NLS-1$
}
return part;
}
示例10: getVersion
import org.teiid.core.util.StringUtil; //导入依赖的package包/类
/**
* @return Returns the version.
*/
public String getVersion() {
if (this.version != null) {
//normalize to allow for more increments
StringBuilder builder = new StringBuilder();
List<String> parts = StringUtil.split(this.version, "."); //$NON-NLS-1$
for (int i = 0; i < parts.size(); i++) {
if (i > 0) {
builder.append('.');
}
String part = parts.get(i);
if (part.length() < 2 && Character.isDigit(part.charAt(0))) {
builder.append('0');
}
builder.append(part);
}
return builder.toString();
}
return this.version;
}
示例11: getProductValue
import org.teiid.core.util.StringUtil; //导入依赖的package包/类
/**
* Obtains the value that is overriding the default value.
* @param theKey the key whose product value is being requested
* @return the value or <code>null</code> if not overridden by the product
*/
private String getProductValue(String theKey) {
String result = null;
if ((productProps != null) && !StringUtil.isEmpty(theKey)) {
String key = this.pluginId + '.' + theKey;
try {
result = productProps.getString(key);
} catch (MissingResourceException theException) {
// not found in product properties
}
}
return result;
}
示例12: sendCommandComplete
import org.teiid.core.util.StringUtil; //导入依赖的package包/类
@Override
public void sendCommandComplete(String sql, Integer count) {
startMessage('C');
String tag;
if (StringUtil.startsWithIgnoreCase(sql, "BEGIN") || StringUtil.startsWithIgnoreCase(sql, "START TRANSACTION")) {
tag = "BEGIN";
} else if (sql.indexOf(' ') == -1) {
//should already be a completion tag
tag = sql.toUpperCase();
if (count != null) {
tag += " " + count;
}
} else if (StringUtil.startsWithIgnoreCase(sql, "SET ")) {
tag = "SET";
} else {
tag = SqlUtil.getKeyword(sql).toUpperCase();
if (tag.equals("EXEC") || tag.equals("CALL")) {
tag = "SELECT";
}
if (count != null) {
tag += " " + count;
}
}
writeString(tag);
sendMessage();
}
示例13: log
import org.teiid.core.util.StringUtil; //导入依赖的package包/类
@Override
public void log(int level, String context, Throwable t, Object... msg) {
Logger logger = getLogger(context);
Level jbossLevel = convert2JbossLevel(level);
if (msg.length == 0) {
logger.log(jbossLevel, null, t);
}
else if (msg.length == 1 && !(msg[0] instanceof String)) {
String msgStr = StringUtil.toString(msg, " ", false); //$NON-NLS-1$
if (msgStr.indexOf('%') > -1) {
msgStr = StringUtil.replaceAll(msgStr, "%", "%%"); //$NON-NLS-1$ //$NON-NLS-2$
}
logger.logf(jbossLevel, t, msgStr, msg);
}
else {
logger.log(jbossLevel, StringUtil.toString(msg, " ", false), t); //$NON-NLS-1$
}
}
示例14: visit
import org.teiid.core.util.StringUtil; //导入依赖的package包/类
public void visit(Literal obj) {
if (obj.getValue() == null) {
buffer.append(NULL);
return;
}
Class<?> type = obj.getType();
if (Number.class.isAssignableFrom(type)) {
buffer.append(obj.toString());
return;
} else if (obj.getType().equals(DataTypeManager.DefaultDataClasses.DATE)) {
buffer.append(obj.getValue().toString());
return;
} else {
buffer.append("\""); //$NON-NLS-1$
buffer.append(StringUtil.replace(obj.getValue().toString(), "\"", "\"\"")); //$NON-NLS-1$ //$NON-NLS-2$
buffer.append("\""); //$NON-NLS-1$
return;
}
}
示例15: getMetadataProcessor
import org.teiid.core.util.StringUtil; //导入依赖的package包/类
@Override
public MetadataProcessor<Connection> getMetadataProcessor() {
return new JDBCMetdataProcessor() {
@Override
protected Column addColumn(ResultSet columns, Table table,
MetadataFactory metadataFactory, int rsColumns)
throws SQLException {
Column c = super.addColumn(columns, table, metadataFactory, rsColumns);
//The ms jdbc driver does not correctly report the auto incremented column
if (!c.isAutoIncremented() && c.getNativeType() != null && StringUtil.endsWithIgnoreCase(c.getNativeType(), " identity")) { //$NON-NLS-1$
c.setAutoIncremented(true);
}
return c;
}
};
}