id int32 0 165k | repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1 value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 |
|---|---|---|---|---|---|---|---|---|---|---|---|
140,100 | ldapchai/ldapchai | src/main/java/com/novell/ldapchai/provider/WatchdogService.java | WatchdogService.checkTimer | private void checkTimer()
{
try
{
serviceThreadLock.lock();
if ( watchdogTimer == null )
{
// if there is NOT an active timer
if ( !issuedWatchdogWrappers.allValues().isEmpty() )
{
// if there are active providers.
LOGGER.debug( "starting up " + THREAD_NAME + ", " + watchdogFrequency + "ms check frequency" );
// create a new timer
startWatchdogThread();
}
}
}
finally
{
serviceThreadLock.unlock();
}
} | java | private void checkTimer()
{
try
{
serviceThreadLock.lock();
if ( watchdogTimer == null )
{
// if there is NOT an active timer
if ( !issuedWatchdogWrappers.allValues().isEmpty() )
{
// if there are active providers.
LOGGER.debug( "starting up " + THREAD_NAME + ", " + watchdogFrequency + "ms check frequency" );
// create a new timer
startWatchdogThread();
}
}
}
finally
{
serviceThreadLock.unlock();
}
} | [
"private",
"void",
"checkTimer",
"(",
")",
"{",
"try",
"{",
"serviceThreadLock",
".",
"lock",
"(",
")",
";",
"if",
"(",
"watchdogTimer",
"==",
"null",
")",
"{",
"// if there is NOT an active timer",
"if",
"(",
"!",
"issuedWatchdogWrappers",
".",
"allValues",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"// if there are active providers.",
"LOGGER",
".",
"debug",
"(",
"\"starting up \"",
"+",
"THREAD_NAME",
"+",
"\", \"",
"+",
"watchdogFrequency",
"+",
"\"ms check frequency\"",
")",
";",
"// create a new timer",
"startWatchdogThread",
"(",
")",
";",
"}",
"}",
"}",
"finally",
"{",
"serviceThreadLock",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] | Regulate the timer. This is important because the timer task creates its own thread,
and if the task isn't cleaned up, there could be a thread leak. | [
"Regulate",
"the",
"timer",
".",
"This",
"is",
"important",
"because",
"the",
"timer",
"task",
"creates",
"its",
"own",
"thread",
"and",
"if",
"the",
"task",
"isn",
"t",
"cleaned",
"up",
"there",
"could",
"be",
"a",
"thread",
"leak",
"."
] | a6d4b5dbfa4e270db0ce70892512cbe39e64b874 | https://github.com/ldapchai/ldapchai/blob/a6d4b5dbfa4e270db0ce70892512cbe39e64b874/src/main/java/com/novell/ldapchai/provider/WatchdogService.java#L71-L94 |
140,101 | ldapchai/ldapchai | src/main/java/com/novell/ldapchai/util/ConfigObjectRecord.java | ConfigObjectRecord.createNew | public static ConfigObjectRecord createNew( final ChaiEntry entry,
final String attr,
final String recordType,
final String guid1,
final String guid2 )
{
//Ensure the entry is not null
if ( entry == null )
{
throw new NullPointerException( "entry can not be null" );
}
//Ensure the record type is not null
if ( recordType == null )
{
throw new NullPointerException( "recordType can not be null" );
}
//Make sure the attr is not null
if ( attr == null )
{
throw new NullPointerException( "attr can not be null" );
}
// truncate record type to 4 chars.
final String effectiveRecordType = recordType.length() > 4
? recordType.substring( 0, 4 )
: recordType;
final ConfigObjectRecord cor = new ConfigObjectRecord();
cor.objectEntry = entry;
cor.attr = attr;
cor.recordType = effectiveRecordType;
cor.guid1 = ( guid1 == null || guid1.length() < 1 ) ? EMPTY_RECORD_VALUE : guid1;
cor.guid2 = ( guid2 == null || guid2.length() < 1 ) ? EMPTY_RECORD_VALUE : guid2;
return cor;
} | java | public static ConfigObjectRecord createNew( final ChaiEntry entry,
final String attr,
final String recordType,
final String guid1,
final String guid2 )
{
//Ensure the entry is not null
if ( entry == null )
{
throw new NullPointerException( "entry can not be null" );
}
//Ensure the record type is not null
if ( recordType == null )
{
throw new NullPointerException( "recordType can not be null" );
}
//Make sure the attr is not null
if ( attr == null )
{
throw new NullPointerException( "attr can not be null" );
}
// truncate record type to 4 chars.
final String effectiveRecordType = recordType.length() > 4
? recordType.substring( 0, 4 )
: recordType;
final ConfigObjectRecord cor = new ConfigObjectRecord();
cor.objectEntry = entry;
cor.attr = attr;
cor.recordType = effectiveRecordType;
cor.guid1 = ( guid1 == null || guid1.length() < 1 ) ? EMPTY_RECORD_VALUE : guid1;
cor.guid2 = ( guid2 == null || guid2.length() < 1 ) ? EMPTY_RECORD_VALUE : guid2;
return cor;
} | [
"public",
"static",
"ConfigObjectRecord",
"createNew",
"(",
"final",
"ChaiEntry",
"entry",
",",
"final",
"String",
"attr",
",",
"final",
"String",
"recordType",
",",
"final",
"String",
"guid1",
",",
"final",
"String",
"guid2",
")",
"{",
"//Ensure the entry is not null",
"if",
"(",
"entry",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"entry can not be null\"",
")",
";",
"}",
"//Ensure the record type is not null",
"if",
"(",
"recordType",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"recordType can not be null\"",
")",
";",
"}",
"//Make sure the attr is not null",
"if",
"(",
"attr",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"attr can not be null\"",
")",
";",
"}",
"// truncate record type to 4 chars.",
"final",
"String",
"effectiveRecordType",
"=",
"recordType",
".",
"length",
"(",
")",
">",
"4",
"?",
"recordType",
".",
"substring",
"(",
"0",
",",
"4",
")",
":",
"recordType",
";",
"final",
"ConfigObjectRecord",
"cor",
"=",
"new",
"ConfigObjectRecord",
"(",
")",
";",
"cor",
".",
"objectEntry",
"=",
"entry",
";",
"cor",
".",
"attr",
"=",
"attr",
";",
"cor",
".",
"recordType",
"=",
"effectiveRecordType",
";",
"cor",
".",
"guid1",
"=",
"(",
"guid1",
"==",
"null",
"||",
"guid1",
".",
"length",
"(",
")",
"<",
"1",
")",
"?",
"EMPTY_RECORD_VALUE",
":",
"guid1",
";",
"cor",
".",
"guid2",
"=",
"(",
"guid2",
"==",
"null",
"||",
"guid2",
".",
"length",
"(",
")",
"<",
"1",
")",
"?",
"EMPTY_RECORD_VALUE",
":",
"guid2",
";",
"return",
"cor",
";",
"}"
] | Create a new config object record. This will only create a java object representing the config
object record. It is up to the caller to call the updatePayload method which will actually
commit the record to the directory.
@param entry The {@code ChaiEntry} object where the config object record will be stored.
@param attr The ldap attribute name to use for storage.
@param recordType Record type for the record.
@param guid1 The first associated guid value
@param guid2 The second associated guid value
@return A ConfigObjectRecordInstance | [
"Create",
"a",
"new",
"config",
"object",
"record",
".",
"This",
"will",
"only",
"create",
"a",
"java",
"object",
"representing",
"the",
"config",
"object",
"record",
".",
"It",
"is",
"up",
"to",
"the",
"caller",
"to",
"call",
"the",
"updatePayload",
"method",
"which",
"will",
"actually",
"commit",
"the",
"record",
"to",
"the",
"directory",
"."
] | a6d4b5dbfa4e270db0ce70892512cbe39e64b874 | https://github.com/ldapchai/ldapchai/blob/a6d4b5dbfa4e270db0ce70892512cbe39e64b874/src/main/java/com/novell/ldapchai/util/ConfigObjectRecord.java#L93-L132 |
140,102 | ldapchai/ldapchai | src/main/java/com/novell/ldapchai/util/ConfigObjectRecord.java | ConfigObjectRecord.readRecordFromLDAP | public static List<ConfigObjectRecord> readRecordFromLDAP(
final ChaiEntry ldapEntry,
final String attr,
final String recordType,
final Set guid1,
final Set guid2
)
throws ChaiOperationException, ChaiUnavailableException
{
if ( ldapEntry == null )
{
throw new NullPointerException( "ldapEntry can not be null" );
}
if ( attr == null )
{
throw new NullPointerException( "attr can not be null" );
}
if ( recordType == null )
{
throw new NullPointerException( "recordType can not be null" );
}
//Read the attribute
final Set<String> values = ldapEntry.readMultiStringAttribute( attr );
final List<ConfigObjectRecord> cors = new ArrayList<ConfigObjectRecord>();
for ( final String value : values )
{
final ConfigObjectRecord loopRec = parseString( value );
loopRec.objectEntry = ldapEntry;
loopRec.attr = attr;
cors.add( loopRec );
//If it doesnt match any of the tests, then remove the record.
if ( !loopRec.getRecordType().equalsIgnoreCase( recordType ) )
{
cors.remove( loopRec );
}
else if ( guid1 != null && !guid1.contains( loopRec.getGuid1() ) )
{
cors.remove( loopRec );
}
else if ( guid2 != null && !guid2.contains( loopRec.getGuid2() ) )
{
cors.remove( loopRec );
}
}
return cors;
} | java | public static List<ConfigObjectRecord> readRecordFromLDAP(
final ChaiEntry ldapEntry,
final String attr,
final String recordType,
final Set guid1,
final Set guid2
)
throws ChaiOperationException, ChaiUnavailableException
{
if ( ldapEntry == null )
{
throw new NullPointerException( "ldapEntry can not be null" );
}
if ( attr == null )
{
throw new NullPointerException( "attr can not be null" );
}
if ( recordType == null )
{
throw new NullPointerException( "recordType can not be null" );
}
//Read the attribute
final Set<String> values = ldapEntry.readMultiStringAttribute( attr );
final List<ConfigObjectRecord> cors = new ArrayList<ConfigObjectRecord>();
for ( final String value : values )
{
final ConfigObjectRecord loopRec = parseString( value );
loopRec.objectEntry = ldapEntry;
loopRec.attr = attr;
cors.add( loopRec );
//If it doesnt match any of the tests, then remove the record.
if ( !loopRec.getRecordType().equalsIgnoreCase( recordType ) )
{
cors.remove( loopRec );
}
else if ( guid1 != null && !guid1.contains( loopRec.getGuid1() ) )
{
cors.remove( loopRec );
}
else if ( guid2 != null && !guid2.contains( loopRec.getGuid2() ) )
{
cors.remove( loopRec );
}
}
return cors;
} | [
"public",
"static",
"List",
"<",
"ConfigObjectRecord",
">",
"readRecordFromLDAP",
"(",
"final",
"ChaiEntry",
"ldapEntry",
",",
"final",
"String",
"attr",
",",
"final",
"String",
"recordType",
",",
"final",
"Set",
"guid1",
",",
"final",
"Set",
"guid2",
")",
"throws",
"ChaiOperationException",
",",
"ChaiUnavailableException",
"{",
"if",
"(",
"ldapEntry",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"ldapEntry can not be null\"",
")",
";",
"}",
"if",
"(",
"attr",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"attr can not be null\"",
")",
";",
"}",
"if",
"(",
"recordType",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"recordType can not be null\"",
")",
";",
"}",
"//Read the attribute",
"final",
"Set",
"<",
"String",
">",
"values",
"=",
"ldapEntry",
".",
"readMultiStringAttribute",
"(",
"attr",
")",
";",
"final",
"List",
"<",
"ConfigObjectRecord",
">",
"cors",
"=",
"new",
"ArrayList",
"<",
"ConfigObjectRecord",
">",
"(",
")",
";",
"for",
"(",
"final",
"String",
"value",
":",
"values",
")",
"{",
"final",
"ConfigObjectRecord",
"loopRec",
"=",
"parseString",
"(",
"value",
")",
";",
"loopRec",
".",
"objectEntry",
"=",
"ldapEntry",
";",
"loopRec",
".",
"attr",
"=",
"attr",
";",
"cors",
".",
"add",
"(",
"loopRec",
")",
";",
"//If it doesnt match any of the tests, then remove the record.",
"if",
"(",
"!",
"loopRec",
".",
"getRecordType",
"(",
")",
".",
"equalsIgnoreCase",
"(",
"recordType",
")",
")",
"{",
"cors",
".",
"remove",
"(",
"loopRec",
")",
";",
"}",
"else",
"if",
"(",
"guid1",
"!=",
"null",
"&&",
"!",
"guid1",
".",
"contains",
"(",
"loopRec",
".",
"getGuid1",
"(",
")",
")",
")",
"{",
"cors",
".",
"remove",
"(",
"loopRec",
")",
";",
"}",
"else",
"if",
"(",
"guid2",
"!=",
"null",
"&&",
"!",
"guid2",
".",
"contains",
"(",
"loopRec",
".",
"getGuid2",
"(",
")",
")",
")",
"{",
"cors",
".",
"remove",
"(",
"loopRec",
")",
";",
"}",
"}",
"return",
"cors",
";",
"}"
] | Retreive matching config object records from the directory.
@param ldapEntry The ldapEntry object to examine. Must be a valid entry.
@param attr The attribute used to store COR's
@param recordType the record recordType to use, can not be null.
@param guid1 GUID1 value to match on, may be null if no guid1 match is desired.
@param guid2 GUID2 value to match on, may be null if no guid2 match is desired.
@return A List containing matching ConfigObjectRecords
@throws ChaiOperationException If there is an error during the operation
@throws ChaiUnavailableException If the directory server(s) are unavailable | [
"Retreive",
"matching",
"config",
"object",
"records",
"from",
"the",
"directory",
"."
] | a6d4b5dbfa4e270db0ce70892512cbe39e64b874 | https://github.com/ldapchai/ldapchai/blob/a6d4b5dbfa4e270db0ce70892512cbe39e64b874/src/main/java/com/novell/ldapchai/util/ConfigObjectRecord.java#L146-L198 |
140,103 | ldapchai/ldapchai | src/main/java/com/novell/ldapchai/util/ChaiUtility.java | ChaiUtility.createGroup | public static ChaiGroup createGroup( final String parentDN, final String name, final ChaiProvider provider )
throws ChaiOperationException, ChaiUnavailableException
{
//Get a good CN for it
final String objectCN = findUniqueName( name, parentDN, provider );
//Concantonate the entryDN
final StringBuilder entryDN = new StringBuilder();
entryDN.append( "cn=" );
entryDN.append( objectCN );
entryDN.append( ',' );
entryDN.append( parentDN );
//First create the base group.
provider.createEntry( entryDN.toString(), ChaiConstant.OBJECTCLASS_BASE_LDAP_GROUP, Collections.emptyMap() );
//Now build an ldapentry object to add attributes to it
final ChaiEntry theObject = provider.getEntryFactory().newChaiEntry( entryDN.toString() );
//Add the description
theObject.writeStringAttribute( ChaiConstant.ATTR_LDAP_DESCRIPTION, name );
//Return the newly created group.
return provider.getEntryFactory().newChaiGroup( entryDN.toString() );
} | java | public static ChaiGroup createGroup( final String parentDN, final String name, final ChaiProvider provider )
throws ChaiOperationException, ChaiUnavailableException
{
//Get a good CN for it
final String objectCN = findUniqueName( name, parentDN, provider );
//Concantonate the entryDN
final StringBuilder entryDN = new StringBuilder();
entryDN.append( "cn=" );
entryDN.append( objectCN );
entryDN.append( ',' );
entryDN.append( parentDN );
//First create the base group.
provider.createEntry( entryDN.toString(), ChaiConstant.OBJECTCLASS_BASE_LDAP_GROUP, Collections.emptyMap() );
//Now build an ldapentry object to add attributes to it
final ChaiEntry theObject = provider.getEntryFactory().newChaiEntry( entryDN.toString() );
//Add the description
theObject.writeStringAttribute( ChaiConstant.ATTR_LDAP_DESCRIPTION, name );
//Return the newly created group.
return provider.getEntryFactory().newChaiGroup( entryDN.toString() );
} | [
"public",
"static",
"ChaiGroup",
"createGroup",
"(",
"final",
"String",
"parentDN",
",",
"final",
"String",
"name",
",",
"final",
"ChaiProvider",
"provider",
")",
"throws",
"ChaiOperationException",
",",
"ChaiUnavailableException",
"{",
"//Get a good CN for it",
"final",
"String",
"objectCN",
"=",
"findUniqueName",
"(",
"name",
",",
"parentDN",
",",
"provider",
")",
";",
"//Concantonate the entryDN",
"final",
"StringBuilder",
"entryDN",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"entryDN",
".",
"append",
"(",
"\"cn=\"",
")",
";",
"entryDN",
".",
"append",
"(",
"objectCN",
")",
";",
"entryDN",
".",
"append",
"(",
"'",
"'",
")",
";",
"entryDN",
".",
"append",
"(",
"parentDN",
")",
";",
"//First create the base group.",
"provider",
".",
"createEntry",
"(",
"entryDN",
".",
"toString",
"(",
")",
",",
"ChaiConstant",
".",
"OBJECTCLASS_BASE_LDAP_GROUP",
",",
"Collections",
".",
"emptyMap",
"(",
")",
")",
";",
"//Now build an ldapentry object to add attributes to it",
"final",
"ChaiEntry",
"theObject",
"=",
"provider",
".",
"getEntryFactory",
"(",
")",
".",
"newChaiEntry",
"(",
"entryDN",
".",
"toString",
"(",
")",
")",
";",
"//Add the description",
"theObject",
".",
"writeStringAttribute",
"(",
"ChaiConstant",
".",
"ATTR_LDAP_DESCRIPTION",
",",
"name",
")",
";",
"//Return the newly created group.",
"return",
"provider",
".",
"getEntryFactory",
"(",
")",
".",
"newChaiGroup",
"(",
"entryDN",
".",
"toString",
"(",
")",
")",
";",
"}"
] | Creates a new group entry in the ldap directory. A new "groupOfNames" object is created.
The "cn" and "description" ldap attributes are set to the supplied name.
@param parentDN the entryDN of the new group.
@param name name of the group
@param provider a ldap provider be used to create the group.
@return an instance of the ChaiGroup entry
@throws ChaiOperationException If there is an error during the operation
@throws ChaiUnavailableException If the directory server(s) are unavailable | [
"Creates",
"a",
"new",
"group",
"entry",
"in",
"the",
"ldap",
"directory",
".",
"A",
"new",
"groupOfNames",
"object",
"is",
"created",
".",
"The",
"cn",
"and",
"description",
"ldap",
"attributes",
"are",
"set",
"to",
"the",
"supplied",
"name",
"."
] | a6d4b5dbfa4e270db0ce70892512cbe39e64b874 | https://github.com/ldapchai/ldapchai/blob/a6d4b5dbfa4e270db0ce70892512cbe39e64b874/src/main/java/com/novell/ldapchai/util/ChaiUtility.java#L68-L92 |
140,104 | ldapchai/ldapchai | src/main/java/com/novell/ldapchai/util/ChaiUtility.java | ChaiUtility.findUniqueName | public static String findUniqueName( final String baseName, final String containerDN, final ChaiProvider provider )
throws ChaiOperationException, ChaiUnavailableException
{
char ch;
final StringBuilder cnStripped = new StringBuilder();
final String effectiveBasename = ( baseName == null )
? ""
: baseName;
// First boil down the root name. Preserve only the alpha-numerics.
for ( int i = 0; i < effectiveBasename.length(); i++ )
{
ch = effectiveBasename.charAt( i );
if ( Character.isLetterOrDigit( ch ) )
{
cnStripped.append( ch );
}
}
if ( cnStripped.length() == 0 )
{
// Generate a random seed to runServer with, how about the current date
cnStripped.append( System.currentTimeMillis() );
}
// Now we have a base name, let's runServer testing it...
String uniqueCN;
StringBuilder filter;
final Random randomNumber = new Random();
String stringCounter = null;
// Start with a random 3 digit number
int counter = randomNumber.nextInt() % 1000;
while ( true )
{
// Initialize the String Buffer and Unique DN.
filter = new StringBuilder( 64 );
if ( stringCounter != null )
{
uniqueCN = cnStripped.append( stringCounter ).toString();
}
else
{
uniqueCN = cnStripped.toString();
}
filter.append( "(" ).append( ChaiConstant.ATTR_LDAP_COMMON_NAME ).append( "=" ).append( uniqueCN ).append( ")" );
final Map<String, Map<String, String>> results = provider.search( containerDN, filter.toString(), null, SearchScope.ONE );
if ( results.size() == 0 )
{
// No object found!
break;
}
else
{
// Increment it every time
stringCounter = Integer.toString( counter++ );
}
}
return uniqueCN;
} | java | public static String findUniqueName( final String baseName, final String containerDN, final ChaiProvider provider )
throws ChaiOperationException, ChaiUnavailableException
{
char ch;
final StringBuilder cnStripped = new StringBuilder();
final String effectiveBasename = ( baseName == null )
? ""
: baseName;
// First boil down the root name. Preserve only the alpha-numerics.
for ( int i = 0; i < effectiveBasename.length(); i++ )
{
ch = effectiveBasename.charAt( i );
if ( Character.isLetterOrDigit( ch ) )
{
cnStripped.append( ch );
}
}
if ( cnStripped.length() == 0 )
{
// Generate a random seed to runServer with, how about the current date
cnStripped.append( System.currentTimeMillis() );
}
// Now we have a base name, let's runServer testing it...
String uniqueCN;
StringBuilder filter;
final Random randomNumber = new Random();
String stringCounter = null;
// Start with a random 3 digit number
int counter = randomNumber.nextInt() % 1000;
while ( true )
{
// Initialize the String Buffer and Unique DN.
filter = new StringBuilder( 64 );
if ( stringCounter != null )
{
uniqueCN = cnStripped.append( stringCounter ).toString();
}
else
{
uniqueCN = cnStripped.toString();
}
filter.append( "(" ).append( ChaiConstant.ATTR_LDAP_COMMON_NAME ).append( "=" ).append( uniqueCN ).append( ")" );
final Map<String, Map<String, String>> results = provider.search( containerDN, filter.toString(), null, SearchScope.ONE );
if ( results.size() == 0 )
{
// No object found!
break;
}
else
{
// Increment it every time
stringCounter = Integer.toString( counter++ );
}
}
return uniqueCN;
} | [
"public",
"static",
"String",
"findUniqueName",
"(",
"final",
"String",
"baseName",
",",
"final",
"String",
"containerDN",
",",
"final",
"ChaiProvider",
"provider",
")",
"throws",
"ChaiOperationException",
",",
"ChaiUnavailableException",
"{",
"char",
"ch",
";",
"final",
"StringBuilder",
"cnStripped",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"final",
"String",
"effectiveBasename",
"=",
"(",
"baseName",
"==",
"null",
")",
"?",
"\"\"",
":",
"baseName",
";",
"// First boil down the root name. Preserve only the alpha-numerics.",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"effectiveBasename",
".",
"length",
"(",
")",
";",
"i",
"++",
")",
"{",
"ch",
"=",
"effectiveBasename",
".",
"charAt",
"(",
"i",
")",
";",
"if",
"(",
"Character",
".",
"isLetterOrDigit",
"(",
"ch",
")",
")",
"{",
"cnStripped",
".",
"append",
"(",
"ch",
")",
";",
"}",
"}",
"if",
"(",
"cnStripped",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"// Generate a random seed to runServer with, how about the current date",
"cnStripped",
".",
"append",
"(",
"System",
".",
"currentTimeMillis",
"(",
")",
")",
";",
"}",
"// Now we have a base name, let's runServer testing it...",
"String",
"uniqueCN",
";",
"StringBuilder",
"filter",
";",
"final",
"Random",
"randomNumber",
"=",
"new",
"Random",
"(",
")",
";",
"String",
"stringCounter",
"=",
"null",
";",
"// Start with a random 3 digit number",
"int",
"counter",
"=",
"randomNumber",
".",
"nextInt",
"(",
")",
"%",
"1000",
";",
"while",
"(",
"true",
")",
"{",
"// Initialize the String Buffer and Unique DN.",
"filter",
"=",
"new",
"StringBuilder",
"(",
"64",
")",
";",
"if",
"(",
"stringCounter",
"!=",
"null",
")",
"{",
"uniqueCN",
"=",
"cnStripped",
".",
"append",
"(",
"stringCounter",
")",
".",
"toString",
"(",
")",
";",
"}",
"else",
"{",
"uniqueCN",
"=",
"cnStripped",
".",
"toString",
"(",
")",
";",
"}",
"filter",
".",
"append",
"(",
"\"(\"",
")",
".",
"append",
"(",
"ChaiConstant",
".",
"ATTR_LDAP_COMMON_NAME",
")",
".",
"append",
"(",
"\"=\"",
")",
".",
"append",
"(",
"uniqueCN",
")",
".",
"append",
"(",
"\")\"",
")",
";",
"final",
"Map",
"<",
"String",
",",
"Map",
"<",
"String",
",",
"String",
">",
">",
"results",
"=",
"provider",
".",
"search",
"(",
"containerDN",
",",
"filter",
".",
"toString",
"(",
")",
",",
"null",
",",
"SearchScope",
".",
"ONE",
")",
";",
"if",
"(",
"results",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"// No object found!",
"break",
";",
"}",
"else",
"{",
"// Increment it every time",
"stringCounter",
"=",
"Integer",
".",
"toString",
"(",
"counter",
"++",
")",
";",
"}",
"}",
"return",
"uniqueCN",
";",
"}"
] | Derives a unique entry name for an ldap container. Assumes CN as the naming attribute.
@param baseName A text name that will be used for the base of the obejct name. Punctuation and spaces will be stripped.
@param containerDN Directory container in which to check for a unique name
@param provider ChaiProvider to use for ldap connection
@return Fully qualified unique object name for the container specified.
@throws ChaiOperationException If there is an error during the operation
@throws ChaiUnavailableException If the directory server(s) are unavailable | [
"Derives",
"a",
"unique",
"entry",
"name",
"for",
"an",
"ldap",
"container",
".",
"Assumes",
"CN",
"as",
"the",
"naming",
"attribute",
"."
] | a6d4b5dbfa4e270db0ce70892512cbe39e64b874 | https://github.com/ldapchai/ldapchai/blob/a6d4b5dbfa4e270db0ce70892512cbe39e64b874/src/main/java/com/novell/ldapchai/util/ChaiUtility.java#L104-L169 |
140,105 | ldapchai/ldapchai | src/main/java/com/novell/ldapchai/util/ChaiUtility.java | ChaiUtility.entryToLDIF | public static String entryToLDIF( final ChaiEntry theEntry )
throws ChaiUnavailableException, ChaiOperationException
{
final StringBuilder sb = new StringBuilder();
sb.append( "dn: " ).append( theEntry.getEntryDN() ).append( "\n" );
final Map<String, Map<String, List<String>>> results = theEntry.getChaiProvider().searchMultiValues(
theEntry.getEntryDN(),
"(objectClass=*)",
null,
SearchScope.BASE
);
final Map<String, List<String>> props = results.get( theEntry.getEntryDN() );
for ( final Map.Entry<String, List<String>> entry : props.entrySet() )
{
final String attrName = entry.getKey();
final List<String> values = entry.getValue();
for ( final String value : values )
{
sb.append( attrName ).append( ": " ).append( value ).append( '\n' );
}
}
return sb.toString();
} | java | public static String entryToLDIF( final ChaiEntry theEntry )
throws ChaiUnavailableException, ChaiOperationException
{
final StringBuilder sb = new StringBuilder();
sb.append( "dn: " ).append( theEntry.getEntryDN() ).append( "\n" );
final Map<String, Map<String, List<String>>> results = theEntry.getChaiProvider().searchMultiValues(
theEntry.getEntryDN(),
"(objectClass=*)",
null,
SearchScope.BASE
);
final Map<String, List<String>> props = results.get( theEntry.getEntryDN() );
for ( final Map.Entry<String, List<String>> entry : props.entrySet() )
{
final String attrName = entry.getKey();
final List<String> values = entry.getValue();
for ( final String value : values )
{
sb.append( attrName ).append( ": " ).append( value ).append( '\n' );
}
}
return sb.toString();
} | [
"public",
"static",
"String",
"entryToLDIF",
"(",
"final",
"ChaiEntry",
"theEntry",
")",
"throws",
"ChaiUnavailableException",
",",
"ChaiOperationException",
"{",
"final",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"sb",
".",
"append",
"(",
"\"dn: \"",
")",
".",
"append",
"(",
"theEntry",
".",
"getEntryDN",
"(",
")",
")",
".",
"append",
"(",
"\"\\n\"",
")",
";",
"final",
"Map",
"<",
"String",
",",
"Map",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
">",
"results",
"=",
"theEntry",
".",
"getChaiProvider",
"(",
")",
".",
"searchMultiValues",
"(",
"theEntry",
".",
"getEntryDN",
"(",
")",
",",
"\"(objectClass=*)\"",
",",
"null",
",",
"SearchScope",
".",
"BASE",
")",
";",
"final",
"Map",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
"props",
"=",
"results",
".",
"get",
"(",
"theEntry",
".",
"getEntryDN",
"(",
")",
")",
";",
"for",
"(",
"final",
"Map",
".",
"Entry",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
"entry",
":",
"props",
".",
"entrySet",
"(",
")",
")",
"{",
"final",
"String",
"attrName",
"=",
"entry",
".",
"getKey",
"(",
")",
";",
"final",
"List",
"<",
"String",
">",
"values",
"=",
"entry",
".",
"getValue",
"(",
")",
";",
"for",
"(",
"final",
"String",
"value",
":",
"values",
")",
"{",
"sb",
".",
"append",
"(",
"attrName",
")",
".",
"append",
"(",
"\": \"",
")",
".",
"append",
"(",
"value",
")",
".",
"append",
"(",
"'",
"'",
")",
";",
"}",
"}",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}"
] | Convert to an LDIF format. Useful for debugging or other purposes
@param theEntry A valid {@code ChaiEntry}
@return A string containing a properly formatted LDIF view of the entry.
@throws ChaiOperationException If there is an error during the operation
@throws ChaiUnavailableException If the directory server(s) are unavailable | [
"Convert",
"to",
"an",
"LDIF",
"format",
".",
"Useful",
"for",
"debugging",
"or",
"other",
"purposes"
] | a6d4b5dbfa4e270db0ce70892512cbe39e64b874 | https://github.com/ldapchai/ldapchai/blob/a6d4b5dbfa4e270db0ce70892512cbe39e64b874/src/main/java/com/novell/ldapchai/util/ChaiUtility.java#L204-L229 |
140,106 | ldapchai/ldapchai | src/main/java/com/novell/ldapchai/util/ChaiUtility.java | ChaiUtility.determineDirectoryVendor | public static DirectoryVendor determineDirectoryVendor( final ChaiEntry rootDSE )
throws ChaiUnavailableException, ChaiOperationException
{
final Set<String> interestedAttributes = new HashSet<>();
for ( final DirectoryVendor directoryVendor : DirectoryVendor.values() )
{
interestedAttributes.addAll( directoryVendor.getVendorFactory().interestedDseAttributes() );
}
final SearchHelper searchHelper = new SearchHelper();
searchHelper.setAttributes( interestedAttributes.toArray( new String[interestedAttributes.size()] ) );
searchHelper.setFilter( "(objectClass=*)" );
searchHelper.setMaxResults( 1 );
searchHelper.setSearchScope( SearchScope.BASE );
final Map<String, Map<String, List<String>>> results = rootDSE.getChaiProvider().searchMultiValues( "", searchHelper );
if ( results != null && !results.isEmpty() )
{
final Map<String, List<String>> rootDseSearchResults = results.values().iterator().next();
for ( final DirectoryVendor directoryVendor : DirectoryVendor.values() )
{
if ( directoryVendor.getVendorFactory().detectVendorFromRootDSEData( rootDseSearchResults ) )
{
return directoryVendor;
}
}
}
return DirectoryVendor.GENERIC;
} | java | public static DirectoryVendor determineDirectoryVendor( final ChaiEntry rootDSE )
throws ChaiUnavailableException, ChaiOperationException
{
final Set<String> interestedAttributes = new HashSet<>();
for ( final DirectoryVendor directoryVendor : DirectoryVendor.values() )
{
interestedAttributes.addAll( directoryVendor.getVendorFactory().interestedDseAttributes() );
}
final SearchHelper searchHelper = new SearchHelper();
searchHelper.setAttributes( interestedAttributes.toArray( new String[interestedAttributes.size()] ) );
searchHelper.setFilter( "(objectClass=*)" );
searchHelper.setMaxResults( 1 );
searchHelper.setSearchScope( SearchScope.BASE );
final Map<String, Map<String, List<String>>> results = rootDSE.getChaiProvider().searchMultiValues( "", searchHelper );
if ( results != null && !results.isEmpty() )
{
final Map<String, List<String>> rootDseSearchResults = results.values().iterator().next();
for ( final DirectoryVendor directoryVendor : DirectoryVendor.values() )
{
if ( directoryVendor.getVendorFactory().detectVendorFromRootDSEData( rootDseSearchResults ) )
{
return directoryVendor;
}
}
}
return DirectoryVendor.GENERIC;
} | [
"public",
"static",
"DirectoryVendor",
"determineDirectoryVendor",
"(",
"final",
"ChaiEntry",
"rootDSE",
")",
"throws",
"ChaiUnavailableException",
",",
"ChaiOperationException",
"{",
"final",
"Set",
"<",
"String",
">",
"interestedAttributes",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"for",
"(",
"final",
"DirectoryVendor",
"directoryVendor",
":",
"DirectoryVendor",
".",
"values",
"(",
")",
")",
"{",
"interestedAttributes",
".",
"addAll",
"(",
"directoryVendor",
".",
"getVendorFactory",
"(",
")",
".",
"interestedDseAttributes",
"(",
")",
")",
";",
"}",
"final",
"SearchHelper",
"searchHelper",
"=",
"new",
"SearchHelper",
"(",
")",
";",
"searchHelper",
".",
"setAttributes",
"(",
"interestedAttributes",
".",
"toArray",
"(",
"new",
"String",
"[",
"interestedAttributes",
".",
"size",
"(",
")",
"]",
")",
")",
";",
"searchHelper",
".",
"setFilter",
"(",
"\"(objectClass=*)\"",
")",
";",
"searchHelper",
".",
"setMaxResults",
"(",
"1",
")",
";",
"searchHelper",
".",
"setSearchScope",
"(",
"SearchScope",
".",
"BASE",
")",
";",
"final",
"Map",
"<",
"String",
",",
"Map",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
">",
"results",
"=",
"rootDSE",
".",
"getChaiProvider",
"(",
")",
".",
"searchMultiValues",
"(",
"\"\"",
",",
"searchHelper",
")",
";",
"if",
"(",
"results",
"!=",
"null",
"&&",
"!",
"results",
".",
"isEmpty",
"(",
")",
")",
"{",
"final",
"Map",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
"rootDseSearchResults",
"=",
"results",
".",
"values",
"(",
")",
".",
"iterator",
"(",
")",
".",
"next",
"(",
")",
";",
"for",
"(",
"final",
"DirectoryVendor",
"directoryVendor",
":",
"DirectoryVendor",
".",
"values",
"(",
")",
")",
"{",
"if",
"(",
"directoryVendor",
".",
"getVendorFactory",
"(",
")",
".",
"detectVendorFromRootDSEData",
"(",
"rootDseSearchResults",
")",
")",
"{",
"return",
"directoryVendor",
";",
"}",
"}",
"}",
"return",
"DirectoryVendor",
".",
"GENERIC",
";",
"}"
] | Determines the vendor of a the ldap directory by reading RootDSE attributes.
@param rootDSE A valid entry
@return the proper directory vendor, or {@link DirectoryVendor#GENERIC} if the vendor can not be determined.
@throws ChaiUnavailableException If the directory is unreachable
@throws ChaiOperationException If there is an error reading values from the Root DSE entry | [
"Determines",
"the",
"vendor",
"of",
"a",
"the",
"ldap",
"directory",
"by",
"reading",
"RootDSE",
"attributes",
"."
] | a6d4b5dbfa4e270db0ce70892512cbe39e64b874 | https://github.com/ldapchai/ldapchai/blob/a6d4b5dbfa4e270db0ce70892512cbe39e64b874/src/main/java/com/novell/ldapchai/util/ChaiUtility.java#L450-L479 |
140,107 | ldapchai/ldapchai | src/main/java/com/novell/ldapchai/exception/ChaiErrors.java | ChaiErrors.isAuthenticationRelated | static boolean isAuthenticationRelated ( final String message )
{
for ( final DirectoryVendor vendor : DirectoryVendor.values() )
{
final ErrorMap errorMap = vendor.getVendorFactory().getErrorMap();
if ( errorMap.isAuthenticationRelated( message ) )
{
return true;
}
}
return false;
} | java | static boolean isAuthenticationRelated ( final String message )
{
for ( final DirectoryVendor vendor : DirectoryVendor.values() )
{
final ErrorMap errorMap = vendor.getVendorFactory().getErrorMap();
if ( errorMap.isAuthenticationRelated( message ) )
{
return true;
}
}
return false;
} | [
"static",
"boolean",
"isAuthenticationRelated",
"(",
"final",
"String",
"message",
")",
"{",
"for",
"(",
"final",
"DirectoryVendor",
"vendor",
":",
"DirectoryVendor",
".",
"values",
"(",
")",
")",
"{",
"final",
"ErrorMap",
"errorMap",
"=",
"vendor",
".",
"getVendorFactory",
"(",
")",
".",
"getErrorMap",
"(",
")",
";",
"if",
"(",
"errorMap",
".",
"isAuthenticationRelated",
"(",
"message",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Indicates if the error is related to authentication.
@param message error message debug text
@return true if the error is defined as being related to authentication. | [
"Indicates",
"if",
"the",
"error",
"is",
"related",
"to",
"authentication",
"."
] | a6d4b5dbfa4e270db0ce70892512cbe39e64b874 | https://github.com/ldapchai/ldapchai/blob/a6d4b5dbfa4e270db0ce70892512cbe39e64b874/src/main/java/com/novell/ldapchai/exception/ChaiErrors.java#L55-L67 |
140,108 | ldapchai/ldapchai | src/main/java/com/novell/ldapchai/util/SearchHelper.java | SearchHelper.setFilterNot | public void setFilterNot( final String attributeName, final String value )
{
this.setFilter( attributeName, value );
filter = "(!" + filter + ")";
} | java | public void setFilterNot( final String attributeName, final String value )
{
this.setFilter( attributeName, value );
filter = "(!" + filter + ")";
} | [
"public",
"void",
"setFilterNot",
"(",
"final",
"String",
"attributeName",
",",
"final",
"String",
"value",
")",
"{",
"this",
".",
"setFilter",
"(",
"attributeName",
",",
"value",
")",
";",
"filter",
"=",
"\"(!\"",
"+",
"filter",
"+",
"\")\"",
";",
"}"
] | Set up a not exists filter for an attribute name and value pair.
<table border="1"><caption>Example Values</caption>
<tr><td><b>Attribute</b></td><td><b>Value</b></td></tr>
<tr><td>givenName</td><td>John</td></tr>
</table>
<p><i>Result</i></p>
<code>(!(givenName=John))</code>
@param attributeName A valid attribute name
@param value A value that, if it exists, will cause the object to be excluded from the result set. | [
"Set",
"up",
"a",
"not",
"exists",
"filter",
"for",
"an",
"attribute",
"name",
"and",
"value",
"pair",
"."
] | a6d4b5dbfa4e270db0ce70892512cbe39e64b874 | https://github.com/ldapchai/ldapchai/blob/a6d4b5dbfa4e270db0ce70892512cbe39e64b874/src/main/java/com/novell/ldapchai/util/SearchHelper.java#L575-L579 |
140,109 | ldapchai/ldapchai | src/main/java/com/novell/ldapchai/util/SearchHelper.java | SearchHelper.setFilter | public void setFilter( final String attributeName, final String value )
{
filter = new FilterSequence( attributeName, value ).toString();
} | java | public void setFilter( final String attributeName, final String value )
{
filter = new FilterSequence( attributeName, value ).toString();
} | [
"public",
"void",
"setFilter",
"(",
"final",
"String",
"attributeName",
",",
"final",
"String",
"value",
")",
"{",
"filter",
"=",
"new",
"FilterSequence",
"(",
"attributeName",
",",
"value",
")",
".",
"toString",
"(",
")",
";",
"}"
] | Set up a standard filter attribute name and value pair.
<table border="1"><caption>Example Values</caption>
<tr><td><b>Attribute</b></td><td><b>Value</b></td></tr>
<tr><td>givenName</td><td>John</td></tr>
</table>
<p><i>Result</i></p>
<code>(givenName=John)</code>
@param attributeName A valid attribute name
@param value A value that, if it exists, will cause the object to be included in result set. | [
"Set",
"up",
"a",
"standard",
"filter",
"attribute",
"name",
"and",
"value",
"pair",
"."
] | a6d4b5dbfa4e270db0ce70892512cbe39e64b874 | https://github.com/ldapchai/ldapchai/blob/a6d4b5dbfa4e270db0ce70892512cbe39e64b874/src/main/java/com/novell/ldapchai/util/SearchHelper.java#L594-L597 |
140,110 | ldapchai/ldapchai | src/main/java/com/novell/ldapchai/util/SearchHelper.java | SearchHelper.setFilterOr | public void setFilterOr( final Map<String, String> nameValuePairs )
{
if ( nameValuePairs == null )
{
throw new NullPointerException();
}
if ( nameValuePairs.size() < 1 )
{
throw new IllegalArgumentException( "requires at least one key" );
}
final List<FilterSequence> filters = new ArrayList<>();
for ( final Map.Entry<String, String> entry : nameValuePairs.entrySet() )
{
filters.add( new FilterSequence( entry.getKey(), entry.getValue(), FilterSequence.MatchingRuleEnum.EQUALS ) );
}
setFilterBind( filters, "|" );
} | java | public void setFilterOr( final Map<String, String> nameValuePairs )
{
if ( nameValuePairs == null )
{
throw new NullPointerException();
}
if ( nameValuePairs.size() < 1 )
{
throw new IllegalArgumentException( "requires at least one key" );
}
final List<FilterSequence> filters = new ArrayList<>();
for ( final Map.Entry<String, String> entry : nameValuePairs.entrySet() )
{
filters.add( new FilterSequence( entry.getKey(), entry.getValue(), FilterSequence.MatchingRuleEnum.EQUALS ) );
}
setFilterBind( filters, "|" );
} | [
"public",
"void",
"setFilterOr",
"(",
"final",
"Map",
"<",
"String",
",",
"String",
">",
"nameValuePairs",
")",
"{",
"if",
"(",
"nameValuePairs",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
")",
";",
"}",
"if",
"(",
"nameValuePairs",
".",
"size",
"(",
")",
"<",
"1",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"requires at least one key\"",
")",
";",
"}",
"final",
"List",
"<",
"FilterSequence",
">",
"filters",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"final",
"Map",
".",
"Entry",
"<",
"String",
",",
"String",
">",
"entry",
":",
"nameValuePairs",
".",
"entrySet",
"(",
")",
")",
"{",
"filters",
".",
"add",
"(",
"new",
"FilterSequence",
"(",
"entry",
".",
"getKey",
"(",
")",
",",
"entry",
".",
"getValue",
"(",
")",
",",
"FilterSequence",
".",
"MatchingRuleEnum",
".",
"EQUALS",
")",
")",
";",
"}",
"setFilterBind",
"(",
"filters",
",",
"\"|\"",
")",
";",
"}"
] | Set up an OR filter for each map key and value. Consider the following example.
<table border="1"><caption>Example Values</caption>
<tr><td><b>Attribute</b></td><td><b>Value</b></td></tr>
<tr><td>givenName</td><td>John</td></tr>
<tr><td>sn</td><td>Smith</td></tr>
</table>
<p><i>Result</i></p>
<code>(|(givenName=John)(sn=Smith))</code>
@param nameValuePairs A valid list of attribute to name pairs | [
"Set",
"up",
"an",
"OR",
"filter",
"for",
"each",
"map",
"key",
"and",
"value",
".",
"Consider",
"the",
"following",
"example",
"."
] | a6d4b5dbfa4e270db0ce70892512cbe39e64b874 | https://github.com/ldapchai/ldapchai/blob/a6d4b5dbfa4e270db0ce70892512cbe39e64b874/src/main/java/com/novell/ldapchai/util/SearchHelper.java#L612-L630 |
140,111 | ldapchai/ldapchai | src/main/java/com/novell/ldapchai/util/StringHelper.java | StringHelper.convertStrToBoolean | public static boolean convertStrToBoolean( final String string )
{
return !( string == null || string.length() < 1 ) && ( "true".equalsIgnoreCase( string )
|| "1".equalsIgnoreCase( string )
|| "yes".equalsIgnoreCase( string )
|| "y".equalsIgnoreCase( string )
);
} | java | public static boolean convertStrToBoolean( final String string )
{
return !( string == null || string.length() < 1 ) && ( "true".equalsIgnoreCase( string )
|| "1".equalsIgnoreCase( string )
|| "yes".equalsIgnoreCase( string )
|| "y".equalsIgnoreCase( string )
);
} | [
"public",
"static",
"boolean",
"convertStrToBoolean",
"(",
"final",
"String",
"string",
")",
"{",
"return",
"!",
"(",
"string",
"==",
"null",
"||",
"string",
".",
"length",
"(",
")",
"<",
"1",
")",
"&&",
"(",
"\"true\"",
".",
"equalsIgnoreCase",
"(",
"string",
")",
"||",
"\"1\"",
".",
"equalsIgnoreCase",
"(",
"string",
")",
"||",
"\"yes\"",
".",
"equalsIgnoreCase",
"(",
"string",
")",
"||",
"\"y\"",
".",
"equalsIgnoreCase",
"(",
"string",
")",
")",
";",
"}"
] | Convert a string value to a boolean. If the value is a common positive string
value such as "1", "true", "y" or "yes" then TRUE is returned. For any other
value or null, FALSE is returned.
@param string value to test
@return true if the string resolves to a positive value. | [
"Convert",
"a",
"string",
"value",
"to",
"a",
"boolean",
".",
"If",
"the",
"value",
"is",
"a",
"common",
"positive",
"string",
"value",
"such",
"as",
"1",
"true",
"y",
"or",
"yes",
"then",
"TRUE",
"is",
"returned",
".",
"For",
"any",
"other",
"value",
"or",
"null",
"FALSE",
"is",
"returned",
"."
] | a6d4b5dbfa4e270db0ce70892512cbe39e64b874 | https://github.com/ldapchai/ldapchai/blob/a6d4b5dbfa4e270db0ce70892512cbe39e64b874/src/main/java/com/novell/ldapchai/util/StringHelper.java#L46-L53 |
140,112 | ldapchai/ldapchai | src/main/java/com/novell/ldapchai/impl/openldap/entry/OpenLDAPModifyPasswordRequest.java | OpenLDAPModifyPasswordRequest.getEncodedValue | public byte[] getEncodedValue()
{
final String characterEncoding = this.chaiConfiguration.getSetting( ChaiSetting.LDAP_CHARACTER_ENCODING );
final byte[] password = modifyPassword.getBytes( Charset.forName( characterEncoding ) );
final byte[] dn = modifyDn.getBytes( Charset.forName( characterEncoding ) );
// Sequence tag (1) + sequence length (1) + dn tag (1) +
// dn length (1) + dn (variable) + password tag (1) +
// password length (1) + password (variable)
final int encodedLength = 6 + dn.length + password.length;
final byte[] encoded = new byte[encodedLength];
int valueI = 0;
// sequence start
encoded[valueI++] = ( byte ) 0x30;
// length of body
encoded[valueI++] = ( byte ) ( 4 + dn.length + password.length );
encoded[valueI++] = LDAP_TAG_EXOP_X_MODIFY_PASSWD_ID;
encoded[valueI++] = ( byte ) dn.length;
System.arraycopy( dn, 0, encoded, valueI, dn.length );
valueI += dn.length;
encoded[valueI++] = LDAP_TAG_EXOP_X_MODIFY_PASSWD_NEW;
encoded[valueI++] = ( byte ) password.length;
System.arraycopy( password, 0, encoded, valueI, password.length );
valueI += password.length;
return encoded;
} | java | public byte[] getEncodedValue()
{
final String characterEncoding = this.chaiConfiguration.getSetting( ChaiSetting.LDAP_CHARACTER_ENCODING );
final byte[] password = modifyPassword.getBytes( Charset.forName( characterEncoding ) );
final byte[] dn = modifyDn.getBytes( Charset.forName( characterEncoding ) );
// Sequence tag (1) + sequence length (1) + dn tag (1) +
// dn length (1) + dn (variable) + password tag (1) +
// password length (1) + password (variable)
final int encodedLength = 6 + dn.length + password.length;
final byte[] encoded = new byte[encodedLength];
int valueI = 0;
// sequence start
encoded[valueI++] = ( byte ) 0x30;
// length of body
encoded[valueI++] = ( byte ) ( 4 + dn.length + password.length );
encoded[valueI++] = LDAP_TAG_EXOP_X_MODIFY_PASSWD_ID;
encoded[valueI++] = ( byte ) dn.length;
System.arraycopy( dn, 0, encoded, valueI, dn.length );
valueI += dn.length;
encoded[valueI++] = LDAP_TAG_EXOP_X_MODIFY_PASSWD_NEW;
encoded[valueI++] = ( byte ) password.length;
System.arraycopy( password, 0, encoded, valueI, password.length );
valueI += password.length;
return encoded;
} | [
"public",
"byte",
"[",
"]",
"getEncodedValue",
"(",
")",
"{",
"final",
"String",
"characterEncoding",
"=",
"this",
".",
"chaiConfiguration",
".",
"getSetting",
"(",
"ChaiSetting",
".",
"LDAP_CHARACTER_ENCODING",
")",
";",
"final",
"byte",
"[",
"]",
"password",
"=",
"modifyPassword",
".",
"getBytes",
"(",
"Charset",
".",
"forName",
"(",
"characterEncoding",
")",
")",
";",
"final",
"byte",
"[",
"]",
"dn",
"=",
"modifyDn",
".",
"getBytes",
"(",
"Charset",
".",
"forName",
"(",
"characterEncoding",
")",
")",
";",
"// Sequence tag (1) + sequence length (1) + dn tag (1) +",
"// dn length (1) + dn (variable) + password tag (1) +",
"// password length (1) + password (variable)",
"final",
"int",
"encodedLength",
"=",
"6",
"+",
"dn",
".",
"length",
"+",
"password",
".",
"length",
";",
"final",
"byte",
"[",
"]",
"encoded",
"=",
"new",
"byte",
"[",
"encodedLength",
"]",
";",
"int",
"valueI",
"=",
"0",
";",
"// sequence start",
"encoded",
"[",
"valueI",
"++",
"]",
"=",
"(",
"byte",
")",
"0x30",
";",
"// length of body",
"encoded",
"[",
"valueI",
"++",
"]",
"=",
"(",
"byte",
")",
"(",
"4",
"+",
"dn",
".",
"length",
"+",
"password",
".",
"length",
")",
";",
"encoded",
"[",
"valueI",
"++",
"]",
"=",
"LDAP_TAG_EXOP_X_MODIFY_PASSWD_ID",
";",
"encoded",
"[",
"valueI",
"++",
"]",
"=",
"(",
"byte",
")",
"dn",
".",
"length",
";",
"System",
".",
"arraycopy",
"(",
"dn",
",",
"0",
",",
"encoded",
",",
"valueI",
",",
"dn",
".",
"length",
")",
";",
"valueI",
"+=",
"dn",
".",
"length",
";",
"encoded",
"[",
"valueI",
"++",
"]",
"=",
"LDAP_TAG_EXOP_X_MODIFY_PASSWD_NEW",
";",
"encoded",
"[",
"valueI",
"++",
"]",
"=",
"(",
"byte",
")",
"password",
".",
"length",
";",
"System",
".",
"arraycopy",
"(",
"password",
",",
"0",
",",
"encoded",
",",
"valueI",
",",
"password",
".",
"length",
")",
";",
"valueI",
"+=",
"password",
".",
"length",
";",
"return",
"encoded",
";",
"}"
] | Get the BER encoded value for this operation.
@return a bytearray containing the BER sequence. | [
"Get",
"the",
"BER",
"encoded",
"value",
"for",
"this",
"operation",
"."
] | a6d4b5dbfa4e270db0ce70892512cbe39e64b874 | https://github.com/ldapchai/ldapchai/blob/a6d4b5dbfa4e270db0ce70892512cbe39e64b874/src/main/java/com/novell/ldapchai/impl/openldap/entry/OpenLDAPModifyPasswordRequest.java#L142-L177 |
140,113 | toddfast/typeconverter | src/main/java/com/toddfast/util/convert/TypeConverter.java | TypeConverter.registerTypeConversion | public static void registerTypeConversion(Conversion<?> conversion) {
Object[] keys=conversion.getTypeKeys();
if (keys==null) {
return;
}
for (int i=0; i<keys.length; i++) {
registerTypeConversion(keys[i],conversion);
}
} | java | public static void registerTypeConversion(Conversion<?> conversion) {
Object[] keys=conversion.getTypeKeys();
if (keys==null) {
return;
}
for (int i=0; i<keys.length; i++) {
registerTypeConversion(keys[i],conversion);
}
} | [
"public",
"static",
"void",
"registerTypeConversion",
"(",
"Conversion",
"<",
"?",
">",
"conversion",
")",
"{",
"Object",
"[",
"]",
"keys",
"=",
"conversion",
".",
"getTypeKeys",
"(",
")",
";",
"if",
"(",
"keys",
"==",
"null",
")",
"{",
"return",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"keys",
".",
"length",
";",
"i",
"++",
")",
"{",
"registerTypeConversion",
"(",
"keys",
"[",
"i",
"]",
",",
"conversion",
")",
";",
"}",
"}"
] | Register a type conversion object under the specified keys. This
method can be used by developers to register custom type conversion
objects. | [
"Register",
"a",
"type",
"conversion",
"object",
"under",
"the",
"specified",
"keys",
".",
"This",
"method",
"can",
"be",
"used",
"by",
"developers",
"to",
"register",
"custom",
"type",
"conversion",
"objects",
"."
] | 44efa352254faa49edaba5c5935389705aa12b90 | https://github.com/toddfast/typeconverter/blob/44efa352254faa49edaba5c5935389705aa12b90/src/main/java/com/toddfast/util/convert/TypeConverter.java#L205-L215 |
140,114 | toddfast/typeconverter | src/main/java/com/toddfast/util/convert/TypeConverter.java | TypeConverter.getTypeKeys | private static List<Object> getTypeKeys(Conversion<?> conversion) {
List<Object> result=new ArrayList<Object>();
synchronized (typeConversions) {
// Clone the conversions
Map<Object,Conversion<?>> map=
new HashMap<Object,Conversion<?>>(typeConversions);
// Find all keys that map to this conversion instance
for (Map.Entry<Object,Conversion<?>> entry: map.entrySet()) {
if (entry.getValue() == conversion) {
result.add(entry.getKey());
}
}
}
return result;
} | java | private static List<Object> getTypeKeys(Conversion<?> conversion) {
List<Object> result=new ArrayList<Object>();
synchronized (typeConversions) {
// Clone the conversions
Map<Object,Conversion<?>> map=
new HashMap<Object,Conversion<?>>(typeConversions);
// Find all keys that map to this conversion instance
for (Map.Entry<Object,Conversion<?>> entry: map.entrySet()) {
if (entry.getValue() == conversion) {
result.add(entry.getKey());
}
}
}
return result;
} | [
"private",
"static",
"List",
"<",
"Object",
">",
"getTypeKeys",
"(",
"Conversion",
"<",
"?",
">",
"conversion",
")",
"{",
"List",
"<",
"Object",
">",
"result",
"=",
"new",
"ArrayList",
"<",
"Object",
">",
"(",
")",
";",
"synchronized",
"(",
"typeConversions",
")",
"{",
"// Clone the conversions",
"Map",
"<",
"Object",
",",
"Conversion",
"<",
"?",
">",
">",
"map",
"=",
"new",
"HashMap",
"<",
"Object",
",",
"Conversion",
"<",
"?",
">",
">",
"(",
"typeConversions",
")",
";",
"// Find all keys that map to this conversion instance",
"for",
"(",
"Map",
".",
"Entry",
"<",
"Object",
",",
"Conversion",
"<",
"?",
">",
">",
"entry",
":",
"map",
".",
"entrySet",
"(",
")",
")",
"{",
"if",
"(",
"entry",
".",
"getValue",
"(",
")",
"==",
"conversion",
")",
"{",
"result",
".",
"add",
"(",
"entry",
".",
"getKey",
"(",
")",
")",
";",
"}",
"}",
"}",
"return",
"result",
";",
"}"
] | Discover all the type key mappings for this conversion | [
"Discover",
"all",
"the",
"type",
"key",
"mappings",
"for",
"this",
"conversion"
] | 44efa352254faa49edaba5c5935389705aa12b90 | https://github.com/toddfast/typeconverter/blob/44efa352254faa49edaba5c5935389705aa12b90/src/main/java/com/toddfast/util/convert/TypeConverter.java#L244-L262 |
140,115 | toddfast/typeconverter | src/main/java/com/toddfast/util/convert/TypeConverter.java | TypeConverter.getTypeConversion | private static Conversion<?> getTypeConversion(
Object typeKey, Object value) {
// Check if the provided value is already of the target type
if (typeKey instanceof Class && ((Class)typeKey)!=Object.class
&& ((Class)typeKey).isInstance(value)) {
return IDENTITY_CONVERSION;
}
// Find the type conversion object
return (value instanceof Convertible)
? ((Convertible)value).getTypeConversion(typeKey)
: typeConversions.get(typeKey);
} | java | private static Conversion<?> getTypeConversion(
Object typeKey, Object value) {
// Check if the provided value is already of the target type
if (typeKey instanceof Class && ((Class)typeKey)!=Object.class
&& ((Class)typeKey).isInstance(value)) {
return IDENTITY_CONVERSION;
}
// Find the type conversion object
return (value instanceof Convertible)
? ((Convertible)value).getTypeConversion(typeKey)
: typeConversions.get(typeKey);
} | [
"private",
"static",
"Conversion",
"<",
"?",
">",
"getTypeConversion",
"(",
"Object",
"typeKey",
",",
"Object",
"value",
")",
"{",
"// Check if the provided value is already of the target type",
"if",
"(",
"typeKey",
"instanceof",
"Class",
"&&",
"(",
"(",
"Class",
")",
"typeKey",
")",
"!=",
"Object",
".",
"class",
"&&",
"(",
"(",
"Class",
")",
"typeKey",
")",
".",
"isInstance",
"(",
"value",
")",
")",
"{",
"return",
"IDENTITY_CONVERSION",
";",
"}",
"// Find the type conversion object",
"return",
"(",
"value",
"instanceof",
"Convertible",
")",
"?",
"(",
"(",
"Convertible",
")",
"value",
")",
".",
"getTypeConversion",
"(",
"typeKey",
")",
":",
"typeConversions",
".",
"get",
"(",
"typeKey",
")",
";",
"}"
] | Obtain a conversion for the specified type key and value | [
"Obtain",
"a",
"conversion",
"for",
"the",
"specified",
"type",
"key",
"and",
"value"
] | 44efa352254faa49edaba5c5935389705aa12b90 | https://github.com/toddfast/typeconverter/blob/44efa352254faa49edaba5c5935389705aa12b90/src/main/java/com/toddfast/util/convert/TypeConverter.java#L412-L425 |
140,116 | qspin/qtaste | kernel/src/main/java/com/qspin/qtaste/ui/jedit/NonWrappingTextPane.java | NonWrappingTextPane.getScrollableTracksViewportWidth | @Override
public boolean getScrollableTracksViewportWidth() {
Component parent = getParent();
ComponentUI myui = getUI();
return parent == null || (myui.getPreferredSize(this).width <= parent.getSize().width);
} | java | @Override
public boolean getScrollableTracksViewportWidth() {
Component parent = getParent();
ComponentUI myui = getUI();
return parent == null || (myui.getPreferredSize(this).width <= parent.getSize().width);
} | [
"@",
"Override",
"public",
"boolean",
"getScrollableTracksViewportWidth",
"(",
")",
"{",
"Component",
"parent",
"=",
"getParent",
"(",
")",
";",
"ComponentUI",
"myui",
"=",
"getUI",
"(",
")",
";",
"return",
"parent",
"==",
"null",
"||",
"(",
"myui",
".",
"getPreferredSize",
"(",
"this",
")",
".",
"width",
"<=",
"parent",
".",
"getSize",
"(",
")",
".",
"width",
")",
";",
"}"
] | to preserve the full width of the text | [
"to",
"preserve",
"the",
"full",
"width",
"of",
"the",
"text"
] | ba45d4d86eb29b92f157c6e98536dee2002ddfdc | https://github.com/qspin/qtaste/blob/ba45d4d86eb29b92f157c6e98536dee2002ddfdc/kernel/src/main/java/com/qspin/qtaste/ui/jedit/NonWrappingTextPane.java#L266-L272 |
140,117 | qspin/qtaste | kernel/src/main/java/com/qspin/qtaste/ui/jedit/NonWrappingTextPane.java | NonWrappingTextPane.yToLine | public int yToLine(int y) {
FontMetrics fm = this.getFontMetrics(this.getFont());
int height = fm.getHeight();
Document doc = this.getDocument();
int length = doc.getLength();
Element map = doc.getDefaultRootElement();
int startLine = map.getElementIndex(0);
int endline = map.getElementIndex(length);
return Math.max(0, Math.min(endline - 1, y / height + startLine)) - 1;
} | java | public int yToLine(int y) {
FontMetrics fm = this.getFontMetrics(this.getFont());
int height = fm.getHeight();
Document doc = this.getDocument();
int length = doc.getLength();
Element map = doc.getDefaultRootElement();
int startLine = map.getElementIndex(0);
int endline = map.getElementIndex(length);
return Math.max(0, Math.min(endline - 1, y / height + startLine)) - 1;
} | [
"public",
"int",
"yToLine",
"(",
"int",
"y",
")",
"{",
"FontMetrics",
"fm",
"=",
"this",
".",
"getFontMetrics",
"(",
"this",
".",
"getFont",
"(",
")",
")",
";",
"int",
"height",
"=",
"fm",
".",
"getHeight",
"(",
")",
";",
"Document",
"doc",
"=",
"this",
".",
"getDocument",
"(",
")",
";",
"int",
"length",
"=",
"doc",
".",
"getLength",
"(",
")",
";",
"Element",
"map",
"=",
"doc",
".",
"getDefaultRootElement",
"(",
")",
";",
"int",
"startLine",
"=",
"map",
".",
"getElementIndex",
"(",
"0",
")",
";",
"int",
"endline",
"=",
"map",
".",
"getElementIndex",
"(",
"length",
")",
";",
"return",
"Math",
".",
"max",
"(",
"0",
",",
"Math",
".",
"min",
"(",
"endline",
"-",
"1",
",",
"y",
"/",
"height",
"+",
"startLine",
")",
")",
"-",
"1",
";",
"}"
] | Converts a y co-ordinate to a line index.
@param y The y co-ordinate | [
"Converts",
"a",
"y",
"co",
"-",
"ordinate",
"to",
"a",
"line",
"index",
"."
] | ba45d4d86eb29b92f157c6e98536dee2002ddfdc | https://github.com/qspin/qtaste/blob/ba45d4d86eb29b92f157c6e98536dee2002ddfdc/kernel/src/main/java/com/qspin/qtaste/ui/jedit/NonWrappingTextPane.java#L372-L382 |
140,118 | qspin/qtaste | kernel/src/main/java/com/qspin/qtaste/kernel/campaign/CampaignManager.java | CampaignManager.readFile | public Campaign readFile(String fileName) throws Exception {
Campaign result = new Campaign();
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse(fileName);
doc.getDocumentElement().normalize();
Element el = doc.getDocumentElement();
if (!el.getNodeName().equals("campaign")) {
throw new Exception(fileName + " is not a valid xml campain file");
}
result.name = el.getAttributeNode("name").getValue();
NodeList nodeLst = doc.getElementsByTagName("run");
for (int s = 0; s < nodeLst.getLength(); s++) {
Node node = nodeLst.item(s);
if (node.getNodeType() == Node.ELEMENT_NODE) {
Element element = (Element) node;
CampaignRun run = new CampaignRun();
run.testbed = element.getAttribute("testbed");
result.runs.add(run);
NodeList nodeList = element.getElementsByTagName("testsuite");
for (int t = 0; t < nodeList.getLength(); t++) {
TestSuiteParams params = new TestSuiteParams();
run.testsuites.add(params);
params.setDirectory(nodeList.item(t).getAttributes().getNamedItem("directory").getNodeValue());
NodeList childList = nodeList.item(t).getChildNodes();
for (int c = 0; c < childList.getLength(); c++) {
Node childNode = childList.item(c);
if (childNode.getNodeName().equals("testdata")) {
String selectorStr = childNode.getAttributes().getNamedItem("selector").getNodeValue();
String[] selectedRowsStr = selectorStr.split(",");
TreeSet<Integer> selectedRows = new TreeSet<>();
for (String selectedRowStr : selectedRowsStr) {
selectedRows.add(Integer.parseInt(selectedRowStr));
}
params.setDataRows(selectedRows);
}
if (childList.item(c).getNodeName().equals("loopInHours")) {
params.setLoopInHours(true);
}
if (childList.item(c).getNodeName().equals("count")) {
try {
params.setCount(Integer.parseInt(childList.item(c).getTextContent()));
} catch (NumberFormatException e) {
logger.error("count field in " + fileName + " file should be numeric");
}
}
}
}
}
}
return result;
} | java | public Campaign readFile(String fileName) throws Exception {
Campaign result = new Campaign();
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse(fileName);
doc.getDocumentElement().normalize();
Element el = doc.getDocumentElement();
if (!el.getNodeName().equals("campaign")) {
throw new Exception(fileName + " is not a valid xml campain file");
}
result.name = el.getAttributeNode("name").getValue();
NodeList nodeLst = doc.getElementsByTagName("run");
for (int s = 0; s < nodeLst.getLength(); s++) {
Node node = nodeLst.item(s);
if (node.getNodeType() == Node.ELEMENT_NODE) {
Element element = (Element) node;
CampaignRun run = new CampaignRun();
run.testbed = element.getAttribute("testbed");
result.runs.add(run);
NodeList nodeList = element.getElementsByTagName("testsuite");
for (int t = 0; t < nodeList.getLength(); t++) {
TestSuiteParams params = new TestSuiteParams();
run.testsuites.add(params);
params.setDirectory(nodeList.item(t).getAttributes().getNamedItem("directory").getNodeValue());
NodeList childList = nodeList.item(t).getChildNodes();
for (int c = 0; c < childList.getLength(); c++) {
Node childNode = childList.item(c);
if (childNode.getNodeName().equals("testdata")) {
String selectorStr = childNode.getAttributes().getNamedItem("selector").getNodeValue();
String[] selectedRowsStr = selectorStr.split(",");
TreeSet<Integer> selectedRows = new TreeSet<>();
for (String selectedRowStr : selectedRowsStr) {
selectedRows.add(Integer.parseInt(selectedRowStr));
}
params.setDataRows(selectedRows);
}
if (childList.item(c).getNodeName().equals("loopInHours")) {
params.setLoopInHours(true);
}
if (childList.item(c).getNodeName().equals("count")) {
try {
params.setCount(Integer.parseInt(childList.item(c).getTextContent()));
} catch (NumberFormatException e) {
logger.error("count field in " + fileName + " file should be numeric");
}
}
}
}
}
}
return result;
} | [
"public",
"Campaign",
"readFile",
"(",
"String",
"fileName",
")",
"throws",
"Exception",
"{",
"Campaign",
"result",
"=",
"new",
"Campaign",
"(",
")",
";",
"DocumentBuilderFactory",
"dbf",
"=",
"DocumentBuilderFactory",
".",
"newInstance",
"(",
")",
";",
"DocumentBuilder",
"db",
"=",
"dbf",
".",
"newDocumentBuilder",
"(",
")",
";",
"Document",
"doc",
"=",
"db",
".",
"parse",
"(",
"fileName",
")",
";",
"doc",
".",
"getDocumentElement",
"(",
")",
".",
"normalize",
"(",
")",
";",
"Element",
"el",
"=",
"doc",
".",
"getDocumentElement",
"(",
")",
";",
"if",
"(",
"!",
"el",
".",
"getNodeName",
"(",
")",
".",
"equals",
"(",
"\"campaign\"",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"fileName",
"+",
"\" is not a valid xml campain file\"",
")",
";",
"}",
"result",
".",
"name",
"=",
"el",
".",
"getAttributeNode",
"(",
"\"name\"",
")",
".",
"getValue",
"(",
")",
";",
"NodeList",
"nodeLst",
"=",
"doc",
".",
"getElementsByTagName",
"(",
"\"run\"",
")",
";",
"for",
"(",
"int",
"s",
"=",
"0",
";",
"s",
"<",
"nodeLst",
".",
"getLength",
"(",
")",
";",
"s",
"++",
")",
"{",
"Node",
"node",
"=",
"nodeLst",
".",
"item",
"(",
"s",
")",
";",
"if",
"(",
"node",
".",
"getNodeType",
"(",
")",
"==",
"Node",
".",
"ELEMENT_NODE",
")",
"{",
"Element",
"element",
"=",
"(",
"Element",
")",
"node",
";",
"CampaignRun",
"run",
"=",
"new",
"CampaignRun",
"(",
")",
";",
"run",
".",
"testbed",
"=",
"element",
".",
"getAttribute",
"(",
"\"testbed\"",
")",
";",
"result",
".",
"runs",
".",
"add",
"(",
"run",
")",
";",
"NodeList",
"nodeList",
"=",
"element",
".",
"getElementsByTagName",
"(",
"\"testsuite\"",
")",
";",
"for",
"(",
"int",
"t",
"=",
"0",
";",
"t",
"<",
"nodeList",
".",
"getLength",
"(",
")",
";",
"t",
"++",
")",
"{",
"TestSuiteParams",
"params",
"=",
"new",
"TestSuiteParams",
"(",
")",
";",
"run",
".",
"testsuites",
".",
"add",
"(",
"params",
")",
";",
"params",
".",
"setDirectory",
"(",
"nodeList",
".",
"item",
"(",
"t",
")",
".",
"getAttributes",
"(",
")",
".",
"getNamedItem",
"(",
"\"directory\"",
")",
".",
"getNodeValue",
"(",
")",
")",
";",
"NodeList",
"childList",
"=",
"nodeList",
".",
"item",
"(",
"t",
")",
".",
"getChildNodes",
"(",
")",
";",
"for",
"(",
"int",
"c",
"=",
"0",
";",
"c",
"<",
"childList",
".",
"getLength",
"(",
")",
";",
"c",
"++",
")",
"{",
"Node",
"childNode",
"=",
"childList",
".",
"item",
"(",
"c",
")",
";",
"if",
"(",
"childNode",
".",
"getNodeName",
"(",
")",
".",
"equals",
"(",
"\"testdata\"",
")",
")",
"{",
"String",
"selectorStr",
"=",
"childNode",
".",
"getAttributes",
"(",
")",
".",
"getNamedItem",
"(",
"\"selector\"",
")",
".",
"getNodeValue",
"(",
")",
";",
"String",
"[",
"]",
"selectedRowsStr",
"=",
"selectorStr",
".",
"split",
"(",
"\",\"",
")",
";",
"TreeSet",
"<",
"Integer",
">",
"selectedRows",
"=",
"new",
"TreeSet",
"<>",
"(",
")",
";",
"for",
"(",
"String",
"selectedRowStr",
":",
"selectedRowsStr",
")",
"{",
"selectedRows",
".",
"add",
"(",
"Integer",
".",
"parseInt",
"(",
"selectedRowStr",
")",
")",
";",
"}",
"params",
".",
"setDataRows",
"(",
"selectedRows",
")",
";",
"}",
"if",
"(",
"childList",
".",
"item",
"(",
"c",
")",
".",
"getNodeName",
"(",
")",
".",
"equals",
"(",
"\"loopInHours\"",
")",
")",
"{",
"params",
".",
"setLoopInHours",
"(",
"true",
")",
";",
"}",
"if",
"(",
"childList",
".",
"item",
"(",
"c",
")",
".",
"getNodeName",
"(",
")",
".",
"equals",
"(",
"\"count\"",
")",
")",
"{",
"try",
"{",
"params",
".",
"setCount",
"(",
"Integer",
".",
"parseInt",
"(",
"childList",
".",
"item",
"(",
"c",
")",
".",
"getTextContent",
"(",
")",
")",
")",
";",
"}",
"catch",
"(",
"NumberFormatException",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"count field in \"",
"+",
"fileName",
"+",
"\" file should be numeric\"",
")",
";",
"}",
"}",
"}",
"}",
"}",
"}",
"return",
"result",
";",
"}"
] | Read the xml campaign file
@param fileName the xml campaign file
@return an object describing the campaign
@throws java.lang.Exception | [
"Read",
"the",
"xml",
"campaign",
"file"
] | ba45d4d86eb29b92f157c6e98536dee2002ddfdc | https://github.com/qspin/qtaste/blob/ba45d4d86eb29b92f157c6e98536dee2002ddfdc/kernel/src/main/java/com/qspin/qtaste/kernel/campaign/CampaignManager.java#L83-L142 |
140,119 | qspin/qtaste | kernel/src/main/java/com/qspin/qtaste/kernel/campaign/CampaignManager.java | CampaignManager.execute | public boolean execute(Campaign campaign) {
boolean campaignResult = true;
currentCampaign = campaign;
campaignStartTimeStamp = new Date();
try {
createReport();
for (CampaignRun run : currentCampaign.getRuns()) {
if (TestEngine.isAbortedByUser()) {
break;
}
currentTestBed = run.getTestbed();
String testSuiteName = currentCampaign.getName() + " - " + currentTestBed.substring(0,
currentTestBed.lastIndexOf('.'));
TestBedConfiguration.setConfigFile(StaticConfiguration.TESTBED_CONFIG_DIRECTORY + "/" + currentTestBed);
currentTestSuite = MetaTestSuite.createMetaTestSuite(testSuiteName, run.getTestsuites());
if (currentTestSuite == null) {
continue;
}
currentTestSuite.addTestReportListener(this);
campaignResult &= TestEngine.execute(
currentTestSuite); // NOSONAR - Potentially dangerous use of non-short-circuit logic
currentTestSuite.removeTestReportListener(this);
currentTestSuite = null;
}
CampaignReportManager.getInstance().stopReport();
} finally {
TestEngine.tearDown();
campaignStartTimeStamp = null;
currentCampaign = null;
}
return campaignResult;
} | java | public boolean execute(Campaign campaign) {
boolean campaignResult = true;
currentCampaign = campaign;
campaignStartTimeStamp = new Date();
try {
createReport();
for (CampaignRun run : currentCampaign.getRuns()) {
if (TestEngine.isAbortedByUser()) {
break;
}
currentTestBed = run.getTestbed();
String testSuiteName = currentCampaign.getName() + " - " + currentTestBed.substring(0,
currentTestBed.lastIndexOf('.'));
TestBedConfiguration.setConfigFile(StaticConfiguration.TESTBED_CONFIG_DIRECTORY + "/" + currentTestBed);
currentTestSuite = MetaTestSuite.createMetaTestSuite(testSuiteName, run.getTestsuites());
if (currentTestSuite == null) {
continue;
}
currentTestSuite.addTestReportListener(this);
campaignResult &= TestEngine.execute(
currentTestSuite); // NOSONAR - Potentially dangerous use of non-short-circuit logic
currentTestSuite.removeTestReportListener(this);
currentTestSuite = null;
}
CampaignReportManager.getInstance().stopReport();
} finally {
TestEngine.tearDown();
campaignStartTimeStamp = null;
currentCampaign = null;
}
return campaignResult;
} | [
"public",
"boolean",
"execute",
"(",
"Campaign",
"campaign",
")",
"{",
"boolean",
"campaignResult",
"=",
"true",
";",
"currentCampaign",
"=",
"campaign",
";",
"campaignStartTimeStamp",
"=",
"new",
"Date",
"(",
")",
";",
"try",
"{",
"createReport",
"(",
")",
";",
"for",
"(",
"CampaignRun",
"run",
":",
"currentCampaign",
".",
"getRuns",
"(",
")",
")",
"{",
"if",
"(",
"TestEngine",
".",
"isAbortedByUser",
"(",
")",
")",
"{",
"break",
";",
"}",
"currentTestBed",
"=",
"run",
".",
"getTestbed",
"(",
")",
";",
"String",
"testSuiteName",
"=",
"currentCampaign",
".",
"getName",
"(",
")",
"+",
"\" - \"",
"+",
"currentTestBed",
".",
"substring",
"(",
"0",
",",
"currentTestBed",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
")",
";",
"TestBedConfiguration",
".",
"setConfigFile",
"(",
"StaticConfiguration",
".",
"TESTBED_CONFIG_DIRECTORY",
"+",
"\"/\"",
"+",
"currentTestBed",
")",
";",
"currentTestSuite",
"=",
"MetaTestSuite",
".",
"createMetaTestSuite",
"(",
"testSuiteName",
",",
"run",
".",
"getTestsuites",
"(",
")",
")",
";",
"if",
"(",
"currentTestSuite",
"==",
"null",
")",
"{",
"continue",
";",
"}",
"currentTestSuite",
".",
"addTestReportListener",
"(",
"this",
")",
";",
"campaignResult",
"&=",
"TestEngine",
".",
"execute",
"(",
"currentTestSuite",
")",
";",
"// NOSONAR - Potentially dangerous use of non-short-circuit logic",
"currentTestSuite",
".",
"removeTestReportListener",
"(",
"this",
")",
";",
"currentTestSuite",
"=",
"null",
";",
"}",
"CampaignReportManager",
".",
"getInstance",
"(",
")",
".",
"stopReport",
"(",
")",
";",
"}",
"finally",
"{",
"TestEngine",
".",
"tearDown",
"(",
")",
";",
"campaignStartTimeStamp",
"=",
"null",
";",
"currentCampaign",
"=",
"null",
";",
"}",
"return",
"campaignResult",
";",
"}"
] | Executes a campaign
@param campaign the campaign to execute. | [
"Executes",
"a",
"campaign"
] | ba45d4d86eb29b92f157c6e98536dee2002ddfdc | https://github.com/qspin/qtaste/blob/ba45d4d86eb29b92f157c6e98536dee2002ddfdc/kernel/src/main/java/com/qspin/qtaste/kernel/campaign/CampaignManager.java#L167-L199 |
140,120 | qspin/qtaste | kernel/src/main/java/com/qspin/qtaste/kernel/campaign/CampaignManager.java | CampaignManager.createReport | private void createReport() {
CampaignReportManager.getInstance().startReport(campaignStartTimeStamp, currentCampaign.getName());
for (CampaignRun run : currentCampaign.getRuns()) {
CampaignResult result = new CampaignResult(run.getTestbed());
result.setStatus(Status.NOT_EXECUTED);
CampaignReportManager.getInstance().putEntry(result);
}
CampaignReportManager.getInstance().refresh();
} | java | private void createReport() {
CampaignReportManager.getInstance().startReport(campaignStartTimeStamp, currentCampaign.getName());
for (CampaignRun run : currentCampaign.getRuns()) {
CampaignResult result = new CampaignResult(run.getTestbed());
result.setStatus(Status.NOT_EXECUTED);
CampaignReportManager.getInstance().putEntry(result);
}
CampaignReportManager.getInstance().refresh();
} | [
"private",
"void",
"createReport",
"(",
")",
"{",
"CampaignReportManager",
".",
"getInstance",
"(",
")",
".",
"startReport",
"(",
"campaignStartTimeStamp",
",",
"currentCampaign",
".",
"getName",
"(",
")",
")",
";",
"for",
"(",
"CampaignRun",
"run",
":",
"currentCampaign",
".",
"getRuns",
"(",
")",
")",
"{",
"CampaignResult",
"result",
"=",
"new",
"CampaignResult",
"(",
"run",
".",
"getTestbed",
"(",
")",
")",
";",
"result",
".",
"setStatus",
"(",
"Status",
".",
"NOT_EXECUTED",
")",
";",
"CampaignReportManager",
".",
"getInstance",
"(",
")",
".",
"putEntry",
"(",
"result",
")",
";",
"}",
"CampaignReportManager",
".",
"getInstance",
"(",
")",
".",
"refresh",
"(",
")",
";",
"}"
] | Create a empty report. All campaign run will be "Not Executed" | [
"Create",
"a",
"empty",
"report",
".",
"All",
"campaign",
"run",
"will",
"be",
"Not",
"Executed"
] | ba45d4d86eb29b92f157c6e98536dee2002ddfdc | https://github.com/qspin/qtaste/blob/ba45d4d86eb29b92f157c6e98536dee2002ddfdc/kernel/src/main/java/com/qspin/qtaste/kernel/campaign/CampaignManager.java#L215-L224 |
140,121 | qspin/qtaste | kernel/src/main/java/com/qspin/qtaste/tcom/db/impl/JDBCClientImpl.java | JDBCClientImpl.open | public void open() throws SQLException, ClassNotFoundException {
logger.info("Using database driver: " + jdbcDriver);
Class.forName(jdbcDriver);
logger.info("Using database.url: " + jdbcURL);
// connect login/pass
con = DriverManager.getConnection(jdbcURL, user, password);
// Exception will be thrown if something went wrong
connected = true;
} | java | public void open() throws SQLException, ClassNotFoundException {
logger.info("Using database driver: " + jdbcDriver);
Class.forName(jdbcDriver);
logger.info("Using database.url: " + jdbcURL);
// connect login/pass
con = DriverManager.getConnection(jdbcURL, user, password);
// Exception will be thrown if something went wrong
connected = true;
} | [
"public",
"void",
"open",
"(",
")",
"throws",
"SQLException",
",",
"ClassNotFoundException",
"{",
"logger",
".",
"info",
"(",
"\"Using database driver: \"",
"+",
"jdbcDriver",
")",
";",
"Class",
".",
"forName",
"(",
"jdbcDriver",
")",
";",
"logger",
".",
"info",
"(",
"\"Using database.url: \"",
"+",
"jdbcURL",
")",
";",
"// connect login/pass",
"con",
"=",
"DriverManager",
".",
"getConnection",
"(",
"jdbcURL",
",",
"user",
",",
"password",
")",
";",
"// Exception will be thrown if something went wrong",
"connected",
"=",
"true",
";",
"}"
] | Open a JDBC connection to the database
@throws java.sql.SQLException If a SQL error occurs
@throws java.lang.ClassNotFoundException If the driver class does not exists | [
"Open",
"a",
"JDBC",
"connection",
"to",
"the",
"database"
] | ba45d4d86eb29b92f157c6e98536dee2002ddfdc | https://github.com/qspin/qtaste/blob/ba45d4d86eb29b92f157c6e98536dee2002ddfdc/kernel/src/main/java/com/qspin/qtaste/tcom/db/impl/JDBCClientImpl.java#L77-L85 |
140,122 | qspin/qtaste | kernel/src/main/java/com/qspin/qtaste/tcom/db/impl/JDBCClientImpl.java | JDBCClientImpl.executeQuery | public ResultSet executeQuery(String query) throws SQLException, ClassNotFoundException {
if (!connected) {
open();
}
Statement stmt = con.createStatement();
return stmt.executeQuery(query);
} | java | public ResultSet executeQuery(String query) throws SQLException, ClassNotFoundException {
if (!connected) {
open();
}
Statement stmt = con.createStatement();
return stmt.executeQuery(query);
} | [
"public",
"ResultSet",
"executeQuery",
"(",
"String",
"query",
")",
"throws",
"SQLException",
",",
"ClassNotFoundException",
"{",
"if",
"(",
"!",
"connected",
")",
"{",
"open",
"(",
")",
";",
"}",
"Statement",
"stmt",
"=",
"con",
".",
"createStatement",
"(",
")",
";",
"return",
"stmt",
".",
"executeQuery",
"(",
"query",
")",
";",
"}"
] | Execute the specified query
If the SQL connection if not open, it will be opened automatically
@param query The specified query
@return the ResultSet object. The returned ResultSet has to be closed manually.
@throws java.sql.SQLException If a SQL error occurs
@throws java.lang.ClassNotFoundException If the driver class does not exists | [
"Execute",
"the",
"specified",
"query",
"If",
"the",
"SQL",
"connection",
"if",
"not",
"open",
"it",
"will",
"be",
"opened",
"automatically"
] | ba45d4d86eb29b92f157c6e98536dee2002ddfdc | https://github.com/qspin/qtaste/blob/ba45d4d86eb29b92f157c6e98536dee2002ddfdc/kernel/src/main/java/com/qspin/qtaste/tcom/db/impl/JDBCClientImpl.java#L131-L138 |
140,123 | qspin/qtaste | kernel/src/main/java/com/qspin/qtaste/tcom/db/impl/JDBCClientImpl.java | JDBCClientImpl.executeCommand | public boolean executeCommand(String query) throws SQLException, ClassNotFoundException {
if (!connected) {
open();
}
Statement stmt = con.createStatement();
return stmt.execute(query);
} | java | public boolean executeCommand(String query) throws SQLException, ClassNotFoundException {
if (!connected) {
open();
}
Statement stmt = con.createStatement();
return stmt.execute(query);
} | [
"public",
"boolean",
"executeCommand",
"(",
"String",
"query",
")",
"throws",
"SQLException",
",",
"ClassNotFoundException",
"{",
"if",
"(",
"!",
"connected",
")",
"{",
"open",
"(",
")",
";",
"}",
"Statement",
"stmt",
"=",
"con",
".",
"createStatement",
"(",
")",
";",
"return",
"stmt",
".",
"execute",
"(",
"query",
")",
";",
"}"
] | Execute the specified SQL command
If the SQL connection if not open, it will be opened automatically
@param query The specified query
@return the ResultSet object. The returned ResultSet has to be closed manually.
@throws java.sql.SQLException If a SQL error occurs
@throws java.lang.ClassNotFoundException If the driver class does not exists | [
"Execute",
"the",
"specified",
"SQL",
"command",
"If",
"the",
"SQL",
"connection",
"if",
"not",
"open",
"it",
"will",
"be",
"opened",
"automatically"
] | ba45d4d86eb29b92f157c6e98536dee2002ddfdc | https://github.com/qspin/qtaste/blob/ba45d4d86eb29b92f157c6e98536dee2002ddfdc/kernel/src/main/java/com/qspin/qtaste/tcom/db/impl/JDBCClientImpl.java#L149-L156 |
140,124 | qspin/qtaste | plugins_src/sikuli/src/main/java/com/qspin/qtaste/sikuli/Area.java | Area.doubleClick | public void doubleClick(String fileName) throws QTasteException
{
try {
new Region(this.rect).doubleClick(fileName);
}
catch(Exception ex)
{
throw new QTasteException(ex.getMessage(), ex);
}
} | java | public void doubleClick(String fileName) throws QTasteException
{
try {
new Region(this.rect).doubleClick(fileName);
}
catch(Exception ex)
{
throw new QTasteException(ex.getMessage(), ex);
}
} | [
"public",
"void",
"doubleClick",
"(",
"String",
"fileName",
")",
"throws",
"QTasteException",
"{",
"try",
"{",
"new",
"Region",
"(",
"this",
".",
"rect",
")",
".",
"doubleClick",
"(",
"fileName",
")",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"throw",
"new",
"QTasteException",
"(",
"ex",
".",
"getMessage",
"(",
")",
",",
"ex",
")",
";",
"}",
"}"
] | Simulates a double click on the specified image of the area.
@param fileName The image to find.
@throws QTasteException if the file doesn't exist or if no occurrence is found. | [
"Simulates",
"a",
"double",
"click",
"on",
"the",
"specified",
"image",
"of",
"the",
"area",
"."
] | ba45d4d86eb29b92f157c6e98536dee2002ddfdc | https://github.com/qspin/qtaste/blob/ba45d4d86eb29b92f157c6e98536dee2002ddfdc/plugins_src/sikuli/src/main/java/com/qspin/qtaste/sikuli/Area.java#L115-L125 |
140,125 | qspin/qtaste | kernel/src/main/java/com/qspin/qtaste/util/OS.java | OS.getType | public static Type getType() {
String osName = System.getProperty("os.name").toLowerCase();
if (osName.contains("windows")) {
return Type.WINDOWS;
} else if (osName.contains("linux")) {
return Type.LINUX;
} else if (osName.contains("mac")) {
return Type.MAC;
}
return Type.UNKNOWN;
} | java | public static Type getType() {
String osName = System.getProperty("os.name").toLowerCase();
if (osName.contains("windows")) {
return Type.WINDOWS;
} else if (osName.contains("linux")) {
return Type.LINUX;
} else if (osName.contains("mac")) {
return Type.MAC;
}
return Type.UNKNOWN;
} | [
"public",
"static",
"Type",
"getType",
"(",
")",
"{",
"String",
"osName",
"=",
"System",
".",
"getProperty",
"(",
"\"os.name\"",
")",
".",
"toLowerCase",
"(",
")",
";",
"if",
"(",
"osName",
".",
"contains",
"(",
"\"windows\"",
")",
")",
"{",
"return",
"Type",
".",
"WINDOWS",
";",
"}",
"else",
"if",
"(",
"osName",
".",
"contains",
"(",
"\"linux\"",
")",
")",
"{",
"return",
"Type",
".",
"LINUX",
";",
"}",
"else",
"if",
"(",
"osName",
".",
"contains",
"(",
"\"mac\"",
")",
")",
"{",
"return",
"Type",
".",
"MAC",
";",
"}",
"return",
"Type",
".",
"UNKNOWN",
";",
"}"
] | Get OS type.
@return OS type | [
"Get",
"OS",
"type",
"."
] | ba45d4d86eb29b92f157c6e98536dee2002ddfdc | https://github.com/qspin/qtaste/blob/ba45d4d86eb29b92f157c6e98536dee2002ddfdc/kernel/src/main/java/com/qspin/qtaste/util/OS.java#L39-L51 |
140,126 | qspin/qtaste | kernel/src/main/java/com/qspin/qtaste/ui/tools/Utils.java | Utils.copyFiles | public static void copyFiles(File src, File dest) throws IOException {
if (src.isDirectory()) {
dest.mkdirs();
String list[] = src.list();
for (String fileName : list) {
String dest1 = dest.getPath() + "/" + fileName;
String src1 = src.getPath() + "/" + fileName;
// i.e: avoid .svn directory
File src1_ = new File(src1);
File dest1_ = new File(dest1);
if (!src1_.isHidden()) {
copyFiles(src1_, dest1_);
}
}
} else {
FileInputStream fin = new FileInputStream(src);
FileOutputStream fout = new FileOutputStream(dest);
int c;
while ((c = fin.read()) >= 0) {
fout.write(c);
}
fin.close();
fout.close();
}
} | java | public static void copyFiles(File src, File dest) throws IOException {
if (src.isDirectory()) {
dest.mkdirs();
String list[] = src.list();
for (String fileName : list) {
String dest1 = dest.getPath() + "/" + fileName;
String src1 = src.getPath() + "/" + fileName;
// i.e: avoid .svn directory
File src1_ = new File(src1);
File dest1_ = new File(dest1);
if (!src1_.isHidden()) {
copyFiles(src1_, dest1_);
}
}
} else {
FileInputStream fin = new FileInputStream(src);
FileOutputStream fout = new FileOutputStream(dest);
int c;
while ((c = fin.read()) >= 0) {
fout.write(c);
}
fin.close();
fout.close();
}
} | [
"public",
"static",
"void",
"copyFiles",
"(",
"File",
"src",
",",
"File",
"dest",
")",
"throws",
"IOException",
"{",
"if",
"(",
"src",
".",
"isDirectory",
"(",
")",
")",
"{",
"dest",
".",
"mkdirs",
"(",
")",
";",
"String",
"list",
"[",
"]",
"=",
"src",
".",
"list",
"(",
")",
";",
"for",
"(",
"String",
"fileName",
":",
"list",
")",
"{",
"String",
"dest1",
"=",
"dest",
".",
"getPath",
"(",
")",
"+",
"\"/\"",
"+",
"fileName",
";",
"String",
"src1",
"=",
"src",
".",
"getPath",
"(",
")",
"+",
"\"/\"",
"+",
"fileName",
";",
"// i.e: avoid .svn directory",
"File",
"src1_",
"=",
"new",
"File",
"(",
"src1",
")",
";",
"File",
"dest1_",
"=",
"new",
"File",
"(",
"dest1",
")",
";",
"if",
"(",
"!",
"src1_",
".",
"isHidden",
"(",
")",
")",
"{",
"copyFiles",
"(",
"src1_",
",",
"dest1_",
")",
";",
"}",
"}",
"}",
"else",
"{",
"FileInputStream",
"fin",
"=",
"new",
"FileInputStream",
"(",
"src",
")",
";",
"FileOutputStream",
"fout",
"=",
"new",
"FileOutputStream",
"(",
"dest",
")",
";",
"int",
"c",
";",
"while",
"(",
"(",
"c",
"=",
"fin",
".",
"read",
"(",
")",
")",
">=",
"0",
")",
"{",
"fout",
".",
"write",
"(",
"c",
")",
";",
"}",
"fin",
".",
"close",
"(",
")",
";",
"fout",
".",
"close",
"(",
")",
";",
"}",
"}"
] | The method copyFiles being defined | [
"The",
"method",
"copyFiles",
"being",
"defined"
] | ba45d4d86eb29b92f157c6e98536dee2002ddfdc | https://github.com/qspin/qtaste/blob/ba45d4d86eb29b92f157c6e98536dee2002ddfdc/kernel/src/main/java/com/qspin/qtaste/ui/tools/Utils.java#L75-L100 |
140,127 | qspin/qtaste | kernel/src/main/java/com/qspin/qtaste/ui/tools/Utils.java | Utils.collapseJTreeNode | public static int collapseJTreeNode(javax.swing.JTree tree, javax.swing.tree.TreeModel model, Object node, int row, int
depth) {
if (node != null && !model.isLeaf(node)) {
tree.collapseRow(row);
if (depth != 0) {
for (int index = 0; row + 1 < tree.getRowCount() && index < model.getChildCount(node); index++) {
row++;
Object child = model.getChild(node, index);
if (child == null) {
break;
}
javax.swing.tree.TreePath path;
while ((path = tree.getPathForRow(row)) != null && path.getLastPathComponent() != child) {
row++;
}
if (path == null) {
break;
}
row = collapseJTreeNode(tree, model, child, row, depth - 1);
}
}
}
return row;
} | java | public static int collapseJTreeNode(javax.swing.JTree tree, javax.swing.tree.TreeModel model, Object node, int row, int
depth) {
if (node != null && !model.isLeaf(node)) {
tree.collapseRow(row);
if (depth != 0) {
for (int index = 0; row + 1 < tree.getRowCount() && index < model.getChildCount(node); index++) {
row++;
Object child = model.getChild(node, index);
if (child == null) {
break;
}
javax.swing.tree.TreePath path;
while ((path = tree.getPathForRow(row)) != null && path.getLastPathComponent() != child) {
row++;
}
if (path == null) {
break;
}
row = collapseJTreeNode(tree, model, child, row, depth - 1);
}
}
}
return row;
} | [
"public",
"static",
"int",
"collapseJTreeNode",
"(",
"javax",
".",
"swing",
".",
"JTree",
"tree",
",",
"javax",
".",
"swing",
".",
"tree",
".",
"TreeModel",
"model",
",",
"Object",
"node",
",",
"int",
"row",
",",
"int",
"depth",
")",
"{",
"if",
"(",
"node",
"!=",
"null",
"&&",
"!",
"model",
".",
"isLeaf",
"(",
"node",
")",
")",
"{",
"tree",
".",
"collapseRow",
"(",
"row",
")",
";",
"if",
"(",
"depth",
"!=",
"0",
")",
"{",
"for",
"(",
"int",
"index",
"=",
"0",
";",
"row",
"+",
"1",
"<",
"tree",
".",
"getRowCount",
"(",
")",
"&&",
"index",
"<",
"model",
".",
"getChildCount",
"(",
"node",
")",
";",
"index",
"++",
")",
"{",
"row",
"++",
";",
"Object",
"child",
"=",
"model",
".",
"getChild",
"(",
"node",
",",
"index",
")",
";",
"if",
"(",
"child",
"==",
"null",
")",
"{",
"break",
";",
"}",
"javax",
".",
"swing",
".",
"tree",
".",
"TreePath",
"path",
";",
"while",
"(",
"(",
"path",
"=",
"tree",
".",
"getPathForRow",
"(",
"row",
")",
")",
"!=",
"null",
"&&",
"path",
".",
"getLastPathComponent",
"(",
")",
"!=",
"child",
")",
"{",
"row",
"++",
";",
"}",
"if",
"(",
"path",
"==",
"null",
")",
"{",
"break",
";",
"}",
"row",
"=",
"collapseJTreeNode",
"(",
"tree",
",",
"model",
",",
"child",
",",
"row",
",",
"depth",
"-",
"1",
")",
";",
"}",
"}",
"}",
"return",
"row",
";",
"}"
] | Expands a given node in a JTree.
@param tree The JTree to expand.
@param model The TreeModel for tree.
@param node The node within tree to expand.
@param row The displayed row in tree that represents
node.
@param depth The depth to which the tree should be expanded.
Zero will just expand node, a negative
value will fully expand the tree, and a positive
value will recursively expand the tree to that
depth relative to node. | [
"Expands",
"a",
"given",
"node",
"in",
"a",
"JTree",
"."
] | ba45d4d86eb29b92f157c6e98536dee2002ddfdc | https://github.com/qspin/qtaste/blob/ba45d4d86eb29b92f157c6e98536dee2002ddfdc/kernel/src/main/java/com/qspin/qtaste/ui/tools/Utils.java#L182-L205 |
140,128 | qspin/qtaste | kernel/src/main/java/com/qspin/qtaste/tcom/db/impl/ResultSetXMLConverter.java | ResultSetXMLConverter.getDocumentAsXmlString | public static String getDocumentAsXmlString(Document doc) throws TransformerConfigurationException, TransformerException {
DOMSource domSource = new DOMSource(doc);
TransformerFactory tf = TransformerFactory.newInstance();
try {
tf.setAttribute("indent-number", 4);
} catch (IllegalArgumentException e) {
// ignore
}
Transformer transformer = tf.newTransformer();
//transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION,"yes");
transformer.setOutputProperty(OutputKeys.METHOD, "xml");
transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
//
java.io.StringWriter sw = new java.io.StringWriter();
StreamResult sr = new StreamResult(sw);
transformer.transform(domSource, sr);
return sw.toString();
} | java | public static String getDocumentAsXmlString(Document doc) throws TransformerConfigurationException, TransformerException {
DOMSource domSource = new DOMSource(doc);
TransformerFactory tf = TransformerFactory.newInstance();
try {
tf.setAttribute("indent-number", 4);
} catch (IllegalArgumentException e) {
// ignore
}
Transformer transformer = tf.newTransformer();
//transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION,"yes");
transformer.setOutputProperty(OutputKeys.METHOD, "xml");
transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
//
java.io.StringWriter sw = new java.io.StringWriter();
StreamResult sr = new StreamResult(sw);
transformer.transform(domSource, sr);
return sw.toString();
} | [
"public",
"static",
"String",
"getDocumentAsXmlString",
"(",
"Document",
"doc",
")",
"throws",
"TransformerConfigurationException",
",",
"TransformerException",
"{",
"DOMSource",
"domSource",
"=",
"new",
"DOMSource",
"(",
"doc",
")",
";",
"TransformerFactory",
"tf",
"=",
"TransformerFactory",
".",
"newInstance",
"(",
")",
";",
"try",
"{",
"tf",
".",
"setAttribute",
"(",
"\"indent-number\"",
",",
"4",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"e",
")",
"{",
"// ignore",
"}",
"Transformer",
"transformer",
"=",
"tf",
".",
"newTransformer",
"(",
")",
";",
"//transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION,\"yes\");",
"transformer",
".",
"setOutputProperty",
"(",
"OutputKeys",
".",
"METHOD",
",",
"\"xml\"",
")",
";",
"transformer",
".",
"setOutputProperty",
"(",
"OutputKeys",
".",
"ENCODING",
",",
"\"UTF-8\"",
")",
";",
"transformer",
".",
"setOutputProperty",
"(",
"\"{http://xml.apache.org/xslt}indent-amount\"",
",",
"\"4\"",
")",
";",
"transformer",
".",
"setOutputProperty",
"(",
"OutputKeys",
".",
"INDENT",
",",
"\"yes\"",
")",
";",
"//",
"java",
".",
"io",
".",
"StringWriter",
"sw",
"=",
"new",
"java",
".",
"io",
".",
"StringWriter",
"(",
")",
";",
"StreamResult",
"sr",
"=",
"new",
"StreamResult",
"(",
"sw",
")",
";",
"transformer",
".",
"transform",
"(",
"domSource",
",",
"sr",
")",
";",
"return",
"sw",
".",
"toString",
"(",
")",
";",
"}"
] | Return the XMLDocument formatted as a String
@param doc the XML Document
@return A String representation of the XML Document
@throws javax.xml.transform.TransformerConfigurationException
@throws javax.xml.transform.TransformerException | [
"Return",
"the",
"XMLDocument",
"formatted",
"as",
"a",
"String"
] | ba45d4d86eb29b92f157c6e98536dee2002ddfdc | https://github.com/qspin/qtaste/blob/ba45d4d86eb29b92f157c6e98536dee2002ddfdc/kernel/src/main/java/com/qspin/qtaste/tcom/db/impl/ResultSetXMLConverter.java#L168-L187 |
140,129 | qspin/qtaste | kernel/src/main/java/com/qspin/qtaste/tcom/rlogin/RLogin.java | RLogin.connect | public boolean connect() {
if (client.isConnected()) {
logger.warn("Already connected");
return true;
}
try {
logger.info("Connecting to remote host " + remoteHost);
client.connect(remoteHost);
client.rlogin(localUser, remoteUser, terminalType);
writer = new OutputStreamWriter(client.getOutputStream());
outputReaderThread = new Thread(new OutputReader());
outputReaderThread.start();
if (interactive) {
standardInputReaderThread = new Thread(new StandardInputReader());
standardInputReaderThread.start();
}
try {
Thread.sleep(200);
} catch (InterruptedException ex) {
}
if (client.isConnected()) {
return true;
} else {
logger.fatal("Client has been immediately disconnected from remote host:" + remoteHost);
return false;
}
//outputReaderThread.
} catch (IOException e) {
logger.fatal("Could not connect to remote host:" + remoteHost, e);
return false;
}
} | java | public boolean connect() {
if (client.isConnected()) {
logger.warn("Already connected");
return true;
}
try {
logger.info("Connecting to remote host " + remoteHost);
client.connect(remoteHost);
client.rlogin(localUser, remoteUser, terminalType);
writer = new OutputStreamWriter(client.getOutputStream());
outputReaderThread = new Thread(new OutputReader());
outputReaderThread.start();
if (interactive) {
standardInputReaderThread = new Thread(new StandardInputReader());
standardInputReaderThread.start();
}
try {
Thread.sleep(200);
} catch (InterruptedException ex) {
}
if (client.isConnected()) {
return true;
} else {
logger.fatal("Client has been immediately disconnected from remote host:" + remoteHost);
return false;
}
//outputReaderThread.
} catch (IOException e) {
logger.fatal("Could not connect to remote host:" + remoteHost, e);
return false;
}
} | [
"public",
"boolean",
"connect",
"(",
")",
"{",
"if",
"(",
"client",
".",
"isConnected",
"(",
")",
")",
"{",
"logger",
".",
"warn",
"(",
"\"Already connected\"",
")",
";",
"return",
"true",
";",
"}",
"try",
"{",
"logger",
".",
"info",
"(",
"\"Connecting to remote host \"",
"+",
"remoteHost",
")",
";",
"client",
".",
"connect",
"(",
"remoteHost",
")",
";",
"client",
".",
"rlogin",
"(",
"localUser",
",",
"remoteUser",
",",
"terminalType",
")",
";",
"writer",
"=",
"new",
"OutputStreamWriter",
"(",
"client",
".",
"getOutputStream",
"(",
")",
")",
";",
"outputReaderThread",
"=",
"new",
"Thread",
"(",
"new",
"OutputReader",
"(",
")",
")",
";",
"outputReaderThread",
".",
"start",
"(",
")",
";",
"if",
"(",
"interactive",
")",
"{",
"standardInputReaderThread",
"=",
"new",
"Thread",
"(",
"new",
"StandardInputReader",
"(",
")",
")",
";",
"standardInputReaderThread",
".",
"start",
"(",
")",
";",
"}",
"try",
"{",
"Thread",
".",
"sleep",
"(",
"200",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"ex",
")",
"{",
"}",
"if",
"(",
"client",
".",
"isConnected",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"else",
"{",
"logger",
".",
"fatal",
"(",
"\"Client has been immediately disconnected from remote host:\"",
"+",
"remoteHost",
")",
";",
"return",
"false",
";",
"}",
"//outputReaderThread.",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"logger",
".",
"fatal",
"(",
"\"Could not connect to remote host:\"",
"+",
"remoteHost",
",",
"e",
")",
";",
"return",
"false",
";",
"}",
"}"
] | Create a rlogin connection to the specified remote host.
@return true if connected, false otherwise | [
"Create",
"a",
"rlogin",
"connection",
"to",
"the",
"specified",
"remote",
"host",
"."
] | ba45d4d86eb29b92f157c6e98536dee2002ddfdc | https://github.com/qspin/qtaste/blob/ba45d4d86eb29b92f157c6e98536dee2002ddfdc/kernel/src/main/java/com/qspin/qtaste/tcom/rlogin/RLogin.java#L90-L121 |
140,130 | qspin/qtaste | kernel/src/main/java/com/qspin/qtaste/tcom/rlogin/RLogin.java | RLogin.reboot | public boolean reboot() {
if (!sendCommand("reboot")) {
return false;
}
// wait 1 second
try {
Thread.sleep(1000);
} catch (InterruptedException ex) {
}
disconnect();
// check that remote host is not accessible anymore
// open a socket without any parameters. It hasn't been binded or connected
try (Socket socket = new Socket()) {
// bind to a local ephemeral port
socket.bind(null);
socket.connect(new InetSocketAddress(remoteHost, RLoginClient.DEFAULT_PORT), 1);
} catch (SocketTimeoutException e) {
logger.info("Rebooted host " + remoteHost + " successfully");
return true;
} catch (IOException e) {
logger.error("Something went wrong while rebooting host:" + remoteHost);
return false;
}
// Expected to get an exception as the remote host should not be reachable anymore
logger.error(
"Host " + remoteHost + " did not reboot as expected! Please check that no other rlogin client is connected!");
return false;
} | java | public boolean reboot() {
if (!sendCommand("reboot")) {
return false;
}
// wait 1 second
try {
Thread.sleep(1000);
} catch (InterruptedException ex) {
}
disconnect();
// check that remote host is not accessible anymore
// open a socket without any parameters. It hasn't been binded or connected
try (Socket socket = new Socket()) {
// bind to a local ephemeral port
socket.bind(null);
socket.connect(new InetSocketAddress(remoteHost, RLoginClient.DEFAULT_PORT), 1);
} catch (SocketTimeoutException e) {
logger.info("Rebooted host " + remoteHost + " successfully");
return true;
} catch (IOException e) {
logger.error("Something went wrong while rebooting host:" + remoteHost);
return false;
}
// Expected to get an exception as the remote host should not be reachable anymore
logger.error(
"Host " + remoteHost + " did not reboot as expected! Please check that no other rlogin client is connected!");
return false;
} | [
"public",
"boolean",
"reboot",
"(",
")",
"{",
"if",
"(",
"!",
"sendCommand",
"(",
"\"reboot\"",
")",
")",
"{",
"return",
"false",
";",
"}",
"// wait 1 second",
"try",
"{",
"Thread",
".",
"sleep",
"(",
"1000",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"ex",
")",
"{",
"}",
"disconnect",
"(",
")",
";",
"// check that remote host is not accessible anymore",
"// open a socket without any parameters. It hasn't been binded or connected",
"try",
"(",
"Socket",
"socket",
"=",
"new",
"Socket",
"(",
")",
")",
"{",
"// bind to a local ephemeral port",
"socket",
".",
"bind",
"(",
"null",
")",
";",
"socket",
".",
"connect",
"(",
"new",
"InetSocketAddress",
"(",
"remoteHost",
",",
"RLoginClient",
".",
"DEFAULT_PORT",
")",
",",
"1",
")",
";",
"}",
"catch",
"(",
"SocketTimeoutException",
"e",
")",
"{",
"logger",
".",
"info",
"(",
"\"Rebooted host \"",
"+",
"remoteHost",
"+",
"\" successfully\"",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"Something went wrong while rebooting host:\"",
"+",
"remoteHost",
")",
";",
"return",
"false",
";",
"}",
"// Expected to get an exception as the remote host should not be reachable anymore",
"logger",
".",
"error",
"(",
"\"Host \"",
"+",
"remoteHost",
"+",
"\" did not reboot as expected! Please check that no other rlogin client is connected!\"",
")",
";",
"return",
"false",
";",
"}"
] | Reboot the remote host by sending the reboot command and check that
the remote host is not accessible anymore.
@return true if success, false otherwise | [
"Reboot",
"the",
"remote",
"host",
"by",
"sending",
"the",
"reboot",
"command",
"and",
"check",
"that",
"the",
"remote",
"host",
"is",
"not",
"accessible",
"anymore",
"."
] | ba45d4d86eb29b92f157c6e98536dee2002ddfdc | https://github.com/qspin/qtaste/blob/ba45d4d86eb29b92f157c6e98536dee2002ddfdc/kernel/src/main/java/com/qspin/qtaste/tcom/rlogin/RLogin.java#L129-L159 |
140,131 | qspin/qtaste | kernel/src/main/java/com/qspin/qtaste/tcom/rlogin/RLogin.java | RLogin.sendCommand | public boolean sendCommand(String command) {
if (writer != null) {
try {
logger.info("Sending command " + command + " to remote host " + remoteHost);
writer.write(command);
writer.write('\r');
writer.flush();
} catch (IOException e) {
logger.fatal("Error while sending command " + command + " to remote host " + remoteHost, e);
return false;
}
return true;
} else {
return false;
}
} | java | public boolean sendCommand(String command) {
if (writer != null) {
try {
logger.info("Sending command " + command + " to remote host " + remoteHost);
writer.write(command);
writer.write('\r');
writer.flush();
} catch (IOException e) {
logger.fatal("Error while sending command " + command + " to remote host " + remoteHost, e);
return false;
}
return true;
} else {
return false;
}
} | [
"public",
"boolean",
"sendCommand",
"(",
"String",
"command",
")",
"{",
"if",
"(",
"writer",
"!=",
"null",
")",
"{",
"try",
"{",
"logger",
".",
"info",
"(",
"\"Sending command \"",
"+",
"command",
"+",
"\" to remote host \"",
"+",
"remoteHost",
")",
";",
"writer",
".",
"write",
"(",
"command",
")",
";",
"writer",
".",
"write",
"(",
"'",
"'",
")",
";",
"writer",
".",
"flush",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"logger",
".",
"fatal",
"(",
"\"Error while sending command \"",
"+",
"command",
"+",
"\" to remote host \"",
"+",
"remoteHost",
",",
"e",
")",
";",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] | Send the specified command to the remote host
@param command command line, without terminating character
@return true if success, false otherwise | [
"Send",
"the",
"specified",
"command",
"to",
"the",
"remote",
"host"
] | ba45d4d86eb29b92f157c6e98536dee2002ddfdc | https://github.com/qspin/qtaste/blob/ba45d4d86eb29b92f157c6e98536dee2002ddfdc/kernel/src/main/java/com/qspin/qtaste/tcom/rlogin/RLogin.java#L167-L182 |
140,132 | qspin/qtaste | kernel/src/main/java/com/qspin/qtaste/tcom/rlogin/RLogin.java | RLogin.disconnect | public void disconnect() {
try {
if (client.isConnected()) {
client.disconnect();
}
if (standardInputReaderThread != null) {
standardInputReaderThread = null;
}
if (outputReaderThread != null) {
outputReaderThread.join();
outputReaderThread = null;
}
writer = null;
} catch (InterruptedException ex) {
} catch (IOException e) {
logger.fatal("Error while disconnecting from rlogin session. Host: " + remoteHost, e);
}
} | java | public void disconnect() {
try {
if (client.isConnected()) {
client.disconnect();
}
if (standardInputReaderThread != null) {
standardInputReaderThread = null;
}
if (outputReaderThread != null) {
outputReaderThread.join();
outputReaderThread = null;
}
writer = null;
} catch (InterruptedException ex) {
} catch (IOException e) {
logger.fatal("Error while disconnecting from rlogin session. Host: " + remoteHost, e);
}
} | [
"public",
"void",
"disconnect",
"(",
")",
"{",
"try",
"{",
"if",
"(",
"client",
".",
"isConnected",
"(",
")",
")",
"{",
"client",
".",
"disconnect",
"(",
")",
";",
"}",
"if",
"(",
"standardInputReaderThread",
"!=",
"null",
")",
"{",
"standardInputReaderThread",
"=",
"null",
";",
"}",
"if",
"(",
"outputReaderThread",
"!=",
"null",
")",
"{",
"outputReaderThread",
".",
"join",
"(",
")",
";",
"outputReaderThread",
"=",
"null",
";",
"}",
"writer",
"=",
"null",
";",
"}",
"catch",
"(",
"InterruptedException",
"ex",
")",
"{",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"logger",
".",
"fatal",
"(",
"\"Error while disconnecting from rlogin session. Host: \"",
"+",
"remoteHost",
",",
"e",
")",
";",
"}",
"}"
] | Disconnect the rlogin client from the remote host. | [
"Disconnect",
"the",
"rlogin",
"client",
"from",
"the",
"remote",
"host",
"."
] | ba45d4d86eb29b92f157c6e98536dee2002ddfdc | https://github.com/qspin/qtaste/blob/ba45d4d86eb29b92f157c6e98536dee2002ddfdc/kernel/src/main/java/com/qspin/qtaste/tcom/rlogin/RLogin.java#L196-L213 |
140,133 | qspin/qtaste | kernel/src/main/java/com/qspin/qtaste/ui/widget/StepLabelUI.java | StepLabelUI.paintDisabledText | protected void paintDisabledText(JLabel pLabel, Graphics pG, String pStr, int pTextX, int pTextY) {
Graphics2D g2 = (Graphics2D) pG;
pG.setColor(Color.GRAY);
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
pG.drawString(pStr, pTextX, pTextY);
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
/*FontMetrics fm = pG.getFontMetrics();
Rectangle strrect = fm.getStringBounds(pStr, pG).getBounds();
if(pLabel.getText().length() > 0)
{
pG.setColor(ResourceManager.getInstance().getNormalColor());
pG.fillRect(pTextX + strrect.width + SPACE_INC, pTextY + strrect.y, 2, strrect.height);
}*/
} | java | protected void paintDisabledText(JLabel pLabel, Graphics pG, String pStr, int pTextX, int pTextY) {
Graphics2D g2 = (Graphics2D) pG;
pG.setColor(Color.GRAY);
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
pG.drawString(pStr, pTextX, pTextY);
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
/*FontMetrics fm = pG.getFontMetrics();
Rectangle strrect = fm.getStringBounds(pStr, pG).getBounds();
if(pLabel.getText().length() > 0)
{
pG.setColor(ResourceManager.getInstance().getNormalColor());
pG.fillRect(pTextX + strrect.width + SPACE_INC, pTextY + strrect.y, 2, strrect.height);
}*/
} | [
"protected",
"void",
"paintDisabledText",
"(",
"JLabel",
"pLabel",
",",
"Graphics",
"pG",
",",
"String",
"pStr",
",",
"int",
"pTextX",
",",
"int",
"pTextY",
")",
"{",
"Graphics2D",
"g2",
"=",
"(",
"Graphics2D",
")",
"pG",
";",
"pG",
".",
"setColor",
"(",
"Color",
".",
"GRAY",
")",
";",
"g2",
".",
"setRenderingHint",
"(",
"RenderingHints",
".",
"KEY_ANTIALIASING",
",",
"RenderingHints",
".",
"VALUE_ANTIALIAS_ON",
")",
";",
"pG",
".",
"drawString",
"(",
"pStr",
",",
"pTextX",
",",
"pTextY",
")",
";",
"g2",
".",
"setRenderingHint",
"(",
"RenderingHints",
".",
"KEY_ANTIALIASING",
",",
"RenderingHints",
".",
"VALUE_ANTIALIAS_OFF",
")",
";",
"/*FontMetrics fm = pG.getFontMetrics();\n Rectangle strrect = fm.getStringBounds(pStr, pG).getBounds();\n if(pLabel.getText().length() > 0)\n {\n pG.setColor(ResourceManager.getInstance().getNormalColor());\n pG.fillRect(pTextX + strrect.width + SPACE_INC, pTextY + strrect.y, 2, strrect.height);\n }*/",
"}"
] | private static final int SPACE_INC = 12; | [
"private",
"static",
"final",
"int",
"SPACE_INC",
"=",
"12",
";"
] | ba45d4d86eb29b92f157c6e98536dee2002ddfdc | https://github.com/qspin/qtaste/blob/ba45d4d86eb29b92f157c6e98536dee2002ddfdc/kernel/src/main/java/com/qspin/qtaste/ui/widget/StepLabelUI.java#L36-L51 |
140,134 | qspin/qtaste | kernel/src/main/java/com/qspin/qtaste/toolbox/doclet/HTMLFileWriter.java | HTMLFileWriter.close | public void close() {
if (mWithBody) {
mOut.println("</BODY>");
}
mOut.println("</HTML>");
mOut.close();
mOut = null;
} | java | public void close() {
if (mWithBody) {
mOut.println("</BODY>");
}
mOut.println("</HTML>");
mOut.close();
mOut = null;
} | [
"public",
"void",
"close",
"(",
")",
"{",
"if",
"(",
"mWithBody",
")",
"{",
"mOut",
".",
"println",
"(",
"\"</BODY>\"",
")",
";",
"}",
"mOut",
".",
"println",
"(",
"\"</HTML>\"",
")",
";",
"mOut",
".",
"close",
"(",
")",
";",
"mOut",
"=",
"null",
";",
"}"
] | Writes HTML body ending tag if needed and HTML footer and closes file. | [
"Writes",
"HTML",
"body",
"ending",
"tag",
"if",
"needed",
"and",
"HTML",
"footer",
"and",
"closes",
"file",
"."
] | ba45d4d86eb29b92f157c6e98536dee2002ddfdc | https://github.com/qspin/qtaste/blob/ba45d4d86eb29b92f157c6e98536dee2002ddfdc/kernel/src/main/java/com/qspin/qtaste/toolbox/doclet/HTMLFileWriter.java#L85-L92 |
140,135 | qspin/qtaste | kernel/src/main/java/com/qspin/qtaste/toolbox/doclet/HTMLFileWriter.java | HTMLFileWriter.printMethodsSummary | public void printMethodsSummary(ClassDoc classDoc) {
MethodDoc[] methodDocs = TestAPIDoclet.getTestAPIComponentMethods(classDoc);
if (methodDocs.length > 0) {
mOut.println("<P>");
mOut.println("<TABLE BORDER=\"1\" WIDTH=\"100%\" CELLPADDING=\"3\" CELLSPACING=\"0\" SUMMARY=\"\">");
mOut.println("<TR BGCOLOR=\"#CCCCFF\"><TH ALIGN=\"left\" COLSPAN=\"2\"><FONT SIZE=\"+2\"><B>Methods "
+ "Summary</B></FONT></TH></TR>");
for (MethodDoc methodDoc : methodDocs) {
String methodName = methodDoc.name();
mOut.print(
"<TR><TD WIDTH=\"1%\"><CODE><B><A HREF=\"#" + methodName + methodDoc.flatSignature() + "\">" + methodName
+ "</A></B></CODE></TD><TD>");
Tag[] firstSentenceTags = methodDoc.firstSentenceTags();
if (firstSentenceTags.length == 0) {
System.err.println("Warning: method " + methodName + " of " + methodDoc.containingClass().simpleTypeName()
+ " has no description");
}
printInlineTags(firstSentenceTags, classDoc);
mOut.println("</TD>");
}
mOut.println("</TABLE>");
}
} | java | public void printMethodsSummary(ClassDoc classDoc) {
MethodDoc[] methodDocs = TestAPIDoclet.getTestAPIComponentMethods(classDoc);
if (methodDocs.length > 0) {
mOut.println("<P>");
mOut.println("<TABLE BORDER=\"1\" WIDTH=\"100%\" CELLPADDING=\"3\" CELLSPACING=\"0\" SUMMARY=\"\">");
mOut.println("<TR BGCOLOR=\"#CCCCFF\"><TH ALIGN=\"left\" COLSPAN=\"2\"><FONT SIZE=\"+2\"><B>Methods "
+ "Summary</B></FONT></TH></TR>");
for (MethodDoc methodDoc : methodDocs) {
String methodName = methodDoc.name();
mOut.print(
"<TR><TD WIDTH=\"1%\"><CODE><B><A HREF=\"#" + methodName + methodDoc.flatSignature() + "\">" + methodName
+ "</A></B></CODE></TD><TD>");
Tag[] firstSentenceTags = methodDoc.firstSentenceTags();
if (firstSentenceTags.length == 0) {
System.err.println("Warning: method " + methodName + " of " + methodDoc.containingClass().simpleTypeName()
+ " has no description");
}
printInlineTags(firstSentenceTags, classDoc);
mOut.println("</TD>");
}
mOut.println("</TABLE>");
}
} | [
"public",
"void",
"printMethodsSummary",
"(",
"ClassDoc",
"classDoc",
")",
"{",
"MethodDoc",
"[",
"]",
"methodDocs",
"=",
"TestAPIDoclet",
".",
"getTestAPIComponentMethods",
"(",
"classDoc",
")",
";",
"if",
"(",
"methodDocs",
".",
"length",
">",
"0",
")",
"{",
"mOut",
".",
"println",
"(",
"\"<P>\"",
")",
";",
"mOut",
".",
"println",
"(",
"\"<TABLE BORDER=\\\"1\\\" WIDTH=\\\"100%\\\" CELLPADDING=\\\"3\\\" CELLSPACING=\\\"0\\\" SUMMARY=\\\"\\\">\"",
")",
";",
"mOut",
".",
"println",
"(",
"\"<TR BGCOLOR=\\\"#CCCCFF\\\"><TH ALIGN=\\\"left\\\" COLSPAN=\\\"2\\\"><FONT SIZE=\\\"+2\\\"><B>Methods \"",
"+",
"\"Summary</B></FONT></TH></TR>\"",
")",
";",
"for",
"(",
"MethodDoc",
"methodDoc",
":",
"methodDocs",
")",
"{",
"String",
"methodName",
"=",
"methodDoc",
".",
"name",
"(",
")",
";",
"mOut",
".",
"print",
"(",
"\"<TR><TD WIDTH=\\\"1%\\\"><CODE><B><A HREF=\\\"#\"",
"+",
"methodName",
"+",
"methodDoc",
".",
"flatSignature",
"(",
")",
"+",
"\"\\\">\"",
"+",
"methodName",
"+",
"\"</A></B></CODE></TD><TD>\"",
")",
";",
"Tag",
"[",
"]",
"firstSentenceTags",
"=",
"methodDoc",
".",
"firstSentenceTags",
"(",
")",
";",
"if",
"(",
"firstSentenceTags",
".",
"length",
"==",
"0",
")",
"{",
"System",
".",
"err",
".",
"println",
"(",
"\"Warning: method \"",
"+",
"methodName",
"+",
"\" of \"",
"+",
"methodDoc",
".",
"containingClass",
"(",
")",
".",
"simpleTypeName",
"(",
")",
"+",
"\" has no description\"",
")",
";",
"}",
"printInlineTags",
"(",
"firstSentenceTags",
",",
"classDoc",
")",
";",
"mOut",
".",
"println",
"(",
"\"</TD>\"",
")",
";",
"}",
"mOut",
".",
"println",
"(",
"\"</TABLE>\"",
")",
";",
"}",
"}"
] | Prints summary of Test API methods, excluding old-style verbs, in HTML format.
@param classDoc the classDoc of the Test API component | [
"Prints",
"summary",
"of",
"Test",
"API",
"methods",
"excluding",
"old",
"-",
"style",
"verbs",
"in",
"HTML",
"format",
"."
] | ba45d4d86eb29b92f157c6e98536dee2002ddfdc | https://github.com/qspin/qtaste/blob/ba45d4d86eb29b92f157c6e98536dee2002ddfdc/kernel/src/main/java/com/qspin/qtaste/toolbox/doclet/HTMLFileWriter.java#L139-L162 |
140,136 | qspin/qtaste | kernel/src/main/java/com/qspin/qtaste/toolbox/doclet/HTMLFileWriter.java | HTMLFileWriter.getTypeString | private String getTypeString(Type type) {
String typeQualifiedName = type.qualifiedTypeName().replaceFirst("^java\\.lang\\.", "");
typeQualifiedName = typeQualifiedName.replaceFirst("^com\\.qspin\\.qtaste\\.testsuite\\.(QTaste\\w*Exception)", "$1");
String typeDocFileName = null;
if (typeQualifiedName.startsWith("com.qspin.")) {
String javaDocDir = typeQualifiedName.startsWith("com.qspin.qtaste.") ? QTaste_JAVADOC_URL_PREFIX :
SUT_JAVADOC_URL_PREFIX;
typeDocFileName = javaDocDir + typeQualifiedName.replace('.', '/') + ".html";
}
String typeString = typeQualifiedName;
if (typeDocFileName != null) {
typeString = "<A HREF=\"" + typeDocFileName + "\">" + typeString + "</A>";
}
if (type.asParameterizedType() != null) {
ParameterizedType parametrizedType = type.asParameterizedType();
final Type[] parameterTypes = parametrizedType.typeArguments();
if (parameterTypes.length > 0) {
String[] parametersTypeStrings = new String[parameterTypes.length];
for (int i = 0; i < parameterTypes.length; i++) {
parametersTypeStrings[i] = getTypeString(parameterTypes[i]);
}
typeString += "<" + Strings.join(parametersTypeStrings, ",") + ">";
}
}
typeString += type.dimension();
return typeString;
} | java | private String getTypeString(Type type) {
String typeQualifiedName = type.qualifiedTypeName().replaceFirst("^java\\.lang\\.", "");
typeQualifiedName = typeQualifiedName.replaceFirst("^com\\.qspin\\.qtaste\\.testsuite\\.(QTaste\\w*Exception)", "$1");
String typeDocFileName = null;
if (typeQualifiedName.startsWith("com.qspin.")) {
String javaDocDir = typeQualifiedName.startsWith("com.qspin.qtaste.") ? QTaste_JAVADOC_URL_PREFIX :
SUT_JAVADOC_URL_PREFIX;
typeDocFileName = javaDocDir + typeQualifiedName.replace('.', '/') + ".html";
}
String typeString = typeQualifiedName;
if (typeDocFileName != null) {
typeString = "<A HREF=\"" + typeDocFileName + "\">" + typeString + "</A>";
}
if (type.asParameterizedType() != null) {
ParameterizedType parametrizedType = type.asParameterizedType();
final Type[] parameterTypes = parametrizedType.typeArguments();
if (parameterTypes.length > 0) {
String[] parametersTypeStrings = new String[parameterTypes.length];
for (int i = 0; i < parameterTypes.length; i++) {
parametersTypeStrings[i] = getTypeString(parameterTypes[i]);
}
typeString += "<" + Strings.join(parametersTypeStrings, ",") + ">";
}
}
typeString += type.dimension();
return typeString;
} | [
"private",
"String",
"getTypeString",
"(",
"Type",
"type",
")",
"{",
"String",
"typeQualifiedName",
"=",
"type",
".",
"qualifiedTypeName",
"(",
")",
".",
"replaceFirst",
"(",
"\"^java\\\\.lang\\\\.\"",
",",
"\"\"",
")",
";",
"typeQualifiedName",
"=",
"typeQualifiedName",
".",
"replaceFirst",
"(",
"\"^com\\\\.qspin\\\\.qtaste\\\\.testsuite\\\\.(QTaste\\\\w*Exception)\"",
",",
"\"$1\"",
")",
";",
"String",
"typeDocFileName",
"=",
"null",
";",
"if",
"(",
"typeQualifiedName",
".",
"startsWith",
"(",
"\"com.qspin.\"",
")",
")",
"{",
"String",
"javaDocDir",
"=",
"typeQualifiedName",
".",
"startsWith",
"(",
"\"com.qspin.qtaste.\"",
")",
"?",
"QTaste_JAVADOC_URL_PREFIX",
":",
"SUT_JAVADOC_URL_PREFIX",
";",
"typeDocFileName",
"=",
"javaDocDir",
"+",
"typeQualifiedName",
".",
"replace",
"(",
"'",
"'",
",",
"'",
"'",
")",
"+",
"\".html\"",
";",
"}",
"String",
"typeString",
"=",
"typeQualifiedName",
";",
"if",
"(",
"typeDocFileName",
"!=",
"null",
")",
"{",
"typeString",
"=",
"\"<A HREF=\\\"\"",
"+",
"typeDocFileName",
"+",
"\"\\\">\"",
"+",
"typeString",
"+",
"\"</A>\"",
";",
"}",
"if",
"(",
"type",
".",
"asParameterizedType",
"(",
")",
"!=",
"null",
")",
"{",
"ParameterizedType",
"parametrizedType",
"=",
"type",
".",
"asParameterizedType",
"(",
")",
";",
"final",
"Type",
"[",
"]",
"parameterTypes",
"=",
"parametrizedType",
".",
"typeArguments",
"(",
")",
";",
"if",
"(",
"parameterTypes",
".",
"length",
">",
"0",
")",
"{",
"String",
"[",
"]",
"parametersTypeStrings",
"=",
"new",
"String",
"[",
"parameterTypes",
".",
"length",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"parameterTypes",
".",
"length",
";",
"i",
"++",
")",
"{",
"parametersTypeStrings",
"[",
"i",
"]",
"=",
"getTypeString",
"(",
"parameterTypes",
"[",
"i",
"]",
")",
";",
"}",
"typeString",
"+=",
"\"<\"",
"+",
"Strings",
".",
"join",
"(",
"parametersTypeStrings",
",",
"\",\"",
")",
"+",
"\">\"",
";",
"}",
"}",
"typeString",
"+=",
"type",
".",
"dimension",
"(",
")",
";",
"return",
"typeString",
";",
"}"
] | Returns type string.
@param type type for which to return type string
@return type string, including parametrized types, dimensions and links. | [
"Returns",
"type",
"string",
"."
] | ba45d4d86eb29b92f157c6e98536dee2002ddfdc | https://github.com/qspin/qtaste/blob/ba45d4d86eb29b92f157c6e98536dee2002ddfdc/kernel/src/main/java/com/qspin/qtaste/toolbox/doclet/HTMLFileWriter.java#L284-L311 |
140,137 | qspin/qtaste | kernel/src/main/java/com/qspin/qtaste/toolbox/doclet/HTMLFileWriter.java | HTMLFileWriter.printInlineTags | private void printInlineTags(Tag[] tags, ClassDoc classDoc) {
for (Tag tag : tags) {
if ((tag instanceof SeeTag) && tag.name().equals("@link")) {
SeeTag seeTag = (SeeTag) tag;
boolean sameClass = seeTag.referencedClass() == classDoc;
String fullClassName = seeTag.referencedClassName();
String memberName = seeTag.referencedMemberName();
String className = fullClassName.substring(fullClassName.lastIndexOf('.') + 1);
List<String> nameParts = new ArrayList<>();
if (!sameClass) {
nameParts.add(className);
}
if (memberName != null) {
nameParts.add(memberName);
}
String name = Strings.join(nameParts, ".");
if (fullClassName.lastIndexOf('.') >= 0) {
String packageName = fullClassName.substring(0, fullClassName.lastIndexOf('.'));
String urlPrefix = "";
if (!sameClass && packageName.startsWith("com.qspin.") && !packageName.equals(
"com.qspin.qtaste.testapi.api")) {
String javaDocDir = packageName.startsWith("com.qspin.qtaste.") ? QTaste_JAVADOC_URL_PREFIX :
SUT_JAVADOC_URL_PREFIX;
urlPrefix = javaDocDir + packageName.replace('.', '/') + "/";
}
String url =
(sameClass ? "" : urlPrefix + className + ".html") + (memberName != null ? "#" + memberName : "");
mOut.print("<A HREF=\"" + url + "\">" + name + "</A>");
} else {
mOut.print(name);
}
} else {
mOut.print(tag.text());
}
}
} | java | private void printInlineTags(Tag[] tags, ClassDoc classDoc) {
for (Tag tag : tags) {
if ((tag instanceof SeeTag) && tag.name().equals("@link")) {
SeeTag seeTag = (SeeTag) tag;
boolean sameClass = seeTag.referencedClass() == classDoc;
String fullClassName = seeTag.referencedClassName();
String memberName = seeTag.referencedMemberName();
String className = fullClassName.substring(fullClassName.lastIndexOf('.') + 1);
List<String> nameParts = new ArrayList<>();
if (!sameClass) {
nameParts.add(className);
}
if (memberName != null) {
nameParts.add(memberName);
}
String name = Strings.join(nameParts, ".");
if (fullClassName.lastIndexOf('.') >= 0) {
String packageName = fullClassName.substring(0, fullClassName.lastIndexOf('.'));
String urlPrefix = "";
if (!sameClass && packageName.startsWith("com.qspin.") && !packageName.equals(
"com.qspin.qtaste.testapi.api")) {
String javaDocDir = packageName.startsWith("com.qspin.qtaste.") ? QTaste_JAVADOC_URL_PREFIX :
SUT_JAVADOC_URL_PREFIX;
urlPrefix = javaDocDir + packageName.replace('.', '/') + "/";
}
String url =
(sameClass ? "" : urlPrefix + className + ".html") + (memberName != null ? "#" + memberName : "");
mOut.print("<A HREF=\"" + url + "\">" + name + "</A>");
} else {
mOut.print(name);
}
} else {
mOut.print(tag.text());
}
}
} | [
"private",
"void",
"printInlineTags",
"(",
"Tag",
"[",
"]",
"tags",
",",
"ClassDoc",
"classDoc",
")",
"{",
"for",
"(",
"Tag",
"tag",
":",
"tags",
")",
"{",
"if",
"(",
"(",
"tag",
"instanceof",
"SeeTag",
")",
"&&",
"tag",
".",
"name",
"(",
")",
".",
"equals",
"(",
"\"@link\"",
")",
")",
"{",
"SeeTag",
"seeTag",
"=",
"(",
"SeeTag",
")",
"tag",
";",
"boolean",
"sameClass",
"=",
"seeTag",
".",
"referencedClass",
"(",
")",
"==",
"classDoc",
";",
"String",
"fullClassName",
"=",
"seeTag",
".",
"referencedClassName",
"(",
")",
";",
"String",
"memberName",
"=",
"seeTag",
".",
"referencedMemberName",
"(",
")",
";",
"String",
"className",
"=",
"fullClassName",
".",
"substring",
"(",
"fullClassName",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
"+",
"1",
")",
";",
"List",
"<",
"String",
">",
"nameParts",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"if",
"(",
"!",
"sameClass",
")",
"{",
"nameParts",
".",
"add",
"(",
"className",
")",
";",
"}",
"if",
"(",
"memberName",
"!=",
"null",
")",
"{",
"nameParts",
".",
"add",
"(",
"memberName",
")",
";",
"}",
"String",
"name",
"=",
"Strings",
".",
"join",
"(",
"nameParts",
",",
"\".\"",
")",
";",
"if",
"(",
"fullClassName",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
">=",
"0",
")",
"{",
"String",
"packageName",
"=",
"fullClassName",
".",
"substring",
"(",
"0",
",",
"fullClassName",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
")",
";",
"String",
"urlPrefix",
"=",
"\"\"",
";",
"if",
"(",
"!",
"sameClass",
"&&",
"packageName",
".",
"startsWith",
"(",
"\"com.qspin.\"",
")",
"&&",
"!",
"packageName",
".",
"equals",
"(",
"\"com.qspin.qtaste.testapi.api\"",
")",
")",
"{",
"String",
"javaDocDir",
"=",
"packageName",
".",
"startsWith",
"(",
"\"com.qspin.qtaste.\"",
")",
"?",
"QTaste_JAVADOC_URL_PREFIX",
":",
"SUT_JAVADOC_URL_PREFIX",
";",
"urlPrefix",
"=",
"javaDocDir",
"+",
"packageName",
".",
"replace",
"(",
"'",
"'",
",",
"'",
"'",
")",
"+",
"\"/\"",
";",
"}",
"String",
"url",
"=",
"(",
"sameClass",
"?",
"\"\"",
":",
"urlPrefix",
"+",
"className",
"+",
"\".html\"",
")",
"+",
"(",
"memberName",
"!=",
"null",
"?",
"\"#\"",
"+",
"memberName",
":",
"\"\"",
")",
";",
"mOut",
".",
"print",
"(",
"\"<A HREF=\\\"\"",
"+",
"url",
"+",
"\"\\\">\"",
"+",
"name",
"+",
"\"</A>\"",
")",
";",
"}",
"else",
"{",
"mOut",
".",
"print",
"(",
"name",
")",
";",
"}",
"}",
"else",
"{",
"mOut",
".",
"print",
"(",
"tag",
".",
"text",
"(",
")",
")",
";",
"}",
"}",
"}"
] | Prints inline tags, in HTML format.
@param tags the array of Tag to print | [
"Prints",
"inline",
"tags",
"in",
"HTML",
"format",
"."
] | ba45d4d86eb29b92f157c6e98536dee2002ddfdc | https://github.com/qspin/qtaste/blob/ba45d4d86eb29b92f157c6e98536dee2002ddfdc/kernel/src/main/java/com/qspin/qtaste/toolbox/doclet/HTMLFileWriter.java#L358-L396 |
140,138 | qspin/qtaste | kernel/src/main/java/com/qspin/qtaste/ui/jedit/LineNumberPanel.java | LineNumberPanel.updateSize | private void updateSize() {
int newLineCount = ActionUtils.getLineCount(pane);
if (newLineCount == lineCount) {
return;
}
lineCount = newLineCount;
int h = (int) pane.getPreferredSize().getHeight();
int d = (int) Math.log10(lineCount) + 1;
if (d < 1) {
d = 1;
}
int w = d * charWidth + r_margin + l_margin;
format = "%" + d + "d";
setPreferredSize(new Dimension(w, h));
getParent().doLayout();
} | java | private void updateSize() {
int newLineCount = ActionUtils.getLineCount(pane);
if (newLineCount == lineCount) {
return;
}
lineCount = newLineCount;
int h = (int) pane.getPreferredSize().getHeight();
int d = (int) Math.log10(lineCount) + 1;
if (d < 1) {
d = 1;
}
int w = d * charWidth + r_margin + l_margin;
format = "%" + d + "d";
setPreferredSize(new Dimension(w, h));
getParent().doLayout();
} | [
"private",
"void",
"updateSize",
"(",
")",
"{",
"int",
"newLineCount",
"=",
"ActionUtils",
".",
"getLineCount",
"(",
"pane",
")",
";",
"if",
"(",
"newLineCount",
"==",
"lineCount",
")",
"{",
"return",
";",
"}",
"lineCount",
"=",
"newLineCount",
";",
"int",
"h",
"=",
"(",
"int",
")",
"pane",
".",
"getPreferredSize",
"(",
")",
".",
"getHeight",
"(",
")",
";",
"int",
"d",
"=",
"(",
"int",
")",
"Math",
".",
"log10",
"(",
"lineCount",
")",
"+",
"1",
";",
"if",
"(",
"d",
"<",
"1",
")",
"{",
"d",
"=",
"1",
";",
"}",
"int",
"w",
"=",
"d",
"*",
"charWidth",
"+",
"r_margin",
"+",
"l_margin",
";",
"format",
"=",
"\"%\"",
"+",
"d",
"+",
"\"d\"",
";",
"setPreferredSize",
"(",
"new",
"Dimension",
"(",
"w",
",",
"h",
")",
")",
";",
"getParent",
"(",
")",
".",
"doLayout",
"(",
")",
";",
"}"
] | Update the size of the line numbers based on the length of the document | [
"Update",
"the",
"size",
"of",
"the",
"line",
"numbers",
"based",
"on",
"the",
"length",
"of",
"the",
"document"
] | ba45d4d86eb29b92f157c6e98536dee2002ddfdc | https://github.com/qspin/qtaste/blob/ba45d4d86eb29b92f157c6e98536dee2002ddfdc/kernel/src/main/java/com/qspin/qtaste/ui/jedit/LineNumberPanel.java#L146-L161 |
140,139 | qspin/qtaste | kernel/src/main/java/com/qspin/qtaste/ui/jedit/LineNumberPanel.java | LineNumberPanel.getScrollPane | public JScrollPane getScrollPane(JTextComponent editorPane) {
Container p = editorPane.getParent();
while (p != null) {
if (p instanceof JScrollPane) {
return (JScrollPane) p;
}
p = p.getParent();
}
return null;
} | java | public JScrollPane getScrollPane(JTextComponent editorPane) {
Container p = editorPane.getParent();
while (p != null) {
if (p instanceof JScrollPane) {
return (JScrollPane) p;
}
p = p.getParent();
}
return null;
} | [
"public",
"JScrollPane",
"getScrollPane",
"(",
"JTextComponent",
"editorPane",
")",
"{",
"Container",
"p",
"=",
"editorPane",
".",
"getParent",
"(",
")",
";",
"while",
"(",
"p",
"!=",
"null",
")",
"{",
"if",
"(",
"p",
"instanceof",
"JScrollPane",
")",
"{",
"return",
"(",
"JScrollPane",
")",
"p",
";",
"}",
"p",
"=",
"p",
".",
"getParent",
"(",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Get the JscrollPane that contains an editor pane, or null if none.
@param editorPane an editor pane
@return the JscrollPane that contains the editor pane, or null if none | [
"Get",
"the",
"JscrollPane",
"that",
"contains",
"an",
"editor",
"pane",
"or",
"null",
"if",
"none",
"."
] | ba45d4d86eb29b92f157c6e98536dee2002ddfdc | https://github.com/qspin/qtaste/blob/ba45d4d86eb29b92f157c6e98536dee2002ddfdc/kernel/src/main/java/com/qspin/qtaste/ui/jedit/LineNumberPanel.java#L169-L178 |
140,140 | qspin/qtaste | kernel/src/main/java/com/qspin/qtaste/util/FileUtilities.java | FileUtilities.copy | public static void copy(File source, File dest) throws IOException {
if (dest.isDirectory()) {
dest = new File(dest + File.separator + source.getName());
}
FileChannel in = null, out = null;
try {
in = new FileInputStream(source).getChannel();
out = new FileOutputStream(dest).getChannel();
long size = in.size();
MappedByteBuffer buf = in.map(FileChannel.MapMode.READ_ONLY, 0, size);
out.write(buf);
} finally {
if (in != null) {
in.close();
}
if (out != null) {
out.close();
}
}
} | java | public static void copy(File source, File dest) throws IOException {
if (dest.isDirectory()) {
dest = new File(dest + File.separator + source.getName());
}
FileChannel in = null, out = null;
try {
in = new FileInputStream(source).getChannel();
out = new FileOutputStream(dest).getChannel();
long size = in.size();
MappedByteBuffer buf = in.map(FileChannel.MapMode.READ_ONLY, 0, size);
out.write(buf);
} finally {
if (in != null) {
in.close();
}
if (out != null) {
out.close();
}
}
} | [
"public",
"static",
"void",
"copy",
"(",
"File",
"source",
",",
"File",
"dest",
")",
"throws",
"IOException",
"{",
"if",
"(",
"dest",
".",
"isDirectory",
"(",
")",
")",
"{",
"dest",
"=",
"new",
"File",
"(",
"dest",
"+",
"File",
".",
"separator",
"+",
"source",
".",
"getName",
"(",
")",
")",
";",
"}",
"FileChannel",
"in",
"=",
"null",
",",
"out",
"=",
"null",
";",
"try",
"{",
"in",
"=",
"new",
"FileInputStream",
"(",
"source",
")",
".",
"getChannel",
"(",
")",
";",
"out",
"=",
"new",
"FileOutputStream",
"(",
"dest",
")",
".",
"getChannel",
"(",
")",
";",
"long",
"size",
"=",
"in",
".",
"size",
"(",
")",
";",
"MappedByteBuffer",
"buf",
"=",
"in",
".",
"map",
"(",
"FileChannel",
".",
"MapMode",
".",
"READ_ONLY",
",",
"0",
",",
"size",
")",
";",
"out",
".",
"write",
"(",
"buf",
")",
";",
"}",
"finally",
"{",
"if",
"(",
"in",
"!=",
"null",
")",
"{",
"in",
".",
"close",
"(",
")",
";",
"}",
"if",
"(",
"out",
"!=",
"null",
")",
"{",
"out",
".",
"close",
"(",
")",
";",
"}",
"}",
"}"
] | Fast and simple file copy.
@param source source file
@param dest destination file or directory | [
"Fast",
"and",
"simple",
"file",
"copy",
"."
] | ba45d4d86eb29b92f157c6e98536dee2002ddfdc | https://github.com/qspin/qtaste/blob/ba45d4d86eb29b92f157c6e98536dee2002ddfdc/kernel/src/main/java/com/qspin/qtaste/util/FileUtilities.java#L94-L116 |
140,141 | qspin/qtaste | kernel/src/main/java/com/qspin/qtaste/util/FileUtilities.java | FileUtilities.readFileContent | public static String readFileContent(String filename) throws FileNotFoundException, IOException {
BufferedReader reader = new BufferedReader(new FileReader(filename));
StringBuilder content = new StringBuilder();
String line;
final String eol = System.getProperty("line.separator");
while ((line = reader.readLine()) != null) {
content.append(line);
content.append(eol);
}
reader.close();
return content.toString();
} | java | public static String readFileContent(String filename) throws FileNotFoundException, IOException {
BufferedReader reader = new BufferedReader(new FileReader(filename));
StringBuilder content = new StringBuilder();
String line;
final String eol = System.getProperty("line.separator");
while ((line = reader.readLine()) != null) {
content.append(line);
content.append(eol);
}
reader.close();
return content.toString();
} | [
"public",
"static",
"String",
"readFileContent",
"(",
"String",
"filename",
")",
"throws",
"FileNotFoundException",
",",
"IOException",
"{",
"BufferedReader",
"reader",
"=",
"new",
"BufferedReader",
"(",
"new",
"FileReader",
"(",
"filename",
")",
")",
";",
"StringBuilder",
"content",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"String",
"line",
";",
"final",
"String",
"eol",
"=",
"System",
".",
"getProperty",
"(",
"\"line.separator\"",
")",
";",
"while",
"(",
"(",
"line",
"=",
"reader",
".",
"readLine",
"(",
")",
")",
"!=",
"null",
")",
"{",
"content",
".",
"append",
"(",
"line",
")",
";",
"content",
".",
"append",
"(",
"eol",
")",
";",
"}",
"reader",
".",
"close",
"(",
")",
";",
"return",
"content",
".",
"toString",
"(",
")",
";",
"}"
] | Reads file content.
@param filename name of the file to read
@return string containing the file content
@throws java.io.FileNotFoundException
@throws java.io.IOException | [
"Reads",
"file",
"content",
"."
] | ba45d4d86eb29b92f157c6e98536dee2002ddfdc | https://github.com/qspin/qtaste/blob/ba45d4d86eb29b92f157c6e98536dee2002ddfdc/kernel/src/main/java/com/qspin/qtaste/util/FileUtilities.java#L159-L170 |
140,142 | qspin/qtaste | kernel/src/main/java/com/qspin/qtaste/util/FileUtilities.java | FileUtilities.listResourceFiles | public static String[] listResourceFiles(Class<?> clazz, String resourceDirName) throws URISyntaxException, IOException {
if (!resourceDirName.endsWith("/")) {
resourceDirName = resourceDirName + "/";
}
URL dirURL = clazz.getResource(resourceDirName);
if (dirURL == null) {
throw new IOException("Resource directory " + resourceDirName + " not found");
}
if (dirURL.getProtocol().equals("file")) {
File[] entries = new File(dirURL.toURI()).listFiles(File::isFile);
String[] fileNames = new String[entries.length];
for (int i = 0; i < entries.length; i++) {
fileNames[i] = entries[i].toString();
}
return fileNames;
}
if (dirURL.getProtocol().equals("jar")) {
String jarPath = dirURL.getPath().substring(5, dirURL.getPath().indexOf("!")); //strip out only the JAR file
try (JarFile jar = new JarFile(jarPath)) {
Enumeration<JarEntry> entries = jar.entries(); //gives ALL entries in jar
List<String> result = new ArrayList<>();
String relativeResourceDirName = resourceDirName.startsWith("/") ? resourceDirName.substring(1) : resourceDirName;
while (entries.hasMoreElements()) {
String name = entries.nextElement().getName();
if (name.startsWith(relativeResourceDirName) && !name.equals(relativeResourceDirName)) { //filter according to the path
String entry = name.substring(relativeResourceDirName.length());
int checkSubdir = entry.indexOf("/");
if (checkSubdir < 0) {
// not a subdirectory
result.add(entry);
}
}
}
return result.toArray(new String[result.size()]);
}
}
throw new UnsupportedOperationException("Cannot list files for URL " + dirURL);
} | java | public static String[] listResourceFiles(Class<?> clazz, String resourceDirName) throws URISyntaxException, IOException {
if (!resourceDirName.endsWith("/")) {
resourceDirName = resourceDirName + "/";
}
URL dirURL = clazz.getResource(resourceDirName);
if (dirURL == null) {
throw new IOException("Resource directory " + resourceDirName + " not found");
}
if (dirURL.getProtocol().equals("file")) {
File[] entries = new File(dirURL.toURI()).listFiles(File::isFile);
String[] fileNames = new String[entries.length];
for (int i = 0; i < entries.length; i++) {
fileNames[i] = entries[i].toString();
}
return fileNames;
}
if (dirURL.getProtocol().equals("jar")) {
String jarPath = dirURL.getPath().substring(5, dirURL.getPath().indexOf("!")); //strip out only the JAR file
try (JarFile jar = new JarFile(jarPath)) {
Enumeration<JarEntry> entries = jar.entries(); //gives ALL entries in jar
List<String> result = new ArrayList<>();
String relativeResourceDirName = resourceDirName.startsWith("/") ? resourceDirName.substring(1) : resourceDirName;
while (entries.hasMoreElements()) {
String name = entries.nextElement().getName();
if (name.startsWith(relativeResourceDirName) && !name.equals(relativeResourceDirName)) { //filter according to the path
String entry = name.substring(relativeResourceDirName.length());
int checkSubdir = entry.indexOf("/");
if (checkSubdir < 0) {
// not a subdirectory
result.add(entry);
}
}
}
return result.toArray(new String[result.size()]);
}
}
throw new UnsupportedOperationException("Cannot list files for URL " + dirURL);
} | [
"public",
"static",
"String",
"[",
"]",
"listResourceFiles",
"(",
"Class",
"<",
"?",
">",
"clazz",
",",
"String",
"resourceDirName",
")",
"throws",
"URISyntaxException",
",",
"IOException",
"{",
"if",
"(",
"!",
"resourceDirName",
".",
"endsWith",
"(",
"\"/\"",
")",
")",
"{",
"resourceDirName",
"=",
"resourceDirName",
"+",
"\"/\"",
";",
"}",
"URL",
"dirURL",
"=",
"clazz",
".",
"getResource",
"(",
"resourceDirName",
")",
";",
"if",
"(",
"dirURL",
"==",
"null",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Resource directory \"",
"+",
"resourceDirName",
"+",
"\" not found\"",
")",
";",
"}",
"if",
"(",
"dirURL",
".",
"getProtocol",
"(",
")",
".",
"equals",
"(",
"\"file\"",
")",
")",
"{",
"File",
"[",
"]",
"entries",
"=",
"new",
"File",
"(",
"dirURL",
".",
"toURI",
"(",
")",
")",
".",
"listFiles",
"(",
"File",
"::",
"isFile",
")",
";",
"String",
"[",
"]",
"fileNames",
"=",
"new",
"String",
"[",
"entries",
".",
"length",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"entries",
".",
"length",
";",
"i",
"++",
")",
"{",
"fileNames",
"[",
"i",
"]",
"=",
"entries",
"[",
"i",
"]",
".",
"toString",
"(",
")",
";",
"}",
"return",
"fileNames",
";",
"}",
"if",
"(",
"dirURL",
".",
"getProtocol",
"(",
")",
".",
"equals",
"(",
"\"jar\"",
")",
")",
"{",
"String",
"jarPath",
"=",
"dirURL",
".",
"getPath",
"(",
")",
".",
"substring",
"(",
"5",
",",
"dirURL",
".",
"getPath",
"(",
")",
".",
"indexOf",
"(",
"\"!\"",
")",
")",
";",
"//strip out only the JAR file",
"try",
"(",
"JarFile",
"jar",
"=",
"new",
"JarFile",
"(",
"jarPath",
")",
")",
"{",
"Enumeration",
"<",
"JarEntry",
">",
"entries",
"=",
"jar",
".",
"entries",
"(",
")",
";",
"//gives ALL entries in jar",
"List",
"<",
"String",
">",
"result",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"String",
"relativeResourceDirName",
"=",
"resourceDirName",
".",
"startsWith",
"(",
"\"/\"",
")",
"?",
"resourceDirName",
".",
"substring",
"(",
"1",
")",
":",
"resourceDirName",
";",
"while",
"(",
"entries",
".",
"hasMoreElements",
"(",
")",
")",
"{",
"String",
"name",
"=",
"entries",
".",
"nextElement",
"(",
")",
".",
"getName",
"(",
")",
";",
"if",
"(",
"name",
".",
"startsWith",
"(",
"relativeResourceDirName",
")",
"&&",
"!",
"name",
".",
"equals",
"(",
"relativeResourceDirName",
")",
")",
"{",
"//filter according to the path",
"String",
"entry",
"=",
"name",
".",
"substring",
"(",
"relativeResourceDirName",
".",
"length",
"(",
")",
")",
";",
"int",
"checkSubdir",
"=",
"entry",
".",
"indexOf",
"(",
"\"/\"",
")",
";",
"if",
"(",
"checkSubdir",
"<",
"0",
")",
"{",
"// not a subdirectory",
"result",
".",
"add",
"(",
"entry",
")",
";",
"}",
"}",
"}",
"return",
"result",
".",
"toArray",
"(",
"new",
"String",
"[",
"result",
".",
"size",
"(",
")",
"]",
")",
";",
"}",
"}",
"throw",
"new",
"UnsupportedOperationException",
"(",
"\"Cannot list files for URL \"",
"+",
"dirURL",
")",
";",
"}"
] | List directory files in a resource folder. Not recursive.
Works for regular files and also JARs.
@param clazz Any java class that lives in the same place as the resources you want.
@param resourceDirName resource folder path.
@return the full path name of each folder file, not the full paths.
@throws URISyntaxException
@throws IOException | [
"List",
"directory",
"files",
"in",
"a",
"resource",
"folder",
".",
"Not",
"recursive",
".",
"Works",
"for",
"regular",
"files",
"and",
"also",
"JARs",
"."
] | ba45d4d86eb29b92f157c6e98536dee2002ddfdc | https://github.com/qspin/qtaste/blob/ba45d4d86eb29b92f157c6e98536dee2002ddfdc/kernel/src/main/java/com/qspin/qtaste/util/FileUtilities.java#L226-L265 |
140,143 | qspin/qtaste | kernel/src/main/java/com/qspin/qtaste/ui/tools/FileMask.java | FileMask.accept | public boolean accept(File f) {
if (f != null) {
if (f.isDirectory()) {
return false;
}
String extension = getExtension(f);
if (extension != null && filters.get(getExtension(f)) != null) {
return true;
}
}
return false;
} | java | public boolean accept(File f) {
if (f != null) {
if (f.isDirectory()) {
return false;
}
String extension = getExtension(f);
if (extension != null && filters.get(getExtension(f)) != null) {
return true;
}
}
return false;
} | [
"public",
"boolean",
"accept",
"(",
"File",
"f",
")",
"{",
"if",
"(",
"f",
"!=",
"null",
")",
"{",
"if",
"(",
"f",
".",
"isDirectory",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"String",
"extension",
"=",
"getExtension",
"(",
"f",
")",
";",
"if",
"(",
"extension",
"!=",
"null",
"&&",
"filters",
".",
"get",
"(",
"getExtension",
"(",
"f",
")",
")",
"!=",
"null",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Retourne true si le fichier doit etre montre dans le repertoire,
false s'il ne doit pas l'etre.
Les fichier commencant par "." sont ignores.
@see #getExtension
@see FileFilter#accept | [
"Retourne",
"true",
"si",
"le",
"fichier",
"doit",
"etre",
"montre",
"dans",
"le",
"repertoire",
"false",
"s",
"il",
"ne",
"doit",
"pas",
"l",
"etre",
"."
] | ba45d4d86eb29b92f157c6e98536dee2002ddfdc | https://github.com/qspin/qtaste/blob/ba45d4d86eb29b92f157c6e98536dee2002ddfdc/kernel/src/main/java/com/qspin/qtaste/ui/tools/FileMask.java#L119-L130 |
140,144 | qspin/qtaste | kernel/src/main/java/com/qspin/qtaste/ui/tools/FileMask.java | FileMask.getExtension | public String getExtension(File f) {
if (f != null) {
String filename = f.getName();
int i = filename.lastIndexOf('.');
if (i > 0 && i < filename.length() - 1) {
return filename.substring(i + 1).toLowerCase();
}
}
return null;
} | java | public String getExtension(File f) {
if (f != null) {
String filename = f.getName();
int i = filename.lastIndexOf('.');
if (i > 0 && i < filename.length() - 1) {
return filename.substring(i + 1).toLowerCase();
}
}
return null;
} | [
"public",
"String",
"getExtension",
"(",
"File",
"f",
")",
"{",
"if",
"(",
"f",
"!=",
"null",
")",
"{",
"String",
"filename",
"=",
"f",
".",
"getName",
"(",
")",
";",
"int",
"i",
"=",
"filename",
".",
"lastIndexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"i",
">",
"0",
"&&",
"i",
"<",
"filename",
".",
"length",
"(",
")",
"-",
"1",
")",
"{",
"return",
"filename",
".",
"substring",
"(",
"i",
"+",
"1",
")",
".",
"toLowerCase",
"(",
")",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Retourne l'extention du nom du fichier.
@see #getExtension
@see FileFilter#accept | [
"Retourne",
"l",
"extention",
"du",
"nom",
"du",
"fichier",
"."
] | ba45d4d86eb29b92f157c6e98536dee2002ddfdc | https://github.com/qspin/qtaste/blob/ba45d4d86eb29b92f157c6e98536dee2002ddfdc/kernel/src/main/java/com/qspin/qtaste/ui/tools/FileMask.java#L138-L147 |
140,145 | qspin/qtaste | kernel/src/main/java/com/qspin/qtaste/config/XMLConfiguration.java | XMLConfiguration.getProperty | @Override
public List<Object> getProperty(String key) {
List<?> nodes = fetchNodeList(key);
if (nodes.size() == 0) {
return null;
} else {
List<Object> list = new ArrayList<>();
for (Object node : nodes) {
ConfigurationNode configurationNode = (ConfigurationNode) node;
if (configurationNode.getValue() != null) {
list.add(configurationNode.getValue());
}
}
if (list.size() < 1) {
return null;
} else {
return list;
}
}
} | java | @Override
public List<Object> getProperty(String key) {
List<?> nodes = fetchNodeList(key);
if (nodes.size() == 0) {
return null;
} else {
List<Object> list = new ArrayList<>();
for (Object node : nodes) {
ConfigurationNode configurationNode = (ConfigurationNode) node;
if (configurationNode.getValue() != null) {
list.add(configurationNode.getValue());
}
}
if (list.size() < 1) {
return null;
} else {
return list;
}
}
} | [
"@",
"Override",
"public",
"List",
"<",
"Object",
">",
"getProperty",
"(",
"String",
"key",
")",
"{",
"List",
"<",
"?",
">",
"nodes",
"=",
"fetchNodeList",
"(",
"key",
")",
";",
"if",
"(",
"nodes",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"return",
"null",
";",
"}",
"else",
"{",
"List",
"<",
"Object",
">",
"list",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"Object",
"node",
":",
"nodes",
")",
"{",
"ConfigurationNode",
"configurationNode",
"=",
"(",
"ConfigurationNode",
")",
"node",
";",
"if",
"(",
"configurationNode",
".",
"getValue",
"(",
")",
"!=",
"null",
")",
"{",
"list",
".",
"add",
"(",
"configurationNode",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}",
"if",
"(",
"list",
".",
"size",
"(",
")",
"<",
"1",
")",
"{",
"return",
"null",
";",
"}",
"else",
"{",
"return",
"list",
";",
"}",
"}",
"}"
] | Fetches the specified property. This task is delegated to the associated
expression engine.
@param key the key to be looked up
@return the found value | [
"Fetches",
"the",
"specified",
"property",
".",
"This",
"task",
"is",
"delegated",
"to",
"the",
"associated",
"expression",
"engine",
"."
] | ba45d4d86eb29b92f157c6e98536dee2002ddfdc | https://github.com/qspin/qtaste/blob/ba45d4d86eb29b92f157c6e98536dee2002ddfdc/kernel/src/main/java/com/qspin/qtaste/config/XMLConfiguration.java#L46-L67 |
140,146 | qspin/qtaste | kernel/src/main/java/com/qspin/qtaste/addon/AddOnManager.java | AddOnManager.loadAddOns | public void loadAddOns() {
List<String> addonToLoad = getAddOnClasses();
for (File f : new File(StaticConfiguration.PLUGINS_HOME).listFiles()) {
if (f.isFile() && f.getName().toUpperCase().endsWith(".JAR")) {
AddOnMetadata meta = AddOnMetadata.createAddOnMetadata(f);
if (meta != null) {
mAddons.add(meta);
LOGGER.debug("load " + meta.getMainClass());
if (addonToLoad.contains(meta.getMainClass())) {
loadAddOn(meta);
}
}
}
}
} | java | public void loadAddOns() {
List<String> addonToLoad = getAddOnClasses();
for (File f : new File(StaticConfiguration.PLUGINS_HOME).listFiles()) {
if (f.isFile() && f.getName().toUpperCase().endsWith(".JAR")) {
AddOnMetadata meta = AddOnMetadata.createAddOnMetadata(f);
if (meta != null) {
mAddons.add(meta);
LOGGER.debug("load " + meta.getMainClass());
if (addonToLoad.contains(meta.getMainClass())) {
loadAddOn(meta);
}
}
}
}
} | [
"public",
"void",
"loadAddOns",
"(",
")",
"{",
"List",
"<",
"String",
">",
"addonToLoad",
"=",
"getAddOnClasses",
"(",
")",
";",
"for",
"(",
"File",
"f",
":",
"new",
"File",
"(",
"StaticConfiguration",
".",
"PLUGINS_HOME",
")",
".",
"listFiles",
"(",
")",
")",
"{",
"if",
"(",
"f",
".",
"isFile",
"(",
")",
"&&",
"f",
".",
"getName",
"(",
")",
".",
"toUpperCase",
"(",
")",
".",
"endsWith",
"(",
"\".JAR\"",
")",
")",
"{",
"AddOnMetadata",
"meta",
"=",
"AddOnMetadata",
".",
"createAddOnMetadata",
"(",
"f",
")",
";",
"if",
"(",
"meta",
"!=",
"null",
")",
"{",
"mAddons",
".",
"add",
"(",
"meta",
")",
";",
"LOGGER",
".",
"debug",
"(",
"\"load \"",
"+",
"meta",
".",
"getMainClass",
"(",
")",
")",
";",
"if",
"(",
"addonToLoad",
".",
"contains",
"(",
"meta",
".",
"getMainClass",
"(",
")",
")",
")",
"{",
"loadAddOn",
"(",
"meta",
")",
";",
"}",
"}",
"}",
"}",
"}"
] | Loads and registers all add-ons references in the engine configuration file. | [
"Loads",
"and",
"registers",
"all",
"add",
"-",
"ons",
"references",
"in",
"the",
"engine",
"configuration",
"file",
"."
] | ba45d4d86eb29b92f157c6e98536dee2002ddfdc | https://github.com/qspin/qtaste/blob/ba45d4d86eb29b92f157c6e98536dee2002ddfdc/kernel/src/main/java/com/qspin/qtaste/addon/AddOnManager.java#L37-L51 |
140,147 | qspin/qtaste | kernel/src/main/java/com/qspin/qtaste/addon/AddOnManager.java | AddOnManager.registerAddOn | boolean registerAddOn(AddOn pAddOn) {
if (!mRegisteredAddOns.containsKey(pAddOn.getAddOnId())) {
mRegisteredAddOns.put(pAddOn.getAddOnId(), pAddOn);
if (pAddOn.hasConfiguration()) {
addConfiguration(pAddOn.getAddOnId(), pAddOn.getConfigurationPane());
}
LOGGER.info("The add-on " + pAddOn.getAddOnId() + " has been registered.");
return true;
} else {
LOGGER.warn("The add-on " + pAddOn.getAddOnId() + " is alreadry registered.");
return false;
}
} | java | boolean registerAddOn(AddOn pAddOn) {
if (!mRegisteredAddOns.containsKey(pAddOn.getAddOnId())) {
mRegisteredAddOns.put(pAddOn.getAddOnId(), pAddOn);
if (pAddOn.hasConfiguration()) {
addConfiguration(pAddOn.getAddOnId(), pAddOn.getConfigurationPane());
}
LOGGER.info("The add-on " + pAddOn.getAddOnId() + " has been registered.");
return true;
} else {
LOGGER.warn("The add-on " + pAddOn.getAddOnId() + " is alreadry registered.");
return false;
}
} | [
"boolean",
"registerAddOn",
"(",
"AddOn",
"pAddOn",
")",
"{",
"if",
"(",
"!",
"mRegisteredAddOns",
".",
"containsKey",
"(",
"pAddOn",
".",
"getAddOnId",
"(",
")",
")",
")",
"{",
"mRegisteredAddOns",
".",
"put",
"(",
"pAddOn",
".",
"getAddOnId",
"(",
")",
",",
"pAddOn",
")",
";",
"if",
"(",
"pAddOn",
".",
"hasConfiguration",
"(",
")",
")",
"{",
"addConfiguration",
"(",
"pAddOn",
".",
"getAddOnId",
"(",
")",
",",
"pAddOn",
".",
"getConfigurationPane",
"(",
")",
")",
";",
"}",
"LOGGER",
".",
"info",
"(",
"\"The add-on \"",
"+",
"pAddOn",
".",
"getAddOnId",
"(",
")",
"+",
"\" has been registered.\"",
")",
";",
"return",
"true",
";",
"}",
"else",
"{",
"LOGGER",
".",
"warn",
"(",
"\"The add-on \"",
"+",
"pAddOn",
".",
"getAddOnId",
"(",
")",
"+",
"\" is alreadry registered.\"",
")",
";",
"return",
"false",
";",
"}",
"}"
] | Registers the add-on. If the add-on is not loaded, loads it.
@param pAddOn The add-on to register.
@return <code>true</code> if the add-on is successfully registered. | [
"Registers",
"the",
"add",
"-",
"on",
".",
"If",
"the",
"add",
"-",
"on",
"is",
"not",
"loaded",
"loads",
"it",
"."
] | ba45d4d86eb29b92f157c6e98536dee2002ddfdc | https://github.com/qspin/qtaste/blob/ba45d4d86eb29b92f157c6e98536dee2002ddfdc/kernel/src/main/java/com/qspin/qtaste/addon/AddOnManager.java#L137-L149 |
140,148 | qspin/qtaste | kernel/src/main/java/com/qspin/qtaste/addon/AddOnManager.java | AddOnManager.getAddOn | public AddOn getAddOn(String pAddOnId) {
if (mRegisteredAddOns.containsKey(pAddOnId)) {
return mRegisteredAddOns.get(pAddOnId);
} else {
LOGGER.warn("Add-on " + pAddOnId + " is not loaded.");
return null;
}
} | java | public AddOn getAddOn(String pAddOnId) {
if (mRegisteredAddOns.containsKey(pAddOnId)) {
return mRegisteredAddOns.get(pAddOnId);
} else {
LOGGER.warn("Add-on " + pAddOnId + " is not loaded.");
return null;
}
} | [
"public",
"AddOn",
"getAddOn",
"(",
"String",
"pAddOnId",
")",
"{",
"if",
"(",
"mRegisteredAddOns",
".",
"containsKey",
"(",
"pAddOnId",
")",
")",
"{",
"return",
"mRegisteredAddOns",
".",
"get",
"(",
"pAddOnId",
")",
";",
"}",
"else",
"{",
"LOGGER",
".",
"warn",
"(",
"\"Add-on \"",
"+",
"pAddOnId",
"+",
"\" is not loaded.\"",
")",
";",
"return",
"null",
";",
"}",
"}"
] | Returns the registered add-on identified by the identifier.
@param pAddOnId The add-on's identifier.
@return The registered add-on identified by the identifier. | [
"Returns",
"the",
"registered",
"add",
"-",
"on",
"identified",
"by",
"the",
"identifier",
"."
] | ba45d4d86eb29b92f157c6e98536dee2002ddfdc | https://github.com/qspin/qtaste/blob/ba45d4d86eb29b92f157c6e98536dee2002ddfdc/kernel/src/main/java/com/qspin/qtaste/addon/AddOnManager.java#L157-L165 |
140,149 | qspin/qtaste | plugins_src/javagui-fx/src/main/java/com/qspin/qtaste/javaguifx/server/PopupTextSetter.java | PopupTextSetter.executeCommand | @Override
public Boolean executeCommand(int timeout, String componentName, Object... data) throws QTasteException {
setData(data);
long maxTime = System.currentTimeMillis() + 1000 * timeout;
while (System.currentTimeMillis() < maxTime) {
Stage targetPopup = null;
for (Stage stage : findPopups()) {
// if (!stage.isVisible() || !dialog.isEnabled()) {
// String msg = "Ignore the dialog '" + dialog.getTitle() + "' cause:\n ";
// if (!dialog.isVisible()) {
// msg += "\t is not visible";
// }
// if (!dialog.isEnabled()) {
// msg += "\t is not enabled";
// }
// LOGGER.info(msg);
// continue;
// }
// if (activateAndFocusComponentWindow(dialog))
// {
// targetPopup = dialog;
// }
// else
// {
// LOGGER.info("Ignore the dialog '" + dialog.getTitle() + "' cause:\n \t is not focused");
// }
}
// component = findTextComponent(targetPopup);
//
// if ( component != null && !component.isDisabled() && checkComponentIsVisible(component) )
// break;
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
LOGGER.warn("Exception during the component search sleep...");
}
}
if (component == null) {
throw new QTasteTestFailException("The text field component is not found.");
}
if (component.isDisabled()) {
throw new QTasteTestFailException("The text field component is not enabled.");
}
if (!checkComponentIsVisible(component)) {
throw new QTasteTestFailException("The text field component is not visible!");
}
prepareActions();
Platform.runLater(this);
return true;
} | java | @Override
public Boolean executeCommand(int timeout, String componentName, Object... data) throws QTasteException {
setData(data);
long maxTime = System.currentTimeMillis() + 1000 * timeout;
while (System.currentTimeMillis() < maxTime) {
Stage targetPopup = null;
for (Stage stage : findPopups()) {
// if (!stage.isVisible() || !dialog.isEnabled()) {
// String msg = "Ignore the dialog '" + dialog.getTitle() + "' cause:\n ";
// if (!dialog.isVisible()) {
// msg += "\t is not visible";
// }
// if (!dialog.isEnabled()) {
// msg += "\t is not enabled";
// }
// LOGGER.info(msg);
// continue;
// }
// if (activateAndFocusComponentWindow(dialog))
// {
// targetPopup = dialog;
// }
// else
// {
// LOGGER.info("Ignore the dialog '" + dialog.getTitle() + "' cause:\n \t is not focused");
// }
}
// component = findTextComponent(targetPopup);
//
// if ( component != null && !component.isDisabled() && checkComponentIsVisible(component) )
// break;
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
LOGGER.warn("Exception during the component search sleep...");
}
}
if (component == null) {
throw new QTasteTestFailException("The text field component is not found.");
}
if (component.isDisabled()) {
throw new QTasteTestFailException("The text field component is not enabled.");
}
if (!checkComponentIsVisible(component)) {
throw new QTasteTestFailException("The text field component is not visible!");
}
prepareActions();
Platform.runLater(this);
return true;
} | [
"@",
"Override",
"public",
"Boolean",
"executeCommand",
"(",
"int",
"timeout",
",",
"String",
"componentName",
",",
"Object",
"...",
"data",
")",
"throws",
"QTasteException",
"{",
"setData",
"(",
"data",
")",
";",
"long",
"maxTime",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
"+",
"1000",
"*",
"timeout",
";",
"while",
"(",
"System",
".",
"currentTimeMillis",
"(",
")",
"<",
"maxTime",
")",
"{",
"Stage",
"targetPopup",
"=",
"null",
";",
"for",
"(",
"Stage",
"stage",
":",
"findPopups",
"(",
")",
")",
"{",
"// if (!stage.isVisible() || !dialog.isEnabled()) {",
"// String msg = \"Ignore the dialog '\" + dialog.getTitle() + \"' cause:\\n \";",
"// if (!dialog.isVisible()) {",
"// msg += \"\\t is not visible\";",
"// }",
"// if (!dialog.isEnabled()) {",
"// msg += \"\\t is not enabled\";",
"// }",
"// LOGGER.info(msg);",
"// continue;",
"// }",
"//\t\t\t\tif (activateAndFocusComponentWindow(dialog))",
"//\t\t\t\t{",
"//\t\t\t\t\ttargetPopup = dialog;",
"//\t\t\t\t}",
"//\t\t\t\telse",
"//\t\t\t\t{",
"//\t\t\t\t\tLOGGER.info(\"Ignore the dialog '\" + dialog.getTitle() + \"' cause:\\n \\t is not focused\");",
"//\t\t\t\t}",
"}",
"//\t\t\tcomponent = findTextComponent(targetPopup);",
"//",
"//\t\t\tif ( component != null && !component.isDisabled() && checkComponentIsVisible(component) )",
"//\t\t\t\tbreak;",
"try",
"{",
"Thread",
".",
"sleep",
"(",
"1000",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"LOGGER",
".",
"warn",
"(",
"\"Exception during the component search sleep...\"",
")",
";",
"}",
"}",
"if",
"(",
"component",
"==",
"null",
")",
"{",
"throw",
"new",
"QTasteTestFailException",
"(",
"\"The text field component is not found.\"",
")",
";",
"}",
"if",
"(",
"component",
".",
"isDisabled",
"(",
")",
")",
"{",
"throw",
"new",
"QTasteTestFailException",
"(",
"\"The text field component is not enabled.\"",
")",
";",
"}",
"if",
"(",
"!",
"checkComponentIsVisible",
"(",
"component",
")",
")",
"{",
"throw",
"new",
"QTasteTestFailException",
"(",
"\"The text field component is not visible!\"",
")",
";",
"}",
"prepareActions",
"(",
")",
";",
"Platform",
".",
"runLater",
"(",
"this",
")",
";",
"return",
"true",
";",
"}"
] | Commander which sets a value in the input field of a popup.
@param data INTEGER - the timeout value; OBJECT - with the value to insert. The toString method will be used on the object.
@return true if the command is successfully performed.
@throws QTasteException | [
"Commander",
"which",
"sets",
"a",
"value",
"in",
"the",
"input",
"field",
"of",
"a",
"popup",
"."
] | ba45d4d86eb29b92f157c6e98536dee2002ddfdc | https://github.com/qspin/qtaste/blob/ba45d4d86eb29b92f157c6e98536dee2002ddfdc/plugins_src/javagui-fx/src/main/java/com/qspin/qtaste/javaguifx/server/PopupTextSetter.java#L48-L102 |
140,150 | qspin/qtaste | kernel/src/main/java/com/qspin/qtaste/ui/jedit/TextUtilities.java | TextUtilities.tabsToSpaces | public static String tabsToSpaces(String in, int tabSize) {
StringBuilder buf = new StringBuilder();
int width = 0;
for (int i = 0; i < in.length(); i++) {
switch (in.charAt(i)) {
case '\t':
int count = tabSize - (width % tabSize);
width += count;
while (--count >= 0) {
buf.append(' ');
}
break;
case '\n':
width = 0;
buf.append(in.charAt(i));
break;
default:
width++;
buf.append(in.charAt(i));
break;
}
}
return buf.toString();
} | java | public static String tabsToSpaces(String in, int tabSize) {
StringBuilder buf = new StringBuilder();
int width = 0;
for (int i = 0; i < in.length(); i++) {
switch (in.charAt(i)) {
case '\t':
int count = tabSize - (width % tabSize);
width += count;
while (--count >= 0) {
buf.append(' ');
}
break;
case '\n':
width = 0;
buf.append(in.charAt(i));
break;
default:
width++;
buf.append(in.charAt(i));
break;
}
}
return buf.toString();
} | [
"public",
"static",
"String",
"tabsToSpaces",
"(",
"String",
"in",
",",
"int",
"tabSize",
")",
"{",
"StringBuilder",
"buf",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"int",
"width",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"in",
".",
"length",
"(",
")",
";",
"i",
"++",
")",
"{",
"switch",
"(",
"in",
".",
"charAt",
"(",
"i",
")",
")",
"{",
"case",
"'",
"'",
":",
"int",
"count",
"=",
"tabSize",
"-",
"(",
"width",
"%",
"tabSize",
")",
";",
"width",
"+=",
"count",
";",
"while",
"(",
"--",
"count",
">=",
"0",
")",
"{",
"buf",
".",
"append",
"(",
"'",
"'",
")",
";",
"}",
"break",
";",
"case",
"'",
"'",
":",
"width",
"=",
"0",
";",
"buf",
".",
"append",
"(",
"in",
".",
"charAt",
"(",
"i",
")",
")",
";",
"break",
";",
"default",
":",
"width",
"++",
";",
"buf",
".",
"append",
"(",
"in",
".",
"charAt",
"(",
"i",
")",
")",
";",
"break",
";",
"}",
"}",
"return",
"buf",
".",
"toString",
"(",
")",
";",
"}"
] | Converts tabs to consecutive spaces in the specified string.
@param in The string
@param tabSize The tab size | [
"Converts",
"tabs",
"to",
"consecutive",
"spaces",
"in",
"the",
"specified",
"string",
"."
] | ba45d4d86eb29b92f157c6e98536dee2002ddfdc | https://github.com/qspin/qtaste/blob/ba45d4d86eb29b92f157c6e98536dee2002ddfdc/kernel/src/main/java/com/qspin/qtaste/ui/jedit/TextUtilities.java#L239-L262 |
140,151 | qspin/qtaste | kernel/src/main/java/com/qspin/qtaste/ui/jedit/TextUtilities.java | TextUtilities.toTitleCase | public static String toTitleCase(String str) {
if (str.length() == 0) {
return str;
} else {
return Character.toUpperCase(str.charAt(0)) + str.substring(1).toLowerCase();
}
} | java | public static String toTitleCase(String str) {
if (str.length() == 0) {
return str;
} else {
return Character.toUpperCase(str.charAt(0)) + str.substring(1).toLowerCase();
}
} | [
"public",
"static",
"String",
"toTitleCase",
"(",
"String",
"str",
")",
"{",
"if",
"(",
"str",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"return",
"str",
";",
"}",
"else",
"{",
"return",
"Character",
".",
"toUpperCase",
"(",
"str",
".",
"charAt",
"(",
"0",
")",
")",
"+",
"str",
".",
"substring",
"(",
"1",
")",
".",
"toLowerCase",
"(",
")",
";",
"}",
"}"
] | Converts the specified string to title case, by capitalizing the
first letter.
@param str The string
@since jEdit 4.0pre1 | [
"Converts",
"the",
"specified",
"string",
"to",
"title",
"case",
"by",
"capitalizing",
"the",
"first",
"letter",
"."
] | ba45d4d86eb29b92f157c6e98536dee2002ddfdc | https://github.com/qspin/qtaste/blob/ba45d4d86eb29b92f157c6e98536dee2002ddfdc/kernel/src/main/java/com/qspin/qtaste/ui/jedit/TextUtilities.java#L328-L334 |
140,152 | qspin/qtaste | kernel/src/main/java/com/qspin/qtaste/util/Version.java | Version.getManifestAttributeValue | protected String getManifestAttributeValue(Attributes.Name attributeName) {
try {
String value = attributes.getValue(attributeName);
return value != null ? value : "undefined";
} catch (NullPointerException e) {
return "undefined";
} catch (IllegalArgumentException e) {
logger.error("Invalid attribute name when reading jar manifest for reading version information: " + e.getMessage());
return "undefined";
}
} | java | protected String getManifestAttributeValue(Attributes.Name attributeName) {
try {
String value = attributes.getValue(attributeName);
return value != null ? value : "undefined";
} catch (NullPointerException e) {
return "undefined";
} catch (IllegalArgumentException e) {
logger.error("Invalid attribute name when reading jar manifest for reading version information: " + e.getMessage());
return "undefined";
}
} | [
"protected",
"String",
"getManifestAttributeValue",
"(",
"Attributes",
".",
"Name",
"attributeName",
")",
"{",
"try",
"{",
"String",
"value",
"=",
"attributes",
".",
"getValue",
"(",
"attributeName",
")",
";",
"return",
"value",
"!=",
"null",
"?",
"value",
":",
"\"undefined\"",
";",
"}",
"catch",
"(",
"NullPointerException",
"e",
")",
"{",
"return",
"\"undefined\"",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"Invalid attribute name when reading jar manifest for reading version information: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"return",
"\"undefined\"",
";",
"}",
"}"
] | Gets the value of an attribute of the manifest.
@param attributeName the name of the attribute
@return the value of the attribute, or "undefined" if the attribute couldn't be read | [
"Gets",
"the",
"value",
"of",
"an",
"attribute",
"of",
"the",
"manifest",
"."
] | ba45d4d86eb29b92f157c6e98536dee2002ddfdc | https://github.com/qspin/qtaste/blob/ba45d4d86eb29b92f157c6e98536dee2002ddfdc/kernel/src/main/java/com/qspin/qtaste/util/Version.java#L112-L122 |
140,153 | qspin/qtaste | kernel/src/main/java/com/qspin/qtaste/config/StaticConfiguration.java | StaticConfiguration.getQTasteRoot | private static String getQTasteRoot() {
String qtasteRoot = System.getenv("QTASTE_ROOT");
if (qtasteRoot == null) {
System.err.println("QTASTE_ROOT environment variable is not defined");
System.exit(1);
}
try {
qtasteRoot = new File(qtasteRoot).getCanonicalPath();
} catch (IOException e) {
System.err.println("QTASTE_ROOT environment variable is invalid (" + qtasteRoot + ")");
System.exit(1);
}
return qtasteRoot;
} | java | private static String getQTasteRoot() {
String qtasteRoot = System.getenv("QTASTE_ROOT");
if (qtasteRoot == null) {
System.err.println("QTASTE_ROOT environment variable is not defined");
System.exit(1);
}
try {
qtasteRoot = new File(qtasteRoot).getCanonicalPath();
} catch (IOException e) {
System.err.println("QTASTE_ROOT environment variable is invalid (" + qtasteRoot + ")");
System.exit(1);
}
return qtasteRoot;
} | [
"private",
"static",
"String",
"getQTasteRoot",
"(",
")",
"{",
"String",
"qtasteRoot",
"=",
"System",
".",
"getenv",
"(",
"\"QTASTE_ROOT\"",
")",
";",
"if",
"(",
"qtasteRoot",
"==",
"null",
")",
"{",
"System",
".",
"err",
".",
"println",
"(",
"\"QTASTE_ROOT environment variable is not defined\"",
")",
";",
"System",
".",
"exit",
"(",
"1",
")",
";",
"}",
"try",
"{",
"qtasteRoot",
"=",
"new",
"File",
"(",
"qtasteRoot",
")",
".",
"getCanonicalPath",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"System",
".",
"err",
".",
"println",
"(",
"\"QTASTE_ROOT environment variable is invalid (\"",
"+",
"qtasteRoot",
"+",
"\")\"",
")",
";",
"System",
".",
"exit",
"(",
"1",
")",
";",
"}",
"return",
"qtasteRoot",
";",
"}"
] | Get QTaste root directory from QTASTE_ROOT environment variable.
@return the QTaste root directory | [
"Get",
"QTaste",
"root",
"directory",
"from",
"QTASTE_ROOT",
"environment",
"variable",
"."
] | ba45d4d86eb29b92f157c6e98536dee2002ddfdc | https://github.com/qspin/qtaste/blob/ba45d4d86eb29b92f157c6e98536dee2002ddfdc/kernel/src/main/java/com/qspin/qtaste/config/StaticConfiguration.java#L74-L87 |
140,154 | qspin/qtaste | plugins_src/javagui-fx/src/main/java/com/qspin/qtaste/javaguifx/server/ComponentCommander.java | ComponentCommander.findPopups | protected static List<Stage> findPopups() throws QTasteTestFailException {
//find all popups
List<Stage> popupFound = new ArrayList<>();
for (Stage stage : getStages()) {
Parent root = stage.getScene().getRoot();
if (isAPopup(stage)) {
//it's maybe a popup... a popup is modal and not resizable and has a DialogPane root
DialogPane dialog = (DialogPane) root;
LOGGER.trace("Find a popup with the title '" + stage.getTitle() + "'.");
popupFound.add(stage);
}
}
return popupFound;
} | java | protected static List<Stage> findPopups() throws QTasteTestFailException {
//find all popups
List<Stage> popupFound = new ArrayList<>();
for (Stage stage : getStages()) {
Parent root = stage.getScene().getRoot();
if (isAPopup(stage)) {
//it's maybe a popup... a popup is modal and not resizable and has a DialogPane root
DialogPane dialog = (DialogPane) root;
LOGGER.trace("Find a popup with the title '" + stage.getTitle() + "'.");
popupFound.add(stage);
}
}
return popupFound;
} | [
"protected",
"static",
"List",
"<",
"Stage",
">",
"findPopups",
"(",
")",
"throws",
"QTasteTestFailException",
"{",
"//find all popups",
"List",
"<",
"Stage",
">",
"popupFound",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"Stage",
"stage",
":",
"getStages",
"(",
")",
")",
"{",
"Parent",
"root",
"=",
"stage",
".",
"getScene",
"(",
")",
".",
"getRoot",
"(",
")",
";",
"if",
"(",
"isAPopup",
"(",
"stage",
")",
")",
"{",
"//it's maybe a popup... a popup is modal and not resizable and has a DialogPane root",
"DialogPane",
"dialog",
"=",
"(",
"DialogPane",
")",
"root",
";",
"LOGGER",
".",
"trace",
"(",
"\"Find a popup with the title '\"",
"+",
"stage",
".",
"getTitle",
"(",
")",
"+",
"\"'.\"",
")",
";",
"popupFound",
".",
"add",
"(",
"stage",
")",
";",
"}",
"}",
"return",
"popupFound",
";",
"}"
] | Finds all popups. A Component is a popup if it's a DialogPane, modal and not resizable.
@return the list of all found popups. | [
"Finds",
"all",
"popups",
".",
"A",
"Component",
"is",
"a",
"popup",
"if",
"it",
"s",
"a",
"DialogPane",
"modal",
"and",
"not",
"resizable",
"."
] | ba45d4d86eb29b92f157c6e98536dee2002ddfdc | https://github.com/qspin/qtaste/blob/ba45d4d86eb29b92f157c6e98536dee2002ddfdc/plugins_src/javagui-fx/src/main/java/com/qspin/qtaste/javaguifx/server/ComponentCommander.java#L155-L168 |
140,155 | qspin/qtaste | plugins_src/javagui-fx/src/main/java/com/qspin/qtaste/javaguifx/server/ComponentCommander.java | ComponentCommander.activateAndFocusWindow | protected boolean activateAndFocusWindow(Stage window) {
if (!window.isFocused()) {
if (!window.isShowing()) {
LOGGER.trace("cannot activate and focus the window '" + window.getTitle() + "' cause its window is not showing");
return false;
}
LOGGER.trace("try to activate and focus the window '" + window.getTitle() + "' cause its window is not focused");
StageFocusedListener stageFocusedListener = new StageFocusedListener(window);
window.focusedProperty().addListener(stageFocusedListener);
PlatformImpl.runAndWait(() -> {
window.toFront();
window.requestFocus();
});
boolean windowFocused = stageFocusedListener.waitUntilWindowFocused();
window.focusedProperty().removeListener(stageFocusedListener);
LOGGER.trace("window focused ? " + windowFocused);
if (!window.isFocused()) {
LOGGER.warn("The window activation/focus process failed!!!");
return false;
}
LOGGER.trace("The window activation/focus process is completed!!!");
} else {
LOGGER.trace("the window '" + window.getTitle() + "' is already focused");
}
return true;
} | java | protected boolean activateAndFocusWindow(Stage window) {
if (!window.isFocused()) {
if (!window.isShowing()) {
LOGGER.trace("cannot activate and focus the window '" + window.getTitle() + "' cause its window is not showing");
return false;
}
LOGGER.trace("try to activate and focus the window '" + window.getTitle() + "' cause its window is not focused");
StageFocusedListener stageFocusedListener = new StageFocusedListener(window);
window.focusedProperty().addListener(stageFocusedListener);
PlatformImpl.runAndWait(() -> {
window.toFront();
window.requestFocus();
});
boolean windowFocused = stageFocusedListener.waitUntilWindowFocused();
window.focusedProperty().removeListener(stageFocusedListener);
LOGGER.trace("window focused ? " + windowFocused);
if (!window.isFocused()) {
LOGGER.warn("The window activation/focus process failed!!!");
return false;
}
LOGGER.trace("The window activation/focus process is completed!!!");
} else {
LOGGER.trace("the window '" + window.getTitle() + "' is already focused");
}
return true;
} | [
"protected",
"boolean",
"activateAndFocusWindow",
"(",
"Stage",
"window",
")",
"{",
"if",
"(",
"!",
"window",
".",
"isFocused",
"(",
")",
")",
"{",
"if",
"(",
"!",
"window",
".",
"isShowing",
"(",
")",
")",
"{",
"LOGGER",
".",
"trace",
"(",
"\"cannot activate and focus the window '\"",
"+",
"window",
".",
"getTitle",
"(",
")",
"+",
"\"' cause its window is not showing\"",
")",
";",
"return",
"false",
";",
"}",
"LOGGER",
".",
"trace",
"(",
"\"try to activate and focus the window '\"",
"+",
"window",
".",
"getTitle",
"(",
")",
"+",
"\"' cause its window is not focused\"",
")",
";",
"StageFocusedListener",
"stageFocusedListener",
"=",
"new",
"StageFocusedListener",
"(",
"window",
")",
";",
"window",
".",
"focusedProperty",
"(",
")",
".",
"addListener",
"(",
"stageFocusedListener",
")",
";",
"PlatformImpl",
".",
"runAndWait",
"(",
"(",
")",
"->",
"{",
"window",
".",
"toFront",
"(",
")",
";",
"window",
".",
"requestFocus",
"(",
")",
";",
"}",
")",
";",
"boolean",
"windowFocused",
"=",
"stageFocusedListener",
".",
"waitUntilWindowFocused",
"(",
")",
";",
"window",
".",
"focusedProperty",
"(",
")",
".",
"removeListener",
"(",
"stageFocusedListener",
")",
";",
"LOGGER",
".",
"trace",
"(",
"\"window focused ? \"",
"+",
"windowFocused",
")",
";",
"if",
"(",
"!",
"window",
".",
"isFocused",
"(",
")",
")",
"{",
"LOGGER",
".",
"warn",
"(",
"\"The window activation/focus process failed!!!\"",
")",
";",
"return",
"false",
";",
"}",
"LOGGER",
".",
"trace",
"(",
"\"The window activation/focus process is completed!!!\"",
")",
";",
"}",
"else",
"{",
"LOGGER",
".",
"trace",
"(",
"\"the window '\"",
"+",
"window",
".",
"getTitle",
"(",
")",
"+",
"\"' is already focused\"",
")",
";",
"}",
"return",
"true",
";",
"}"
] | Try to activate and focus the stage window.
@param window the stage window to activate.
@return <code>true</code> only if the stage window is active at the end of the activation process. | [
"Try",
"to",
"activate",
"and",
"focus",
"the",
"stage",
"window",
"."
] | ba45d4d86eb29b92f157c6e98536dee2002ddfdc | https://github.com/qspin/qtaste/blob/ba45d4d86eb29b92f157c6e98536dee2002ddfdc/plugins_src/javagui-fx/src/main/java/com/qspin/qtaste/javaguifx/server/ComponentCommander.java#L224-L251 |
140,156 | qspin/qtaste | plugins_src/javagui/src/main/java/com/qspin/qtaste/javagui/server/ComponentCommander.java | ComponentCommander.findPopups | protected static List<JDialog> findPopups() {
//find all popups
List<JDialog> popupFound = new ArrayList<>();
for (Window window : getDisplayableWindows()) {
// LOGGER.debug("parse window - type : " + window.getClass());
if (isAPopup(window)) {
//it's maybe a popup... a popup is modal and not resizable and containt a JOptionPane component.
JDialog dialog = (JDialog) window;
LOGGER.trace("Find a popup with the title '" + dialog.getTitle() + "'.");
popupFound.add(dialog);
}
}
return popupFound;
} | java | protected static List<JDialog> findPopups() {
//find all popups
List<JDialog> popupFound = new ArrayList<>();
for (Window window : getDisplayableWindows()) {
// LOGGER.debug("parse window - type : " + window.getClass());
if (isAPopup(window)) {
//it's maybe a popup... a popup is modal and not resizable and containt a JOptionPane component.
JDialog dialog = (JDialog) window;
LOGGER.trace("Find a popup with the title '" + dialog.getTitle() + "'.");
popupFound.add(dialog);
}
}
return popupFound;
} | [
"protected",
"static",
"List",
"<",
"JDialog",
">",
"findPopups",
"(",
")",
"{",
"//find all popups",
"List",
"<",
"JDialog",
">",
"popupFound",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"Window",
"window",
":",
"getDisplayableWindows",
"(",
")",
")",
"{",
"//\t\t\tLOGGER.debug(\"parse window - type : \" + window.getClass());",
"if",
"(",
"isAPopup",
"(",
"window",
")",
")",
"{",
"//it's maybe a popup... a popup is modal and not resizable and containt a JOptionPane component.",
"JDialog",
"dialog",
"=",
"(",
"JDialog",
")",
"window",
";",
"LOGGER",
".",
"trace",
"(",
"\"Find a popup with the title '\"",
"+",
"dialog",
".",
"getTitle",
"(",
")",
"+",
"\"'.\"",
")",
";",
"popupFound",
".",
"add",
"(",
"dialog",
")",
";",
"}",
"}",
"return",
"popupFound",
";",
"}"
] | Finds all popups. A Component is a popup if it's a JDialog, modal and not resizable.
@return the list of all found popups. | [
"Finds",
"all",
"popups",
".",
"A",
"Component",
"is",
"a",
"popup",
"if",
"it",
"s",
"a",
"JDialog",
"modal",
"and",
"not",
"resizable",
"."
] | ba45d4d86eb29b92f157c6e98536dee2002ddfdc | https://github.com/qspin/qtaste/blob/ba45d4d86eb29b92f157c6e98536dee2002ddfdc/plugins_src/javagui/src/main/java/com/qspin/qtaste/javagui/server/ComponentCommander.java#L148-L161 |
140,157 | qspin/qtaste | kernel/src/main/java/com/qspin/qtaste/util/PythonHelper.java | PythonHelper.execute | public static String execute(String fileName, String... arguments) throws PyException {
return execute(fileName, true, arguments);
} | java | public static String execute(String fileName, String... arguments) throws PyException {
return execute(fileName, true, arguments);
} | [
"public",
"static",
"String",
"execute",
"(",
"String",
"fileName",
",",
"String",
"...",
"arguments",
")",
"throws",
"PyException",
"{",
"return",
"execute",
"(",
"fileName",
",",
"true",
",",
"arguments",
")",
";",
"}"
] | Executes a python script and return its output.
@param fileName the filename of the python script to execute
@param arguments the arguments to pass to the python script
@return the output of the python script execution (combined standard and error outputs)
@throws PyException in case of exception during Python script execution | [
"Executes",
"a",
"python",
"script",
"and",
"return",
"its",
"output",
"."
] | ba45d4d86eb29b92f157c6e98536dee2002ddfdc | https://github.com/qspin/qtaste/blob/ba45d4d86eb29b92f157c6e98536dee2002ddfdc/kernel/src/main/java/com/qspin/qtaste/util/PythonHelper.java#L47-L49 |
140,158 | qspin/qtaste | kernel/src/main/java/com/qspin/qtaste/util/PythonHelper.java | PythonHelper.execute | public static String execute(String fileName, boolean redirectOutput, String... arguments) throws PyException {
Properties properties = new Properties();
properties.setProperty("python.home", StaticConfiguration.JYTHON_HOME);
properties.setProperty("python.path", StaticConfiguration.FORMATTER_DIR);
PythonInterpreter.initialize(System.getProperties(), properties, new String[] {""});
try (PythonInterpreter interp = new PythonInterpreter(new org.python.core.PyStringMap(),
new org.python.core.PySystemState())) {
StringWriter output = null;
if (redirectOutput) {
output = new StringWriter();
interp.setOut(output);
interp.setErr(output);
}
interp.cleanup();
interp.exec("import sys;sys.argv[1:]= [r'" + StringUtils.join(arguments, "','") + "']");
interp.exec("__name__ = '__main__'");
interp.exec("execfile(r'" + fileName + "')");
return redirectOutput ? output.toString() : null;
}
} | java | public static String execute(String fileName, boolean redirectOutput, String... arguments) throws PyException {
Properties properties = new Properties();
properties.setProperty("python.home", StaticConfiguration.JYTHON_HOME);
properties.setProperty("python.path", StaticConfiguration.FORMATTER_DIR);
PythonInterpreter.initialize(System.getProperties(), properties, new String[] {""});
try (PythonInterpreter interp = new PythonInterpreter(new org.python.core.PyStringMap(),
new org.python.core.PySystemState())) {
StringWriter output = null;
if (redirectOutput) {
output = new StringWriter();
interp.setOut(output);
interp.setErr(output);
}
interp.cleanup();
interp.exec("import sys;sys.argv[1:]= [r'" + StringUtils.join(arguments, "','") + "']");
interp.exec("__name__ = '__main__'");
interp.exec("execfile(r'" + fileName + "')");
return redirectOutput ? output.toString() : null;
}
} | [
"public",
"static",
"String",
"execute",
"(",
"String",
"fileName",
",",
"boolean",
"redirectOutput",
",",
"String",
"...",
"arguments",
")",
"throws",
"PyException",
"{",
"Properties",
"properties",
"=",
"new",
"Properties",
"(",
")",
";",
"properties",
".",
"setProperty",
"(",
"\"python.home\"",
",",
"StaticConfiguration",
".",
"JYTHON_HOME",
")",
";",
"properties",
".",
"setProperty",
"(",
"\"python.path\"",
",",
"StaticConfiguration",
".",
"FORMATTER_DIR",
")",
";",
"PythonInterpreter",
".",
"initialize",
"(",
"System",
".",
"getProperties",
"(",
")",
",",
"properties",
",",
"new",
"String",
"[",
"]",
"{",
"\"\"",
"}",
")",
";",
"try",
"(",
"PythonInterpreter",
"interp",
"=",
"new",
"PythonInterpreter",
"(",
"new",
"org",
".",
"python",
".",
"core",
".",
"PyStringMap",
"(",
")",
",",
"new",
"org",
".",
"python",
".",
"core",
".",
"PySystemState",
"(",
")",
")",
")",
"{",
"StringWriter",
"output",
"=",
"null",
";",
"if",
"(",
"redirectOutput",
")",
"{",
"output",
"=",
"new",
"StringWriter",
"(",
")",
";",
"interp",
".",
"setOut",
"(",
"output",
")",
";",
"interp",
".",
"setErr",
"(",
"output",
")",
";",
"}",
"interp",
".",
"cleanup",
"(",
")",
";",
"interp",
".",
"exec",
"(",
"\"import sys;sys.argv[1:]= [r'\"",
"+",
"StringUtils",
".",
"join",
"(",
"arguments",
",",
"\"','\"",
")",
"+",
"\"']\"",
")",
";",
"interp",
".",
"exec",
"(",
"\"__name__ = '__main__'\"",
")",
";",
"interp",
".",
"exec",
"(",
"\"execfile(r'\"",
"+",
"fileName",
"+",
"\"')\"",
")",
";",
"return",
"redirectOutput",
"?",
"output",
".",
"toString",
"(",
")",
":",
"null",
";",
"}",
"}"
] | Executes a python script, returning its output or not.
@param fileName the filename of the python script to execute
@param redirectOutput true to redirect outputs and return them, false otherwise
@param arguments the arguments to pass to the python script
@return the output of the python script execution (combined standard and error outputs) or null if outputs were not
redirected
@throws PyException in case of exception during Python script execution | [
"Executes",
"a",
"python",
"script",
"returning",
"its",
"output",
"or",
"not",
"."
] | ba45d4d86eb29b92f157c6e98536dee2002ddfdc | https://github.com/qspin/qtaste/blob/ba45d4d86eb29b92f157c6e98536dee2002ddfdc/kernel/src/main/java/com/qspin/qtaste/util/PythonHelper.java#L61-L81 |
140,159 | qspin/qtaste | kernel/src/main/java/com/qspin/qtaste/util/Strings.java | Strings.toNullTerminatedFixedSizeByteArray | public static byte[] toNullTerminatedFixedSizeByteArray(String s, int length) {
if (s.length() >= length) {
s = s.substring(0, length - 1);
}
while (s.length() < length) {
s += '\0';
}
return s.getBytes();
} | java | public static byte[] toNullTerminatedFixedSizeByteArray(String s, int length) {
if (s.length() >= length) {
s = s.substring(0, length - 1);
}
while (s.length() < length) {
s += '\0';
}
return s.getBytes();
} | [
"public",
"static",
"byte",
"[",
"]",
"toNullTerminatedFixedSizeByteArray",
"(",
"String",
"s",
",",
"int",
"length",
")",
"{",
"if",
"(",
"s",
".",
"length",
"(",
")",
">=",
"length",
")",
"{",
"s",
"=",
"s",
".",
"substring",
"(",
"0",
",",
"length",
"-",
"1",
")",
";",
"}",
"while",
"(",
"s",
".",
"length",
"(",
")",
"<",
"length",
")",
"{",
"s",
"+=",
"'",
"'",
";",
"}",
"return",
"s",
".",
"getBytes",
"(",
")",
";",
"}"
] | Converts a string to a null-terminated fixed size byte array.
@param s string to convert
@param length size of the byte array to return
@return byte array of specified length containing the string s null-terminated | [
"Converts",
"a",
"string",
"to",
"a",
"null",
"-",
"terminated",
"fixed",
"size",
"byte",
"array",
"."
] | ba45d4d86eb29b92f157c6e98536dee2002ddfdc | https://github.com/qspin/qtaste/blob/ba45d4d86eb29b92f157c6e98536dee2002ddfdc/kernel/src/main/java/com/qspin/qtaste/util/Strings.java#L85-L93 |
140,160 | qspin/qtaste | kernel/src/main/java/com/qspin/qtaste/util/Strings.java | Strings.fromNullTerminatedByteArray | public static String fromNullTerminatedByteArray(byte[] array) {
int stringSize = array.length;
for (int i = 0; i < array.length; i++) {
if (array[i] == 0) {
stringSize = i;
break;
}
}
return new String(array, 0, stringSize);
} | java | public static String fromNullTerminatedByteArray(byte[] array) {
int stringSize = array.length;
for (int i = 0; i < array.length; i++) {
if (array[i] == 0) {
stringSize = i;
break;
}
}
return new String(array, 0, stringSize);
} | [
"public",
"static",
"String",
"fromNullTerminatedByteArray",
"(",
"byte",
"[",
"]",
"array",
")",
"{",
"int",
"stringSize",
"=",
"array",
".",
"length",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"array",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"array",
"[",
"i",
"]",
"==",
"0",
")",
"{",
"stringSize",
"=",
"i",
";",
"break",
";",
"}",
"}",
"return",
"new",
"String",
"(",
"array",
",",
"0",
",",
"stringSize",
")",
";",
"}"
] | Converts a null-terminated byte array into a string.
@param array byte array containing a null-terminated string
@return string from array | [
"Converts",
"a",
"null",
"-",
"terminated",
"byte",
"array",
"into",
"a",
"string",
"."
] | ba45d4d86eb29b92f157c6e98536dee2002ddfdc | https://github.com/qspin/qtaste/blob/ba45d4d86eb29b92f157c6e98536dee2002ddfdc/kernel/src/main/java/com/qspin/qtaste/util/Strings.java#L101-L111 |
140,161 | qspin/qtaste | kernel/src/main/java/com/qspin/qtaste/tcom/jmx/impl/JMXAgent.java | JMXAgent.register | public synchronized void register() throws Exception {
if (mbeanName != null) {
throw new Exception("Agent already registered");
}
mbeanName = new ObjectName(getClass().getPackage().getName() + ":type=" + getClass().getSimpleName());
logger.info("Registering JMX agent " + mbeanName);
ManagementFactory.getPlatformMBeanServer().registerMBean(this, mbeanName);
logger.info("JMX agent " + mbeanName + " registered");
} | java | public synchronized void register() throws Exception {
if (mbeanName != null) {
throw new Exception("Agent already registered");
}
mbeanName = new ObjectName(getClass().getPackage().getName() + ":type=" + getClass().getSimpleName());
logger.info("Registering JMX agent " + mbeanName);
ManagementFactory.getPlatformMBeanServer().registerMBean(this, mbeanName);
logger.info("JMX agent " + mbeanName + " registered");
} | [
"public",
"synchronized",
"void",
"register",
"(",
")",
"throws",
"Exception",
"{",
"if",
"(",
"mbeanName",
"!=",
"null",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Agent already registered\"",
")",
";",
"}",
"mbeanName",
"=",
"new",
"ObjectName",
"(",
"getClass",
"(",
")",
".",
"getPackage",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\":type=\"",
"+",
"getClass",
"(",
")",
".",
"getSimpleName",
"(",
")",
")",
";",
"logger",
".",
"info",
"(",
"\"Registering JMX agent \"",
"+",
"mbeanName",
")",
";",
"ManagementFactory",
".",
"getPlatformMBeanServer",
"(",
")",
".",
"registerMBean",
"(",
"this",
",",
"mbeanName",
")",
";",
"logger",
".",
"info",
"(",
"\"JMX agent \"",
"+",
"mbeanName",
"+",
"\" registered\"",
")",
";",
"}"
] | Register the JMX agent
@throws java.lang.Exception | [
"Register",
"the",
"JMX",
"agent"
] | ba45d4d86eb29b92f157c6e98536dee2002ddfdc | https://github.com/qspin/qtaste/blob/ba45d4d86eb29b92f157c6e98536dee2002ddfdc/kernel/src/main/java/com/qspin/qtaste/tcom/jmx/impl/JMXAgent.java#L74-L82 |
140,162 | qspin/qtaste | kernel/src/main/java/com/qspin/qtaste/tcom/jmx/impl/JMXAgent.java | JMXAgent.unregister | public synchronized void unregister() throws Exception {
if (mbeanName == null) {
throw new Exception("Agent not registered");
}
logger.info("Unregistering JMX agent " + mbeanName);
ManagementFactory.getPlatformMBeanServer().unregisterMBean(mbeanName);
logger.info("JMX agent " + mbeanName + " unregistered");
} | java | public synchronized void unregister() throws Exception {
if (mbeanName == null) {
throw new Exception("Agent not registered");
}
logger.info("Unregistering JMX agent " + mbeanName);
ManagementFactory.getPlatformMBeanServer().unregisterMBean(mbeanName);
logger.info("JMX agent " + mbeanName + " unregistered");
} | [
"public",
"synchronized",
"void",
"unregister",
"(",
")",
"throws",
"Exception",
"{",
"if",
"(",
"mbeanName",
"==",
"null",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Agent not registered\"",
")",
";",
"}",
"logger",
".",
"info",
"(",
"\"Unregistering JMX agent \"",
"+",
"mbeanName",
")",
";",
"ManagementFactory",
".",
"getPlatformMBeanServer",
"(",
")",
".",
"unregisterMBean",
"(",
"mbeanName",
")",
";",
"logger",
".",
"info",
"(",
"\"JMX agent \"",
"+",
"mbeanName",
"+",
"\" unregistered\"",
")",
";",
"}"
] | Unregister the JMX agent | [
"Unregister",
"the",
"JMX",
"agent"
] | ba45d4d86eb29b92f157c6e98536dee2002ddfdc | https://github.com/qspin/qtaste/blob/ba45d4d86eb29b92f157c6e98536dee2002ddfdc/kernel/src/main/java/com/qspin/qtaste/tcom/jmx/impl/JMXAgent.java#L87-L94 |
140,163 | qspin/qtaste | kernel/src/main/java/com/qspin/qtaste/tcom/jmx/impl/JMXAgent.java | JMXAgent.sendNotification | public synchronized void sendNotification(PropertyChangeEvent pEvt) {
String oldValue = pEvt.getOldValue() == null ? "null" : pEvt.getOldValue().toString();
String newValue = pEvt.getNewValue() == null ? "null" : pEvt.getNewValue().toString();
String sourceName = pEvt.getSource().getClass().getCanonicalName();
String message = sourceName + ":" + pEvt.getPropertyName() + " changed from " + oldValue + " to " + newValue;
Notification n = new AttributeChangeNotification(sourceName, notifSequenceNumber++, System.currentTimeMillis(), message,
pEvt.getPropertyName(), "java.lang.String", oldValue, newValue);
sendNotification(n);
logger.trace("Sent notification: " + message);
} | java | public synchronized void sendNotification(PropertyChangeEvent pEvt) {
String oldValue = pEvt.getOldValue() == null ? "null" : pEvt.getOldValue().toString();
String newValue = pEvt.getNewValue() == null ? "null" : pEvt.getNewValue().toString();
String sourceName = pEvt.getSource().getClass().getCanonicalName();
String message = sourceName + ":" + pEvt.getPropertyName() + " changed from " + oldValue + " to " + newValue;
Notification n = new AttributeChangeNotification(sourceName, notifSequenceNumber++, System.currentTimeMillis(), message,
pEvt.getPropertyName(), "java.lang.String", oldValue, newValue);
sendNotification(n);
logger.trace("Sent notification: " + message);
} | [
"public",
"synchronized",
"void",
"sendNotification",
"(",
"PropertyChangeEvent",
"pEvt",
")",
"{",
"String",
"oldValue",
"=",
"pEvt",
".",
"getOldValue",
"(",
")",
"==",
"null",
"?",
"\"null\"",
":",
"pEvt",
".",
"getOldValue",
"(",
")",
".",
"toString",
"(",
")",
";",
"String",
"newValue",
"=",
"pEvt",
".",
"getNewValue",
"(",
")",
"==",
"null",
"?",
"\"null\"",
":",
"pEvt",
".",
"getNewValue",
"(",
")",
".",
"toString",
"(",
")",
";",
"String",
"sourceName",
"=",
"pEvt",
".",
"getSource",
"(",
")",
".",
"getClass",
"(",
")",
".",
"getCanonicalName",
"(",
")",
";",
"String",
"message",
"=",
"sourceName",
"+",
"\":\"",
"+",
"pEvt",
".",
"getPropertyName",
"(",
")",
"+",
"\" changed from \"",
"+",
"oldValue",
"+",
"\" to \"",
"+",
"newValue",
";",
"Notification",
"n",
"=",
"new",
"AttributeChangeNotification",
"(",
"sourceName",
",",
"notifSequenceNumber",
"++",
",",
"System",
".",
"currentTimeMillis",
"(",
")",
",",
"message",
",",
"pEvt",
".",
"getPropertyName",
"(",
")",
",",
"\"java.lang.String\"",
",",
"oldValue",
",",
"newValue",
")",
";",
"sendNotification",
"(",
"n",
")",
";",
"logger",
".",
"trace",
"(",
"\"Sent notification: \"",
"+",
"message",
")",
";",
"}"
] | Send a JMX notification of a property change event
@param pEvt a property change event | [
"Send",
"a",
"JMX",
"notification",
"of",
"a",
"property",
"change",
"event"
] | ba45d4d86eb29b92f157c6e98536dee2002ddfdc | https://github.com/qspin/qtaste/blob/ba45d4d86eb29b92f157c6e98536dee2002ddfdc/kernel/src/main/java/com/qspin/qtaste/tcom/jmx/impl/JMXAgent.java#L101-L110 |
140,164 | qspin/qtaste | kernel/src/main/java/com/qspin/qtaste/util/Exec.java | Exec.exec | public int exec(String cmd, Map<String, String> env) throws IOException, InterruptedException {
return exec(cmd, env, System.out, System.err, null);
} | java | public int exec(String cmd, Map<String, String> env) throws IOException, InterruptedException {
return exec(cmd, env, System.out, System.err, null);
} | [
"public",
"int",
"exec",
"(",
"String",
"cmd",
",",
"Map",
"<",
"String",
",",
"String",
">",
"env",
")",
"throws",
"IOException",
",",
"InterruptedException",
"{",
"return",
"exec",
"(",
"cmd",
",",
"env",
",",
"System",
".",
"out",
",",
"System",
".",
"err",
",",
"null",
")",
";",
"}"
] | Executes the a command specified in parameter.
@param cmd a specified system command
@param env the environment variables map to use or null to inherit process environment
@return the cancel value of the process. By convention, 0 indicates normal termination | [
"Executes",
"the",
"a",
"command",
"specified",
"in",
"parameter",
"."
] | ba45d4d86eb29b92f157c6e98536dee2002ddfdc | https://github.com/qspin/qtaste/blob/ba45d4d86eb29b92f157c6e98536dee2002ddfdc/kernel/src/main/java/com/qspin/qtaste/util/Exec.java#L63-L65 |
140,165 | qspin/qtaste | kernel/src/main/java/com/qspin/qtaste/util/Exec.java | Exec.exec | public int exec(String cmd, Map<String, String> env, OutputStream stdout, OutputStream stderr, ByteArrayOutputStream
output, File dir)
throws IOException, InterruptedException {
//logger.debug("Executing '" + cmd + "'");
if (output == null) {
output = new ByteArrayOutputStream();
}
try {
String[] envp;
if (env != null) {
envp = new String[env.size()];
int i = 0;
for (Map.Entry<String, String> envMapEntry : env.entrySet()) {
envp[i++] = envMapEntry.getKey() + "=" + envMapEntry.getValue();
}
} else {
envp = null;
}
process = Runtime.getRuntime().exec(cmd, envp, dir);
process.getOutputStream().close();
MyReader t1 = new MyReader(process.getInputStream(), stdout, output);
MyReader t2 = new MyReader(process.getErrorStream(), stderr, output);
t1.start();
t2.start();
int exitCode = process.waitFor();
process = null;
t1.cancel();
t2.cancel();
t1.join();
t2.join();
//if (output.size() > 0) {
// logger.debug("Executed command output:\n" + output.toString());
//}
return exitCode;
} finally {
process = null;
}
} | java | public int exec(String cmd, Map<String, String> env, OutputStream stdout, OutputStream stderr, ByteArrayOutputStream
output, File dir)
throws IOException, InterruptedException {
//logger.debug("Executing '" + cmd + "'");
if (output == null) {
output = new ByteArrayOutputStream();
}
try {
String[] envp;
if (env != null) {
envp = new String[env.size()];
int i = 0;
for (Map.Entry<String, String> envMapEntry : env.entrySet()) {
envp[i++] = envMapEntry.getKey() + "=" + envMapEntry.getValue();
}
} else {
envp = null;
}
process = Runtime.getRuntime().exec(cmd, envp, dir);
process.getOutputStream().close();
MyReader t1 = new MyReader(process.getInputStream(), stdout, output);
MyReader t2 = new MyReader(process.getErrorStream(), stderr, output);
t1.start();
t2.start();
int exitCode = process.waitFor();
process = null;
t1.cancel();
t2.cancel();
t1.join();
t2.join();
//if (output.size() > 0) {
// logger.debug("Executed command output:\n" + output.toString());
//}
return exitCode;
} finally {
process = null;
}
} | [
"public",
"int",
"exec",
"(",
"String",
"cmd",
",",
"Map",
"<",
"String",
",",
"String",
">",
"env",
",",
"OutputStream",
"stdout",
",",
"OutputStream",
"stderr",
",",
"ByteArrayOutputStream",
"output",
",",
"File",
"dir",
")",
"throws",
"IOException",
",",
"InterruptedException",
"{",
"//logger.debug(\"Executing '\" + cmd + \"'\");",
"if",
"(",
"output",
"==",
"null",
")",
"{",
"output",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"}",
"try",
"{",
"String",
"[",
"]",
"envp",
";",
"if",
"(",
"env",
"!=",
"null",
")",
"{",
"envp",
"=",
"new",
"String",
"[",
"env",
".",
"size",
"(",
")",
"]",
";",
"int",
"i",
"=",
"0",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"String",
">",
"envMapEntry",
":",
"env",
".",
"entrySet",
"(",
")",
")",
"{",
"envp",
"[",
"i",
"++",
"]",
"=",
"envMapEntry",
".",
"getKey",
"(",
")",
"+",
"\"=\"",
"+",
"envMapEntry",
".",
"getValue",
"(",
")",
";",
"}",
"}",
"else",
"{",
"envp",
"=",
"null",
";",
"}",
"process",
"=",
"Runtime",
".",
"getRuntime",
"(",
")",
".",
"exec",
"(",
"cmd",
",",
"envp",
",",
"dir",
")",
";",
"process",
".",
"getOutputStream",
"(",
")",
".",
"close",
"(",
")",
";",
"MyReader",
"t1",
"=",
"new",
"MyReader",
"(",
"process",
".",
"getInputStream",
"(",
")",
",",
"stdout",
",",
"output",
")",
";",
"MyReader",
"t2",
"=",
"new",
"MyReader",
"(",
"process",
".",
"getErrorStream",
"(",
")",
",",
"stderr",
",",
"output",
")",
";",
"t1",
".",
"start",
"(",
")",
";",
"t2",
".",
"start",
"(",
")",
";",
"int",
"exitCode",
"=",
"process",
".",
"waitFor",
"(",
")",
";",
"process",
"=",
"null",
";",
"t1",
".",
"cancel",
"(",
")",
";",
"t2",
".",
"cancel",
"(",
")",
";",
"t1",
".",
"join",
"(",
")",
";",
"t2",
".",
"join",
"(",
")",
";",
"//if (output.size() > 0) {",
"// logger.debug(\"Executed command output:\\n\" + output.toString());",
"//}",
"return",
"exitCode",
";",
"}",
"finally",
"{",
"process",
"=",
"null",
";",
"}",
"}"
] | Executes the a command specified in the specified directory.
@param cmd a specified system command
@param env the environment variables map to use or null to inherit process environment
@param stdout an OutputStream for stdout
@param stderr an OutputStream for stderr
@param output the ByteArrayOutputStream will get a copy of the output and error streams of the subprocess
@param dir the working directory of the subprocess, or null if the subprocess should inherit the working directory of the
current process
@return the cancel value of the process. By convention, 0 indicates normal termination | [
"Executes",
"the",
"a",
"command",
"specified",
"in",
"the",
"specified",
"directory",
"."
] | ba45d4d86eb29b92f157c6e98536dee2002ddfdc | https://github.com/qspin/qtaste/blob/ba45d4d86eb29b92f157c6e98536dee2002ddfdc/kernel/src/main/java/com/qspin/qtaste/util/Exec.java#L137-L175 |
140,166 | qspin/qtaste | kernel/src/main/java/com/qspin/qtaste/util/GeneratePythonlibDoc.java | GeneratePythonlibDoc.generate | public static synchronized void generate() {
LOGGER.debug("Generating documentation of test documentation included in pythonlib directories.");
try {
IS_RUNNING = true;
List<File> pythonLibDirectories = findPythonLibDirectories(ROOT_SCRIPT_DIRECTORY);
List<File> pythonScriptFiles = findPythonScripts(pythonLibDirectories);
for (File script : pythonScriptFiles) {
if (hasToGenerateDocumentation(script)) {
GenerateTestStepsModulesDoc.generate(script.getAbsolutePath());
}
}
ALREADY_RUN = true;
} catch (Exception ex) {
ex.printStackTrace();
} finally {
IS_RUNNING = false;
}
} | java | public static synchronized void generate() {
LOGGER.debug("Generating documentation of test documentation included in pythonlib directories.");
try {
IS_RUNNING = true;
List<File> pythonLibDirectories = findPythonLibDirectories(ROOT_SCRIPT_DIRECTORY);
List<File> pythonScriptFiles = findPythonScripts(pythonLibDirectories);
for (File script : pythonScriptFiles) {
if (hasToGenerateDocumentation(script)) {
GenerateTestStepsModulesDoc.generate(script.getAbsolutePath());
}
}
ALREADY_RUN = true;
} catch (Exception ex) {
ex.printStackTrace();
} finally {
IS_RUNNING = false;
}
} | [
"public",
"static",
"synchronized",
"void",
"generate",
"(",
")",
"{",
"LOGGER",
".",
"debug",
"(",
"\"Generating documentation of test documentation included in pythonlib directories.\"",
")",
";",
"try",
"{",
"IS_RUNNING",
"=",
"true",
";",
"List",
"<",
"File",
">",
"pythonLibDirectories",
"=",
"findPythonLibDirectories",
"(",
"ROOT_SCRIPT_DIRECTORY",
")",
";",
"List",
"<",
"File",
">",
"pythonScriptFiles",
"=",
"findPythonScripts",
"(",
"pythonLibDirectories",
")",
";",
"for",
"(",
"File",
"script",
":",
"pythonScriptFiles",
")",
"{",
"if",
"(",
"hasToGenerateDocumentation",
"(",
"script",
")",
")",
"{",
"GenerateTestStepsModulesDoc",
".",
"generate",
"(",
"script",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"}",
"}",
"ALREADY_RUN",
"=",
"true",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"ex",
".",
"printStackTrace",
"(",
")",
";",
"}",
"finally",
"{",
"IS_RUNNING",
"=",
"false",
";",
"}",
"}"
] | Generates the documentation of scripts located in a pythonlib directory. | [
"Generates",
"the",
"documentation",
"of",
"scripts",
"located",
"in",
"a",
"pythonlib",
"directory",
"."
] | ba45d4d86eb29b92f157c6e98536dee2002ddfdc | https://github.com/qspin/qtaste/blob/ba45d4d86eb29b92f157c6e98536dee2002ddfdc/kernel/src/main/java/com/qspin/qtaste/util/GeneratePythonlibDoc.java#L84-L102 |
140,167 | qspin/qtaste | kernel/src/main/java/com/qspin/qtaste/util/GeneratePythonlibDoc.java | GeneratePythonlibDoc.findPythonScripts | private static List<File> findPythonScripts(List<File> pythonLibDirectories) {
List<File> scripts = new ArrayList<>();
for (File dir : pythonLibDirectories) {
if (dir.exists()) {
scripts.addAll(Arrays.asList(dir.listFiles(PYTHON_SCRIPT_FILE_FILTER)));
}
}
return scripts;
} | java | private static List<File> findPythonScripts(List<File> pythonLibDirectories) {
List<File> scripts = new ArrayList<>();
for (File dir : pythonLibDirectories) {
if (dir.exists()) {
scripts.addAll(Arrays.asList(dir.listFiles(PYTHON_SCRIPT_FILE_FILTER)));
}
}
return scripts;
} | [
"private",
"static",
"List",
"<",
"File",
">",
"findPythonScripts",
"(",
"List",
"<",
"File",
">",
"pythonLibDirectories",
")",
"{",
"List",
"<",
"File",
">",
"scripts",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"File",
"dir",
":",
"pythonLibDirectories",
")",
"{",
"if",
"(",
"dir",
".",
"exists",
"(",
")",
")",
"{",
"scripts",
".",
"addAll",
"(",
"Arrays",
".",
"asList",
"(",
"dir",
".",
"listFiles",
"(",
"PYTHON_SCRIPT_FILE_FILTER",
")",
")",
")",
";",
"}",
"}",
"return",
"scripts",
";",
"}"
] | Searches for all python script files contains in the directories.
@param pythonLibDirectories A list of directories to scan.
@return A list of all found files. | [
"Searches",
"for",
"all",
"python",
"script",
"files",
"contains",
"in",
"the",
"directories",
"."
] | ba45d4d86eb29b92f157c6e98536dee2002ddfdc | https://github.com/qspin/qtaste/blob/ba45d4d86eb29b92f157c6e98536dee2002ddfdc/kernel/src/main/java/com/qspin/qtaste/util/GeneratePythonlibDoc.java#L139-L147 |
140,168 | qspin/qtaste | kernel/src/main/java/com/qspin/qtaste/util/PropertiesHistory.java | PropertiesHistory.checkPropertyValueOrTransition | public void checkPropertyValueOrTransition(String propertyValueOrTransition, double maxTime)
throws QTasteDataException, QTasteTestFailException {
long beginTime_ms = System.currentTimeMillis();
long maxTime_ms = Math.round(maxTime * 1000);
propertyValueOrTransition = propertyValueOrTransition.toLowerCase();
String[] splitted = propertyValueOrTransition.split(" *: *", 2);
if (splitted.length != 2) {
throw new QTasteDataException("Invalid syntax");
}
String property = splitted[0];
if (property.length() == 0) {
throw new QTasteDataException("Invalid syntax");
}
String transition = splitted[1];
boolean mustBeAtBegin = transition.matches("^\\[.*");
if (mustBeAtBegin) {
transition = transition.replaceFirst("^\\[ *", "");
}
boolean mustBeAtEnd = transition.matches(".*\\]$");
if (mustBeAtEnd) {
transition = transition.replaceFirst(" *\\]$", "");
}
String[] values = transition.split(" *-> *");
if ((values.length != 1) && (values.length != 2)) {
throw new QTasteDataException("Invalid syntax");
}
String expectedValueOrTransition = propertyValueOrTransition.replaceFirst(".*?: *", "");
long remainingTime_ms = maxTime_ms - (System.currentTimeMillis() - beginTime_ms);
checkPropertyValueOrTransition(property, values, mustBeAtBegin, mustBeAtEnd, remainingTime_ms, expectedValueOrTransition);
} | java | public void checkPropertyValueOrTransition(String propertyValueOrTransition, double maxTime)
throws QTasteDataException, QTasteTestFailException {
long beginTime_ms = System.currentTimeMillis();
long maxTime_ms = Math.round(maxTime * 1000);
propertyValueOrTransition = propertyValueOrTransition.toLowerCase();
String[] splitted = propertyValueOrTransition.split(" *: *", 2);
if (splitted.length != 2) {
throw new QTasteDataException("Invalid syntax");
}
String property = splitted[0];
if (property.length() == 0) {
throw new QTasteDataException("Invalid syntax");
}
String transition = splitted[1];
boolean mustBeAtBegin = transition.matches("^\\[.*");
if (mustBeAtBegin) {
transition = transition.replaceFirst("^\\[ *", "");
}
boolean mustBeAtEnd = transition.matches(".*\\]$");
if (mustBeAtEnd) {
transition = transition.replaceFirst(" *\\]$", "");
}
String[] values = transition.split(" *-> *");
if ((values.length != 1) && (values.length != 2)) {
throw new QTasteDataException("Invalid syntax");
}
String expectedValueOrTransition = propertyValueOrTransition.replaceFirst(".*?: *", "");
long remainingTime_ms = maxTime_ms - (System.currentTimeMillis() - beginTime_ms);
checkPropertyValueOrTransition(property, values, mustBeAtBegin, mustBeAtEnd, remainingTime_ms, expectedValueOrTransition);
} | [
"public",
"void",
"checkPropertyValueOrTransition",
"(",
"String",
"propertyValueOrTransition",
",",
"double",
"maxTime",
")",
"throws",
"QTasteDataException",
",",
"QTasteTestFailException",
"{",
"long",
"beginTime_ms",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"long",
"maxTime_ms",
"=",
"Math",
".",
"round",
"(",
"maxTime",
"*",
"1000",
")",
";",
"propertyValueOrTransition",
"=",
"propertyValueOrTransition",
".",
"toLowerCase",
"(",
")",
";",
"String",
"[",
"]",
"splitted",
"=",
"propertyValueOrTransition",
".",
"split",
"(",
"\" *: *\"",
",",
"2",
")",
";",
"if",
"(",
"splitted",
".",
"length",
"!=",
"2",
")",
"{",
"throw",
"new",
"QTasteDataException",
"(",
"\"Invalid syntax\"",
")",
";",
"}",
"String",
"property",
"=",
"splitted",
"[",
"0",
"]",
";",
"if",
"(",
"property",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"throw",
"new",
"QTasteDataException",
"(",
"\"Invalid syntax\"",
")",
";",
"}",
"String",
"transition",
"=",
"splitted",
"[",
"1",
"]",
";",
"boolean",
"mustBeAtBegin",
"=",
"transition",
".",
"matches",
"(",
"\"^\\\\[.*\"",
")",
";",
"if",
"(",
"mustBeAtBegin",
")",
"{",
"transition",
"=",
"transition",
".",
"replaceFirst",
"(",
"\"^\\\\[ *\"",
",",
"\"\"",
")",
";",
"}",
"boolean",
"mustBeAtEnd",
"=",
"transition",
".",
"matches",
"(",
"\".*\\\\]$\"",
")",
";",
"if",
"(",
"mustBeAtEnd",
")",
"{",
"transition",
"=",
"transition",
".",
"replaceFirst",
"(",
"\" *\\\\]$\"",
",",
"\"\"",
")",
";",
"}",
"String",
"[",
"]",
"values",
"=",
"transition",
".",
"split",
"(",
"\" *-> *\"",
")",
";",
"if",
"(",
"(",
"values",
".",
"length",
"!=",
"1",
")",
"&&",
"(",
"values",
".",
"length",
"!=",
"2",
")",
")",
"{",
"throw",
"new",
"QTasteDataException",
"(",
"\"Invalid syntax\"",
")",
";",
"}",
"String",
"expectedValueOrTransition",
"=",
"propertyValueOrTransition",
".",
"replaceFirst",
"(",
"\".*?: *\"",
",",
"\"\"",
")",
";",
"long",
"remainingTime_ms",
"=",
"maxTime_ms",
"-",
"(",
"System",
".",
"currentTimeMillis",
"(",
")",
"-",
"beginTime_ms",
")",
";",
"checkPropertyValueOrTransition",
"(",
"property",
",",
"values",
",",
"mustBeAtBegin",
",",
"mustBeAtEnd",
",",
"remainingTime_ms",
",",
"expectedValueOrTransition",
")",
";",
"}"
] | Checks that a property reaches a given value or do a given values
transition within given time.
If found, remove old values from history.
@param propertyValueOrTransition the property value or transition to check (case insensitive)
<dl>
<dd>Format: "<code><i>property</i>:</code>[<code>[</code>]<code><i>expected_value</i></code>[<code>]</code>]" or
"<code><i>property</i>:</code>[<code>[</code>]<code><i>initial_value</i>-><i>final_value</i></code>[<code>]</code>]"
<dd>beginning <code>[</code> means that the expected or initial value must be the first one in the current values history
<dd>ending <code>]</code> means that the expected or final value must be the last one in the current values history
</dl>
@param maxTime the maximum time to wait for the property value or transition, in seconds
@throws QTasteDataException in case of invalid syntax in propertyValueOrTransition
@throws QTasteTestFailException if the property doesn't reach specified value or do specified values transition or
if a possible notification loss occurred
within specified time | [
"Checks",
"that",
"a",
"property",
"reaches",
"a",
"given",
"value",
"or",
"do",
"a",
"given",
"values",
"transition",
"within",
"given",
"time",
".",
"If",
"found",
"remove",
"old",
"values",
"from",
"history",
"."
] | ba45d4d86eb29b92f157c6e98536dee2002ddfdc | https://github.com/qspin/qtaste/blob/ba45d4d86eb29b92f157c6e98536dee2002ddfdc/kernel/src/main/java/com/qspin/qtaste/util/PropertiesHistory.java#L228-L258 |
140,169 | qspin/qtaste | kernel/src/main/java/com/qspin/qtaste/util/HashtableLinkedList.java | HashtableLinkedList.readObject | private synchronized void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
// rebuild hash hashtable
hash = new Hashtable<>();
for (NameValue<N, V> nameValue : order) {
putInHash(nameValue.name, nameValue.value);
}
} | java | private synchronized void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
// rebuild hash hashtable
hash = new Hashtable<>();
for (NameValue<N, V> nameValue : order) {
putInHash(nameValue.name, nameValue.value);
}
} | [
"private",
"synchronized",
"void",
"readObject",
"(",
"java",
".",
"io",
".",
"ObjectInputStream",
"in",
")",
"throws",
"IOException",
",",
"ClassNotFoundException",
"{",
"in",
".",
"defaultReadObject",
"(",
")",
";",
"// rebuild hash hashtable",
"hash",
"=",
"new",
"Hashtable",
"<>",
"(",
")",
";",
"for",
"(",
"NameValue",
"<",
"N",
",",
"V",
">",
"nameValue",
":",
"order",
")",
"{",
"putInHash",
"(",
"nameValue",
".",
"name",
",",
"nameValue",
".",
"value",
")",
";",
"}",
"}"
] | and rebuild hash hashtable | [
"and",
"rebuild",
"hash",
"hashtable"
] | ba45d4d86eb29b92f157c6e98536dee2002ddfdc | https://github.com/qspin/qtaste/blob/ba45d4d86eb29b92f157c6e98536dee2002ddfdc/kernel/src/main/java/com/qspin/qtaste/util/HashtableLinkedList.java#L158-L166 |
140,170 | qspin/qtaste | kernel/src/main/java/com/qspin/qtaste/tcom/jmx/impl/JMXClient.java | JMXClient.removeNotificationListener | public boolean removeNotificationListener(String mbeanName, NotificationListener listener) throws Exception {
if (isConnected()) {
ObjectName objectName = new ObjectName(mbeanName);
mbsc.removeNotificationListener(objectName, listener, null, null);
jmxc.removeConnectionNotificationListener(listener);
return true;
} else {
return false;
}
} | java | public boolean removeNotificationListener(String mbeanName, NotificationListener listener) throws Exception {
if (isConnected()) {
ObjectName objectName = new ObjectName(mbeanName);
mbsc.removeNotificationListener(objectName, listener, null, null);
jmxc.removeConnectionNotificationListener(listener);
return true;
} else {
return false;
}
} | [
"public",
"boolean",
"removeNotificationListener",
"(",
"String",
"mbeanName",
",",
"NotificationListener",
"listener",
")",
"throws",
"Exception",
"{",
"if",
"(",
"isConnected",
"(",
")",
")",
"{",
"ObjectName",
"objectName",
"=",
"new",
"ObjectName",
"(",
"mbeanName",
")",
";",
"mbsc",
".",
"removeNotificationListener",
"(",
"objectName",
",",
"listener",
",",
"null",
",",
"null",
")",
";",
"jmxc",
".",
"removeConnectionNotificationListener",
"(",
"listener",
")",
";",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] | Removes listener as notification and connection notification listener.
@return true if successful, false otherwise
@throws java.lang.Exception | [
"Removes",
"listener",
"as",
"notification",
"and",
"connection",
"notification",
"listener",
"."
] | ba45d4d86eb29b92f157c6e98536dee2002ddfdc | https://github.com/qspin/qtaste/blob/ba45d4d86eb29b92f157c6e98536dee2002ddfdc/kernel/src/main/java/com/qspin/qtaste/tcom/jmx/impl/JMXClient.java#L113-L122 |
140,171 | qspin/qtaste | kernel/src/main/java/com/qspin/qtaste/ui/jedit/PythonIndentAction.java | PythonIndentAction.getIndent | public static String getIndent(String line) {
if (line == null || line.length() == 0) {
return "";
}
int i = 0;
while (i < line.length() && line.charAt(i) == '\t') {
i++;
}
return line.substring(0, i);
} | java | public static String getIndent(String line) {
if (line == null || line.length() == 0) {
return "";
}
int i = 0;
while (i < line.length() && line.charAt(i) == '\t') {
i++;
}
return line.substring(0, i);
} | [
"public",
"static",
"String",
"getIndent",
"(",
"String",
"line",
")",
"{",
"if",
"(",
"line",
"==",
"null",
"||",
"line",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"return",
"\"\"",
";",
"}",
"int",
"i",
"=",
"0",
";",
"while",
"(",
"i",
"<",
"line",
".",
"length",
"(",
")",
"&&",
"line",
".",
"charAt",
"(",
"i",
")",
"==",
"'",
"'",
")",
"{",
"i",
"++",
";",
"}",
"return",
"line",
".",
"substring",
"(",
"0",
",",
"i",
")",
";",
"}"
] | Get the indentation of a line of text.
This is the subString from
beginning of line to the first non-space char
@param line the line of text
@return indentation of line. | [
"Get",
"the",
"indentation",
"of",
"a",
"line",
"of",
"text",
".",
"This",
"is",
"the",
"subString",
"from",
"beginning",
"of",
"line",
"to",
"the",
"first",
"non",
"-",
"space",
"char"
] | ba45d4d86eb29b92f157c6e98536dee2002ddfdc | https://github.com/qspin/qtaste/blob/ba45d4d86eb29b92f157c6e98536dee2002ddfdc/kernel/src/main/java/com/qspin/qtaste/ui/jedit/PythonIndentAction.java#L71-L80 |
140,172 | qspin/qtaste | kernel/src/main/java/com/qspin/qtaste/toolbox/simulators/SimulatorImpl.java | SimulatorImpl.scheduleTask | public void scheduleTask(PyObject task, double delay) {
mTimer.schedule(new PythonCallTimerTask(task), Math.round(delay * 1000));
} | java | public void scheduleTask(PyObject task, double delay) {
mTimer.schedule(new PythonCallTimerTask(task), Math.round(delay * 1000));
} | [
"public",
"void",
"scheduleTask",
"(",
"PyObject",
"task",
",",
"double",
"delay",
")",
"{",
"mTimer",
".",
"schedule",
"(",
"new",
"PythonCallTimerTask",
"(",
"task",
")",
",",
"Math",
".",
"round",
"(",
"delay",
"*",
"1000",
")",
")",
";",
"}"
] | Schedules the specified task for execution after the specified delay.
@param task Python object callable without arguments, to schedule
@param delay delay in seconds before task is to be executed | [
"Schedules",
"the",
"specified",
"task",
"for",
"execution",
"after",
"the",
"specified",
"delay",
"."
] | ba45d4d86eb29b92f157c6e98536dee2002ddfdc | https://github.com/qspin/qtaste/blob/ba45d4d86eb29b92f157c6e98536dee2002ddfdc/kernel/src/main/java/com/qspin/qtaste/toolbox/simulators/SimulatorImpl.java#L116-L118 |
140,173 | qspin/qtaste | kernel/src/main/java/com/qspin/qtaste/toolbox/simulators/SimulatorImpl.java | SimulatorImpl.logAndThrowException | private static void logAndThrowException(String message, PyException e) throws Exception {
LOGGER.error(message, e);
throw new Exception(message + ":\n" + PythonHelper.getMessage(e));
} | java | private static void logAndThrowException(String message, PyException e) throws Exception {
LOGGER.error(message, e);
throw new Exception(message + ":\n" + PythonHelper.getMessage(e));
} | [
"private",
"static",
"void",
"logAndThrowException",
"(",
"String",
"message",
",",
"PyException",
"e",
")",
"throws",
"Exception",
"{",
"LOGGER",
".",
"error",
"(",
"message",
",",
"e",
")",
";",
"throw",
"new",
"Exception",
"(",
"message",
"+",
"\":\\n\"",
"+",
"PythonHelper",
".",
"getMessage",
"(",
"e",
")",
")",
";",
"}"
] | Logs message and exception and throws Exception.
@param message message
@param e PyException
@throws java.lang.Exception Exception built with 'message + ":\n" + message_of_e' | [
"Logs",
"message",
"and",
"exception",
"and",
"throws",
"Exception",
"."
] | ba45d4d86eb29b92f157c6e98536dee2002ddfdc | https://github.com/qspin/qtaste/blob/ba45d4d86eb29b92f157c6e98536dee2002ddfdc/kernel/src/main/java/com/qspin/qtaste/toolbox/simulators/SimulatorImpl.java#L281-L284 |
140,174 | qspin/qtaste | kernel/src/main/java/com/qspin/qtaste/reporter/ReportFormatter.java | ReportFormatter.getSubstitutedTemplateContent | protected static String getSubstitutedTemplateContent(String templateContent, NamesValuesList<String, String> namesValues) {
String templateContentSubst = templateContent;
// substitute the name/values
for (NameValue<String, String> nameValue : namesValues) {
templateContentSubst = templateContentSubst.replace(nameValue.name, nameValue.value);
}
return templateContentSubst;
} | java | protected static String getSubstitutedTemplateContent(String templateContent, NamesValuesList<String, String> namesValues) {
String templateContentSubst = templateContent;
// substitute the name/values
for (NameValue<String, String> nameValue : namesValues) {
templateContentSubst = templateContentSubst.replace(nameValue.name, nameValue.value);
}
return templateContentSubst;
} | [
"protected",
"static",
"String",
"getSubstitutedTemplateContent",
"(",
"String",
"templateContent",
",",
"NamesValuesList",
"<",
"String",
",",
"String",
">",
"namesValues",
")",
"{",
"String",
"templateContentSubst",
"=",
"templateContent",
";",
"// substitute the name/values",
"for",
"(",
"NameValue",
"<",
"String",
",",
"String",
">",
"nameValue",
":",
"namesValues",
")",
"{",
"templateContentSubst",
"=",
"templateContentSubst",
".",
"replace",
"(",
"nameValue",
".",
"name",
",",
"nameValue",
".",
"value",
")",
";",
"}",
"return",
"templateContentSubst",
";",
"}"
] | Substitutes names by values in template and return result.
@param templateContent content of the template to substitute
@param namesValues list of names/values to substitute
@return result of substitution | [
"Substitutes",
"names",
"by",
"values",
"in",
"template",
"and",
"return",
"result",
"."
] | ba45d4d86eb29b92f157c6e98536dee2002ddfdc | https://github.com/qspin/qtaste/blob/ba45d4d86eb29b92f157c6e98536dee2002ddfdc/kernel/src/main/java/com/qspin/qtaste/reporter/ReportFormatter.java#L78-L86 |
140,175 | qspin/qtaste | kernel/src/main/java/com/qspin/qtaste/ui/tools/HTMLDocumentLoader.java | HTMLDocumentLoader.getParser | public synchronized HTMLEditorKit.Parser getParser() {
if (parser == null) {
try {
Class<?> c = Class.forName("javax.swing.text.html.parser.ParserDelegator");
parser = (HTMLEditorKit.Parser) c.newInstance();
} catch (Exception e) {
}
}
return parser;
} | java | public synchronized HTMLEditorKit.Parser getParser() {
if (parser == null) {
try {
Class<?> c = Class.forName("javax.swing.text.html.parser.ParserDelegator");
parser = (HTMLEditorKit.Parser) c.newInstance();
} catch (Exception e) {
}
}
return parser;
} | [
"public",
"synchronized",
"HTMLEditorKit",
".",
"Parser",
"getParser",
"(",
")",
"{",
"if",
"(",
"parser",
"==",
"null",
")",
"{",
"try",
"{",
"Class",
"<",
"?",
">",
"c",
"=",
"Class",
".",
"forName",
"(",
"\"javax.swing.text.html.parser.ParserDelegator\"",
")",
";",
"parser",
"=",
"(",
"HTMLEditorKit",
".",
"Parser",
")",
"c",
".",
"newInstance",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"}",
"}",
"return",
"parser",
";",
"}"
] | Methods that allow customization of the parser and the callback | [
"Methods",
"that",
"allow",
"customization",
"of",
"the",
"parser",
"and",
"the",
"callback"
] | ba45d4d86eb29b92f157c6e98536dee2002ddfdc | https://github.com/qspin/qtaste/blob/ba45d4d86eb29b92f157c6e98536dee2002ddfdc/kernel/src/main/java/com/qspin/qtaste/ui/tools/HTMLDocumentLoader.java#L100-L109 |
140,176 | tango-controls/JTango | server/src/main/java/org/tango/orb/IORDump.java | IORDump.iorAnalysis | private void iorAnalysis() throws DevFailed {
if (!iorString.startsWith("IOR:")) {
throw DevFailedUtils.newDevFailed("CORBA_ERROR", iorString + " not an IOR");
}
final ORB orb = ORBManager.getOrb();
final ParsedIOR pior = new ParsedIOR((org.jacorb.orb.ORB) orb, iorString);
final org.omg.IOP.IOR ior = pior.getIOR();
typeId = ior.type_id;
final List<Profile> profiles = pior.getProfiles();
for (final Profile profile : profiles) {
if (profile instanceof IIOPProfile) {
final IIOPProfile iiopProfile = ((IIOPProfile) profile).to_GIOP_1_0();
iiopVersion = (int) iiopProfile.version().major + "." + (int) iiopProfile.version().minor;
final String name = ((IIOPAddress) iiopProfile.getAddress()).getOriginalHost();
java.net.InetAddress iadd = null;
try {
iadd = java.net.InetAddress.getByName(name);
} catch (final UnknownHostException e) {
throw DevFailedUtils.newDevFailed(e);
}
hostName = iadd.getHostName();
port = ((IIOPAddress) iiopProfile.getAddress()).getPort();
if (port < 0) {
port += 65536;
}
} else {
throw DevFailedUtils.newDevFailed("CORBA_ERROR", iorString + " not an IOR");
}
}
// code for old jacorb 2.3
// final List<IIOPProfile> profiles = pior.getProfiles();
// for (IIOPProfile profile : profiles) {
// iiopVersion = (int) profile.version().major + "." + (int)
// p.version().minor;
// final String name = ((IIOPAddress)
// profile.getAddress()).getOriginalHost();
// java.net.InetAddress iadd = null;
// try {
// iadd = java.net.InetAddress.getByName(name);
// } catch (final UnknownHostException e) {
// throw DevFailedUtils.newDevFailed(e);
// }
// hostName = iadd.getHostName();
//
// port = ((IIOPAddress) profile.getAddress()).getPort();
// if (port < 0) {
// port += 65536;
// }
// }
} | java | private void iorAnalysis() throws DevFailed {
if (!iorString.startsWith("IOR:")) {
throw DevFailedUtils.newDevFailed("CORBA_ERROR", iorString + " not an IOR");
}
final ORB orb = ORBManager.getOrb();
final ParsedIOR pior = new ParsedIOR((org.jacorb.orb.ORB) orb, iorString);
final org.omg.IOP.IOR ior = pior.getIOR();
typeId = ior.type_id;
final List<Profile> profiles = pior.getProfiles();
for (final Profile profile : profiles) {
if (profile instanceof IIOPProfile) {
final IIOPProfile iiopProfile = ((IIOPProfile) profile).to_GIOP_1_0();
iiopVersion = (int) iiopProfile.version().major + "." + (int) iiopProfile.version().minor;
final String name = ((IIOPAddress) iiopProfile.getAddress()).getOriginalHost();
java.net.InetAddress iadd = null;
try {
iadd = java.net.InetAddress.getByName(name);
} catch (final UnknownHostException e) {
throw DevFailedUtils.newDevFailed(e);
}
hostName = iadd.getHostName();
port = ((IIOPAddress) iiopProfile.getAddress()).getPort();
if (port < 0) {
port += 65536;
}
} else {
throw DevFailedUtils.newDevFailed("CORBA_ERROR", iorString + " not an IOR");
}
}
// code for old jacorb 2.3
// final List<IIOPProfile> profiles = pior.getProfiles();
// for (IIOPProfile profile : profiles) {
// iiopVersion = (int) profile.version().major + "." + (int)
// p.version().minor;
// final String name = ((IIOPAddress)
// profile.getAddress()).getOriginalHost();
// java.net.InetAddress iadd = null;
// try {
// iadd = java.net.InetAddress.getByName(name);
// } catch (final UnknownHostException e) {
// throw DevFailedUtils.newDevFailed(e);
// }
// hostName = iadd.getHostName();
//
// port = ((IIOPAddress) profile.getAddress()).getPort();
// if (port < 0) {
// port += 65536;
// }
// }
} | [
"private",
"void",
"iorAnalysis",
"(",
")",
"throws",
"DevFailed",
"{",
"if",
"(",
"!",
"iorString",
".",
"startsWith",
"(",
"\"IOR:\"",
")",
")",
"{",
"throw",
"DevFailedUtils",
".",
"newDevFailed",
"(",
"\"CORBA_ERROR\"",
",",
"iorString",
"+",
"\" not an IOR\"",
")",
";",
"}",
"final",
"ORB",
"orb",
"=",
"ORBManager",
".",
"getOrb",
"(",
")",
";",
"final",
"ParsedIOR",
"pior",
"=",
"new",
"ParsedIOR",
"(",
"(",
"org",
".",
"jacorb",
".",
"orb",
".",
"ORB",
")",
"orb",
",",
"iorString",
")",
";",
"final",
"org",
".",
"omg",
".",
"IOP",
".",
"IOR",
"ior",
"=",
"pior",
".",
"getIOR",
"(",
")",
";",
"typeId",
"=",
"ior",
".",
"type_id",
";",
"final",
"List",
"<",
"Profile",
">",
"profiles",
"=",
"pior",
".",
"getProfiles",
"(",
")",
";",
"for",
"(",
"final",
"Profile",
"profile",
":",
"profiles",
")",
"{",
"if",
"(",
"profile",
"instanceof",
"IIOPProfile",
")",
"{",
"final",
"IIOPProfile",
"iiopProfile",
"=",
"(",
"(",
"IIOPProfile",
")",
"profile",
")",
".",
"to_GIOP_1_0",
"(",
")",
";",
"iiopVersion",
"=",
"(",
"int",
")",
"iiopProfile",
".",
"version",
"(",
")",
".",
"major",
"+",
"\".\"",
"+",
"(",
"int",
")",
"iiopProfile",
".",
"version",
"(",
")",
".",
"minor",
";",
"final",
"String",
"name",
"=",
"(",
"(",
"IIOPAddress",
")",
"iiopProfile",
".",
"getAddress",
"(",
")",
")",
".",
"getOriginalHost",
"(",
")",
";",
"java",
".",
"net",
".",
"InetAddress",
"iadd",
"=",
"null",
";",
"try",
"{",
"iadd",
"=",
"java",
".",
"net",
".",
"InetAddress",
".",
"getByName",
"(",
"name",
")",
";",
"}",
"catch",
"(",
"final",
"UnknownHostException",
"e",
")",
"{",
"throw",
"DevFailedUtils",
".",
"newDevFailed",
"(",
"e",
")",
";",
"}",
"hostName",
"=",
"iadd",
".",
"getHostName",
"(",
")",
";",
"port",
"=",
"(",
"(",
"IIOPAddress",
")",
"iiopProfile",
".",
"getAddress",
"(",
")",
")",
".",
"getPort",
"(",
")",
";",
"if",
"(",
"port",
"<",
"0",
")",
"{",
"port",
"+=",
"65536",
";",
"}",
"}",
"else",
"{",
"throw",
"DevFailedUtils",
".",
"newDevFailed",
"(",
"\"CORBA_ERROR\"",
",",
"iorString",
"+",
"\" not an IOR\"",
")",
";",
"}",
"}",
"// code for old jacorb 2.3",
"// final List<IIOPProfile> profiles = pior.getProfiles();",
"// for (IIOPProfile profile : profiles) {",
"// iiopVersion = (int) profile.version().major + \".\" + (int)",
"// p.version().minor;",
"// final String name = ((IIOPAddress)",
"// profile.getAddress()).getOriginalHost();",
"// java.net.InetAddress iadd = null;",
"// try {",
"// iadd = java.net.InetAddress.getByName(name);",
"// } catch (final UnknownHostException e) {",
"// throw DevFailedUtils.newDevFailed(e);",
"// }",
"// hostName = iadd.getHostName();",
"//",
"// port = ((IIOPAddress) profile.getAddress()).getPort();",
"// if (port < 0) {",
"// port += 65536;",
"// }",
"// }",
"}"
] | Make the IOR analyse | [
"Make",
"the",
"IOR",
"analyse"
] | 1ccc9dcb83e6de2359a9f1906d170571cacf1345 | https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/server/src/main/java/org/tango/orb/IORDump.java#L70-L122 |
140,177 | tango-controls/JTango | dao/src/main/java/fr/esrf/TangoDs/TemplCommand.java | TemplCommand.analyse_methods | public void analyse_methods() throws DevFailed
{
//
// Analyse the execution method given by the user
//
this.exe_method = analyse_method_exe(device_class_name,exe_method_name);
//
// Analyse the state method if one is given by the user
//
if (state_method_name != null)
this.state_method = analyse_method_state(device_class_name,state_method_name);
} | java | public void analyse_methods() throws DevFailed
{
//
// Analyse the execution method given by the user
//
this.exe_method = analyse_method_exe(device_class_name,exe_method_name);
//
// Analyse the state method if one is given by the user
//
if (state_method_name != null)
this.state_method = analyse_method_state(device_class_name,state_method_name);
} | [
"public",
"void",
"analyse_methods",
"(",
")",
"throws",
"DevFailed",
"{",
"//",
"// Analyse the execution method given by the user",
"//",
"this",
".",
"exe_method",
"=",
"analyse_method_exe",
"(",
"device_class_name",
",",
"exe_method_name",
")",
";",
"//",
"// Analyse the state method if one is given by the user",
"//",
"if",
"(",
"state_method_name",
"!=",
"null",
")",
"this",
".",
"state_method",
"=",
"analyse_method_state",
"(",
"device_class_name",
",",
"state_method_name",
")",
";",
"}"
] | Analyse the method given at construction time.
This method check if the method(s) given at construction time fulfill the
required specification. It always analyse the execution method and eventually
the command allowed method.
@exception DevFailed If one of the method does not fulfill the requirements.
Click <a href="../../tango_basic/idl_html/Tango.html#DevFailed">here</a> to read
<b>DevFailed</b> exception specification | [
"Analyse",
"the",
"method",
"given",
"at",
"construction",
"time",
"."
] | 1ccc9dcb83e6de2359a9f1906d170571cacf1345 | https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/dao/src/main/java/fr/esrf/TangoDs/TemplCommand.java#L366-L382 |
140,178 | tango-controls/JTango | dao/src/main/java/fr/esrf/TangoDs/TemplCommand.java | TemplCommand.find_method | protected Method find_method(Method[] meth_list,String meth_name) throws DevFailed
{
int i;
Method meth_found = null;
for (i = 0;i < meth_list.length;i++)
{
if (meth_name.equals(meth_list[i].getName()))
{
for (int j = i + 1;j < meth_list.length;j++)
{
if (meth_name.equals(meth_list[j].getName()))
{
StringBuffer mess = new StringBuffer("Method overloading is not supported for command (Method name = ");
mess.append(meth_name);
mess.append(")");
Except.throw_exception("API_OverloadingNotSupported",
mess.toString(),
"TemplCommand.find_method()");
}
}
meth_found = meth_list[i];
break;
}
}
if (i == meth_list.length)
{
StringBuffer mess = new StringBuffer("Command ");
mess.append(name);
mess.append(": Can't find method ");
mess.append(meth_name);
Except.throw_exception("API_MethodNotFound",
mess.toString(),
"TemplCommand.find_method()");
}
return meth_found;
} | java | protected Method find_method(Method[] meth_list,String meth_name) throws DevFailed
{
int i;
Method meth_found = null;
for (i = 0;i < meth_list.length;i++)
{
if (meth_name.equals(meth_list[i].getName()))
{
for (int j = i + 1;j < meth_list.length;j++)
{
if (meth_name.equals(meth_list[j].getName()))
{
StringBuffer mess = new StringBuffer("Method overloading is not supported for command (Method name = ");
mess.append(meth_name);
mess.append(")");
Except.throw_exception("API_OverloadingNotSupported",
mess.toString(),
"TemplCommand.find_method()");
}
}
meth_found = meth_list[i];
break;
}
}
if (i == meth_list.length)
{
StringBuffer mess = new StringBuffer("Command ");
mess.append(name);
mess.append(": Can't find method ");
mess.append(meth_name);
Except.throw_exception("API_MethodNotFound",
mess.toString(),
"TemplCommand.find_method()");
}
return meth_found;
} | [
"protected",
"Method",
"find_method",
"(",
"Method",
"[",
"]",
"meth_list",
",",
"String",
"meth_name",
")",
"throws",
"DevFailed",
"{",
"int",
"i",
";",
"Method",
"meth_found",
"=",
"null",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"meth_list",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"meth_name",
".",
"equals",
"(",
"meth_list",
"[",
"i",
"]",
".",
"getName",
"(",
")",
")",
")",
"{",
"for",
"(",
"int",
"j",
"=",
"i",
"+",
"1",
";",
"j",
"<",
"meth_list",
".",
"length",
";",
"j",
"++",
")",
"{",
"if",
"(",
"meth_name",
".",
"equals",
"(",
"meth_list",
"[",
"j",
"]",
".",
"getName",
"(",
")",
")",
")",
"{",
"StringBuffer",
"mess",
"=",
"new",
"StringBuffer",
"(",
"\"Method overloading is not supported for command (Method name = \"",
")",
";",
"mess",
".",
"append",
"(",
"meth_name",
")",
";",
"mess",
".",
"append",
"(",
"\")\"",
")",
";",
"Except",
".",
"throw_exception",
"(",
"\"API_OverloadingNotSupported\"",
",",
"mess",
".",
"toString",
"(",
")",
",",
"\"TemplCommand.find_method()\"",
")",
";",
"}",
"}",
"meth_found",
"=",
"meth_list",
"[",
"i",
"]",
";",
"break",
";",
"}",
"}",
"if",
"(",
"i",
"==",
"meth_list",
".",
"length",
")",
"{",
"StringBuffer",
"mess",
"=",
"new",
"StringBuffer",
"(",
"\"Command \"",
")",
";",
"mess",
".",
"append",
"(",
"name",
")",
";",
"mess",
".",
"append",
"(",
"\": Can't find method \"",
")",
";",
"mess",
".",
"append",
"(",
"meth_name",
")",
";",
"Except",
".",
"throw_exception",
"(",
"\"API_MethodNotFound\"",
",",
"mess",
".",
"toString",
"(",
")",
",",
"\"TemplCommand.find_method()\"",
")",
";",
"}",
"return",
"meth_found",
";",
"}"
] | Retrieve a Method object from a Method list from its name.
@param meth_list The Method object list
@return The wanted method
@exception DevFailed If the method is not known or if two methods are found
with the same name
Click <a href="../../tango_basic/idl_html/Tango.html#DevFailed">here</a> to read
<b>DevFailed</b> exception specification | [
"Retrieve",
"a",
"Method",
"object",
"from",
"a",
"Method",
"list",
"from",
"its",
"name",
"."
] | 1ccc9dcb83e6de2359a9f1906d170571cacf1345 | https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/dao/src/main/java/fr/esrf/TangoDs/TemplCommand.java#L708-L747 |
140,179 | tango-controls/JTango | dao/src/main/java/fr/esrf/TangoDs/TemplCommand.java | TemplCommand.get_tango_type | protected int get_tango_type(Class type_cl) throws DevFailed
{
int type = 0;
//
// For arrays
//
if (type_cl.isArray() == true)
{
String type_name = type_cl.getComponentType().getName();
if (type_name.equals("byte"))
type = Tango_DEVVAR_CHARARRAY;
else if (type_name.equals("short"))
type = Tango_DEVVAR_SHORTARRAY;
else if (type_name.equals("int"))
type = Tango_DEVVAR_LONGARRAY;
else if (type_name.equals("float"))
type = Tango_DEVVAR_FLOATARRAY;
else if (type_name.equals("double"))
type = Tango_DEVVAR_DOUBLEARRAY;
else if (type_name.equals("java.lang.String"))
type = Tango_DEVVAR_STRINGARRAY;
else
{
StringBuffer mess = new StringBuffer("Argument array of ");
mess.append(type_name);
mess.append(" not supported");
Except.throw_exception("API_MethodArgument",
mess.toString(),
"TemplCommandIn.get_tango_type()");
}
}
//
// For all the other types
//
else
{
String type_name = type_cl.getName();
if (type_name.equals("boolean"))
type = Tango_DEV_BOOLEAN;
else if (type_name.equals("short"))
type = Tango_DEV_SHORT;
else if (type_name.equals("int"))
type = Tango_DEV_LONG;
else if (type_name.equals("long"))
type = Tango_DEV_LONG64;
else if (type_name.equals("float"))
type = Tango_DEV_FLOAT;
else if (type_name.equals("double"))
type = Tango_DEV_DOUBLE;
else if (type_name.equals("java.lang.String"))
type = Tango_DEV_STRING;
else if (type_name.equals("Tango.DevVarLongStringArray"))
type = Tango_DEVVAR_LONGSTRINGARRAY;
else if (type_name.equals("Tango.DevVarDoubleStringArray"))
type = Tango_DEVVAR_DOUBLESTRINGARRAY;
else if (type_name .equals("Tango.State"))
type = Tango_DEV_STATE;
else
{
StringBuffer mess = new StringBuffer("Argument ");
mess.append(type_name);
mess.append(" not supported");
Except.throw_exception("API_MethodArgument",
mess.toString(),
"TemplCommandIn.get_tango_type()");
}
}
return type;
} | java | protected int get_tango_type(Class type_cl) throws DevFailed
{
int type = 0;
//
// For arrays
//
if (type_cl.isArray() == true)
{
String type_name = type_cl.getComponentType().getName();
if (type_name.equals("byte"))
type = Tango_DEVVAR_CHARARRAY;
else if (type_name.equals("short"))
type = Tango_DEVVAR_SHORTARRAY;
else if (type_name.equals("int"))
type = Tango_DEVVAR_LONGARRAY;
else if (type_name.equals("float"))
type = Tango_DEVVAR_FLOATARRAY;
else if (type_name.equals("double"))
type = Tango_DEVVAR_DOUBLEARRAY;
else if (type_name.equals("java.lang.String"))
type = Tango_DEVVAR_STRINGARRAY;
else
{
StringBuffer mess = new StringBuffer("Argument array of ");
mess.append(type_name);
mess.append(" not supported");
Except.throw_exception("API_MethodArgument",
mess.toString(),
"TemplCommandIn.get_tango_type()");
}
}
//
// For all the other types
//
else
{
String type_name = type_cl.getName();
if (type_name.equals("boolean"))
type = Tango_DEV_BOOLEAN;
else if (type_name.equals("short"))
type = Tango_DEV_SHORT;
else if (type_name.equals("int"))
type = Tango_DEV_LONG;
else if (type_name.equals("long"))
type = Tango_DEV_LONG64;
else if (type_name.equals("float"))
type = Tango_DEV_FLOAT;
else if (type_name.equals("double"))
type = Tango_DEV_DOUBLE;
else if (type_name.equals("java.lang.String"))
type = Tango_DEV_STRING;
else if (type_name.equals("Tango.DevVarLongStringArray"))
type = Tango_DEVVAR_LONGSTRINGARRAY;
else if (type_name.equals("Tango.DevVarDoubleStringArray"))
type = Tango_DEVVAR_DOUBLESTRINGARRAY;
else if (type_name .equals("Tango.State"))
type = Tango_DEV_STATE;
else
{
StringBuffer mess = new StringBuffer("Argument ");
mess.append(type_name);
mess.append(" not supported");
Except.throw_exception("API_MethodArgument",
mess.toString(),
"TemplCommandIn.get_tango_type()");
}
}
return type;
} | [
"protected",
"int",
"get_tango_type",
"(",
"Class",
"type_cl",
")",
"throws",
"DevFailed",
"{",
"int",
"type",
"=",
"0",
";",
"//",
"// For arrays",
"//",
"if",
"(",
"type_cl",
".",
"isArray",
"(",
")",
"==",
"true",
")",
"{",
"String",
"type_name",
"=",
"type_cl",
".",
"getComponentType",
"(",
")",
".",
"getName",
"(",
")",
";",
"if",
"(",
"type_name",
".",
"equals",
"(",
"\"byte\"",
")",
")",
"type",
"=",
"Tango_DEVVAR_CHARARRAY",
";",
"else",
"if",
"(",
"type_name",
".",
"equals",
"(",
"\"short\"",
")",
")",
"type",
"=",
"Tango_DEVVAR_SHORTARRAY",
";",
"else",
"if",
"(",
"type_name",
".",
"equals",
"(",
"\"int\"",
")",
")",
"type",
"=",
"Tango_DEVVAR_LONGARRAY",
";",
"else",
"if",
"(",
"type_name",
".",
"equals",
"(",
"\"float\"",
")",
")",
"type",
"=",
"Tango_DEVVAR_FLOATARRAY",
";",
"else",
"if",
"(",
"type_name",
".",
"equals",
"(",
"\"double\"",
")",
")",
"type",
"=",
"Tango_DEVVAR_DOUBLEARRAY",
";",
"else",
"if",
"(",
"type_name",
".",
"equals",
"(",
"\"java.lang.String\"",
")",
")",
"type",
"=",
"Tango_DEVVAR_STRINGARRAY",
";",
"else",
"{",
"StringBuffer",
"mess",
"=",
"new",
"StringBuffer",
"(",
"\"Argument array of \"",
")",
";",
"mess",
".",
"append",
"(",
"type_name",
")",
";",
"mess",
".",
"append",
"(",
"\" not supported\"",
")",
";",
"Except",
".",
"throw_exception",
"(",
"\"API_MethodArgument\"",
",",
"mess",
".",
"toString",
"(",
")",
",",
"\"TemplCommandIn.get_tango_type()\"",
")",
";",
"}",
"}",
"//",
"// For all the other types",
"//",
"else",
"{",
"String",
"type_name",
"=",
"type_cl",
".",
"getName",
"(",
")",
";",
"if",
"(",
"type_name",
".",
"equals",
"(",
"\"boolean\"",
")",
")",
"type",
"=",
"Tango_DEV_BOOLEAN",
";",
"else",
"if",
"(",
"type_name",
".",
"equals",
"(",
"\"short\"",
")",
")",
"type",
"=",
"Tango_DEV_SHORT",
";",
"else",
"if",
"(",
"type_name",
".",
"equals",
"(",
"\"int\"",
")",
")",
"type",
"=",
"Tango_DEV_LONG",
";",
"else",
"if",
"(",
"type_name",
".",
"equals",
"(",
"\"long\"",
")",
")",
"type",
"=",
"Tango_DEV_LONG64",
";",
"else",
"if",
"(",
"type_name",
".",
"equals",
"(",
"\"float\"",
")",
")",
"type",
"=",
"Tango_DEV_FLOAT",
";",
"else",
"if",
"(",
"type_name",
".",
"equals",
"(",
"\"double\"",
")",
")",
"type",
"=",
"Tango_DEV_DOUBLE",
";",
"else",
"if",
"(",
"type_name",
".",
"equals",
"(",
"\"java.lang.String\"",
")",
")",
"type",
"=",
"Tango_DEV_STRING",
";",
"else",
"if",
"(",
"type_name",
".",
"equals",
"(",
"\"Tango.DevVarLongStringArray\"",
")",
")",
"type",
"=",
"Tango_DEVVAR_LONGSTRINGARRAY",
";",
"else",
"if",
"(",
"type_name",
".",
"equals",
"(",
"\"Tango.DevVarDoubleStringArray\"",
")",
")",
"type",
"=",
"Tango_DEVVAR_DOUBLESTRINGARRAY",
";",
"else",
"if",
"(",
"type_name",
".",
"equals",
"(",
"\"Tango.State\"",
")",
")",
"type",
"=",
"Tango_DEV_STATE",
";",
"else",
"{",
"StringBuffer",
"mess",
"=",
"new",
"StringBuffer",
"(",
"\"Argument \"",
")",
";",
"mess",
".",
"append",
"(",
"type_name",
")",
";",
"mess",
".",
"append",
"(",
"\" not supported\"",
")",
";",
"Except",
".",
"throw_exception",
"(",
"\"API_MethodArgument\"",
",",
"mess",
".",
"toString",
"(",
")",
",",
"\"TemplCommandIn.get_tango_type()\"",
")",
";",
"}",
"}",
"return",
"type",
";",
"}"
] | Get the TANGO type for a command argument.
This type is retrieved from the method executing the command argument
Class object reference
@param type_cl The argument Class object
@return The TANGO type
@exception DevFailed If the argument is not a TANGO supported type
Click <a href="../../tango_basic/idl_html/Tango.html#DevFailed">here</a> to read
<b>DevFailed</b> exception specification | [
"Get",
"the",
"TANGO",
"type",
"for",
"a",
"command",
"argument",
"."
] | 1ccc9dcb83e6de2359a9f1906d170571cacf1345 | https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/dao/src/main/java/fr/esrf/TangoDs/TemplCommand.java#L777-L852 |
140,180 | tango-controls/JTango | dao/src/main/java/fr/esrf/TangoDs/TemplCommand.java | TemplCommand.is_allowed | public boolean is_allowed(DeviceImpl dev,Any data_in)
{
if (state_method == null)
return true;
else
{
//
// If the Method reference is not null, execute the method with the invoke
// method
//
try
{
java.lang.Object[] meth_param = new java.lang.Object[1];
meth_param[0] = data_in;
java.lang.Object obj = state_method.invoke(dev,meth_param);
return (Boolean) obj;
}
catch(InvocationTargetException e)
{
return false;
}
catch(IllegalArgumentException e)
{
return false;
}
catch (IllegalAccessException e)
{
return false;
}
}
} | java | public boolean is_allowed(DeviceImpl dev,Any data_in)
{
if (state_method == null)
return true;
else
{
//
// If the Method reference is not null, execute the method with the invoke
// method
//
try
{
java.lang.Object[] meth_param = new java.lang.Object[1];
meth_param[0] = data_in;
java.lang.Object obj = state_method.invoke(dev,meth_param);
return (Boolean) obj;
}
catch(InvocationTargetException e)
{
return false;
}
catch(IllegalArgumentException e)
{
return false;
}
catch (IllegalAccessException e)
{
return false;
}
}
} | [
"public",
"boolean",
"is_allowed",
"(",
"DeviceImpl",
"dev",
",",
"Any",
"data_in",
")",
"{",
"if",
"(",
"state_method",
"==",
"null",
")",
"return",
"true",
";",
"else",
"{",
"//",
"// If the Method reference is not null, execute the method with the invoke",
"// method",
"//",
"try",
"{",
"java",
".",
"lang",
".",
"Object",
"[",
"]",
"meth_param",
"=",
"new",
"java",
".",
"lang",
".",
"Object",
"[",
"1",
"]",
";",
"meth_param",
"[",
"0",
"]",
"=",
"data_in",
";",
"java",
".",
"lang",
".",
"Object",
"obj",
"=",
"state_method",
".",
"invoke",
"(",
"dev",
",",
"meth_param",
")",
";",
"return",
"(",
"Boolean",
")",
"obj",
";",
"}",
"catch",
"(",
"InvocationTargetException",
"e",
")",
"{",
"return",
"false",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"e",
")",
"{",
"return",
"false",
";",
"}",
"catch",
"(",
"IllegalAccessException",
"e",
")",
"{",
"return",
"false",
";",
"}",
"}",
"}"
] | Invoke the command allowed method given at object creation time.
This method is automtically called by the TANGO core classes when the
associated command is requested by a client to check if the command is allowed
in the actual device state. If the user give a command allowed method
at object creation time, this method will be invoked.
@param dev The device on which the command must be executed
@param data_in The incoming data still packed in a CORBA Any object. For
command created with this TemplCommand class, this Any object does not
contain data
@return A boolean set to true is the command is allowed. Otherwise, the
return value is false. This return value is always set to true if the user
does not supply a method to be excuted. If a method has been supplied, the
return value is the value returned by the user supplied mehod. | [
"Invoke",
"the",
"command",
"allowed",
"method",
"given",
"at",
"object",
"creation",
"time",
"."
] | 1ccc9dcb83e6de2359a9f1906d170571cacf1345 | https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/dao/src/main/java/fr/esrf/TangoDs/TemplCommand.java#L889-L921 |
140,181 | tango-controls/JTango | dao/src/main/java/fr/esrf/TangoApi/helpers/CommandHelper.java | CommandHelper.extract | public static Object extract(final DeviceData deviceDataArgout) throws DevFailed {
Object argout = null;
switch (deviceDataArgout.getType()) {
case TangoConst.Tango_DEV_SHORT:
argout = Short.valueOf(deviceDataArgout.extractShort());
break;
case TangoConst.Tango_DEV_USHORT:
argout = Integer.valueOf(deviceDataArgout.extractUShort()).shortValue();
break;
case TangoConst.Tango_DEV_CHAR:
Except.throw_exception("TANGO_WRONG_DATA_ERROR",
"out type Tango_DEV_CHAR not supported",
"CommandHelper.extract(deviceDataArgout)");
break;
case TangoConst.Tango_DEV_UCHAR:
Except.throw_exception("TANGO_WRONG_DATA_ERROR",
"out type Tango_DEV_UCHAR not supported",
"CommandHelper.extract(deviceDataArgout)");
break;
case TangoConst.Tango_DEV_LONG:
argout = Integer.valueOf(deviceDataArgout.extractLong());
break;
case TangoConst.Tango_DEV_ULONG:
argout = Long.valueOf(deviceDataArgout.extractULong());
break;
case TangoConst.Tango_DEV_LONG64:
argout = Long.valueOf(deviceDataArgout.extractLong64());
break;
case TangoConst.Tango_DEV_ULONG64:
argout = Long.valueOf(deviceDataArgout.extractULong64());
break;
case TangoConst.Tango_DEV_INT:
argout = Integer.valueOf(deviceDataArgout.extractLong());
break;
case TangoConst.Tango_DEV_FLOAT:
argout = Float.valueOf(deviceDataArgout.extractFloat());
break;
case TangoConst.Tango_DEV_DOUBLE:
argout = Double.valueOf(deviceDataArgout.extractDouble());
break;
case TangoConst.Tango_DEV_STRING:
argout = deviceDataArgout.extractString();
break;
case TangoConst.Tango_DEV_BOOLEAN:
argout = Boolean.valueOf(deviceDataArgout.extractBoolean());
break;
case TangoConst.Tango_DEV_STATE:
argout = deviceDataArgout.extractDevState();
break;
case TangoConst.Tango_DEVVAR_DOUBLESTRINGARRAY:
argout = deviceDataArgout.extractDoubleStringArray();
break;
case TangoConst.Tango_DEVVAR_LONGSTRINGARRAY:
argout = deviceDataArgout.extractLongStringArray();
break;
default:
Except.throw_exception("TANGO_WRONG_DATA_ERROR", "output type "
+ deviceDataArgout.getType() + " not supported",
"CommandHelper.extract(Short value,deviceDataArgout)");
break;
}
return argout;
} | java | public static Object extract(final DeviceData deviceDataArgout) throws DevFailed {
Object argout = null;
switch (deviceDataArgout.getType()) {
case TangoConst.Tango_DEV_SHORT:
argout = Short.valueOf(deviceDataArgout.extractShort());
break;
case TangoConst.Tango_DEV_USHORT:
argout = Integer.valueOf(deviceDataArgout.extractUShort()).shortValue();
break;
case TangoConst.Tango_DEV_CHAR:
Except.throw_exception("TANGO_WRONG_DATA_ERROR",
"out type Tango_DEV_CHAR not supported",
"CommandHelper.extract(deviceDataArgout)");
break;
case TangoConst.Tango_DEV_UCHAR:
Except.throw_exception("TANGO_WRONG_DATA_ERROR",
"out type Tango_DEV_UCHAR not supported",
"CommandHelper.extract(deviceDataArgout)");
break;
case TangoConst.Tango_DEV_LONG:
argout = Integer.valueOf(deviceDataArgout.extractLong());
break;
case TangoConst.Tango_DEV_ULONG:
argout = Long.valueOf(deviceDataArgout.extractULong());
break;
case TangoConst.Tango_DEV_LONG64:
argout = Long.valueOf(deviceDataArgout.extractLong64());
break;
case TangoConst.Tango_DEV_ULONG64:
argout = Long.valueOf(deviceDataArgout.extractULong64());
break;
case TangoConst.Tango_DEV_INT:
argout = Integer.valueOf(deviceDataArgout.extractLong());
break;
case TangoConst.Tango_DEV_FLOAT:
argout = Float.valueOf(deviceDataArgout.extractFloat());
break;
case TangoConst.Tango_DEV_DOUBLE:
argout = Double.valueOf(deviceDataArgout.extractDouble());
break;
case TangoConst.Tango_DEV_STRING:
argout = deviceDataArgout.extractString();
break;
case TangoConst.Tango_DEV_BOOLEAN:
argout = Boolean.valueOf(deviceDataArgout.extractBoolean());
break;
case TangoConst.Tango_DEV_STATE:
argout = deviceDataArgout.extractDevState();
break;
case TangoConst.Tango_DEVVAR_DOUBLESTRINGARRAY:
argout = deviceDataArgout.extractDoubleStringArray();
break;
case TangoConst.Tango_DEVVAR_LONGSTRINGARRAY:
argout = deviceDataArgout.extractLongStringArray();
break;
default:
Except.throw_exception("TANGO_WRONG_DATA_ERROR", "output type "
+ deviceDataArgout.getType() + " not supported",
"CommandHelper.extract(Short value,deviceDataArgout)");
break;
}
return argout;
} | [
"public",
"static",
"Object",
"extract",
"(",
"final",
"DeviceData",
"deviceDataArgout",
")",
"throws",
"DevFailed",
"{",
"Object",
"argout",
"=",
"null",
";",
"switch",
"(",
"deviceDataArgout",
".",
"getType",
"(",
")",
")",
"{",
"case",
"TangoConst",
".",
"Tango_DEV_SHORT",
":",
"argout",
"=",
"Short",
".",
"valueOf",
"(",
"deviceDataArgout",
".",
"extractShort",
"(",
")",
")",
";",
"break",
";",
"case",
"TangoConst",
".",
"Tango_DEV_USHORT",
":",
"argout",
"=",
"Integer",
".",
"valueOf",
"(",
"deviceDataArgout",
".",
"extractUShort",
"(",
")",
")",
".",
"shortValue",
"(",
")",
";",
"break",
";",
"case",
"TangoConst",
".",
"Tango_DEV_CHAR",
":",
"Except",
".",
"throw_exception",
"(",
"\"TANGO_WRONG_DATA_ERROR\"",
",",
"\"out type Tango_DEV_CHAR not supported\"",
",",
"\"CommandHelper.extract(deviceDataArgout)\"",
")",
";",
"break",
";",
"case",
"TangoConst",
".",
"Tango_DEV_UCHAR",
":",
"Except",
".",
"throw_exception",
"(",
"\"TANGO_WRONG_DATA_ERROR\"",
",",
"\"out type Tango_DEV_UCHAR not supported\"",
",",
"\"CommandHelper.extract(deviceDataArgout)\"",
")",
";",
"break",
";",
"case",
"TangoConst",
".",
"Tango_DEV_LONG",
":",
"argout",
"=",
"Integer",
".",
"valueOf",
"(",
"deviceDataArgout",
".",
"extractLong",
"(",
")",
")",
";",
"break",
";",
"case",
"TangoConst",
".",
"Tango_DEV_ULONG",
":",
"argout",
"=",
"Long",
".",
"valueOf",
"(",
"deviceDataArgout",
".",
"extractULong",
"(",
")",
")",
";",
"break",
";",
"case",
"TangoConst",
".",
"Tango_DEV_LONG64",
":",
"argout",
"=",
"Long",
".",
"valueOf",
"(",
"deviceDataArgout",
".",
"extractLong64",
"(",
")",
")",
";",
"break",
";",
"case",
"TangoConst",
".",
"Tango_DEV_ULONG64",
":",
"argout",
"=",
"Long",
".",
"valueOf",
"(",
"deviceDataArgout",
".",
"extractULong64",
"(",
")",
")",
";",
"break",
";",
"case",
"TangoConst",
".",
"Tango_DEV_INT",
":",
"argout",
"=",
"Integer",
".",
"valueOf",
"(",
"deviceDataArgout",
".",
"extractLong",
"(",
")",
")",
";",
"break",
";",
"case",
"TangoConst",
".",
"Tango_DEV_FLOAT",
":",
"argout",
"=",
"Float",
".",
"valueOf",
"(",
"deviceDataArgout",
".",
"extractFloat",
"(",
")",
")",
";",
"break",
";",
"case",
"TangoConst",
".",
"Tango_DEV_DOUBLE",
":",
"argout",
"=",
"Double",
".",
"valueOf",
"(",
"deviceDataArgout",
".",
"extractDouble",
"(",
")",
")",
";",
"break",
";",
"case",
"TangoConst",
".",
"Tango_DEV_STRING",
":",
"argout",
"=",
"deviceDataArgout",
".",
"extractString",
"(",
")",
";",
"break",
";",
"case",
"TangoConst",
".",
"Tango_DEV_BOOLEAN",
":",
"argout",
"=",
"Boolean",
".",
"valueOf",
"(",
"deviceDataArgout",
".",
"extractBoolean",
"(",
")",
")",
";",
"break",
";",
"case",
"TangoConst",
".",
"Tango_DEV_STATE",
":",
"argout",
"=",
"deviceDataArgout",
".",
"extractDevState",
"(",
")",
";",
"break",
";",
"case",
"TangoConst",
".",
"Tango_DEVVAR_DOUBLESTRINGARRAY",
":",
"argout",
"=",
"deviceDataArgout",
".",
"extractDoubleStringArray",
"(",
")",
";",
"break",
";",
"case",
"TangoConst",
".",
"Tango_DEVVAR_LONGSTRINGARRAY",
":",
"argout",
"=",
"deviceDataArgout",
".",
"extractLongStringArray",
"(",
")",
";",
"break",
";",
"default",
":",
"Except",
".",
"throw_exception",
"(",
"\"TANGO_WRONG_DATA_ERROR\"",
",",
"\"output type \"",
"+",
"deviceDataArgout",
".",
"getType",
"(",
")",
"+",
"\" not supported\"",
",",
"\"CommandHelper.extract(Short value,deviceDataArgout)\"",
")",
";",
"break",
";",
"}",
"return",
"argout",
";",
"}"
] | Extract data to DeviceData to an Object
@param deviceDataArgout
the DeviceData to read
@return Object, possibles Classe : Short, String, Long, Float, Boolean,
Integer, Double, DevState, DevVarDoubleStringArray or
DevVarLongStringArray.
@throws DevFailed | [
"Extract",
"data",
"to",
"DeviceData",
"to",
"an",
"Object"
] | 1ccc9dcb83e6de2359a9f1906d170571cacf1345 | https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/dao/src/main/java/fr/esrf/TangoApi/helpers/CommandHelper.java#L113-L176 |
140,182 | tango-controls/JTango | server/src/main/java/org/tango/logging/LoggingManager.java | LoggingManager.setLoggingLevel | public void setLoggingLevel(final String deviceName, final int loggingLevel) {
System.out.println("set logging level " + deviceName + "-" + LoggingLevel.getLevelFromInt(loggingLevel));
logger.debug("set logging level to {} on {}", LoggingLevel.getLevelFromInt(loggingLevel), deviceName);
if (rootLoggingLevel < loggingLevel) {
setRootLoggingLevel(loggingLevel);
}
// setLoggingLevel(loggingLevel);
loggingLevels.put(deviceName, loggingLevel);
for (final DeviceAppender appender : deviceAppenders.values()) {
if (deviceName.equalsIgnoreCase(appender.getDeviceName())) {
appender.setLevel(loggingLevel);
break;
}
}
for (final FileAppender appender : fileAppenders.values()) {
if (deviceName.equalsIgnoreCase(appender.getDeviceName())) {
appender.setLevel(loggingLevel);
break;
}
}
} | java | public void setLoggingLevel(final String deviceName, final int loggingLevel) {
System.out.println("set logging level " + deviceName + "-" + LoggingLevel.getLevelFromInt(loggingLevel));
logger.debug("set logging level to {} on {}", LoggingLevel.getLevelFromInt(loggingLevel), deviceName);
if (rootLoggingLevel < loggingLevel) {
setRootLoggingLevel(loggingLevel);
}
// setLoggingLevel(loggingLevel);
loggingLevels.put(deviceName, loggingLevel);
for (final DeviceAppender appender : deviceAppenders.values()) {
if (deviceName.equalsIgnoreCase(appender.getDeviceName())) {
appender.setLevel(loggingLevel);
break;
}
}
for (final FileAppender appender : fileAppenders.values()) {
if (deviceName.equalsIgnoreCase(appender.getDeviceName())) {
appender.setLevel(loggingLevel);
break;
}
}
} | [
"public",
"void",
"setLoggingLevel",
"(",
"final",
"String",
"deviceName",
",",
"final",
"int",
"loggingLevel",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"set logging level \"",
"+",
"deviceName",
"+",
"\"-\"",
"+",
"LoggingLevel",
".",
"getLevelFromInt",
"(",
"loggingLevel",
")",
")",
";",
"logger",
".",
"debug",
"(",
"\"set logging level to {} on {}\"",
",",
"LoggingLevel",
".",
"getLevelFromInt",
"(",
"loggingLevel",
")",
",",
"deviceName",
")",
";",
"if",
"(",
"rootLoggingLevel",
"<",
"loggingLevel",
")",
"{",
"setRootLoggingLevel",
"(",
"loggingLevel",
")",
";",
"}",
"// setLoggingLevel(loggingLevel);",
"loggingLevels",
".",
"put",
"(",
"deviceName",
",",
"loggingLevel",
")",
";",
"for",
"(",
"final",
"DeviceAppender",
"appender",
":",
"deviceAppenders",
".",
"values",
"(",
")",
")",
"{",
"if",
"(",
"deviceName",
".",
"equalsIgnoreCase",
"(",
"appender",
".",
"getDeviceName",
"(",
")",
")",
")",
"{",
"appender",
".",
"setLevel",
"(",
"loggingLevel",
")",
";",
"break",
";",
"}",
"}",
"for",
"(",
"final",
"FileAppender",
"appender",
":",
"fileAppenders",
".",
"values",
"(",
")",
")",
"{",
"if",
"(",
"deviceName",
".",
"equalsIgnoreCase",
"(",
"appender",
".",
"getDeviceName",
"(",
")",
")",
")",
"{",
"appender",
".",
"setLevel",
"(",
"loggingLevel",
")",
";",
"break",
";",
"}",
"}",
"}"
] | Set the logging level of a device
@param deviceName the device name
@param loggingLevel the level | [
"Set",
"the",
"logging",
"level",
"of",
"a",
"device"
] | 1ccc9dcb83e6de2359a9f1906d170571cacf1345 | https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/server/src/main/java/org/tango/logging/LoggingManager.java#L103-L123 |
140,183 | tango-controls/JTango | server/src/main/java/org/tango/logging/LoggingManager.java | LoggingManager.setRootLoggingLevel | public void setRootLoggingLevel(final int loggingLevel) {
rootLoggingLevel = loggingLevel;
if (rootLoggerBack != null) {
rootLoggerBack.setLevel(LoggingLevel.getLevelFromInt(loggingLevel));
}
} | java | public void setRootLoggingLevel(final int loggingLevel) {
rootLoggingLevel = loggingLevel;
if (rootLoggerBack != null) {
rootLoggerBack.setLevel(LoggingLevel.getLevelFromInt(loggingLevel));
}
} | [
"public",
"void",
"setRootLoggingLevel",
"(",
"final",
"int",
"loggingLevel",
")",
"{",
"rootLoggingLevel",
"=",
"loggingLevel",
";",
"if",
"(",
"rootLoggerBack",
"!=",
"null",
")",
"{",
"rootLoggerBack",
".",
"setLevel",
"(",
"LoggingLevel",
".",
"getLevelFromInt",
"(",
"loggingLevel",
")",
")",
";",
"}",
"}"
] | Set the level of the root logger
@param loggingLevel | [
"Set",
"the",
"level",
"of",
"the",
"root",
"logger"
] | 1ccc9dcb83e6de2359a9f1906d170571cacf1345 | https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/server/src/main/java/org/tango/logging/LoggingManager.java#L130-L135 |
140,184 | tango-controls/JTango | server/src/main/java/org/tango/logging/LoggingManager.java | LoggingManager.setLoggingLevel | public void setLoggingLevel(final int loggingLevel, final Class<?>... deviceClassNames) {
if (rootLoggingLevel < loggingLevel) {
setRootLoggingLevel(loggingLevel);
}
System.out.println("set logging to " + LoggingLevel.getLevelFromInt(loggingLevel));
final Logger tangoLogger = LoggerFactory.getLogger("org.tango.server");
if (tangoLogger instanceof ch.qos.logback.classic.Logger) {
final ch.qos.logback.classic.Logger logbackLogger = (ch.qos.logback.classic.Logger) tangoLogger;
logbackLogger.setLevel(LoggingLevel.getLevelFromInt(loggingLevel));
}
final Logger blackboxLogger = LoggerFactory.getLogger(Constants.CLIENT_REQUESTS_LOGGER);
if (blackboxLogger instanceof ch.qos.logback.classic.Logger) {
final ch.qos.logback.classic.Logger logbackLogger = (ch.qos.logback.classic.Logger) blackboxLogger;
logbackLogger.setLevel(LoggingLevel.getLevelFromInt(loggingLevel));
}
for (int i = 0; i < deviceClassNames.length; i++) {
final Logger deviceLogger = LoggerFactory.getLogger(deviceClassNames[i]);
if (deviceLogger instanceof ch.qos.logback.classic.Logger) {
final ch.qos.logback.classic.Logger logbackLogger = (ch.qos.logback.classic.Logger) deviceLogger;
logbackLogger.setLevel(LoggingLevel.getLevelFromInt(loggingLevel));
}
}
} | java | public void setLoggingLevel(final int loggingLevel, final Class<?>... deviceClassNames) {
if (rootLoggingLevel < loggingLevel) {
setRootLoggingLevel(loggingLevel);
}
System.out.println("set logging to " + LoggingLevel.getLevelFromInt(loggingLevel));
final Logger tangoLogger = LoggerFactory.getLogger("org.tango.server");
if (tangoLogger instanceof ch.qos.logback.classic.Logger) {
final ch.qos.logback.classic.Logger logbackLogger = (ch.qos.logback.classic.Logger) tangoLogger;
logbackLogger.setLevel(LoggingLevel.getLevelFromInt(loggingLevel));
}
final Logger blackboxLogger = LoggerFactory.getLogger(Constants.CLIENT_REQUESTS_LOGGER);
if (blackboxLogger instanceof ch.qos.logback.classic.Logger) {
final ch.qos.logback.classic.Logger logbackLogger = (ch.qos.logback.classic.Logger) blackboxLogger;
logbackLogger.setLevel(LoggingLevel.getLevelFromInt(loggingLevel));
}
for (int i = 0; i < deviceClassNames.length; i++) {
final Logger deviceLogger = LoggerFactory.getLogger(deviceClassNames[i]);
if (deviceLogger instanceof ch.qos.logback.classic.Logger) {
final ch.qos.logback.classic.Logger logbackLogger = (ch.qos.logback.classic.Logger) deviceLogger;
logbackLogger.setLevel(LoggingLevel.getLevelFromInt(loggingLevel));
}
}
} | [
"public",
"void",
"setLoggingLevel",
"(",
"final",
"int",
"loggingLevel",
",",
"final",
"Class",
"<",
"?",
">",
"...",
"deviceClassNames",
")",
"{",
"if",
"(",
"rootLoggingLevel",
"<",
"loggingLevel",
")",
"{",
"setRootLoggingLevel",
"(",
"loggingLevel",
")",
";",
"}",
"System",
".",
"out",
".",
"println",
"(",
"\"set logging to \"",
"+",
"LoggingLevel",
".",
"getLevelFromInt",
"(",
"loggingLevel",
")",
")",
";",
"final",
"Logger",
"tangoLogger",
"=",
"LoggerFactory",
".",
"getLogger",
"(",
"\"org.tango.server\"",
")",
";",
"if",
"(",
"tangoLogger",
"instanceof",
"ch",
".",
"qos",
".",
"logback",
".",
"classic",
".",
"Logger",
")",
"{",
"final",
"ch",
".",
"qos",
".",
"logback",
".",
"classic",
".",
"Logger",
"logbackLogger",
"=",
"(",
"ch",
".",
"qos",
".",
"logback",
".",
"classic",
".",
"Logger",
")",
"tangoLogger",
";",
"logbackLogger",
".",
"setLevel",
"(",
"LoggingLevel",
".",
"getLevelFromInt",
"(",
"loggingLevel",
")",
")",
";",
"}",
"final",
"Logger",
"blackboxLogger",
"=",
"LoggerFactory",
".",
"getLogger",
"(",
"Constants",
".",
"CLIENT_REQUESTS_LOGGER",
")",
";",
"if",
"(",
"blackboxLogger",
"instanceof",
"ch",
".",
"qos",
".",
"logback",
".",
"classic",
".",
"Logger",
")",
"{",
"final",
"ch",
".",
"qos",
".",
"logback",
".",
"classic",
".",
"Logger",
"logbackLogger",
"=",
"(",
"ch",
".",
"qos",
".",
"logback",
".",
"classic",
".",
"Logger",
")",
"blackboxLogger",
";",
"logbackLogger",
".",
"setLevel",
"(",
"LoggingLevel",
".",
"getLevelFromInt",
"(",
"loggingLevel",
")",
")",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"deviceClassNames",
".",
"length",
";",
"i",
"++",
")",
"{",
"final",
"Logger",
"deviceLogger",
"=",
"LoggerFactory",
".",
"getLogger",
"(",
"deviceClassNames",
"[",
"i",
"]",
")",
";",
"if",
"(",
"deviceLogger",
"instanceof",
"ch",
".",
"qos",
".",
"logback",
".",
"classic",
".",
"Logger",
")",
"{",
"final",
"ch",
".",
"qos",
".",
"logback",
".",
"classic",
".",
"Logger",
"logbackLogger",
"=",
"(",
"ch",
".",
"qos",
".",
"logback",
".",
"classic",
".",
"Logger",
")",
"deviceLogger",
";",
"logbackLogger",
".",
"setLevel",
"(",
"LoggingLevel",
".",
"getLevelFromInt",
"(",
"loggingLevel",
")",
")",
";",
"}",
"}",
"}"
] | Set the level of all loggers of JTangoServer
@param loggingLevel | [
"Set",
"the",
"level",
"of",
"all",
"loggers",
"of",
"JTangoServer"
] | 1ccc9dcb83e6de2359a9f1906d170571cacf1345 | https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/server/src/main/java/org/tango/logging/LoggingManager.java#L142-L166 |
140,185 | tango-controls/JTango | server/src/main/java/org/tango/logging/LoggingManager.java | LoggingManager.addDeviceAppender | public void addDeviceAppender(final String deviceTargetName, final Class<?> deviceClassName,
final String loggingDeviceName) throws DevFailed {
if (rootLoggerBack != null) {
logger.debug("add device appender {} on {}", deviceTargetName, loggingDeviceName);
final DeviceAppender appender = new DeviceAppender(deviceTargetName, loggingDeviceName);
deviceAppenders.put(loggingDeviceName.toLowerCase(Locale.ENGLISH), appender);
rootLoggerBack.addAppender(appender);
// debug level by default
setLoggingLevel(LoggingLevel.DEBUG.toInt(), deviceClassName);
setLoggingLevel(loggingDeviceName, LoggingLevel.DEBUG.toInt());
appender.start();
}
} | java | public void addDeviceAppender(final String deviceTargetName, final Class<?> deviceClassName,
final String loggingDeviceName) throws DevFailed {
if (rootLoggerBack != null) {
logger.debug("add device appender {} on {}", deviceTargetName, loggingDeviceName);
final DeviceAppender appender = new DeviceAppender(deviceTargetName, loggingDeviceName);
deviceAppenders.put(loggingDeviceName.toLowerCase(Locale.ENGLISH), appender);
rootLoggerBack.addAppender(appender);
// debug level by default
setLoggingLevel(LoggingLevel.DEBUG.toInt(), deviceClassName);
setLoggingLevel(loggingDeviceName, LoggingLevel.DEBUG.toInt());
appender.start();
}
} | [
"public",
"void",
"addDeviceAppender",
"(",
"final",
"String",
"deviceTargetName",
",",
"final",
"Class",
"<",
"?",
">",
"deviceClassName",
",",
"final",
"String",
"loggingDeviceName",
")",
"throws",
"DevFailed",
"{",
"if",
"(",
"rootLoggerBack",
"!=",
"null",
")",
"{",
"logger",
".",
"debug",
"(",
"\"add device appender {} on {}\"",
",",
"deviceTargetName",
",",
"loggingDeviceName",
")",
";",
"final",
"DeviceAppender",
"appender",
"=",
"new",
"DeviceAppender",
"(",
"deviceTargetName",
",",
"loggingDeviceName",
")",
";",
"deviceAppenders",
".",
"put",
"(",
"loggingDeviceName",
".",
"toLowerCase",
"(",
"Locale",
".",
"ENGLISH",
")",
",",
"appender",
")",
";",
"rootLoggerBack",
".",
"addAppender",
"(",
"appender",
")",
";",
"// debug level by default",
"setLoggingLevel",
"(",
"LoggingLevel",
".",
"DEBUG",
".",
"toInt",
"(",
")",
",",
"deviceClassName",
")",
";",
"setLoggingLevel",
"(",
"loggingDeviceName",
",",
"LoggingLevel",
".",
"DEBUG",
".",
"toInt",
"(",
")",
")",
";",
"appender",
".",
"start",
"(",
")",
";",
"}",
"}"
] | Logging of device sent to logviewer device
@param deviceTargetName
@param deviceClassName
@param loggingDeviceName
@throws DevFailed | [
"Logging",
"of",
"device",
"sent",
"to",
"logviewer",
"device"
] | 1ccc9dcb83e6de2359a9f1906d170571cacf1345 | https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/server/src/main/java/org/tango/logging/LoggingManager.java#L176-L188 |
140,186 | tango-controls/JTango | server/src/main/java/org/tango/logging/LoggingManager.java | LoggingManager.addFileAppender | public void addFileAppender(final String fileName, final String deviceName) throws DevFailed {
if (rootLoggerBack != null) {
logger.debug("add file appender of {} in {}", deviceName, fileName);
final String deviceNameLower = deviceName.toLowerCase(Locale.ENGLISH);
final File f = new File(fileName);
if (!f.exists()) {
try {
f.createNewFile();
} catch (final IOException e) {
throw DevFailedUtils.newDevFailed(ExceptionMessages.CANNOT_OPEN_FILE, "impossible to open file "
+ fileName);
}
}
if (!f.canWrite()) {
throw DevFailedUtils.newDevFailed(ExceptionMessages.CANNOT_OPEN_FILE, "impossible to open file " + fileName);
}
// debug level by default
// setLoggingLevel(deviceName, LoggingLevel.DEBUG.toInt());
System.out.println("create file " + f);
final LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
final FileAppender rfAppender = new FileAppender(deviceNameLower);
fileAppenders.put(deviceNameLower, rfAppender);
rfAppender.setName("FILE-" + deviceNameLower);
rfAppender.setLevel(rootLoggingLevel);
// rfAppender.setContext(appender.getContext());
rfAppender.setFile(fileName);
rfAppender.setAppend(true);
rfAppender.setContext(loggerContext);
final FixedWindowRollingPolicy rollingPolicy = new FixedWindowRollingPolicy();
// rolling policies need to know their parent
// it's one of the rare cases, where a sub-component knows about its parent
rollingPolicy.setParent(rfAppender);
rollingPolicy.setContext(loggerContext);
rollingPolicy.setFileNamePattern(fileName + "%i");
rollingPolicy.setMaxIndex(1);
rollingPolicy.setMaxIndex(3);
rollingPolicy.start();
final SizeBasedTriggeringPolicy<ILoggingEvent> triggeringPolicy = new SizeBasedTriggeringPolicy<ILoggingEvent>();
triggeringPolicy.setMaxFileSize(FileSize.valueOf("5 mb"));
triggeringPolicy.setContext(loggerContext);
triggeringPolicy.start();
final PatternLayoutEncoder encoder = new PatternLayoutEncoder();
encoder.setContext(loggerContext);
encoder.setPattern("%-5level %d %X{deviceName} - %thread | %logger{25}.%M:%L - %msg%n");
encoder.start();
rfAppender.setEncoder(encoder);
rfAppender.setRollingPolicy(rollingPolicy);
rfAppender.setTriggeringPolicy(triggeringPolicy);
rfAppender.start();
rootLoggerBack.addAppender(rfAppender);
rfAppender.start();
// OPTIONAL: print logback internal status messages
// StatusPrinter.print(loggerContext);
}
} | java | public void addFileAppender(final String fileName, final String deviceName) throws DevFailed {
if (rootLoggerBack != null) {
logger.debug("add file appender of {} in {}", deviceName, fileName);
final String deviceNameLower = deviceName.toLowerCase(Locale.ENGLISH);
final File f = new File(fileName);
if (!f.exists()) {
try {
f.createNewFile();
} catch (final IOException e) {
throw DevFailedUtils.newDevFailed(ExceptionMessages.CANNOT_OPEN_FILE, "impossible to open file "
+ fileName);
}
}
if (!f.canWrite()) {
throw DevFailedUtils.newDevFailed(ExceptionMessages.CANNOT_OPEN_FILE, "impossible to open file " + fileName);
}
// debug level by default
// setLoggingLevel(deviceName, LoggingLevel.DEBUG.toInt());
System.out.println("create file " + f);
final LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
final FileAppender rfAppender = new FileAppender(deviceNameLower);
fileAppenders.put(deviceNameLower, rfAppender);
rfAppender.setName("FILE-" + deviceNameLower);
rfAppender.setLevel(rootLoggingLevel);
// rfAppender.setContext(appender.getContext());
rfAppender.setFile(fileName);
rfAppender.setAppend(true);
rfAppender.setContext(loggerContext);
final FixedWindowRollingPolicy rollingPolicy = new FixedWindowRollingPolicy();
// rolling policies need to know their parent
// it's one of the rare cases, where a sub-component knows about its parent
rollingPolicy.setParent(rfAppender);
rollingPolicy.setContext(loggerContext);
rollingPolicy.setFileNamePattern(fileName + "%i");
rollingPolicy.setMaxIndex(1);
rollingPolicy.setMaxIndex(3);
rollingPolicy.start();
final SizeBasedTriggeringPolicy<ILoggingEvent> triggeringPolicy = new SizeBasedTriggeringPolicy<ILoggingEvent>();
triggeringPolicy.setMaxFileSize(FileSize.valueOf("5 mb"));
triggeringPolicy.setContext(loggerContext);
triggeringPolicy.start();
final PatternLayoutEncoder encoder = new PatternLayoutEncoder();
encoder.setContext(loggerContext);
encoder.setPattern("%-5level %d %X{deviceName} - %thread | %logger{25}.%M:%L - %msg%n");
encoder.start();
rfAppender.setEncoder(encoder);
rfAppender.setRollingPolicy(rollingPolicy);
rfAppender.setTriggeringPolicy(triggeringPolicy);
rfAppender.start();
rootLoggerBack.addAppender(rfAppender);
rfAppender.start();
// OPTIONAL: print logback internal status messages
// StatusPrinter.print(loggerContext);
}
} | [
"public",
"void",
"addFileAppender",
"(",
"final",
"String",
"fileName",
",",
"final",
"String",
"deviceName",
")",
"throws",
"DevFailed",
"{",
"if",
"(",
"rootLoggerBack",
"!=",
"null",
")",
"{",
"logger",
".",
"debug",
"(",
"\"add file appender of {} in {}\"",
",",
"deviceName",
",",
"fileName",
")",
";",
"final",
"String",
"deviceNameLower",
"=",
"deviceName",
".",
"toLowerCase",
"(",
"Locale",
".",
"ENGLISH",
")",
";",
"final",
"File",
"f",
"=",
"new",
"File",
"(",
"fileName",
")",
";",
"if",
"(",
"!",
"f",
".",
"exists",
"(",
")",
")",
"{",
"try",
"{",
"f",
".",
"createNewFile",
"(",
")",
";",
"}",
"catch",
"(",
"final",
"IOException",
"e",
")",
"{",
"throw",
"DevFailedUtils",
".",
"newDevFailed",
"(",
"ExceptionMessages",
".",
"CANNOT_OPEN_FILE",
",",
"\"impossible to open file \"",
"+",
"fileName",
")",
";",
"}",
"}",
"if",
"(",
"!",
"f",
".",
"canWrite",
"(",
")",
")",
"{",
"throw",
"DevFailedUtils",
".",
"newDevFailed",
"(",
"ExceptionMessages",
".",
"CANNOT_OPEN_FILE",
",",
"\"impossible to open file \"",
"+",
"fileName",
")",
";",
"}",
"// debug level by default",
"// setLoggingLevel(deviceName, LoggingLevel.DEBUG.toInt());",
"System",
".",
"out",
".",
"println",
"(",
"\"create file \"",
"+",
"f",
")",
";",
"final",
"LoggerContext",
"loggerContext",
"=",
"(",
"LoggerContext",
")",
"LoggerFactory",
".",
"getILoggerFactory",
"(",
")",
";",
"final",
"FileAppender",
"rfAppender",
"=",
"new",
"FileAppender",
"(",
"deviceNameLower",
")",
";",
"fileAppenders",
".",
"put",
"(",
"deviceNameLower",
",",
"rfAppender",
")",
";",
"rfAppender",
".",
"setName",
"(",
"\"FILE-\"",
"+",
"deviceNameLower",
")",
";",
"rfAppender",
".",
"setLevel",
"(",
"rootLoggingLevel",
")",
";",
"// rfAppender.setContext(appender.getContext());",
"rfAppender",
".",
"setFile",
"(",
"fileName",
")",
";",
"rfAppender",
".",
"setAppend",
"(",
"true",
")",
";",
"rfAppender",
".",
"setContext",
"(",
"loggerContext",
")",
";",
"final",
"FixedWindowRollingPolicy",
"rollingPolicy",
"=",
"new",
"FixedWindowRollingPolicy",
"(",
")",
";",
"// rolling policies need to know their parent",
"// it's one of the rare cases, where a sub-component knows about its parent",
"rollingPolicy",
".",
"setParent",
"(",
"rfAppender",
")",
";",
"rollingPolicy",
".",
"setContext",
"(",
"loggerContext",
")",
";",
"rollingPolicy",
".",
"setFileNamePattern",
"(",
"fileName",
"+",
"\"%i\"",
")",
";",
"rollingPolicy",
".",
"setMaxIndex",
"(",
"1",
")",
";",
"rollingPolicy",
".",
"setMaxIndex",
"(",
"3",
")",
";",
"rollingPolicy",
".",
"start",
"(",
")",
";",
"final",
"SizeBasedTriggeringPolicy",
"<",
"ILoggingEvent",
">",
"triggeringPolicy",
"=",
"new",
"SizeBasedTriggeringPolicy",
"<",
"ILoggingEvent",
">",
"(",
")",
";",
"triggeringPolicy",
".",
"setMaxFileSize",
"(",
"FileSize",
".",
"valueOf",
"(",
"\"5 mb\"",
")",
")",
";",
"triggeringPolicy",
".",
"setContext",
"(",
"loggerContext",
")",
";",
"triggeringPolicy",
".",
"start",
"(",
")",
";",
"final",
"PatternLayoutEncoder",
"encoder",
"=",
"new",
"PatternLayoutEncoder",
"(",
")",
";",
"encoder",
".",
"setContext",
"(",
"loggerContext",
")",
";",
"encoder",
".",
"setPattern",
"(",
"\"%-5level %d %X{deviceName} - %thread | %logger{25}.%M:%L - %msg%n\"",
")",
";",
"encoder",
".",
"start",
"(",
")",
";",
"rfAppender",
".",
"setEncoder",
"(",
"encoder",
")",
";",
"rfAppender",
".",
"setRollingPolicy",
"(",
"rollingPolicy",
")",
";",
"rfAppender",
".",
"setTriggeringPolicy",
"(",
"triggeringPolicy",
")",
";",
"rfAppender",
".",
"start",
"(",
")",
";",
"rootLoggerBack",
".",
"addAppender",
"(",
"rfAppender",
")",
";",
"rfAppender",
".",
"start",
"(",
")",
";",
"// OPTIONAL: print logback internal status messages",
"// StatusPrinter.print(loggerContext);",
"}",
"}"
] | Add an file appender for a device
@param fileName
@param deviceName
@throws DevFailed | [
"Add",
"an",
"file",
"appender",
"for",
"a",
"device"
] | 1ccc9dcb83e6de2359a9f1906d170571cacf1345 | https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/server/src/main/java/org/tango/logging/LoggingManager.java#L197-L257 |
140,187 | tango-controls/JTango | server/src/main/java/org/tango/server/export/TangoExporter.java | TangoExporter.exportAll | @Override
public void exportAll() throws DevFailed {
// load tango db cache
DatabaseFactory.getDatabase().loadCache(serverName, hostName);
// special case for admin device
final DeviceClassBuilder clazz = new DeviceClassBuilder(AdminDevice.class, Constants.ADMIN_SERVER_CLASS_NAME);
deviceClassList.add(clazz);
final DeviceImpl dev = buildDevice(Constants.ADMIN_DEVICE_DOMAIN + "/" + serverName, clazz);
((AdminDevice) dev.getBusinessObject()).setTangoExporter(this);
((AdminDevice) dev.getBusinessObject()).setClassList(deviceClassList);
// load server class
exportDevices();
// init polling pool config
TangoCacheManager.initPoolConf();
// clear tango db cache (used only for server start-up phase)
DatabaseFactory.getDatabase().clearCache();
} | java | @Override
public void exportAll() throws DevFailed {
// load tango db cache
DatabaseFactory.getDatabase().loadCache(serverName, hostName);
// special case for admin device
final DeviceClassBuilder clazz = new DeviceClassBuilder(AdminDevice.class, Constants.ADMIN_SERVER_CLASS_NAME);
deviceClassList.add(clazz);
final DeviceImpl dev = buildDevice(Constants.ADMIN_DEVICE_DOMAIN + "/" + serverName, clazz);
((AdminDevice) dev.getBusinessObject()).setTangoExporter(this);
((AdminDevice) dev.getBusinessObject()).setClassList(deviceClassList);
// load server class
exportDevices();
// init polling pool config
TangoCacheManager.initPoolConf();
// clear tango db cache (used only for server start-up phase)
DatabaseFactory.getDatabase().clearCache();
} | [
"@",
"Override",
"public",
"void",
"exportAll",
"(",
")",
"throws",
"DevFailed",
"{",
"// load tango db cache",
"DatabaseFactory",
".",
"getDatabase",
"(",
")",
".",
"loadCache",
"(",
"serverName",
",",
"hostName",
")",
";",
"// special case for admin device",
"final",
"DeviceClassBuilder",
"clazz",
"=",
"new",
"DeviceClassBuilder",
"(",
"AdminDevice",
".",
"class",
",",
"Constants",
".",
"ADMIN_SERVER_CLASS_NAME",
")",
";",
"deviceClassList",
".",
"add",
"(",
"clazz",
")",
";",
"final",
"DeviceImpl",
"dev",
"=",
"buildDevice",
"(",
"Constants",
".",
"ADMIN_DEVICE_DOMAIN",
"+",
"\"/\"",
"+",
"serverName",
",",
"clazz",
")",
";",
"(",
"(",
"AdminDevice",
")",
"dev",
".",
"getBusinessObject",
"(",
")",
")",
".",
"setTangoExporter",
"(",
"this",
")",
";",
"(",
"(",
"AdminDevice",
")",
"dev",
".",
"getBusinessObject",
"(",
")",
")",
".",
"setClassList",
"(",
"deviceClassList",
")",
";",
"// load server class",
"exportDevices",
"(",
")",
";",
"// init polling pool config",
"TangoCacheManager",
".",
"initPoolConf",
"(",
")",
";",
"// clear tango db cache (used only for server start-up phase)",
"DatabaseFactory",
".",
"getDatabase",
"(",
")",
".",
"clearCache",
"(",
")",
";",
"}"
] | Build all devices of all classes that are is this executable
@throws DevFailed | [
"Build",
"all",
"devices",
"of",
"all",
"classes",
"that",
"are",
"is",
"this",
"executable"
] | 1ccc9dcb83e6de2359a9f1906d170571cacf1345 | https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/server/src/main/java/org/tango/server/export/TangoExporter.java#L75-L94 |
140,188 | tango-controls/JTango | server/src/main/java/org/tango/server/export/TangoExporter.java | TangoExporter.exportDevices | @Override
public void exportDevices() throws DevFailed {
// load server class
for (final Entry<String, Class<?>> entry : tangoClasses.entrySet()) {
final String tangoClass = entry.getKey();
final Class<?> deviceClass = entry.getValue();
logger.debug("loading class {}", deviceClass.getCanonicalName());
final DeviceClassBuilder deviceClassBuilder = new DeviceClassBuilder(deviceClass, tangoClass);
deviceClassList.add(deviceClassBuilder);
// export all its devices
final String[] deviceList = DatabaseFactory.getDatabase().getDeviceList(serverName, tangoClass);
logger.debug("devices found {}", Arrays.toString(deviceList));
// if (deviceList.length == 0) {
// throw DevFailedUtils.newDevFailed(ExceptionMessages.DB_ACCESS, "No device defined in database for class "
// + tangoClass);
// }
for (final String deviceName : deviceList) {
buildDevice(deviceName, deviceClassBuilder);
}
}
} | java | @Override
public void exportDevices() throws DevFailed {
// load server class
for (final Entry<String, Class<?>> entry : tangoClasses.entrySet()) {
final String tangoClass = entry.getKey();
final Class<?> deviceClass = entry.getValue();
logger.debug("loading class {}", deviceClass.getCanonicalName());
final DeviceClassBuilder deviceClassBuilder = new DeviceClassBuilder(deviceClass, tangoClass);
deviceClassList.add(deviceClassBuilder);
// export all its devices
final String[] deviceList = DatabaseFactory.getDatabase().getDeviceList(serverName, tangoClass);
logger.debug("devices found {}", Arrays.toString(deviceList));
// if (deviceList.length == 0) {
// throw DevFailedUtils.newDevFailed(ExceptionMessages.DB_ACCESS, "No device defined in database for class "
// + tangoClass);
// }
for (final String deviceName : deviceList) {
buildDevice(deviceName, deviceClassBuilder);
}
}
} | [
"@",
"Override",
"public",
"void",
"exportDevices",
"(",
")",
"throws",
"DevFailed",
"{",
"// load server class",
"for",
"(",
"final",
"Entry",
"<",
"String",
",",
"Class",
"<",
"?",
">",
">",
"entry",
":",
"tangoClasses",
".",
"entrySet",
"(",
")",
")",
"{",
"final",
"String",
"tangoClass",
"=",
"entry",
".",
"getKey",
"(",
")",
";",
"final",
"Class",
"<",
"?",
">",
"deviceClass",
"=",
"entry",
".",
"getValue",
"(",
")",
";",
"logger",
".",
"debug",
"(",
"\"loading class {}\"",
",",
"deviceClass",
".",
"getCanonicalName",
"(",
")",
")",
";",
"final",
"DeviceClassBuilder",
"deviceClassBuilder",
"=",
"new",
"DeviceClassBuilder",
"(",
"deviceClass",
",",
"tangoClass",
")",
";",
"deviceClassList",
".",
"add",
"(",
"deviceClassBuilder",
")",
";",
"// export all its devices",
"final",
"String",
"[",
"]",
"deviceList",
"=",
"DatabaseFactory",
".",
"getDatabase",
"(",
")",
".",
"getDeviceList",
"(",
"serverName",
",",
"tangoClass",
")",
";",
"logger",
".",
"debug",
"(",
"\"devices found {}\"",
",",
"Arrays",
".",
"toString",
"(",
"deviceList",
")",
")",
";",
"// if (deviceList.length == 0) {",
"// throw DevFailedUtils.newDevFailed(ExceptionMessages.DB_ACCESS, \"No device defined in database for class \"",
"// + tangoClass);",
"// }",
"for",
"(",
"final",
"String",
"deviceName",
":",
"deviceList",
")",
"{",
"buildDevice",
"(",
"deviceName",
",",
"deviceClassBuilder",
")",
";",
"}",
"}",
"}"
] | Export all devices except admin device
@throws DevFailed | [
"Export",
"all",
"devices",
"except",
"admin",
"device"
] | 1ccc9dcb83e6de2359a9f1906d170571cacf1345 | https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/server/src/main/java/org/tango/server/export/TangoExporter.java#L101-L121 |
140,189 | tango-controls/JTango | server/src/main/java/org/tango/server/export/TangoExporter.java | TangoExporter.unexportDevices | @Override
public void unexportDevices() throws DevFailed {
xlogger.entry();
final List<DeviceClassBuilder> clazzToRemove = new ArrayList<DeviceClassBuilder>();
for (final DeviceClassBuilder clazz : deviceClassList) {
if (!clazz.getDeviceClass().equals(AdminDevice.class)) {
for (final DeviceImpl device : clazz.getDeviceImplList()) {
logger.debug("unexport device {}", device.getName());
ORBUtils.unexportDevice(device);
}
clazz.clearDevices();
clazzToRemove.add(clazz);
}
}
for (final DeviceClassBuilder deviceClassBuilder : clazzToRemove) {
deviceClassList.remove(deviceClassBuilder);
}
// unregisterServer();
// deviceClassList.clear();
xlogger.exit();
} | java | @Override
public void unexportDevices() throws DevFailed {
xlogger.entry();
final List<DeviceClassBuilder> clazzToRemove = new ArrayList<DeviceClassBuilder>();
for (final DeviceClassBuilder clazz : deviceClassList) {
if (!clazz.getDeviceClass().equals(AdminDevice.class)) {
for (final DeviceImpl device : clazz.getDeviceImplList()) {
logger.debug("unexport device {}", device.getName());
ORBUtils.unexportDevice(device);
}
clazz.clearDevices();
clazzToRemove.add(clazz);
}
}
for (final DeviceClassBuilder deviceClassBuilder : clazzToRemove) {
deviceClassList.remove(deviceClassBuilder);
}
// unregisterServer();
// deviceClassList.clear();
xlogger.exit();
} | [
"@",
"Override",
"public",
"void",
"unexportDevices",
"(",
")",
"throws",
"DevFailed",
"{",
"xlogger",
".",
"entry",
"(",
")",
";",
"final",
"List",
"<",
"DeviceClassBuilder",
">",
"clazzToRemove",
"=",
"new",
"ArrayList",
"<",
"DeviceClassBuilder",
">",
"(",
")",
";",
"for",
"(",
"final",
"DeviceClassBuilder",
"clazz",
":",
"deviceClassList",
")",
"{",
"if",
"(",
"!",
"clazz",
".",
"getDeviceClass",
"(",
")",
".",
"equals",
"(",
"AdminDevice",
".",
"class",
")",
")",
"{",
"for",
"(",
"final",
"DeviceImpl",
"device",
":",
"clazz",
".",
"getDeviceImplList",
"(",
")",
")",
"{",
"logger",
".",
"debug",
"(",
"\"unexport device {}\"",
",",
"device",
".",
"getName",
"(",
")",
")",
";",
"ORBUtils",
".",
"unexportDevice",
"(",
"device",
")",
";",
"}",
"clazz",
".",
"clearDevices",
"(",
")",
";",
"clazzToRemove",
".",
"add",
"(",
"clazz",
")",
";",
"}",
"}",
"for",
"(",
"final",
"DeviceClassBuilder",
"deviceClassBuilder",
":",
"clazzToRemove",
")",
"{",
"deviceClassList",
".",
"remove",
"(",
"deviceClassBuilder",
")",
";",
"}",
"// unregisterServer();",
"// deviceClassList.clear();",
"xlogger",
".",
"exit",
"(",
")",
";",
"}"
] | Unexport all except admin device
@throws DevFailed | [
"Unexport",
"all",
"except",
"admin",
"device"
] | 1ccc9dcb83e6de2359a9f1906d170571cacf1345 | https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/server/src/main/java/org/tango/server/export/TangoExporter.java#L128-L148 |
140,190 | tango-controls/JTango | server/src/main/java/org/tango/server/properties/DevicePropertiesImpl.java | DevicePropertiesImpl.update | public void update() throws DevFailed {
xlogger.entry();
final Map<String, String[]> property = PropertiesUtils.getDeviceProperties(deviceName);
if (property != null && property.size() != 0) {
try {
propertyMethod.invoke(businessObject, property);
} catch (final IllegalArgumentException e) {
throw DevFailedUtils.newDevFailed(e);
} catch (final IllegalAccessException e) {
throw DevFailedUtils.newDevFailed(e);
} catch (final SecurityException e) {
throw DevFailedUtils.newDevFailed(e);
} catch (final InvocationTargetException e) {
throw DevFailedUtils.newDevFailed(e);
}
}
xlogger.exit();
} | java | public void update() throws DevFailed {
xlogger.entry();
final Map<String, String[]> property = PropertiesUtils.getDeviceProperties(deviceName);
if (property != null && property.size() != 0) {
try {
propertyMethod.invoke(businessObject, property);
} catch (final IllegalArgumentException e) {
throw DevFailedUtils.newDevFailed(e);
} catch (final IllegalAccessException e) {
throw DevFailedUtils.newDevFailed(e);
} catch (final SecurityException e) {
throw DevFailedUtils.newDevFailed(e);
} catch (final InvocationTargetException e) {
throw DevFailedUtils.newDevFailed(e);
}
}
xlogger.exit();
} | [
"public",
"void",
"update",
"(",
")",
"throws",
"DevFailed",
"{",
"xlogger",
".",
"entry",
"(",
")",
";",
"final",
"Map",
"<",
"String",
",",
"String",
"[",
"]",
">",
"property",
"=",
"PropertiesUtils",
".",
"getDeviceProperties",
"(",
"deviceName",
")",
";",
"if",
"(",
"property",
"!=",
"null",
"&&",
"property",
".",
"size",
"(",
")",
"!=",
"0",
")",
"{",
"try",
"{",
"propertyMethod",
".",
"invoke",
"(",
"businessObject",
",",
"property",
")",
";",
"}",
"catch",
"(",
"final",
"IllegalArgumentException",
"e",
")",
"{",
"throw",
"DevFailedUtils",
".",
"newDevFailed",
"(",
"e",
")",
";",
"}",
"catch",
"(",
"final",
"IllegalAccessException",
"e",
")",
"{",
"throw",
"DevFailedUtils",
".",
"newDevFailed",
"(",
"e",
")",
";",
"}",
"catch",
"(",
"final",
"SecurityException",
"e",
")",
"{",
"throw",
"DevFailedUtils",
".",
"newDevFailed",
"(",
"e",
")",
";",
"}",
"catch",
"(",
"final",
"InvocationTargetException",
"e",
")",
"{",
"throw",
"DevFailedUtils",
".",
"newDevFailed",
"(",
"e",
")",
";",
"}",
"}",
"xlogger",
".",
"exit",
"(",
")",
";",
"}"
] | update all properties and values of this device
@throws DevFailed | [
"update",
"all",
"properties",
"and",
"values",
"of",
"this",
"device"
] | 1ccc9dcb83e6de2359a9f1906d170571cacf1345 | https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/server/src/main/java/org/tango/server/properties/DevicePropertiesImpl.java#L55-L73 |
140,191 | tango-controls/JTango | client/src/main/java/fr/esrf/TangoApi/Group/AttributeGroup.java | AttributeGroup.add | private synchronized void add(final String... attributes) throws DevFailed {
userAttributesNames = new String[attributes.length];
devices = new DeviceProxy[attributes.length];
int i = 0;
for (final String attributeName : attributes) {
final String deviceName = TangoUtil.getfullDeviceNameForAttribute(attributeName)
.toLowerCase(Locale.ENGLISH);
final String fullAttribute = TangoUtil.getfullAttributeNameForAttribute(attributeName).toLowerCase(
Locale.ENGLISH);
userAttributesNames[i] = fullAttribute;
try {
final DeviceProxy device = ProxyFactory.getInstance().createDeviceProxy(deviceName);
devices[i++] = device;
if (!devicesMap.containsKey(deviceName)) {
devicesMap.put(deviceName, device);
}
} catch (final DevFailed e) {
if (throwExceptions) {
throw e;
} else {
devices[i++] = null;
if (!devicesMap.containsKey(deviceName)) {
devicesMap.put(deviceName, null);
}
}
}
final String attribute = fullAttribute.split("/")[3];
if (!attributesMap.containsKey(deviceName)) {
final List<String> attributesNames = new ArrayList<String>();
attributesNames.add(attribute);
attributesMap.put(deviceName, attributesNames);
} else {
attributesMap.get(deviceName).add(attribute);
}
}
} | java | private synchronized void add(final String... attributes) throws DevFailed {
userAttributesNames = new String[attributes.length];
devices = new DeviceProxy[attributes.length];
int i = 0;
for (final String attributeName : attributes) {
final String deviceName = TangoUtil.getfullDeviceNameForAttribute(attributeName)
.toLowerCase(Locale.ENGLISH);
final String fullAttribute = TangoUtil.getfullAttributeNameForAttribute(attributeName).toLowerCase(
Locale.ENGLISH);
userAttributesNames[i] = fullAttribute;
try {
final DeviceProxy device = ProxyFactory.getInstance().createDeviceProxy(deviceName);
devices[i++] = device;
if (!devicesMap.containsKey(deviceName)) {
devicesMap.put(deviceName, device);
}
} catch (final DevFailed e) {
if (throwExceptions) {
throw e;
} else {
devices[i++] = null;
if (!devicesMap.containsKey(deviceName)) {
devicesMap.put(deviceName, null);
}
}
}
final String attribute = fullAttribute.split("/")[3];
if (!attributesMap.containsKey(deviceName)) {
final List<String> attributesNames = new ArrayList<String>();
attributesNames.add(attribute);
attributesMap.put(deviceName, attributesNames);
} else {
attributesMap.get(deviceName).add(attribute);
}
}
} | [
"private",
"synchronized",
"void",
"add",
"(",
"final",
"String",
"...",
"attributes",
")",
"throws",
"DevFailed",
"{",
"userAttributesNames",
"=",
"new",
"String",
"[",
"attributes",
".",
"length",
"]",
";",
"devices",
"=",
"new",
"DeviceProxy",
"[",
"attributes",
".",
"length",
"]",
";",
"int",
"i",
"=",
"0",
";",
"for",
"(",
"final",
"String",
"attributeName",
":",
"attributes",
")",
"{",
"final",
"String",
"deviceName",
"=",
"TangoUtil",
".",
"getfullDeviceNameForAttribute",
"(",
"attributeName",
")",
".",
"toLowerCase",
"(",
"Locale",
".",
"ENGLISH",
")",
";",
"final",
"String",
"fullAttribute",
"=",
"TangoUtil",
".",
"getfullAttributeNameForAttribute",
"(",
"attributeName",
")",
".",
"toLowerCase",
"(",
"Locale",
".",
"ENGLISH",
")",
";",
"userAttributesNames",
"[",
"i",
"]",
"=",
"fullAttribute",
";",
"try",
"{",
"final",
"DeviceProxy",
"device",
"=",
"ProxyFactory",
".",
"getInstance",
"(",
")",
".",
"createDeviceProxy",
"(",
"deviceName",
")",
";",
"devices",
"[",
"i",
"++",
"]",
"=",
"device",
";",
"if",
"(",
"!",
"devicesMap",
".",
"containsKey",
"(",
"deviceName",
")",
")",
"{",
"devicesMap",
".",
"put",
"(",
"deviceName",
",",
"device",
")",
";",
"}",
"}",
"catch",
"(",
"final",
"DevFailed",
"e",
")",
"{",
"if",
"(",
"throwExceptions",
")",
"{",
"throw",
"e",
";",
"}",
"else",
"{",
"devices",
"[",
"i",
"++",
"]",
"=",
"null",
";",
"if",
"(",
"!",
"devicesMap",
".",
"containsKey",
"(",
"deviceName",
")",
")",
"{",
"devicesMap",
".",
"put",
"(",
"deviceName",
",",
"null",
")",
";",
"}",
"}",
"}",
"final",
"String",
"attribute",
"=",
"fullAttribute",
".",
"split",
"(",
"\"/\"",
")",
"[",
"3",
"]",
";",
"if",
"(",
"!",
"attributesMap",
".",
"containsKey",
"(",
"deviceName",
")",
")",
"{",
"final",
"List",
"<",
"String",
">",
"attributesNames",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"attributesNames",
".",
"add",
"(",
"attribute",
")",
";",
"attributesMap",
".",
"put",
"(",
"deviceName",
",",
"attributesNames",
")",
";",
"}",
"else",
"{",
"attributesMap",
".",
"get",
"(",
"deviceName",
")",
".",
"add",
"(",
"attribute",
")",
";",
"}",
"}",
"}"
] | Add a list of devices in the group or add a list of patterns
@param attributes
The attribute list
@throws DevFailed | [
"Add",
"a",
"list",
"of",
"devices",
"in",
"the",
"group",
"or",
"add",
"a",
"list",
"of",
"patterns"
] | 1ccc9dcb83e6de2359a9f1906d170571cacf1345 | https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/client/src/main/java/fr/esrf/TangoApi/Group/AttributeGroup.java#L90-L125 |
140,192 | tango-controls/JTango | client/src/main/java/fr/soleil/tango/clientapi/util/TypeConversionUtil.java | TypeConversionUtil.getWritePart | public static Object getWritePart(final Object array, final AttrWriteType writeType) {
if (writeType.equals(AttrWriteType.READ_WRITE)) {
return Array.get(array, 1);
} else {
return Array.get(array, 0);
}
} | java | public static Object getWritePart(final Object array, final AttrWriteType writeType) {
if (writeType.equals(AttrWriteType.READ_WRITE)) {
return Array.get(array, 1);
} else {
return Array.get(array, 0);
}
} | [
"public",
"static",
"Object",
"getWritePart",
"(",
"final",
"Object",
"array",
",",
"final",
"AttrWriteType",
"writeType",
")",
"{",
"if",
"(",
"writeType",
".",
"equals",
"(",
"AttrWriteType",
".",
"READ_WRITE",
")",
")",
"{",
"return",
"Array",
".",
"get",
"(",
"array",
",",
"1",
")",
";",
"}",
"else",
"{",
"return",
"Array",
".",
"get",
"(",
"array",
",",
"0",
")",
";",
"}",
"}"
] | Extract the write part of a scalar attribute
@param array
@param writeType
@return | [
"Extract",
"the",
"write",
"part",
"of",
"a",
"scalar",
"attribute"
] | 1ccc9dcb83e6de2359a9f1906d170571cacf1345 | https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/client/src/main/java/fr/soleil/tango/clientapi/util/TypeConversionUtil.java#L35-L41 |
140,193 | tango-controls/JTango | client/src/main/java/fr/soleil/tango/clientapi/util/TypeConversionUtil.java | TypeConversionUtil.castToType | @SuppressWarnings("unchecked")
public static <T> T castToType(final Class<T> type, final Object val) throws DevFailed {
T result;
if (val == null) {
result = null;
} else if (type.isAssignableFrom(val.getClass())) {
result = (T) val;
} else {
LOGGER.debug("converting {} to {}", val.getClass().getCanonicalName(), type.getCanonicalName());
// if input is not an array and we want to convert it to an array.
// Put
// the value in an array
Object array = val;
if (!val.getClass().isArray() && type.isArray()) {
array = Array.newInstance(val.getClass(), 1);
Array.set(array, 0, val);
}
final Transmorph transmorph = new Transmorph(creatConv());
try {
result = transmorph.convert(array, type);
} catch (final ConverterException e) {
LOGGER.error("convertion error", e);
throw DevFailedUtils.newDevFailed(e);
}
}
return result;
} | java | @SuppressWarnings("unchecked")
public static <T> T castToType(final Class<T> type, final Object val) throws DevFailed {
T result;
if (val == null) {
result = null;
} else if (type.isAssignableFrom(val.getClass())) {
result = (T) val;
} else {
LOGGER.debug("converting {} to {}", val.getClass().getCanonicalName(), type.getCanonicalName());
// if input is not an array and we want to convert it to an array.
// Put
// the value in an array
Object array = val;
if (!val.getClass().isArray() && type.isArray()) {
array = Array.newInstance(val.getClass(), 1);
Array.set(array, 0, val);
}
final Transmorph transmorph = new Transmorph(creatConv());
try {
result = transmorph.convert(array, type);
} catch (final ConverterException e) {
LOGGER.error("convertion error", e);
throw DevFailedUtils.newDevFailed(e);
}
}
return result;
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"<",
"T",
">",
"T",
"castToType",
"(",
"final",
"Class",
"<",
"T",
">",
"type",
",",
"final",
"Object",
"val",
")",
"throws",
"DevFailed",
"{",
"T",
"result",
";",
"if",
"(",
"val",
"==",
"null",
")",
"{",
"result",
"=",
"null",
";",
"}",
"else",
"if",
"(",
"type",
".",
"isAssignableFrom",
"(",
"val",
".",
"getClass",
"(",
")",
")",
")",
"{",
"result",
"=",
"(",
"T",
")",
"val",
";",
"}",
"else",
"{",
"LOGGER",
".",
"debug",
"(",
"\"converting {} to {}\"",
",",
"val",
".",
"getClass",
"(",
")",
".",
"getCanonicalName",
"(",
")",
",",
"type",
".",
"getCanonicalName",
"(",
")",
")",
";",
"// if input is not an array and we want to convert it to an array.",
"// Put",
"// the value in an array",
"Object",
"array",
"=",
"val",
";",
"if",
"(",
"!",
"val",
".",
"getClass",
"(",
")",
".",
"isArray",
"(",
")",
"&&",
"type",
".",
"isArray",
"(",
")",
")",
"{",
"array",
"=",
"Array",
".",
"newInstance",
"(",
"val",
".",
"getClass",
"(",
")",
",",
"1",
")",
";",
"Array",
".",
"set",
"(",
"array",
",",
"0",
",",
"val",
")",
";",
"}",
"final",
"Transmorph",
"transmorph",
"=",
"new",
"Transmorph",
"(",
"creatConv",
"(",
")",
")",
";",
"try",
"{",
"result",
"=",
"transmorph",
".",
"convert",
"(",
"array",
",",
"type",
")",
";",
"}",
"catch",
"(",
"final",
"ConverterException",
"e",
")",
"{",
"LOGGER",
".",
"error",
"(",
"\"convertion error\"",
",",
"e",
")",
";",
"throw",
"DevFailedUtils",
".",
"newDevFailed",
"(",
"e",
")",
";",
"}",
"}",
"return",
"result",
";",
"}"
] | Convert an object to another object.
@see Transmorph
@param <T>
@param type
@param val
@return
@throws DevFailed | [
"Convert",
"an",
"object",
"to",
"another",
"object",
"."
] | 1ccc9dcb83e6de2359a9f1906d170571cacf1345 | https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/client/src/main/java/fr/soleil/tango/clientapi/util/TypeConversionUtil.java#L94-L121 |
140,194 | tango-controls/JTango | client/src/main/java/fr/soleil/tango/clientapi/util/TypeConversionUtil.java | TypeConversionUtil.extractReadOrWrite | public static Object extractReadOrWrite(final Part part, final DeviceAttribute da, final Object readWrite)
throws DevFailed {
// separate read and written values
final Object result;
final int dimRead;
if (da.getDimY() != 0) {
dimRead = da.getDimX() * da.getDimY();
} else {
dimRead = da.getDimX();
}
if (Array.getLength(readWrite) < dimRead) {
result = readWrite;
} else if (Part.READ.equals(part)) {
result = Array.newInstance(readWrite.getClass().getComponentType(), dimRead);
System.arraycopy(readWrite, 0, result, 0, dimRead);
} else {
result = Array.newInstance(readWrite.getClass().getComponentType(), Array.getLength(readWrite) - dimRead);
System.arraycopy(readWrite, dimRead, result, 0, Array.getLength(result));
}
return result;
} | java | public static Object extractReadOrWrite(final Part part, final DeviceAttribute da, final Object readWrite)
throws DevFailed {
// separate read and written values
final Object result;
final int dimRead;
if (da.getDimY() != 0) {
dimRead = da.getDimX() * da.getDimY();
} else {
dimRead = da.getDimX();
}
if (Array.getLength(readWrite) < dimRead) {
result = readWrite;
} else if (Part.READ.equals(part)) {
result = Array.newInstance(readWrite.getClass().getComponentType(), dimRead);
System.arraycopy(readWrite, 0, result, 0, dimRead);
} else {
result = Array.newInstance(readWrite.getClass().getComponentType(), Array.getLength(readWrite) - dimRead);
System.arraycopy(readWrite, dimRead, result, 0, Array.getLength(result));
}
return result;
} | [
"public",
"static",
"Object",
"extractReadOrWrite",
"(",
"final",
"Part",
"part",
",",
"final",
"DeviceAttribute",
"da",
",",
"final",
"Object",
"readWrite",
")",
"throws",
"DevFailed",
"{",
"// separate read and written values",
"final",
"Object",
"result",
";",
"final",
"int",
"dimRead",
";",
"if",
"(",
"da",
".",
"getDimY",
"(",
")",
"!=",
"0",
")",
"{",
"dimRead",
"=",
"da",
".",
"getDimX",
"(",
")",
"*",
"da",
".",
"getDimY",
"(",
")",
";",
"}",
"else",
"{",
"dimRead",
"=",
"da",
".",
"getDimX",
"(",
")",
";",
"}",
"if",
"(",
"Array",
".",
"getLength",
"(",
"readWrite",
")",
"<",
"dimRead",
")",
"{",
"result",
"=",
"readWrite",
";",
"}",
"else",
"if",
"(",
"Part",
".",
"READ",
".",
"equals",
"(",
"part",
")",
")",
"{",
"result",
"=",
"Array",
".",
"newInstance",
"(",
"readWrite",
".",
"getClass",
"(",
")",
".",
"getComponentType",
"(",
")",
",",
"dimRead",
")",
";",
"System",
".",
"arraycopy",
"(",
"readWrite",
",",
"0",
",",
"result",
",",
"0",
",",
"dimRead",
")",
";",
"}",
"else",
"{",
"result",
"=",
"Array",
".",
"newInstance",
"(",
"readWrite",
".",
"getClass",
"(",
")",
".",
"getComponentType",
"(",
")",
",",
"Array",
".",
"getLength",
"(",
"readWrite",
")",
"-",
"dimRead",
")",
";",
"System",
".",
"arraycopy",
"(",
"readWrite",
",",
"dimRead",
",",
"result",
",",
"0",
",",
"Array",
".",
"getLength",
"(",
"result",
")",
")",
";",
"}",
"return",
"result",
";",
"}"
] | Extract read or write part of a Tango attribute. For spectrum and image
@param part
@param da
@param readWrite
@return
@throws DevFailed | [
"Extract",
"read",
"or",
"write",
"part",
"of",
"a",
"Tango",
"attribute",
".",
"For",
"spectrum",
"and",
"image"
] | 1ccc9dcb83e6de2359a9f1906d170571cacf1345 | https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/client/src/main/java/fr/soleil/tango/clientapi/util/TypeConversionUtil.java#L143-L165 |
140,195 | tango-controls/JTango | dao/src/main/java/fr/esrf/TangoDs/GetLoggingLevelCmd.java | GetLoggingLevelCmd.execute | public Any execute(DeviceImpl device, Any in_any) throws DevFailed
{
Util.out4.println("GetLoggingLevelCmd::execute(): arrived");
String[] dvsa = null;
try {
dvsa = extract_DevVarStringArray(in_any);
}
catch (DevFailed df) {
Util.out3.println("GetLoggingLevelCmd::execute() --> Wrong argument type");
Except.re_throw_exception(df,
"API_IncompatibleCmdArgumentType",
"Imcompatible command argument type, expected type is : DevVarStringArray",
"GetLoggingLevelCmd.execute");
}
Any out_any = insert(Logging.instance().get_logging_level(dvsa));
Util.out4.println("Leaving GetLoggingLevelCmd.execute()");
return out_any;
} | java | public Any execute(DeviceImpl device, Any in_any) throws DevFailed
{
Util.out4.println("GetLoggingLevelCmd::execute(): arrived");
String[] dvsa = null;
try {
dvsa = extract_DevVarStringArray(in_any);
}
catch (DevFailed df) {
Util.out3.println("GetLoggingLevelCmd::execute() --> Wrong argument type");
Except.re_throw_exception(df,
"API_IncompatibleCmdArgumentType",
"Imcompatible command argument type, expected type is : DevVarStringArray",
"GetLoggingLevelCmd.execute");
}
Any out_any = insert(Logging.instance().get_logging_level(dvsa));
Util.out4.println("Leaving GetLoggingLevelCmd.execute()");
return out_any;
} | [
"public",
"Any",
"execute",
"(",
"DeviceImpl",
"device",
",",
"Any",
"in_any",
")",
"throws",
"DevFailed",
"{",
"Util",
".",
"out4",
".",
"println",
"(",
"\"GetLoggingLevelCmd::execute(): arrived\"",
")",
";",
"String",
"[",
"]",
"dvsa",
"=",
"null",
";",
"try",
"{",
"dvsa",
"=",
"extract_DevVarStringArray",
"(",
"in_any",
")",
";",
"}",
"catch",
"(",
"DevFailed",
"df",
")",
"{",
"Util",
".",
"out3",
".",
"println",
"(",
"\"GetLoggingLevelCmd::execute() --> Wrong argument type\"",
")",
";",
"Except",
".",
"re_throw_exception",
"(",
"df",
",",
"\"API_IncompatibleCmdArgumentType\"",
",",
"\"Imcompatible command argument type, expected type is : DevVarStringArray\"",
",",
"\"GetLoggingLevelCmd.execute\"",
")",
";",
"}",
"Any",
"out_any",
"=",
"insert",
"(",
"Logging",
".",
"instance",
"(",
")",
".",
"get_logging_level",
"(",
"dvsa",
")",
")",
";",
"Util",
".",
"out4",
".",
"println",
"(",
"\"Leaving GetLoggingLevelCmd.execute()\"",
")",
";",
"return",
"out_any",
";",
"}"
] | Executes the GetLoggingLevelCmd TANGO command | [
"Executes",
"the",
"GetLoggingLevelCmd",
"TANGO",
"command"
] | 1ccc9dcb83e6de2359a9f1906d170571cacf1345 | https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/dao/src/main/java/fr/esrf/TangoDs/GetLoggingLevelCmd.java#L55-L76 |
140,196 | tango-controls/JTango | common/src/main/java/org/tango/TangoHostManager.java | TangoHostManager.getFirstFullTangoHost | public static String getFirstFullTangoHost() throws DevFailed {
// TODO
final String TANGO_HOST_ERROR = "API_GetTangoHostFailed";
// Get the tango_host
String host = getFirstHost();
try {
// Get FQDN for host
final InetAddress iadd = InetAddress.getByName(host);
host = iadd.getCanonicalHostName();
} catch (final UnknownHostException e) {
throw DevFailedUtils.newDevFailed(TANGO_HOST_ERROR, e.toString());
}
return host + ':' + getFirstPort();
} | java | public static String getFirstFullTangoHost() throws DevFailed {
// TODO
final String TANGO_HOST_ERROR = "API_GetTangoHostFailed";
// Get the tango_host
String host = getFirstHost();
try {
// Get FQDN for host
final InetAddress iadd = InetAddress.getByName(host);
host = iadd.getCanonicalHostName();
} catch (final UnknownHostException e) {
throw DevFailedUtils.newDevFailed(TANGO_HOST_ERROR, e.toString());
}
return host + ':' + getFirstPort();
} | [
"public",
"static",
"String",
"getFirstFullTangoHost",
"(",
")",
"throws",
"DevFailed",
"{",
"// TODO",
"final",
"String",
"TANGO_HOST_ERROR",
"=",
"\"API_GetTangoHostFailed\"",
";",
"// Get the tango_host",
"String",
"host",
"=",
"getFirstHost",
"(",
")",
";",
"try",
"{",
"// Get FQDN for host",
"final",
"InetAddress",
"iadd",
"=",
"InetAddress",
".",
"getByName",
"(",
"host",
")",
";",
"host",
"=",
"iadd",
".",
"getCanonicalHostName",
"(",
")",
";",
"}",
"catch",
"(",
"final",
"UnknownHostException",
"e",
")",
"{",
"throw",
"DevFailedUtils",
".",
"newDevFailed",
"(",
"TANGO_HOST_ERROR",
",",
"e",
".",
"toString",
"(",
")",
")",
";",
"}",
"return",
"host",
"+",
"'",
"'",
"+",
"getFirstPort",
"(",
")",
";",
"}"
] | Returns the TANGO_HOST with full qualified name.
@param tangoHost default Tango_host
@return the TANGO_HOST with full qualified name.
@throws DevFailed if TANGO_HOST value has a bad syntax. | [
"Returns",
"the",
"TANGO_HOST",
"with",
"full",
"qualified",
"name",
"."
] | 1ccc9dcb83e6de2359a9f1906d170571cacf1345 | https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/common/src/main/java/org/tango/TangoHostManager.java#L103-L119 |
140,197 | tango-controls/JTango | common/src/main/java/fr/esrf/TangoApi/Group/Group.java | Group.get_hierarchy | private Vector get_hierarchy() {
synchronized (this) {
final Vector h = new Vector();
final Iterator it = elements.iterator();
while (it.hasNext()) {
final GroupElement e = (GroupElement) it.next();
if (e instanceof GroupDeviceElement) {
h.add(e);
} else {
h.add(((Group) e).get_hierarchy());
}
}
return h;
}
} | java | private Vector get_hierarchy() {
synchronized (this) {
final Vector h = new Vector();
final Iterator it = elements.iterator();
while (it.hasNext()) {
final GroupElement e = (GroupElement) it.next();
if (e instanceof GroupDeviceElement) {
h.add(e);
} else {
h.add(((Group) e).get_hierarchy());
}
}
return h;
}
} | [
"private",
"Vector",
"get_hierarchy",
"(",
")",
"{",
"synchronized",
"(",
"this",
")",
"{",
"final",
"Vector",
"h",
"=",
"new",
"Vector",
"(",
")",
";",
"final",
"Iterator",
"it",
"=",
"elements",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"it",
".",
"hasNext",
"(",
")",
")",
"{",
"final",
"GroupElement",
"e",
"=",
"(",
"GroupElement",
")",
"it",
".",
"next",
"(",
")",
";",
"if",
"(",
"e",
"instanceof",
"GroupDeviceElement",
")",
"{",
"h",
".",
"add",
"(",
"e",
")",
";",
"}",
"else",
"{",
"h",
".",
"add",
"(",
"(",
"(",
"Group",
")",
"e",
")",
".",
"get_hierarchy",
"(",
")",
")",
";",
"}",
"}",
"return",
"h",
";",
"}",
"}"
] | Returns the group's hierarchy | [
"Returns",
"the",
"group",
"s",
"hierarchy"
] | 1ccc9dcb83e6de2359a9f1906d170571cacf1345 | https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/common/src/main/java/fr/esrf/TangoApi/Group/Group.java#L423-L437 |
140,198 | tango-controls/JTango | common/src/main/java/fr/esrf/TangoApi/Group/Group.java | Group.get_size_i | private int get_size_i(final boolean fwd) {
int size = 0;
final Iterator it = elements.iterator();
while (it.hasNext()) {
final GroupElement e = (GroupElement) it.next();
if (e instanceof GroupDeviceElement || fwd) {
size += e.get_size(true);
}
}
return size;
} | java | private int get_size_i(final boolean fwd) {
int size = 0;
final Iterator it = elements.iterator();
while (it.hasNext()) {
final GroupElement e = (GroupElement) it.next();
if (e instanceof GroupDeviceElement || fwd) {
size += e.get_size(true);
}
}
return size;
} | [
"private",
"int",
"get_size_i",
"(",
"final",
"boolean",
"fwd",
")",
"{",
"int",
"size",
"=",
"0",
";",
"final",
"Iterator",
"it",
"=",
"elements",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"it",
".",
"hasNext",
"(",
")",
")",
"{",
"final",
"GroupElement",
"e",
"=",
"(",
"GroupElement",
")",
"it",
".",
"next",
"(",
")",
";",
"if",
"(",
"e",
"instanceof",
"GroupDeviceElement",
"||",
"fwd",
")",
"{",
"size",
"+=",
"e",
".",
"get_size",
"(",
"true",
")",
";",
"}",
"}",
"return",
"size",
";",
"}"
] | Returns the group's size - internal impl | [
"Returns",
"the",
"group",
"s",
"size",
"-",
"internal",
"impl"
] | 1ccc9dcb83e6de2359a9f1906d170571cacf1345 | https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/common/src/main/java/fr/esrf/TangoApi/Group/Group.java#L440-L450 |
140,199 | tango-controls/JTango | common/src/main/java/fr/esrf/TangoApi/Group/Group.java | Group.add_i | private boolean add_i(final GroupElement e) {
if (e == null || e == this) {
// -DEBUG
System.out.println("Group::add_i::failed to add " + e.get_name() + " (null or self)");
return false;
}
final GroupElement ge = find_i(e.get_name(), e instanceof Group ? false : true);
if (ge != null && ge != this) {
// -DEBUG
System.out.println("Group::add_i::failed to add " + e.get_name() + " (already attached)");
return false;
}
elements.add(e);
e.set_parent(this);
return true;
} | java | private boolean add_i(final GroupElement e) {
if (e == null || e == this) {
// -DEBUG
System.out.println("Group::add_i::failed to add " + e.get_name() + " (null or self)");
return false;
}
final GroupElement ge = find_i(e.get_name(), e instanceof Group ? false : true);
if (ge != null && ge != this) {
// -DEBUG
System.out.println("Group::add_i::failed to add " + e.get_name() + " (already attached)");
return false;
}
elements.add(e);
e.set_parent(this);
return true;
} | [
"private",
"boolean",
"add_i",
"(",
"final",
"GroupElement",
"e",
")",
"{",
"if",
"(",
"e",
"==",
"null",
"||",
"e",
"==",
"this",
")",
"{",
"// -DEBUG",
"System",
".",
"out",
".",
"println",
"(",
"\"Group::add_i::failed to add \"",
"+",
"e",
".",
"get_name",
"(",
")",
"+",
"\" (null or self)\"",
")",
";",
"return",
"false",
";",
"}",
"final",
"GroupElement",
"ge",
"=",
"find_i",
"(",
"e",
".",
"get_name",
"(",
")",
",",
"e",
"instanceof",
"Group",
"?",
"false",
":",
"true",
")",
";",
"if",
"(",
"ge",
"!=",
"null",
"&&",
"ge",
"!=",
"this",
")",
"{",
"// -DEBUG",
"System",
".",
"out",
".",
"println",
"(",
"\"Group::add_i::failed to add \"",
"+",
"e",
".",
"get_name",
"(",
")",
"+",
"\" (already attached)\"",
")",
";",
"return",
"false",
";",
"}",
"elements",
".",
"add",
"(",
"e",
")",
";",
"e",
".",
"set_parent",
"(",
"this",
")",
";",
"return",
"true",
";",
"}"
] | Adds an element to the group | [
"Adds",
"an",
"element",
"to",
"the",
"group"
] | 1ccc9dcb83e6de2359a9f1906d170571cacf1345 | https://github.com/tango-controls/JTango/blob/1ccc9dcb83e6de2359a9f1906d170571cacf1345/common/src/main/java/fr/esrf/TangoApi/Group/Group.java#L492-L507 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.