code
stringlengths
73
34.1k
label
stringclasses
1 value
public Font getFont( int code ) { Style s = _tokenStyles.get( new Integer( code ) ); if( s == null ) { s = getStyle( DEFAULT_STYLE ); } return getFont( s ); }
java
public Style getStyleForScanValue( int code ) { Style s = _tokenStyles.get( new Integer( code ) ); if( s == null ) { s = getStyle( DEFAULT_STYLE ); } return s; }
java
@Override public Font getFont( AttributeSet attr ) { boolean bUnderline = StyleConstants.isUnderline( attr ); boolean bStrikethrough = StyleConstants.isStrikeThrough( attr ); if( !bUnderline && !bStrikethrough ) { // StyleContext ignores the Underline and Strikethrough attribute return ...
java
public static GosuPathEntry createPathEntryForModuleFile(IFile moduleFile) { try { InputStream is = moduleFile.openInputStream(); try { SimpleXmlNode moduleNode = SimpleXmlNode.parse(is); IDirectory rootDir = moduleFile.getParent(); List<IDirectory> sourceDirs = new ArrayList<ID...
java
private static int minLen(String... patterns) { int minLen = patterns[0].length(); for (String str : patterns) { if (str.length() < minLen) { minLen = str.length(); } } return minLen; }
java
private int rollHash(int hashvalue, String str, int i) { // 'roll' hash char outchar = str.charAt(str.length() - 1 - i); char inchar = str.charAt(str.length() - _block - 1 - i); hashvalue = A * hashvalue + CHAR_HASHES[inchar] - _Apowblock * CHAR_HASHES[outchar]; return hashvalue; }
java
private int reverseHash(String str) { int hash = 0; int len = str.length(); for (int i = 0; i < _block; i++) { char c = str.charAt(len - i - 1); hash = A * hash + CHAR_HASHES[c]; } return hash; }
java
@Override public void insertString( int offset, String str, AttributeSet a ) throws BadLocationException { switch( str ) { case "(": str = addParenthesis(); break; case "\n": str = addWhiteSpace( offset ); break; case "\"": str = addMatchingQuotation...
java
public void stopWatching() { try { _watchService.close(); _watchService = null; _watchedDirectories = null; } catch (IOException e) { throw new RuntimeException("Could not stop watching directories!", e); } }
java
public void watchDirectoryTree(Path dir) { if (_watchedDirectories == null) { throw new IllegalStateException("DirectoryWatcher.close() was called. Please make a new instance."); } try { if (Files.exists(dir)) { Files.walkFileTree(dir, new SimpleFileVisitor<Path>() { @Override ...
java
public List getModelUpdatedOrFilteredByPredicate() { List model = getModel(); if( _filter != null ) { model = new ArrayList( model ); //duplicate because, insanely, ColUtil.filter is destructive for( Iterator it = model.iterator(); it.hasNext(); ) { Object o = it.next(); ...
java
private Class getMapType() { Class mapType = Map.class; IParsedElement parent = getParsedElement().getParent(); if( parent instanceof NewExpression ) { IType newType = ((NewExpression)parent).getType(); IJavaClassInfo classInfo = IRTypeResolver.getJavaBackedClass(newType); Class java...
java
private Class getCollectionType() { Class collectionType = Collection.class; IParsedElement parent = getParsedElement().getParent(); if( parent instanceof NewExpression ) { IType newType = ((NewExpression)parent).getType(); IJavaClassInfo classInfo = IRTypeResolver.getJavaBackedClass(newTy...
java
public static IRStatement compileInitializerAssignment( TopLevelTransformationContext context, InitializerAssignment stmt, IRExpression root ) { return InitializerAssignmentTransformer.compile( context, stmt, root ); }
java
public void setParent( IParseTree l ) { if( l != null && !l.contains( this ) && getLength() > 0 ) { throw new IllegalArgumentException( "Attempted set the parent location, but the parent location's area is not a superset of this location's area." ); } if( _pe != null ) { ParsedElement ...
java
public boolean areOffsetAndExtentEqual( IParseTree location ) { return location != null && location.getOffset() == getOffset() && location.getExtent() == getExtent(); }
java
public IType getFeatureType() { if( _delegate.getFeatureType().isArray() ) { return _delegate.getFeatureType(); } return _delegate.getFeatureType().getArrayType(); }
java
public static <E> StringBuffer join( String glue, Collection<E> charSequences ) { StringBuffer buf = new StringBuffer(); int i = 0; for( Object charSequence : charSequences ) { if( i > 0 ) { buf.append( glue ); } buf.append( charSequence ); i++; } return b...
java
public static String escapeForJava( String string ) { String result; StringBuffer resultBuffer = null; for( int i = 0, length = string.length(); i < length; i++ ) { char ch = string.charAt( i ); String escape = escapeForJava( ch ); if( escape != null ) { if( resultBuffe...
java
public static <Q> LockingLazyVar<Q> make( final LazyVarInit<Q> init ) { return new LockingLazyVar<Q>(){ protected Q init() { return init.init(); } }; }
java
private List<List<IType>> extractContextTypes( List<? extends IInvocableType> funcTypes ) { if( funcTypes != null ) { ArrayList<List<IType>> returnList = new ArrayList<>(); for( IInvocableType funcType : funcTypes ) { for( int i = 0; i < funcType.getParameterTypes().length; i++ ) ...
java
private List<IFunctionSymbol> maybeAddPrivateFunctionsIfSuperInSamePackage( String name, List<IFunctionSymbol> functions ) { ICompilableTypeInternal gsClass = getGosuClass(); if( gsClass == null ) { return functions; } IType supertype = gsClass.getSupertype(); if( gsClass instanceof IGo...
java
public IConstructorType getConstructorType( IType classBean, Expression[] eArgs, List<IConstructorType> listAllMatchingMethods, ParserBase parserState ) throws ParseException { if( classBean == null ) { throw new ParseException( parserState == null ? null : parserState.makeFullParserState(), Res.MSG_BEA...
java
public Value evaluate( Debugger debugger ) throws InvocationException { RuntimeState runtimeState = getRuntimeState( debugger ); Location suspendedLoc = debugger.getSuspendedLocation(); VirtualMachine vm = suspendedLoc.virtualMachine(); ClassType classType = runtimeState.getCodeRunnerClass( vm ); ...
java
public static List<String> getJreJars() { String javaHome = System.getProperty("java.home"); Path libsDir = FileSystems.getDefault().getPath(javaHome, "/lib"); List<String> retval = GosucUtil.getIbmClasspath(); try { retval.addAll(Files.walk(libsDir) .filter( path -> path.toFile().is...
java
protected static List<String> getIbmClasspath() { List<String> retval = new ArrayList<>(); if(System.getProperty("java.vendor").equals("IBM Corporation")) { String fileSeparator = System.getProperty("file.separator"); String classpathSeparator = System.getProperty("path.separator"); String[] b...
java
public void refresh( Path file ) { EditorHost editor = findTab( file ); if( editor != null ) { // The file is open in an editor, refresh it with the contents of the file try( Reader reader = PathUtil.createReader( file ) ) { editor.refresh( StreamUtil.getContent( reader ) ); ...
java
public static Expression getUnwrappedExpression( Expression expression ) { while( expression instanceof ImplicitTypeAsExpression ) { expression = ((ImplicitTypeAsExpression) expression).getLHS(); } return expression; }
java
private boolean isReadObjectOrWriteObjectMethod( Symbol symbol ) { if ( symbol instanceof DynamicFunctionSymbol ) { DynamicFunctionSymbol dfs = (DynamicFunctionSymbol) symbol; if (dfs.getDisplayName().equals("readObject")) { IType[] argTypes = dfs.getArgTypes(); return argTypes != null &...
java
private boolean areTypeNamesEqual(String name1, String name2) { return name1.replace('$', '.').equals(name2.replace('$', '.')); }
java
public IType getType() { IType type = getTypeImpl(); if (TypeSystem.isDeleted(type)) { type = TypeSystem.getErrorType(); } return type; }
java
private static String xmlEncode(String input, boolean attribute) { if (input == null || input.length() == 0) { return attribute ? "\"\"" : input; } StringBuilder output = new StringBuilder(); if (attribute) { output.append(0); // reserve space for leading quote } char quoteChar = 0; ...
java
public void reassignClassLoader() { ClassLoader loader = _module.getModuleClassLoader(); if( loader.getParent() instanceof IInjectableClassLoader ) { // Dispose the GosuPluginContainer "singleton" and create a new one ((IInjectableClassLoader)loader.getParent()).dispose(); // Dispose the Modul...
java
public Object invoke( Object[] args ) { Object value = getValue(); if( value instanceof ISymbol ) { return ((Symbol)value).invoke( args ); } if( value instanceof IBlock ) { return ((IBlock) value).invokeWithArgs( args ); } Method method = (Method)value; Object ret; ...
java
public static ObjectSize deepSizeOf(Object obj, IObjectSizeFilter filter, int maxObjects) { Map<Object, Object> visited = new IdentityHashMap<Object, Object>(); Stack<ObjectEntry> stack = new Stack<ObjectEntry>(); InvocationCounter sizeHistogram = new InvocationCounter(false); long result = interna...
java
public Object evaluate() { if( !isCompileTimeConstant() ) { return super.evaluate(); } return (Boolean)getCondition().evaluate() ? getFirst().evaluate() : getSecond().evaluate(); }
java
public static int arrayHashCode(Object array) { if (array == null) { return 0; } IType arrayType = TypeSystem.getFromObject(array); int iLen = arrayType.getArrayLength(array); int hashCode = 0; for (int i = 0; i < iLen; i++) { Object value = arrayType.getArrayComponent(array, i); ...
java
public Integer getStyleCodeAtPosition( int iPosition ) { if( _locations == null || _locations.isEmpty() ) { return null; } IParseTree l; try { l = IParseTree.Search.getDeepestLocation( _locations, iPosition - _locationsOffset, true ); } catch( Throwable t ) { // O...
java
private Integer getStyleCodeForParsedElement( int iPosition, IParsedElement parsedElem ) { if( parsedElem instanceof IBeanMethodCallStatement ) { // Always inspect the IBeanMethodCallExpression rather than the corresponding statement parsedElem = ((IBeanMethodCallStatement)parsedElem).getBeanMetho...
java
public int getScannerStart( int p ) { Element elem = getDefaultRootElement(); int lineNum = elem.getElementIndex( p ); Element line = elem.getElement( lineNum ); AttributeSet a = line.getAttributes(); while( a.isDefined( CommentAttribute ) && lineNum > 0 ) { lineNum -= 1; line = el...
java
@Override protected void insertUpdate( DefaultDocumentEvent chng, AttributeSet attr ) { super.insertUpdate( chng, attr ); // Update comment marks Element root = getDefaultRootElement(); DocumentEvent.ElementChange ec = chng.getChange( root ); if( ec != null ) { Element[] added = ec.ge...
java
public static <Q> LocklessLazyVar<Q> make( final LazyVarInit<Q> closure ) { return new LocklessLazyVar<Q>(){ protected Q init() { return closure.init(); } }; }
java
public static IParsedElement boundingParent( List<IParseTree> locations, int position, Class<? extends IParsedElement>... possibleTypes ) { IParseTree location = IParseTree.Search.getDeepestLocation( locations, position, true ); IParsedElement pe = null; if( location != null ) { pe = location.g...
java
public static IParseTree[] findSpanningLogicalRange( IParseTree start, IParseTree end ) { while( end != null ) { IParseTree deepestAtStart = start; while( deepestAtStart != null ) { if( deepestAtStart.isSiblingOf( end ) ) { IParseTree[] returnVal = new IParseTree[2]...
java
public static List<GosuPathEntry> convertClasspathToGosuPathEntries(List<File> classpath) { // this is a hack to prevent loading of gosu directly from jar files in Diamond, // which prevents people from just embedding it in src and thus possibly having ND problems // it can be removed once "modules" are fig...
java
@Override protected ITerminalStatement getLeastSignificantTerminalStatement_internal( boolean[] bAbsolute ) { ITerminalStatement termRet = null; bAbsolute[0] = true; boolean bBreak = false; ITerminalStatement lastCaseTerm = null; if( _cases != null ) { for( int i = 0; i < _cases.length...
java
public static <T extends Annotation> Builder<T> builder(Class<T> annotationType) { return new Builder<T>(annotationType); }
java
public static <T extends Annotation> T create(Class<T> annotationType, Object value) { return new Builder<T>(annotationType).withValue(value).create(); }
java
public static <T extends Annotation> T create(Class<T> annotationType) { return new Builder<T>(annotationType).create(); }
java
public Object evaluate() { if( !isCompileTimeConstant() ) { return super.evaluate(); } Object lhsValue = getLHS().evaluate(); Object rhsValue = getRHS().evaluate(); IType lhsType = getLHS().getType(); IType rhsType = getRHS().getType(); if( _strOperator.equals( ">" ) ) ...
java
public static byte[] toBytes(CharSequence seq) { try { return seq.toString().getBytes("UTF-8"); } catch (UnsupportedEncodingException ex) { throw new RuntimeException(ex); // shouldn't happen since UTF-8 is supported by all JVMs per spec } }
java
public static Properties toProperties(String propFileText) throws CharacterCodingException { CharsetEncoder encoder = Charset.forName("ISO-8859-1").newEncoder().onUnmappableCharacter(CodingErrorAction.REPORT); byte[] bytes = encoder.encode(CharBuffer.wrap(propFileText)).array(); Properties props = new Prope...
java
public static Reader getInputStreamReader(InputStream in, String charset) { try { return new InputStreamReader(in, charset); } catch (UnsupportedEncodingException ex) { throw new RuntimeException(ex); // shouldn't happen since UTF-8 is supported by all JVMs per spec } }
java
public static Writer getOutputStreamWriter(OutputStream out) { try { return new OutputStreamWriter(out, "UTF-8"); } catch (UnsupportedEncodingException ex) { throw new RuntimeException(ex); // shouldn't happen since UTF-8 is supported by all JVMs per spec } }
java
public static byte[] getContent(InputStream in) throws IOException { try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); copy(in, baos); return baos.toByteArray(); } finally { in.close(); } }
java
public static String getContent(Reader in) throws IOException { try { StringWriter sw = new StringWriter(); copy(in, sw); return sw.toString(); } finally { in.close(); } }
java
public static void copy(InputStream in, Writer writer) throws IOException { copy(getInputStreamReader(in), writer); writer.flush(); }
java
public static void copy(Reader reader, OutputStream out) throws IOException { copy(reader, getOutputStreamWriter(out)); out.flush(); }
java
public static void copy(Reader in, Writer out) throws IOException { char[] buf = new char[1024]; while (true) { int count = in.read(buf); if (count < 0) { break; } out.write(buf, 0, count); } out.flush(); }
java
private void forward( MouseWheelEvent e ) { e = new MouseWheelEvent( e.getComponent().getParent(), e.getID(), e.getWhen(), e.getModifiers(), e.getX(), e.getY(), e.getClickCount(), e.isPopupTrigger(), e.getScrollType(), e.getScrollAmount(), e.getWheelRotation() ); Toolkit.getDefaultToolkit().getSystemEventQueu...
java
public static IType parseTypeLiteral(String typeName) { try { IType type = GosuParserFactory.createParser(typeName).parseTypeLiteral(null).getType().getType(); if (type instanceof IErrorType) { throw new RuntimeException("Type not found: " + typeName); } return type; } catch (Par...
java
public static TaskQueue getInstance( ILogger logger, String strQueueName ) { if( strQueueName == null ) { return null; } TaskQueue taskQueue = QUEUE_MAP.get( strQueueName ); if( taskQueue == null ) { taskQueue = new TaskQueue( logger, strQueueName ); QUEUE_MAP.put( strQueueN...
java
public static void emptyAndRemoveQueue( String strQueueName ) { TaskQueue taskQueue = QUEUE_MAP.get( strQueueName ); if( taskQueue != null ) { taskQueue.emptyQueue(); synchronized( taskQueue._queue ) { taskQueue._shutdown = true; taskQueue._queue.notifyAll(); } ...
java
@Override public void run() { while( !_shutdown ) { try { Runnable task; synchronized( _queue ) { while( _queue.isEmpty() ) { if( _shutdown ) { return; } _queue.wait(); } ...
java
protected void log( Throwable t ) { if( _logger == null ) { t.printStackTrace(); } else { _logger.warn( "Error running job.", t ); } }
java
public String toDebugString() { StringBuilder sb = new StringBuilder(); sb.append("GosuPathEntry:\n"); sb.append(" root: ").append(_root.toJavaFile().getAbsolutePath()).append("\n"); for (IDirectory src : _srcs) { sb.append(" src: ").append(src.toJavaFile().getAbsolutePath()).append("\n"); }...
java
public static MethodDescriptor buildScriptableMethodDescriptorNoArgs( Class actionClass, String methodName ) { MethodDescriptor md = _buildMethodDescriptor( actionClass, methodName, EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, EMPTY_CLASS_ARRAY ); makeScriptable( md ); return md; }
java
public static MethodDescriptor buildScriptableMethodDescriptor( Class actionClass, String methodName, String[] parameterNames, Class[] parameterTypes ) { MethodDescriptor md = _buildMethodDescriptor( actionClass, methodName, parameterNames, parameterTypes, parameterTypes ); makeScriptable( md ); retur...
java
public static MethodDescriptor buildScriptableDeprecatedMethodDescriptor( Class actionClass, String methodName, String[] parameterNames, Class[] parameterTypes ) { MethodDescriptor md = _buildMethodDescriptor( actionClass, methodName, parameterNames, parameterTypes, parameterTypes ); makeScriptableDepreca...
java
public static MethodDescriptor buildHiddenMethodDescriptor( Class actionClass, String methodName, String[] parameterNames, Class[] parameterTypes ) { MethodDescriptor md = _buildMethodDescriptor( actionClass, methodName, parameterNames, parameterTypes, parameterTypes ); md.setHidden( true ); return md...
java
static public TypedPropertyDescriptor buildScriptablePropertyDescriptor( String propertyName, Class beanClass, String getterName, String setterName ) { TypedPropertyDescriptor pd = _buildPropertyDescriptor( propertyName, beanClass, getterName, setterName ); makeScriptable( pd ); return pd; }
java
public static boolean isVisible( FeatureDescriptor descriptor, IScriptabilityModifier constraint ) { if( constraint == null ) { return true; } IScriptabilityModifier modifier = getVisibilityModifier( descriptor ); if( modifier == null ) { return true; } return modifier.sa...
java
protected static MethodDescriptor _buildMethodDescriptor( Class actionClass, String methodName, String[] parameterNames, Class[] parameterTypes, Class[] actualParameterTypes ) { MethodDescriptor method; assert (parameterNames.length == parameterTypes.length) : "Number of parameter names different from num...
java
protected static TypedPropertyDescriptor _buildPropertyDescriptor( String propertyName, Class beanClass, String getterName, String setterName ) { try { return new TypedPropertyDescriptor( propertyName, beanClass, getterName, setterName ); } catch( IntrospectionException e ) { throw...
java
private static String makeFqn( File file ) { String path = file.getAbsolutePath(); int srcIndex = path.indexOf( "src" + File.separatorChar ); if( srcIndex >= 0 ) { String fqn = path.substring( srcIndex + 4 ).replace( File.separatorChar, '.' ); return fqn.substring( 0, fqn.lastIndexOf( '.' ...
java
private void assignSuperDfs( IDynamicFunctionSymbol dfsDelegate, IGosuClass owner ) { IDynamicFunctionSymbol rawSuperDfs = dfsDelegate.getSuperDfs(); if( rawSuperDfs instanceof DynamicFunctionSymbol ) { while( rawSuperDfs.getBackingDfs() instanceof DynamicFunctionSymbol && rawSuperDfs.getBackingDfs(...
java
public static Throwable findExceptionCause( Throwable e ) { Throwable error = e; Throwable cause = e; while( (error.getCause() != null) && (error.getCause() != error) ) { cause = error.getCause(); error = cause; } return cause; }
java
public static void throwArgMismatchException( IllegalArgumentException exceptionToWrap, String featureName, Class[] actualParameters, Object[] args ) { String argTypes = "("; for( int i = 0; i < actualParameters.length; i++ ) { Class aClass = actualParameters[i]; if( i > 0 ) { ar...
java
public static <T extends Throwable> T findException(Class<T> exceptionTypeToFind, Throwable t) { Throwable cause = t; while (cause != null) { if( exceptionTypeToFind.isAssignableFrom( cause.getClass() ) ) { //noinspection unchecked return (T)cause; } if( cause == ca...
java
public ParseException removeParseException( ResourceKey keyToRemove ) { if( _lnf != null ) { return (ParseException)removeParseIssue( keyToRemove, _lnf._parseExceptions ); } return null; }
java
@SuppressWarnings("unchecked" ) public <E extends IParsedElement> boolean getContainedParsedElementsByType( Class<E> parsedElementType, List<E> listResults ) { return getContainedParsedElementsByTypes( (List<IParsedElement>)listResults, parsedElementType ); }
java
public String readUntil(String character, boolean includeDeliminator) { return readStreamUntil(_javaProcess.getInputStream(), includeDeliminator, character.toCharArray()); }
java
protected <T extends IService, Q extends T> void defineService(Class<? extends T> service, Q defaultImplementation) { if( !_definingServices ) { throw new IllegalStateException( "Service definition must be done only in the defineServices() method." ); } if( !service.isInterface() ) { t...
java
public void updateState() { /* if( _editor.getCaretPosition() == _iCaretPos ) { if( isOtherPopupShowing() ) { resetSmartHelpState(); } return; } */ resetSmartHelpState(); if( isOtherPopupShowing() ) { return; //don't clobber existing popups } ...
java
@Override public String getCurrentFunctionName() { DynamicFunctionSymbol functionSymbol = _bodyContext.getCurrentDFS(); return (functionSymbol == null ? null : functionSymbol.getName()); }
java
private static boolean isGosuClassAccessingProtectedOrInternalMethodOfClassInDifferentClassloader( ICompilableTypeInternal callingClass, IType declaringClass, IRelativeTypeInfo.Accessibility accessibility ) { return (accessibility != IRelativeTypeInfo.Accessibility.PUBLIC || AccessibilityUtil.forType(...
java
@SuppressWarnings("UnusedDeclaration") public static Bindings fromJson( String json ) { try { return PARSER.get().parseJson( json ); } catch( ScriptException e ) { throw new RuntimeException( e ); } }
java
public static <S, T> Map<S, T> compactAndLockHashMap( HashMap<S, T> map ) { if( map == null || map.isEmpty() ) { return Collections.emptyMap(); } if( map.size() == 1 ) { Map.Entry<S, T> stEntry = map.entrySet().iterator().next(); return Collections.singletonMap( stEntry.getKey()...
java
public String parseDotPathWord( String t ) { StringBuilder sb = t == null ? null : new StringBuilder( t == null ? "" : t ); SourceCodeTokenizer tokenizer = getTokenizer(); while( match( null, '.' ) ) { if( sb != null ) { sb.append( '.' ); } int mark = tokenizer.mark(); ...
java
final void addError( ParsedElement parsedElement, ResourceKey errorMsg ) { verify( parsedElement, false, errorMsg, EMPTY_ARRAY ); }
java
protected IRExpression compileExpansionUsingArrayList( IType rootType, IType rootComponentType, IType resultType, IType resultCompType, IType propertyType ) { // Evaluate the root and assign it to a temp variable IRSymbol tempRoot = _cc().makeAndIndexTempSymbol( getDescriptor( rootType ) ); IRStatement temp...
java
private IType cacheType(String name, Pair<IType, ITypeLoader> pair) { if( pair != null ) { IType type = pair.getFirst(); // We have to make sure we aren't replacing an existing type so we obey the return from the put. IType oldType = _typesByName.get(name); if( oldType != null && oldTy...
java
@Override public ITypeRef create( IType type ) { // already a proxy? return as is then if( type instanceof ITypeRef ) { return (ITypeRef)type; } if( type instanceof INonLoadableType ) { throw new UnsupportedOperationException( "Type references are not supported for nonloadable t...
java
private static void setupLoaderChainWithGosuUrl( ClassLoader loader ) { UrlClassLoaderWrapper wrapped = UrlClassLoaderWrapper.wrapIfNotAlreadyVisited( loader ); if( wrapped == null ) { return; } addGosuClassUrl( wrapped ); if( canWrapChain() ) { if( loader != ClassLoader.getSystemClassLo...
java
public void update( EditorHost editor ) { _editor = editor; _icon.setIcon( findIconForResults() ); _feedback.repaint(); repaint(); editor.repaint(); }
java
public final Object convertValue(Object value, IType intrType) { //================================================================================== // Null handling //================================================================================== if( intrType == null ) { return null; ...
java
public Date makeDateFrom( Object obj ) { if( obj == null ) { return null; } if( obj instanceof IDimension ) { obj = ((IDimension)obj).toNumber(); } if( obj instanceof Date ) { return (Date)obj; } if( obj instanceof Number ) { return new Date( ((Nu...
java
public Date parseDateTime( String str ) throws java.text.ParseException { if( str == null ) { return null; } return DateFormat.getDateInstance().parse(str); }
java
public static int getLineAtPosition( JTextComponent editor, int position ) { if( position <= 0 ) { return 1; } String s = editor.getText(); if( position > s.length() ) { position = s.length(); } try { return GosuStringUtil.countMatches( editor.getText( 0, positi...
java
public static int getDeepestWhiteSpaceLineStartAfter( String script, int offset ) { if( offset < 0 ) { return offset; } int i = offset; while( true ) { int lineStartAfter = getWhiteSpaceLineStartAfter( script, i ); if( lineStartAfter == -1 ) { return i; ...
java