本文整理汇总了Java中javax.script.Bindings.size方法的典型用法代码示例。如果您正苦于以下问题:Java Bindings.size方法的具体用法?Java Bindings.size怎么用?Java Bindings.size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.script.Bindings
的用法示例。
在下文中一共展示了Bindings.size方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toJson
import javax.script.Bindings; //导入方法依赖的package包/类
/**
* Serializes this Bindings instance into a JSON formatted StringBuilder with the specified indent of spaces
*/
public static void toJson( @This Bindings thiz, StringBuilder sb, int indent )
{
int iKey = 0;
if( isNewLine( sb ) )
{
indent( sb, indent );
}
if( thiz.size() > 0 )
{
sb.append( "{\n" );
for( String key : thiz.keySet() )
{
indent( sb, indent + 2 );
sb.append( '\"' ).append( key ).append( '\"' ).append( ": " );
Object value = thiz.get( key );
if( value instanceof Pair )
{
value = ((Pair)value).getSecond();
}
if( value instanceof Bindings )
{
toJson( ((Bindings)value), sb, indent + 2 );
}
else if( value instanceof List )
{
listToJson( sb, indent, (List)value );
}
else
{
JsonUtil.appendValue( sb, value );
}
appendCommaNewLine( sb, iKey < thiz.size() - 1 );
iKey++;
}
}
indent( sb, indent );
sb.append( "}" );
}
示例2: toJson
import javax.script.Bindings; //导入方法依赖的package包/类
/**
* Serializes this Bindings instance into a JSON formatted StringBuilder with the specified indent of spaces
*/
public static void toJson( Bindings thisBindings, StringBuilder sb, int indent )
{
int iKey = 0;
if( isNewLine( sb ) )
{
indent( sb, indent );
}
if( thisBindings.size() > 0 )
{
sb.append( "{\n" );
for( String key : thisBindings.keySet() )
{
indent( sb, indent + 2 );
sb.append( '\"' ).append( key ).append( '\"' ).append( ": " );
Object value = thisBindings.get( key );
if( value instanceof Bindings )
{
toJson( (Bindings)value, sb, indent + 2 );
}
else if( value instanceof List )
{
listToJson( sb, indent, (List)value );
}
else
{
appendValue( sb, value );
}
appendCommaNewLine( sb, iKey < thisBindings.size() - 1 );
iKey++;
}
}
indent( sb, indent );
sb.append( "}" );
}
示例3: isTypeDescriptor
import javax.script.Bindings; //导入方法依赖的package包/类
private boolean isTypeDescriptor( Bindings elem )
{
return !(elem.size() == 1 && elem.containsKey( JSCH_REQUIRED ));
}
示例4: toXml
import javax.script.Bindings; //导入方法依赖的package包/类
public static void toXml( @This Bindings thiz, String name, StringBuilder sb, int indent )
{
indent( sb, indent );
sb.append( '<' ).append( name );
if( thiz.size() > 0 )
{
sb.append( ">\n" );
for( String key : thiz.keySet() )
{
Object value = thiz.get( key );
if( value instanceof Pair )
{
value = ((Pair)value).getSecond();
}
if( value instanceof Bindings )
{
toXml( ((Bindings)value), key, sb, indent + 2 );
}
else if( value instanceof List )
{
int len = ((List)value).size();
indent( sb, indent + 2 );
sb.append( "<" ).append( key );
if( len > 0 )
{
sb.append( ">\n" );
for( Object comp : (List)value )
{
if( comp instanceof Pair )
{
comp = ((Pair)comp).getSecond();
}
if( comp instanceof Bindings )
{
toXml( ((Bindings)comp), "li", sb, indent + 4 );
}
else
{
indent( sb, indent + 4 );
sb.append( "<li>" ).append( comp ).append( "</li>\n" );
}
}
indent( sb, indent + 2 );
sb.append( "</" ).append( key ).append( ">\n" );
}
else
{
sb.append( "/>\n" );
}
}
else
{
indent( sb, indent + 2 );
sb.append( '<' ).append( key ).append( ">" );
sb.append( value );
sb.append( "</" ).append( key ).append( ">\n" );
}
}
indent( sb, indent );
sb.append( "</" ).append( name ).append( ">\n" );
}
else
{
sb.append( "/>\n" );
}
}