id
int32 0
3k
| input
stringlengths 43
33.8k
| gt
stringclasses 1
value |
---|---|---|
900 | <s> package net . sf . sveditor . core . db . stmt ; import net . sf . | |
901 | <s> package net . sf . sveditor . core . db . expr ; import net . sf . sveditor . core . db . SVDBItemBase ; import net . sf . sveditor . core . db . SVDBItemType ; import net . sf . sveditor . core . db . SVDBItemUtils ; public class SVDBExpr extends SVDBItemBase { protected SVDBExpr ( SVDBItemType type ) { super ( type ) ; } public String toString ( ) { return SVExprUtils . getDefault ( ) . exprToString ( this | |
902 | <s> package com . pogofish . jadt . sampleast ; import java . util . List ; public abstract class Type { private Type ( ) { } private static final Type _Int = new Int ( ) ; public static final Type _Int ( ) { return _Int ; } private static final Type _Long = new Long ( ) ; public static final Type _Long ( ) { return _Long ; } public static interface Visitor < ResultType > { ResultType visit ( Int x ) ; ResultType visit ( Long x ) ; } public static abstract class VisitorWithDefault < ResultType > implements Visitor < ResultType > { @ Override public ResultType visit ( Int x ) { return getDefault ( x ) ; } @ Override public ResultType visit ( Long x ) { return getDefault ( x ) ; } protected abstract ResultType getDefault ( Type x ) ; } public static interface VoidVisitor { void visit ( Int x ) ; void visit ( Long x ) ; } public static abstract class VoidVisitorWithDefault implements VoidVisitor { @ Override public void visit ( Int x ) { doDefault ( x ) ; } @ Override public void visit ( Long x ) { doDefault ( x ) ; } protected abstract void doDefault ( Type x ) ; } public static final class Int extends Type { public Int ( ) { } @ Override public < ResultType > ResultType accept ( Visitor < ResultType > visitor ) { return visitor . visit ( this ) ; } @ Override public void accept ( VoidVisitor visitor ) { visitor . visit ( this ) ; } @ Override public int hashCode ( ) { return 0 ; } @ Override public boolean equals ( Object obj ) { if ( this == obj ) return true ; if ( obj == null ) return false ; if ( getClass ( ) != obj . getClass ( ) ) return false ; return true ; } @ Override public String toString ( ) { return "Int" ; } } public static final class Long extends Type { public Long ( ) { } @ Override public < ResultType > ResultType accept ( Visitor < ResultType > visitor ) { return visitor . visit ( this ) ; } @ Override | |
903 | <s> package com . asakusafw . testdriver . temporary ; import java . lang . annotation . Annotation ; import java . util . Collection ; import java . util . Collections ; import org . apache . hadoop . io . Text ; import com . asakusafw . testdriver . core . DataModelDefinition ; import com . asakusafw . testdriver . core . DataModelReflection ; import com . asakusafw . testdriver . core . PropertyName ; import com . asakusafw . testdriver . core . PropertyType ; public class MockTextDefinition implements DataModelDefinition < Text > { static final PropertyName VALUE = PropertyName . newInstance ( "value" ) ; @ Override public Class < Text > getModelClass ( ) { return Text . class ; } @ Override public < A extends Annotation > A getAnnotation ( Class < A > annotationType ) { return null ; } @ Override public Collection < PropertyName > getProperties ( | |
904 | <s> package net . sf . sveditor . ui . editor ; import org . eclipse . jface . text . BadLocationException ; import org . eclipse . jface . text . DefaultTextDoubleClickStrategy ; import org . eclipse . jface . text . IDocument ; import org . eclipse . jface . text . IRegion ; import org . eclipse . jface . text . Region ; public class SVDoubleClickStrategy extends DefaultTextDoubleClickStrategy { @ Override protected IRegion findExtendedDoubleClickSelection ( IDocument document , int offset ) { return findWord ( document , offset ) ; } @ Override protected IRegion findWord ( IDocument document , int offset ) { return getWordSelection ( document , offset ) ; } private static final int UNKNOWN = - 1 ; private static final int WS = 0 ; private static final int ID = 1 ; private static final int IDS = 2 ; private static final int AT = 3 ; private static final int FORWARD = 0 ; private static final int BACKWARD = 1 ; private int fState ; private int fAnchorState ; private int fDirection ; private int fStart ; private int fEnd ; private void setAnchor ( int anchor ) { fState = UNKNOWN ; | |
905 | <s> package de . fuberlin . wiwiss . d2rq . nodes ; import java . util . ArrayList ; import java . util . Collection ; import java . util . HashSet ; import java . util . Iterator ; import java . util . List ; import java . util . Set ; import org . apache . commons . logging . Log ; import org . apache . commons . logging . LogFactory ; import com . hp . hpl . jena . datatypes . RDFDatatype ; import com . hp . hpl . jena . graph . Node ; import de . fuberlin . wiwiss . d2rq . algebra . Attribute ; import de . fuberlin . wiwiss . d2rq . expr . AttributeExpr ; import de . fuberlin . wiwiss . d2rq . expr . Conjunction ; import de . fuberlin . wiwiss . d2rq . expr . Equality ; import de . fuberlin . wiwiss . d2rq . expr . Expression ; import de . fuberlin . wiwiss . d2rq . values . BlankNodeID ; import de . fuberlin . wiwiss . d2rq . values . Pattern ; import de . fuberlin . wiwiss . d2rq . values . Translator ; public class NodeSetConstraintBuilder implements NodeSetFilter { private final static Log log = LogFactory . getLog ( NodeSetConstraintBuilder . class ) ; private final static int NODE_TYPE_UNKNOWN = 0 ; private final static int NODE_TYPE_URI = 1 ; private final static int NODE_TYPE_LITERAL = 2 ; private final static int NODE_TYPE_BLANK = 3 ; private boolean isEmpty = false ; private boolean unsupported = false ; private int type = NODE_TYPE_UNKNOWN ; private String constantValue = null ; private String constantLanguage = null ; private RDFDatatype constantDatatype = null ; private Node fixedNode = null ; private Collection < Attribute > attributes = new HashSet < Attribute > ( ) ; private Collection < Pattern > patterns = new HashSet < Pattern > ( ) ; private Collection < Expression > expressions = new HashSet < Expression > ( ) ; private Collection < BlankNodeID > blankNodeIDs = new HashSet < BlankNodeID > ( ) ; private Set < Translator > translators = new HashSet < Translator > ( ) ; private String valueStart = "" ; private String valueEnd = "" ; public void limitToEmptySet ( ) { isEmpty = true ; } public void limitToURIs ( ) { limitToNodeType ( NODE_TYPE_URI ) ; } public void limitToBlankNodes ( ) { limitToNodeType ( NODE_TYPE_BLANK ) ; } public void limitToLiterals ( String language , RDFDatatype datatype ) { if ( isEmpty ) return ; limitToNodeType ( NODE_TYPE_LITERAL ) ; if ( constantLanguage == null ) { constantLanguage = language ; } else { if ( ! constantLanguage . equals ( language ) ) { limitToEmptySet ( ) ; } } | |
906 | <s> package org . rubypeople . rdt . internal . ti ; import org . jruby . ast . CallNode ; import org . jruby . ast . ClassNode ; import org . jruby . ast . ConstNode ; import org . jruby . ast . DefnNode ; import org . jruby . ast . DefsNode ; import org . jruby . ast . IterNode ; import org . jruby . ast . LocalAsgnNode ; import org . jruby . ast . LocalVarNode ; import org . jruby . ast . ModuleNode ; import org . jruby . ast . Node ; import org . rubypeople . rdt . internal . core . parser . InOrderVisitor ; import org . rubypeople . rdt . internal . ti . data . LiteralNodeTypeNames ; import org . rubypeople . rdt . internal . ti . data . TypicalMethodReturnNames ; public class TypeInferenceVisitor extends InOrderVisitor { private Scope globalScope ; private Scope currentScope ; public TypeInferenceVisitor ( Node rootNode ) { globalScope = new Scope ( rootNode , null ) ; currentScope = globalScope ; } public Object visitModuleNode ( ModuleNode iVisited ) { Scope newScope = pushScope ( iVisited ) ; Variable . insertLocalsFromScopeNode ( iVisited . getScope ( ) , newScope ) ; return super . visitModuleNode ( iVisited ) ; } public Object visitClassNode ( ClassNode iVisited ) { Scope newScope = pushScope ( iVisited ) ; Variable . insertLocalsFromScopeNode ( iVisited . getScope ( ) , newScope ) ; return super . visitClassNode ( iVisited ) ; } public Object visitDefnNode ( DefnNode iVisited ) { Scope newScope = pushScope ( iVisited ) ; Variable . insertLocalsFromScopeNode ( iVisited . getScope ( ) , newScope ) ; return super . visitDefnNode ( iVisited ) ; } public Object visitDefsNode ( DefsNode iVisited ) { Scope newScope = pushScope ( iVisited ) ; Variable . insertLocalsFromScopeNode ( iVisited . getScope ( ) , newScope ) ; return super . visitDefsNode ( iVisited ) ; } public Object visitIterNode ( IterNode iVisited ) { pushScope ( iVisited ) ; return super . visitIterNode ( iVisited ) ; } private Scope pushScope ( Node node ) { Scope newScope = new Scope ( node , currentScope ) ; currentScope = newScope ; return newScope ; } private void popScope ( ) { currentScope = currentScope . getParentScope ( ) ; } public Object visitCallNode ( CallNode iVisited ) { Variable var = getVariableByVarNode ( iVisited . getReceiverNode ( ) ) ; if ( var != null ) { } return super . visitCallNode ( iVisited ) ; } private Variable getVariableByVarNode ( Node node ) { if ( node instanceof LocalVarNode ) { LocalVarNode localVarNode = ( LocalVarNode ) node ; return currentScope . getLocalVariableByCount ( localVarNode . getIndex ( ) ) ; } return null ; } public | |
907 | <s> package com . asakusafw . compiler . fileio . flow ; import com . asakusafw . compiler . fileio . external . Ex1MockExporterDescription ; import com . asakusafw . compiler . fileio . model . Ex1 ; import com . asakusafw . compiler . fileio . model . Ex2 ; import com . asakusafw . compiler . fileio . operator . ExOperatorFactory ; import com . asakusafw . compiler . fileio . operator . ExOperatorFactory . Update ; import com . asakusafw . vocabulary . flow . Export ; import com . asakusafw . vocabulary . flow . FlowDescription ; import com . asakusafw . vocabulary . flow . Import ; import com . asakusafw . vocabulary . flow . In ; import com . asakusafw . vocabulary . flow . JobFlow ; import com . asakusafw . vocabulary . flow . Out ; import com . asakusafw . vocabulary . flow . util . CoreOperatorFactory ; @ JobFlow ( name = "job" ) public class TinyInputJob extends FlowDescription { private final In < Ex2 > input ; private final Out < Ex1 > output ; public TinyInputJob ( @ Import ( name = | |
908 | <s> package org . rubypeople . rdt . internal . core . buffer ; public class ToStringSorter { Object [ ] sortedObjects ; String [ ] sortedStrings ; public boolean compare ( String stringOne , String stringTwo ) { return stringOne . compareTo ( stringTwo ) < 0 ; } private void quickSort ( int left , int right ) { int originalLeft = left ; int originalRight = right ; int midIndex = ( left + right ) / 2 ; String midToString = this . sortedStrings [ midIndex ] ; do { while ( compare ( this . sortedStrings [ left ] , midToString ) ) left ++ ; while ( compare ( midToString , this . sortedStrings [ right ] ) ) right -- ; if ( left <= right ) { Object tmp = this . sortedObjects [ left ] ; this . sortedObjects [ left ] = this . sortedObjects [ right ] ; this . sortedObjects [ right ] = tmp ; String tmpToString = this . sortedStrings [ left ] ; | |
909 | <s> package org . oddjob ; import java . util . ArrayList ; import java . util . HashMap ; import java . util . List ; import java . util . Map ; import junit . framework . TestCase ; import org . oddjob . arooa . ArooaDescriptor ; import org . oddjob . arooa . ArooaParseException ; import org . oddjob . arooa . ArooaTools ; import org . oddjob . arooa . ComponentTrinity ; import org . oddjob . arooa . ConfigurationHandle ; import org . oddjob . arooa . MockArooaSession ; import org . oddjob . arooa . convert . ArooaConversionException ; import org . oddjob . arooa . deploy . LinkedDescriptor ; import org . oddjob . arooa . life . ComponentPersister ; import org . oddjob . arooa . life . ComponentProxyResolver ; import org . oddjob . arooa . parsing . ArooaContext ; import org . oddjob . arooa . parsing . CutAndPasteSupport ; import org . oddjob . arooa . parsing . DragPoint ; import org . oddjob . arooa . registry . ComponentPool ; import org . oddjob . arooa . registry . MockComponentPool ; import org . oddjob . arooa . standard . ExtendedTools ; import org . oddjob . arooa . standard . StandardArooaDescriptor ; import org . oddjob . arooa . standard . StandardArooaParser ; import org . oddjob . arooa . standard . StandardTools ; import org . oddjob . arooa . xml . XMLArooaParser ; import org . oddjob . arooa . xml . XMLConfiguration ; import org . oddjob . structural . StructuralEvent ; import org . oddjob . structural . StructuralListener ; public class OddjobTest2 extends TestCase { class OurStructuralListener implements StructuralListener { List < Object > children = new ArrayList < Object > ( ) ; public void childAdded ( StructuralEvent event ) { children . add ( event . getChild ( ) ) ; } public void childRemoved ( StructuralEvent event ) { children . add ( null ) ; } } public void testBadSave ( ) throws ArooaParseException , ArooaConversionException { OurStructuralListener structure = new OurStructuralListener ( ) ; String xml = "<oddjob>" + " <job>" + "" + " </job>" + "</oddjob>" ; Oddjob oddjob = new Oddjob ( ) ; oddjob . setConfiguration ( new XMLConfiguration ( "XML" , xml ) ) ; oddjob . addStructuralListener ( structure ) ; oddjob . run ( ) ; Integer i = new OddjobLookup ( oddjob ) . lookup ( "" , Integer . class ) ; assertEquals ( new Integer ( 1 ) , i ) ; Object sequence = new OddjobLookup ( oddjob ) . lookup ( "sequence" ) ; DragPoint point = oddjob . provideConfigurationSession ( ) . dragPointFor ( sequence ) ; XMLArooaParser xmlParser = new XMLArooaParser ( ) ; ConfigurationHandle handle = xmlParser . parse ( point ) ; ArooaContext xmlDoc = handle . getDocumentContext ( ) ; CutAndPasteSupport . replace ( xmlDoc . getParent ( ) , xmlDoc , new XMLConfiguration ( "Replace" , "<rubbish/>" ) ) ; try { handle . save ( ) ; fail ( "Should fail." ) ; } catch ( Exception e ) { } OddjobLookup lookup = new OddjobLookup ( oddjob ) ; Object sequence2 = lookup . lookup ( "sequence" ) ; Integer i2 = lookup . lookup ( "" , Integer . class ) ; assertEquals ( null , i2 ) ; assertEquals ( structure . children . size ( ) , 3 ) ; assertEquals ( sequence , structure . children . get ( 0 ) ) ; assertEquals ( null , structure . children . get ( 1 ) ) ; assertEquals ( sequence2 , structure . children . get ( 2 ) ) ; oddjob . run ( ) ; Integer i3 = lookup . lookup ( "" , Integer . class ) ; assertEquals ( new Integer ( 1 ) , i3 ) ; oddjob . destroy ( ) ; } class OurComponentPool extends MockComponentPool { Map < String , ArooaContext > contexts = new HashMap < String , ArooaContext > ( ) ; List < Object > components = new ArrayList < Object > ( ) ; List < String > actions = new ArrayList < String > ( ) ; @ Override public void registerComponent ( ComponentTrinity trinity , String id ) { components . add ( trinity . getTheProxy ( ) ) ; contexts . put ( id , trinity . getTheContext ( ) ) ; actions . add ( "A" ) ; } @ Override public void remove ( Object component ) { components . add ( component ) ; actions . add ( "R" ) ; } @ Override public void configure ( Object component ) { } } class OurSession extends MockArooaSession { OurComponentPool pool = new OurComponentPool ( ) ; ArooaDescriptor descriptor ; ArooaTools tools ; public OurSession ( ArooaDescriptor descriptor ) { this . descriptor = descriptor ; this . tools = new ExtendedTools ( new StandardTools ( ) , descriptor ) ; } @ Override public ArooaDescriptor getArooaDescriptor ( ) { return descriptor ; } @ Override public ComponentPool getComponentPool ( ) { return pool ; } @ Override public ArooaTools getTools ( ) { return tools ; } @ Override public ComponentPersister getComponentPersister ( ) { return null ; } @ Override public ComponentProxyResolver getComponentProxyResolver ( ) { return null ; } } public void testBadSave2 ( ) throws ArooaParseException { ArooaDescriptor descriptor = new OddjobDescriptorFactory ( ) . createDescriptor ( null ) ; OurSession session = new OurSession ( new LinkedDescriptor ( descriptor , new StandardArooaDescriptor ( ) ) ) ; String xml = "" + " <job>" + "" + " </job>" + "</oddjob>" ; OddjobServices services = new MockOddjobServices ( ) { @ Override public ClassLoader getClassLoader ( ) { return getClass ( ) . getClassLoader ( ) ; } } ; Oddjob . OddjobRoot root = new Oddjob ( ) . new OddjobRoot ( services ) ; StandardArooaParser parser = new StandardArooaParser ( root , session ) ; parser . parse ( new XMLConfiguration ( "TEST" , xml ) ) ; ArooaContext context = session . pool . contexts . get ( "sequence" ) ; XMLArooaParser xmlParser | |
910 | <s> package com . asakusafw . compiler . flow . join . operator ; import java . lang . annotation . Documented ; import java . lang . annotation . Retention ; import java . lang . annotation . | |
911 | <s> package org . oddjob . scheduling ; import java . util . concurrent . ExecutorService ; import java . util . concurrent . ScheduledExecutorService ; import org . oddjob . OddjobExecutors ; import org . oddjob . OddjobServices ; import org . oddjob . input . InputHandler ; public class OddjobServicesBean implements OddjobServices { private ClassLoader classLoader ; private OddjobExecutors oddjobExecutors ; private InputHandler inputHandler ; @ Override public Object getService ( String serviceName ) { if ( CLASSLOADER_SERVICE . equals ( serviceName ) ) { return classLoader ; } if ( SCHEDULED_EXECUTOR . equals ( serviceName ) && oddjobExecutors != null ) { return oddjobExecutors . getScheduledExecutor ( ) ; } else if ( POOL_EXECUTOR . equals ( serviceName ) && oddjobExecutors != null ) { return oddjobExecutors . getPoolExecutor ( ) ; } else if ( INPUT_HANDLER . equals ( serviceName ) | |
912 | <s> package com . asakusafw . dmdl . windgate . csv . driver ; import com . asakusafw . dmdl . model . AstAttribute ; import com . asakusafw . dmdl . semantics . DmdlSemantics ; import com . asakusafw . dmdl . semantics . PropertyDeclaration ; import com . asakusafw . dmdl . spi . PropertyAttributeDriver ; import com . asakusafw . dmdl . util . AttributeUtil ; | |
913 | <s> package net . sf . sveditor . ui . editor . actions ; import java . util . Iterator ; import java . util . List ; import java . util . ResourceBundle ; import org . eclipse . core . runtime . Assert ; import org . eclipse . jface . text . BadLocationException ; import org . eclipse . jface . text . BadPartitioningException ; import org . eclipse . jface . text . BadPositionCategoryException ; import org . eclipse . jface . text . DefaultPositionUpdater ; import org . eclipse . jface . text . DocumentEvent ; import org . eclipse . jface . text . IDocument ; import org . eclipse . jface . text . IDocumentExtension3 ; import org . eclipse . jface . text . IPositionUpdater ; import org . eclipse . jface . text . IRewriteTarget ; import org . eclipse . jface . text . ITextSelection ; import org . eclipse . jface . text . Position ; import org . eclipse . jface . viewers . ISelection ; import org . eclipse . jface . viewers . ISelectionProvider ; import org . eclipse . ui . IEditorInput ; import org . eclipse . ui . texteditor . IDocumentProvider ; import org . eclipse . ui . texteditor . ITextEditor ; import org . eclipse . ui . texteditor . ITextEditorExtension2 ; import org . eclipse . ui . texteditor . TextEditorAction ; public abstract class BlockCommentAction extends TextEditorAction { public BlockCommentAction ( ResourceBundle bundle , String prefix , ITextEditor editor ) { super ( bundle , prefix , editor ) ; } static class Edit extends DocumentEvent { public static class EditFactory { private static final String CATEGORY = "" ; private static int fgCount = 0 ; private final String fCategory ; private IDocument fDocument ; private IPositionUpdater fUpdater ; public EditFactory ( IDocument document ) { fCategory = CATEGORY + fgCount ++ ; fDocument = document ; } public Edit createEdit ( int offset , int length , String text ) throws BadLocationException { if ( ! fDocument . containsPositionCategory ( fCategory ) ) { fDocument . addPositionCategory ( fCategory ) ; fUpdater = new DefaultPositionUpdater ( fCategory ) ; fDocument . addPositionUpdater ( fUpdater ) ; } Position position = new Position ( offset ) ; try { fDocument . addPosition ( fCategory , position ) ; } catch ( BadPositionCategoryException e ) { Assert . isTrue ( false ) ; } return new Edit ( fDocument , length , text , position ) ; } public void release ( ) { if ( fDocument | |
914 | <s> package org . rubypeople . rdt . internal . ui . util ; import java . io . File ; import org . eclipse . swt . widgets . Composite ; import org . eclipse . swt . widgets . FileDialog ; public class FileSelector extends ResourceSelector { public FileSelector ( Composite parent ) { super ( parent ) ; } @ Override protected void handleBrowseSelected ( ) { FileDialog dialog = new FileDialog ( getShell ( ) ) ; dialog . setText ( browseDialogMessage ) ; setFilterPath ( dialog ) ; String selectedFile = dialog . open ( ) ; if ( selectedFile != null ) { setText ( selectedFile ) ; } } protected void setText ( String selectedFile ) { textField . setText ( selectedFile ) ; } protected boolean setFilterPath ( FileDialog dialog ) { String currentWorkingDir = textField . getText ( ) ; if ( ! currentWorkingDir . trim ( ) . equals ( "" ) ) { File path = new File ( currentWorkingDir ) ; if ( path . exists ( ) ) { dialog . setFilterPath ( currentWorkingDir ) ; return true ; } } return false ; } @ Override protected String | |
915 | <s> package org . oddjob . jmx . client ; import junit . framework . TestCase ; public class ClientInterfaceManagerFactoryTest extends TestCase { interface Foo { public void foo ( ) ; } public void testInvoke ( ) throws Throwable { class MockFoo implements Foo { boolean invoked ; public void foo ( ) { invoked = true ; } } MockFoo foo = new MockFoo ( ) ; class FooClientHandlerFactory extends MockClientInterfaceHandlerFactory < Foo > { private static final long serialVersionUID = 0 ; public Foo createClientHandler ( Foo proxy , ClientSideToolkit toolkit ) { return proxy ; } ; public Class < Foo > interfaceClass ( ) { return Foo . class ; } ; } ClientInterfaceManagerFactory test = new ClientInterfaceManagerFactory ( new ClientInterfaceHandlerFactory [ ] { new FooClientHandlerFactory ( ) } ) ; ClientInterfaceManager cim = test . create ( foo , null ) ; cim . invoke ( Foo . class . getMethod ( "foo" , ( Class < ? > [ ] ) null ) , null ) ; assertTrue ( foo . invoked ) ; } public void testNoFactory ( ) throws Throwable { class MockFoo implements Foo { boolean invoked ; public void foo ( ) { invoked = true ; } } MockFoo foo = new MockFoo ( ) ; ClientInterfaceManagerFactory test = new ClientInterfaceManagerFactory ( null ) ; ClientInterfaceManager cim = test . create ( foo , null ) ; try { cim . invoke ( Foo . class . getMethod ( "foo" , ( Class < ? > [ ] ) null ) , null ) ; fail ( "" ) ; } catch ( IllegalArgumentException e ) { } assertFalse ( foo . invoked ) ; } public void testForObject ( ) throws Throwable { class MockFoo implements Foo { public void foo ( ) { } } MockFoo | |
916 | <s> package com . aptana . rdt . internal . ui . actions ; import java . text . MessageFormat ; import org . eclipse . core . runtime . IProgressMonitor ; import org . eclipse . core . runtime . IStatus ; import org . eclipse . core . runtime . jobs . Job ; import org . eclipse . jface . action . IAction ; import org . eclipse . jface . dialogs . Dialog ; import org . eclipse . jface . viewers . ISelection ; import org . eclipse . swt . widgets . Display ; import org . eclipse . ui . IObjectActionDelegate ; import org . eclipse . ui . IViewActionDelegate ; import org . eclipse . ui . IViewPart ; import org . eclipse . ui . IWorkbenchPart ; import com . aptana . rdt . core . gems . Gem ; import com . aptana . rdt . core . gems . GemListener ; import com . aptana . rdt . core . gems . IGemManager ; import com . aptana . rdt . ui . gems . GemsView ; import com . aptana . rdt . ui . gems . InstallGemDialog ; public class InstallGemActionDelegate implements IObjectActionDelegate , IViewActionDelegate , GemListener { private IAction action ; private GemsView gemsView ; private IGemManager gemManager ; public InstallGemActionDelegate ( ) { } public void setActivePart ( IAction action , IWorkbenchPart targetPart ) { this . action = action ; } public void run ( IAction action ) { InstallGemDialog dialog = new InstallGemDialog ( Display . getCurrent ( ) . getActiveShell ( ) ) ; if ( dialog . open ( ) != Dialog . OK ) return ; final Gem gem = dialog . getGem ( ) ; if ( gem == null || gem . getName ( ) == null || gem . getName ( ) . length ( ) == 0 || ! gem . isInstallable ( ) ) return ; final String sourceURL = dialog . getSourceURL ( ) ; Job job = new Job ( MessageFormat . format ( "" , gem . getName ( ) ) ) { @ Override public IStatus run ( IProgressMonitor monitor ) { return getGemManager ( ) . installGem ( gem , sourceURL , monitor ) ; } } ; job . setUser ( true ) ; job . schedule ( ) ; } public void selectionChanged ( IAction action , ISelection selection ) { this . action = action ; if ( getGemManager ( ) != this . gemManager ) { this . gemManager . removeGemListener ( this ) ; getGemManager ( ) . addGemListener ( this ) ; this . gemManager = getGemManager ( ) ; } action . setEnabled ( isEnabled ( ) ) ; } | |
917 | <s> package org . rubypeople . rdt . internal . ui . text . ruby ; import java . util . Comparator ; import org . eclipse . jface . text . contentassist . ICompletionProposal ; import org . rubypeople . rdt . ui . text . ruby . AbstractProposalSorter ; import org . rubypeople | |
918 | <s> package net . sf . sveditor . core . job_mgr ; import org . eclipse . core . runtime . IProgressMonitor ; public interface IJob { void init ( String name , Runnable runnable ) ; String getName ( ) ; void setPriority ( int p ) ; int getPriority ( ) ; void run ( IProgressMonitor monitor ) ; void addListener ( IJobListener l ) ; void removeListener ( IJobListener l ) ; | |
919 | <s> package net . sf . sveditor . core . tests . parser ; import net . sf . sveditor . core . SVCorePlugin ; import net . sf . sveditor . core . db . SVDBFile ; import net . sf . sveditor . core . parser . SVParseException ; import net . sf . sveditor . core . tests . SVDBTestUtils ; import junit . framework . TestCase ; public class TestParseBehavioralStmts extends TestCase { public void testModulePreBodyImport3 ( ) { String doc = "package p;n" + "endpackagen" + "n" + "" + "t#(n" + "" + "" + "t();n" + "endmodulen" + "n" ; SVCorePlugin . getDefault ( ) . enableDebug ( false ) ; runTest ( "" , doc , new String [ ] { "p" , "t" , "p::*" , "p1::*" , "p2::*" } ) ; } public void testVarDeclForStmt ( ) throws SVParseException { String doc = "module t;n" + "" + "" + "tttx++;n" + "ttendn" + "tendn" + "endmodulen" ; SVCorePlugin . | |
920 | <s> package com . asakusafw . compiler . batch ; import java . lang . reflect . Type ; import java . text . MessageFormat ; import java . util . List ; import com . asakusafw . runtime . util . TypeUtil ; import com . | |
921 | <s> package net . sf . sveditor . ui . argfile . editor ; import org . eclipse . jface . text . rules . IWordDetector ; public class SVArgFileWordDetector implements IWordDetector { private boolean fStartsWithPlus ; | |
922 | <s> package org . rubypeople . rdt . internal . ui . typehierarchy ; import org . eclipse . jface . action . Action ; import org . eclipse . swt . custom . BusyIndicator ; import org . eclipse . ui . | |
923 | <s> package test . modelgen . table . model ; import java . io . DataInput ; import java . io . DataOutput ; import java . io . IOException ; import javax . annotation . Generated ; import org . apache . hadoop . io . Text ; import org . apache . hadoop . io . Writable ; import com . asakusafw . runtime . value . IntOption ; import com . asakusafw . runtime . value . StringOption ; import com . asakusafw . vocabulary . model . DataModel ; import com . asakusafw . vocabulary . model . Property ; import com . asakusafw . vocabulary . model . TableModel ; @ Generated ( "" ) @ DataModel @ TableModel ( name = "" , columns = { "TEXTDATA1" , "INTDATA1" } , primary = { "TEXTDATA1" } ) @ SuppressWarnings ( "deprecation" ) public class ExportTempTest02 implements Writable { @ Property ( name = "TEXTDATA1" ) private StringOption textdata1 = new StringOption ( ) ; @ Property ( name = "INTDATA1" ) private IntOption intdata1 = new IntOption ( ) ; public Text getTextdata1 ( ) { return this . textdata1 . get ( ) ; } public void setTextdata1 ( Text textdata1 ) { this . textdata1 . modify ( textdata1 ) ; } public String getTextdata1AsString ( ) { return this . textdata1 . getAsString ( ) ; } public void setTextdata1AsString ( String textdata1 ) { this . textdata1 . modify ( textdata1 ) ; } public StringOption getTextdata1Option ( ) { return this . textdata1 ; } public void setTextdata1Option ( StringOption textdata1 ) { this . textdata1 . copyFrom ( textdata1 ) ; } public int getIntdata1 ( ) { return this . intdata1 . get ( ) ; } public void setIntdata1 ( int intdata1 ) { this . intdata1 . modify ( intdata1 ) ; } public IntOption getIntdata1Option ( ) { return this . intdata1 ; } public void setIntdata1Option ( IntOption intdata1 ) { this . intdata1 . copyFrom ( intdata1 ) ; } | |
924 | <s> package de . fuberlin . wiwiss . d2rq . optimizer ; import junit . framework . Test ; import | |
925 | <s> package com . asakusafw . testdriver . testing . io ; import java . io . IOException ; import com . asakusafw . runtime . io . ModelInput ; import com . asakusafw . runtime . io . RecordParser ; import com . asakusafw . testdriver . testing . model . Ordered ; public final class OrderedInput implements ModelInput < Ordered > { private final RecordParser parser ; public OrderedInput ( RecordParser parser ) { if ( parser == null ) | |
926 | <s> package org . rubypeople . rdt . internal . ui ; import org . rubypeople . eclipse . shams . resources . ShamProject ; import org . rubypeople . rdt . internal . ui . util . StackTraceLine ; import junit . framework . TestCase ; public class TC_StackTraceLine extends TestCase { private static final String BACKSLASH_FILE_PATH = "" ; private static final String RUBY_CONSOLE_TEST_FAILURE = "" ; private static final String TEST_UNIT_VIEW_BACKTRACE = "" ; private static final String BACKTRACE_WITH_IN = "" ; private static final String WITH_FROM = "" ; private static final String ODD_WITH_FROM = "" ; private static final String WITH_OUT_FROM = "" ; private static final String WITH_TRAILING_SPACE = "" ; private static final String LOOKS_ABSOLUTE = "" ; public void testWithFrom ( ) { assertFalse ( "" , StackTraceLine . isTraceLine ( WITH_TRAILING_SPACE ) ) ; } public void testRelativePathWithPeriod ( ) { assertTrue ( "" , StackTraceLine . isTraceLine ( "" ) ) ; } public void testRelativePathWithoutPeriod ( ) { assertTrue ( "" , StackTraceLine . isTraceLine ( "" ) ) ; } public void testWithTrailingSpace ( ) { assertTrue ( "" , StackTraceLine . isTraceLine ( WITH_FROM ) ) ; StackTraceLine traceLine = new StackTraceLine ( WITH_FROM ) ; assertEquals ( "Filename" , "" , traceLine . getFilename ( ) ) ; assertEquals ( "Line Number" , 4 , traceLine . getLineNumber ( ) ) ; assertEquals ( "Offset" , 6 , traceLine . offset ( ) ) ; assertEquals ( "Length" , 28 , traceLine . length ( ) ) ; } public void testWithOutFrom ( ) { assertTrue ( "" , StackTraceLine . isTraceLine ( WITH_OUT_FROM ) ) ; StackTraceLine traceLine = new StackTraceLine ( WITH_OUT_FROM ) ; assertEquals ( "Filename" , "" , traceLine . getFilename ( ) ) ; assertEquals ( "Line Number" , 4 , traceLine . getLineNumber ( ) ) ; assertEquals ( "Offset" , 0 , traceLine . offset ( ) ) ; assertEquals ( "Length" , 28 , traceLine . length ( ) ) ; } public void testOddWithFrom ( ) { assertTrue ( "" , StackTraceLine . isTraceLine ( ODD_WITH_FROM ) ) ; StackTraceLine traceLine = new StackTraceLine ( ODD_WITH_FROM ) ; assertEquals ( | |
927 | <s> package org . rubypeople . rdt . ui ; import org . eclipse . core . resources . IStorage ; import org . eclipse . jface . viewers . LabelProvider ; import org . eclipse . swt . graphics . Image ; import org . rubypeople . rdt . internal . ui . viewsupport . RubyElementImageProvider ; import org . rubypeople . rdt . internal . ui . viewsupport . StorageLabelProvider ; public class RubyElementLabelProvider extends LabelProvider { public final static int SHOW_OVERLAY_ICONS = 0x002 ; public final static int SHOW_ROOT = 0x004 ; public final static int SHOW_SMALL_ICONS = 0x008 ; public final static int SHOW_VARIABLE = 0x010 ; public final static int SHOW_QUALIFIED = 0x020 ; public final static int SHOW_POST_QUALIFIED = 0x040 ; public final static int SHOW_BASICS = 0x000 ; public final static int SHOW_DEFAULT = new Integer ( SHOW_OVERLAY_ICONS ) . intValue ( ) ; private RubyElementImageProvider fImageLabelProvider ; private StorageLabelProvider fStorageLabelProvider ; private int fFlags ; private int fImageFlags ; private long fTextFlags ; public RubyElementLabelProvider ( ) { this ( SHOW_DEFAULT ) ; } public RubyElementLabelProvider ( int flags ) { fImageLabelProvider = new RubyElementImageProvider ( ) ; fStorageLabelProvider = new StorageLabelProvider ( ) ; fFlags = flags ; updateImageProviderFlags ( ) ; updateTextProviderFlags ( ) ; } private boolean getFlag ( int flag ) { return ( fFlags & flag ) != 0 ; } public void turnOn ( int flags ) { fFlags |= flags ; updateImageProviderFlags ( ) ; updateTextProviderFlags ( ) ; } public void turnOff ( int flags ) { fFlags &= ( ~ flags ) ; updateImageProviderFlags ( ) ; updateTextProviderFlags ( ) ; } private void updateImageProviderFlags ( ) { fImageFlags = 0 ; if ( getFlag ( SHOW_OVERLAY_ICONS ) ) { fImageFlags |= RubyElementImageProvider . OVERLAY_ICONS ; } if ( getFlag ( SHOW_SMALL_ICONS ) ) { fImageFlags |= RubyElementImageProvider . SMALL_ICONS ; } } private void updateTextProviderFlags ( ) { fTextFlags = RubyElementLabels . M_PARAMETER_NAMES ; if ( getFlag ( SHOW_ROOT ) ) { fTextFlags |= RubyElementLabels . APPEND_ROOT_PATH ; } if ( getFlag ( SHOW_VARIABLE ) ) { fTextFlags |= RubyElementLabels . ROOT_VARIABLE ; } if ( getFlag ( SHOW_QUALIFIED ) ) { fTextFlags |= ( RubyElementLabels . F_FULLY_QUALIFIED | RubyElementLabels . M_FULLY_QUALIFIED | RubyElementLabels . I_FULLY_QUALIFIED | RubyElementLabels . T_FILENAME_QUALIFIED | RubyElementLabels . D_QUALIFIED | RubyElementLabels . CF_QUALIFIED | RubyElementLabels . CU_QUALIFIED ) ; } if ( getFlag ( SHOW_POST_QUALIFIED ) ) { fTextFlags |= ( RubyElementLabels . F_POST_QUALIFIED | RubyElementLabels . M_POST_QUALIFIED | RubyElementLabels . I_POST_QUALIFIED | RubyElementLabels . T_POST_QUALIFIED | RubyElementLabels . D_POST_QUALIFIED | RubyElementLabels . CF_POST_QUALIFIED | RubyElementLabels . CU_POST_QUALIFIED ) | RubyElementLabels . P_POST_QUALIFIED ; } } public Image getImage ( | |
928 | <s> package org . rubypeople . rdt . internal . corext . buildpath ; import java . lang . reflect . InvocationTargetException ; import java . util . ArrayList ; import java . util . Collections ; import java . util . List ; import org . eclipse . core . resources . IResource ; import org . eclipse . core . runtime . IProgressMonitor ; import org . eclipse . jface . viewers . StructuredSelection ; import org . rubypeople . rdt . core . IRubyProject ; import org . rubypeople . rdt . core . ISourceFolderRoot ; import org . rubypeople . rdt . core . RubyModelException ; import org . rubypeople . rdt . internal . ui . wizards . NewWizardMessages ; import org . rubypeople . rdt . internal . ui . wizards . buildpaths . newsourcepage . DialogPackageExplorerActionGroup ; import org . rubypeople . rdt . internal . ui . wizards . buildpaths . newsourcepage . LoadpathModifierOperation ; import org . rubypeople . rdt . internal . ui . wizards . buildpaths . newsourcepage . GenerateBuildPathActionGroup . CreateLinkedSourceFolderAction ; import org . rubypeople . rdt . internal . ui . wizards . buildpaths . newsourcepage . LoadpathModifierQueries . ILinkToQuery ; public class LinkedSourceFolderOperation extends LoadpathModifierOperation { private ILoadpathModifierListener fListener ; private ILoadpathInformationProvider fCPInformationProvider ; public LinkedSourceFolderOperation ( ILoadpathModifierListener listener , ILoadpathInformationProvider informationProvider ) { super ( listener , informationProvider , NewWizardMessages . NewSourceContainerWorkbookPage_ToolBar_Link_tooltip , ILoadpathInformationProvider . CREATE_LINK ) ; fListener = listener ; fCPInformationProvider = informationProvider ; } public void run ( IProgressMonitor monitor ) throws InvocationTargetException , InterruptedException { CreateLinkedSourceFolderAction action = new CreateLinkedSourceFolderAction ( ) ; action . selectionChanged ( new StructuredSelection ( fCPInformationProvider . getRubyProject ( ) ) ) ; action . run ( ) ; ISourceFolderRoot createdElement = ( ISourceFolderRoot ) action . getCreatedElement ( ) ; if ( createdElement == null ) { return ; } try { IResource correspondingResource = createdElement . getCorrespondingResource ( ) ; List result = new ArrayList ( ) ; result . add ( correspondingResource ) ; if ( fListener != null ) { | |
929 | <s> package com . asakusafw . utils . collections ; import static org . hamcrest . Matchers . * ; import static org . junit . Assert . * ; import java . io . ByteArrayInputStream ; import java . io . ByteArrayOutputStream ; import java . io . ObjectInputStream ; import java . io . ObjectOutputStream ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . HashSet ; import java . util . Iterator ; import java . util . List ; import java . util . NoSuchElementException ; import java . util . Set ; import org . junit . Test ; public class SingleLinkedListTest { @ Test public void new_empty ( ) { SingleLinkedList < String > list = new SingleLinkedList < String > ( ) ; assertThat ( list . size ( ) , is ( 0 ) ) ; } @ Test public void new_list ( ) { List < String > from = Arrays . asList ( "a" , "b" , "c" ) ; SingleLinkedList < String > list = new SingleLinkedList < String > ( from ) ; assertThat ( list . size ( ) , is ( 3 ) ) ; assertThat ( list . get ( 0 ) , is ( "a" ) ) ; assertThat ( list . get ( 1 ) , is ( "b" ) ) ; assertThat ( list . get ( 2 ) , is ( "c" ) ) ; } @ Test public void new_collection ( ) { List < String > from = Arrays . asList ( "a" , "b" , "c" ) ; SingleLinkedList < String > list = new SingleLinkedList < String > ( new HashSet < String > ( from ) ) ; assertThat ( list . size ( ) , is ( 3 ) ) ; Set < String > to = new HashSet < String > ( ) ; to . add ( list . get ( 0 ) ) ; to . add ( list . get ( 1 ) ) ; to . add ( list . get ( 2 ) ) ; assertThat ( to , is ( ( Object ) new HashSet < String > ( from ) ) ) ; } @ Test public void isEmpty ( ) { { SingleLinkedList < String > list = new SingleLinkedList < String > ( ) ; assertTrue ( list . isEmpty ( ) ) ; } { List < String > from = Arrays . asList ( "a" ) ; SingleLinkedList < String > list = new SingleLinkedList < String > ( from ) ; assertFalse ( list . isEmpty ( ) ) ; } { List < String > from = Arrays . asList ( "a" , "b" , "c" ) ; SingleLinkedList < String > list = new SingleLinkedList < String > ( from ) ; assertFalse ( list . isEmpty ( ) ) ; } } @ Test public void size ( ) { { SingleLinkedList < String > list = new SingleLinkedList < String > ( ) ; assertThat ( list . size ( ) , is ( 0 ) ) ; } { List < String > from = Arrays . asList ( "a" ) ; SingleLinkedList < String > list = new SingleLinkedList < String > ( from ) ; assertThat ( list . size ( ) , is ( 1 ) ) ; } { List < String > from = Arrays . asList ( "a" , "b" , "c" ) ; SingleLinkedList < String > list = new SingleLinkedList < String > ( from ) ; assertThat ( list . size ( ) , is ( 3 ) ) ; } } @ Test public void concat ( ) { { SingleLinkedList < String > list0 = new SingleLinkedList < String > ( ) ; assertThat ( list0 . size ( ) , is ( 0 ) ) ; SingleLinkedList < String > list1 = list0 . concat ( "a" ) ; assertThat ( list0 . size ( ) , is ( 0 ) ) ; assertThat ( list1 . size ( ) , is ( 1 ) ) ; assertThat ( list1 . get ( 0 ) , is ( "a" ) ) ; SingleLinkedList < String > list2 = list1 . concat ( "b" ) ; assertThat ( list0 . size ( ) , is ( 0 ) ) ; assertThat ( list1 . size ( ) , is ( 1 ) ) ; assertThat ( list1 . get ( 0 ) , is ( "a" ) ) ; assertThat ( list2 . size ( ) , is ( 2 ) ) ; assertThat ( list2 . get ( 0 ) , is ( "b" ) ) ; assertThat ( list2 . get ( 1 ) , is ( "a" ) ) ; SingleLinkedList < String > list3 = list2 . concat ( "c" ) ; assertThat ( list0 . size ( ) , is ( 0 ) ) ; assertThat ( list1 . size ( ) , is ( 1 ) ) ; assertThat ( list1 . get ( 0 ) , is ( "a" ) ) ; assertThat ( list2 . size ( ) , is ( 2 ) ) ; assertThat ( list2 . get ( 0 ) , is ( "b" ) ) ; assertThat ( list2 . get ( 1 ) , is ( "a" ) ) ; assertThat ( list3 . size ( ) , is ( 3 ) ) ; assertThat ( list3 . get ( 0 ) , is ( "c" ) ) ; assertThat ( list3 . get ( 1 ) , is ( "b" ) ) ; assertThat ( list3 . get ( 2 ) , is ( "a" ) ) ; } { List < String > from = Arrays . asList ( "a" , "b" , "c" ) ; SingleLinkedList < String > list = new SingleLinkedList < String > ( from ) ; assertThat ( list . size ( ) , is ( 3 ) ) ; assertThat ( list . get ( 0 ) , is ( "a" ) ) ; assertThat ( list . get ( 1 ) , is ( "b" ) ) ; assertThat ( list . get ( 2 ) , is ( "c" ) ) ; SingleLinkedList < String > concat = list . concat ( "d" ) ; assertThat ( list . size ( ) , is ( 3 ) ) ; assertThat ( list . get ( 0 ) , is ( "a" ) ) ; assertThat ( list . get ( 1 ) , is ( "b" ) ) ; assertThat ( list . get ( 2 ) , is ( "c" ) ) ; assertThat ( concat . size ( ) , is ( 4 ) ) ; assertThat ( concat . get ( 0 ) , is ( "d" ) ) ; assertThat ( concat . get ( 1 ) , is ( "a" ) ) ; assertThat ( concat . get ( 2 ) , is ( "b" ) ) ; assertThat ( concat . get ( 3 ) , is ( "c" ) ) ; } } @ Test public void first ( ) { { List < String > from = Arrays . asList ( "a" , "b" , "c" ) ; SingleLinkedList < String > list = new SingleLinkedList < String > ( from ) ; assertThat ( list . first ( ) , is ( "a" ) ) ; } { SingleLinkedList < String > list = new SingleLinkedList < String > ( ) ; try { list . first ( ) ; fail ( ) ; } catch ( NoSuchElementException e ) { } } } @ Test public void rest ( ) { { List < String > from = Arrays . asList ( "a" , "b" , "c" ) ; SingleLinkedList < String > list = new SingleLinkedList < String > ( from ) ; SingleLinkedList < String > rest = list . rest ( ) ; assertThat ( rest . size ( ) , is ( 2 ) ) ; assertThat ( rest . get ( 0 ) , is ( "b" ) ) ; assertThat ( rest . get ( 1 ) , is ( "c" ) ) ; } { SingleLinkedList < String > list = new SingleLinkedList < String > ( ) ; try { list . rest ( ) ; fail ( ) ; } catch ( NoSuchElementException e ) { } } } @ Test public void iterator ( ) { { List < String > from = Arrays . asList ( "a" , "b" , "c" ) ; SingleLinkedList < String > list = new SingleLinkedList < String > ( from ) ; Iterator < String > iter = list . iterator ( ) ; assertTrue ( iter . hasNext ( ) ) ; assertThat ( iter . next ( ) , is ( "a" ) ) ; assertTrue ( iter . hasNext ( ) ) ; assertThat ( iter . next ( ) , is ( "b" ) ) ; assertTrue ( iter . hasNext ( ) ) ; assertThat ( iter . next ( ) , is ( "c" ) ) ; assertFalse ( iter . hasNext ( ) ) ; try { iter . next ( ) ; fail ( ) ; } catch ( NoSuchElementException e ) { } } { SingleLinkedList < String > list = new SingleLinkedList < String > ( ) ; Iterator < String > iter = list . iterator ( ) ; assertFalse ( iter . hasNext ( ) ) ; try { iter . next ( ) ; fail ( ) ; } catch ( NoSuchElementException e ) { } } } @ Test public void fill ( ) { { List < String > from = Arrays . asList ( "a" , "b" , "c" ) ; SingleLinkedList < String > list = new SingleLinkedList < String > ( from ) ; List < String > to = new ArrayList < String > ( ) ; list . fill ( to ) ; assertThat ( list . size ( ) , is ( 3 ) ) ; assertThat ( list . get ( 0 ) , is ( "a" ) ) ; assertThat ( list . get ( 1 ) , is ( "b" ) ) ; assertThat ( list . get ( 2 ) , is ( "c" ) ) ; assertThat ( to , is ( from ) ) ; } { SingleLinkedList < String > list = new SingleLinkedList < String > ( ) ; List < String > to = new ArrayList < String > ( ) ; list . fill ( to ) ; assertThat ( list . size ( ) , is ( 0 ) ) ; assertThat ( to . size ( ) , is ( 0 ) ) ; } } @ Test public void equals ( ) { { SingleLinkedList < ? > a = new SingleLinkedList < String > ( Arrays . < String > asList ( ) ) ; SingleLinkedList < ? > b = new SingleLinkedList < String > ( Arrays . < String > asList ( ) ) ; assertTrue ( a . equals ( b ) ) ; assertTrue ( b . equals ( a ) ) ; } { SingleLinkedList < ? > a = new SingleLinkedList < String > ( Arrays . asList ( "a" ) ) ; SingleLinkedList < ? > b = new SingleLinkedList < String > ( Arrays . < String > asList ( ) ) ; assertFalse ( a . equals ( b ) ) ; assertFalse ( b . equals ( a ) ) ; } { SingleLinkedList < ? > a = new SingleLinkedList < String > ( Arrays . asList ( "a" ) ) ; SingleLinkedList < ? > b = new SingleLinkedList < String > ( Arrays . asList ( "a" ) ) ; assertTrue ( a . equals ( b ) ) ; assertTrue ( b . equals ( a ) ) ; } { SingleLinkedList < ? > a = new SingleLinkedList < String > ( Arrays . asList ( "a" ) ) ; SingleLinkedList < ? > b = new SingleLinkedList < String > ( Arrays . asList ( "b" ) ) ; assertFalse ( a . equals ( b ) ) ; assertFalse ( b . equals ( a ) | |
930 | <s> package org . rubypeople . rdt . refactoring . core ; import java . io . File ; import java . net . URI ; import java . util . ArrayList ; import java . util . HashMap ; import java . util . Iterator ; import java . util . List ; import java . util . Map ; import org . eclipse . core . filesystem . EFS ; import org . eclipse . core . resources . IFile ; import org . eclipse . core . resources . IResource ; import org . eclipse . core . resources . IResourceStatus ; import org . eclipse . core . resources . ResourceAttributes ; import org . eclipse . core . resources . ResourcesPlugin ; import org . eclipse . core . runtime . CoreException ; import org . eclipse . core . runtime . IPath ; import org . eclipse . core . runtime . IStatus ; import org . eclipse . core . runtime . MultiStatus ; import org . eclipse . core . runtime . Status ; import org . rubypeople . rdt . internal . ui . IRubyStatusConstants ; import org . rubypeople . rdt . internal . ui . RubyPlugin ; import org . rubypeople . rdt . internal . ui . RubyUIStatus ; public class Resources { private Resources ( ) { } public static IStatus checkInSync ( IResource resource ) { return checkInSync ( new IResource [ ] { resource } ) ; } public static IStatus checkInSync ( IResource [ ] resources ) { IStatus result = null ; for ( int i = 0 ; i < resources . length ; i ++ ) { IResource resource = resources [ i ] ; if ( ! resource . isSynchronized ( IResource . DEPTH_INFINITE ) ) { result = addOutOfSync ( result , resource ) ; } } if ( result != null ) return result ; return new Status ( IStatus . OK , RubyPlugin . getPluginId ( ) , IStatus . OK , "" , null ) ; } public static IStatus makeCommittable ( IResource resource , Object context ) { return makeCommittable ( new IResource [ ] { resource } , context ) ; } public static IStatus makeCommittable ( IResource [ ] resources , Object context ) { List readOnlyFiles = new ArrayList ( ) ; for ( int i = 0 ; i < resources . length ; i ++ ) { IResource resource = resources [ i ] ; if ( resource . getType ( ) == IResource . FILE && isReadOnly ( resource ) ) readOnlyFiles . add ( resource ) ; } if ( readOnlyFiles . size ( ) == 0 ) return new Status ( IStatus . OK , RubyPlugin . getPluginId ( ) , IStatus . OK , "" , null ) ; Map oldTimeStamps = createModificationStampMap ( readOnlyFiles ) ; IStatus status = ResourcesPlugin . getWorkspace ( ) . validateEdit ( ( IFile [ ] ) readOnlyFiles . toArray ( new IFile [ readOnlyFiles . size ( ) ] ) , context ) ; if ( ! status . isOK ( ) ) return status ; IStatus modified = null ; Map newTimeStamps = createModificationStampMap ( readOnlyFiles ) ; for ( Iterator iter = oldTimeStamps . keySet ( ) . iterator ( ) ; iter . hasNext ( ) ; ) { IFile file = ( IFile ) iter . next ( ) ; if ( ! oldTimeStamps . get ( file ) . equals ( newTimeStamps . get ( file ) ) ) modified = addModified ( modified , file ) ; } if ( modified != null ) return modified ; return new Status ( IStatus . OK , RubyPlugin . getPluginId ( ) , IStatus . OK , "" , null ) ; } private static Map createModificationStampMap ( List files ) { Map map = new HashMap ( ) ; for ( Iterator iter = files . iterator ( ) ; iter . hasNext ( ) ; ) { IFile file = ( IFile ) iter . next ( ) ; map . put ( file , new Long ( file . getModificationStamp ( ) ) ) ; } return map ; } private static IStatus addModified ( IStatus status , IFile file ) { IStatus entry = RubyUIStatus . createError ( IRubyStatusConstants . VALIDATE_EDIT_CHANGED_CONTENT , Messages . format ( "" , file . getFullPath ( ) . toString ( ) ) , null ) ; if ( status == null ) { return entry ; } else if ( status . isMultiStatus ( ) ) { ( ( MultiStatus ) status ) . add ( entry ) ; return status ; } else { MultiStatus result = new MultiStatus ( RubyPlugin . getPluginId ( ) , IRubyStatusConstants . VALIDATE_EDIT_CHANGED_CONTENT , "" , null ) ; | |
931 | <s> package org . oddjob . scheduling ; import java . io . File ; import java . io . IOException ; import java . text . ParseException ; import java . util . ArrayList ; import java . util . Date ; import java . util . List ; import java . util . TimeZone ; import java . util . concurrent . ExecutorService ; import java . util . concurrent . ScheduledExecutorService ; import java . util . concurrent . ScheduledFuture ; import java . util . concurrent . TimeUnit ; import junit . framework . TestCase ; import org . apache . commons . io . FileUtils ; import org . apache . log4j . Logger ; import org . oddjob . FailedToStopException ; import org . oddjob . Helper ; import org . oddjob . IconSteps ; import org . oddjob . MockOddjobExecutors ; import org . oddjob . MockStateful ; import org . oddjob . Oddjob ; import org . oddjob . OddjobLookup ; import org . oddjob . OurDirs ; import org . oddjob . Resetable ; import org . oddjob . StateSteps ; import org . oddjob . Stateful ; import org . oddjob . arooa . convert . ArooaConversionException ; import org . oddjob . arooa . reflect . ArooaPropertyException ; import org . oddjob . arooa . types . ArooaObject ; import org . oddjob . arooa . utils . DateHelper ; import org . oddjob . arooa . xml . XMLConfiguration ; import org . oddjob . framework . SimpleJob ; import org . oddjob . images . IconHelper ; import org . oddjob . jobs . WaitJob ; import org . oddjob . persist . MapPersister ; import org . oddjob . schedules . IntervalTo ; import org . oddjob . schedules . Schedule ; import org . oddjob . schedules . ScheduleContext ; import org . oddjob . schedules . SimpleInterval ; import org . oddjob . schedules . SimpleScheduleResult ; import org . oddjob . schedules . schedules . CountSchedule ; import org . oddjob . schedules . schedules . DailySchedule ; import org . oddjob . schedules . schedules . DateSchedule ; import org . oddjob . schedules . schedules . IntervalSchedule ; import org . oddjob . schedules . schedules . NowSchedule ; import org . oddjob . schedules . schedules . TimeSchedule ; import org . oddjob . state . FlagState ; import org . oddjob . state . JobState ; import org . oddjob . state . ParentState ; import org . oddjob . state . StateEvent ; import org . oddjob . state . StateListener ; public class TimerTest extends TestCase { private static final Logger logger = Logger . getLogger ( TimerTest . class ) ; protected void setUp ( ) { logger . debug ( "" + getName ( ) + "" ) ; } private class OurJob extends MockStateful implements Runnable , Resetable { int resets ; final List < StateListener > listeners = new ArrayList < StateListener > ( ) ; public void addStateListener ( StateListener listener ) { listeners . add ( listener ) ; listener . jobStateChange ( new StateEvent ( this , JobState . READY ) ) ; } public void removeStateListener ( StateListener listener ) { listeners . remove ( listener ) ; } public void run ( ) { List < StateListener > copy = new ArrayList < StateListener > ( listeners ) ; for ( StateListener listener : copy ) { listener . jobStateChange ( new StateEvent ( this , JobState . EXECUTING ) ) ; listener . jobStateChange ( new StateEvent ( this , JobState . COMPLETE ) ) ; } } public boolean hardReset ( ) { ++ resets ; return true ; } public boolean softReset ( ) { throw new RuntimeException ( "Unexpected." ) ; } } private class OurScheduledExecutorService extends MockScheduledExecutorService { Runnable runnable ; long delay ; public ScheduledFuture < ? > schedule ( Runnable runnable , long delay , TimeUnit unit ) { OurScheduledExecutorService . this . delay = delay ; OurScheduledExecutorService . this . runnable = runnable ; return new MockScheduledFuture < Void > ( ) ; } } ; public void testSimpleNonRepeatingSchedule ( ) throws Exception { DateSchedule schedule = new DateSchedule ( ) ; schedule . setOn ( "2020-12-25" ) ; OurJob ourJob = new OurJob ( ) ; ManualClock clock = new ManualClock ( "2020-12-24" ) ; Timer test = new Timer ( ) ; test . setSchedule ( schedule ) ; test . setJob ( ourJob ) ; test . setHaltOnFailure ( true ) ; test . setClock ( clock ) ; OurScheduledExecutorService oddjobServices = new OurScheduledExecutorService ( ) ; test . setScheduleExecutorService ( oddjobServices ) ; StateSteps state = new StateSteps ( test ) ; state . startCheck ( ParentState . READY , ParentState . EXECUTING , ParentState . ACTIVE ) ; IconSteps icons = new IconSteps ( test ) ; icons . startCheck ( IconHelper . READY , IconHelper . EXECUTING , IconHelper . SLEEPING ) ; test . run ( ) ; state . checkNow ( ) ; icons . checkNow ( ) ; Date expected = DateHelper . parseDate ( "2020-12-25" ) ; assertEquals ( expected , test . getNextDue ( ) ) ; assertEquals ( expected , test . getCurrent ( ) . getFromDate ( ) ) ; assertEquals ( 24 * 60 * 60 * 1000L , oddjobServices . delay ) ; state . startCheck ( ParentState . ACTIVE , ParentState . COMPLETE ) ; icons . startCheck ( IconHelper . SLEEPING , IconHelper . EXECUTING , IconHelper . COMPLETE ) ; oddjobServices . delay = - 1 ; oddjobServices . runnable . run ( ) ; oddjobServices . runnable = null ; assertNull ( null , test . getNextDue ( ) ) ; assertNull ( null , test . getCurrent ( ) ) ; assertEquals ( expected , test . getLastDue ( ) ) ; assertEquals ( - 1 , oddjobServices . delay ) ; assertEquals ( 1 , ourJob . resets ) ; state . checkNow ( ) ; icons . checkNow ( ) ; clock . setDate ( "" ) ; state . startCheck ( ParentState . COMPLETE , ParentState . READY ) ; icons . startCheck ( IconHelper . COMPLETE , IconHelper . READY ) ; test . hardReset ( ) ; state . checkNow ( ) ; icons . checkNow ( ) ; state . startCheck ( ParentState . READY , ParentState . EXECUTING , ParentState . ACTIVE ) ; icons . startCheck ( IconHelper . READY , IconHelper . EXECUTING , IconHelper . SLEEPING ) ; test . run ( ) ; state . checkNow ( ) ; icons . checkNow ( ) ; assertEquals ( expected , test . getNextDue ( ) ) ; assertEquals ( expected , test . getCurrent ( ) . getFromDate ( ) ) ; assertEquals ( 0L , oddjobServices . delay ) ; state . startCheck ( ParentState . ACTIVE , ParentState . COMPLETE ) ; icons . startCheck ( IconHelper . SLEEPING , IconHelper . EXECUTING , IconHelper . COMPLETE ) ; oddjobServices . delay = - 1 ; oddjobServices . runnable . run ( ) ; oddjobServices . runnable = null ; assertNull ( null , test . getNextDue ( ) ) ; assertNull ( null , test . getCurrent ( ) ) ; assertEquals ( expected , test . getLastDue ( ) ) ; assertEquals ( - 1 , oddjobServices . delay ) ; assertEquals ( 3 , ourJob . resets ) ; state . checkNow ( ) ; icons . checkNow ( ) ; test . setJob ( null ) ; test . destroy ( ) ; assertEquals ( 0 , ourJob . listeners . size ( ) ) ; } public void testRecurringScheduleWhenStopped ( ) throws ParseException { FlagState job = new FlagState ( ) ; job . setState ( JobState . COMPLETE ) ; DailySchedule time = new DailySchedule ( ) ; time . setFrom ( "14:45" ) ; time . setTo ( "14:55" ) ; ManualClock clock = new ManualClock ( "" ) ; Timer test = new Timer ( ) ; test . setSchedule ( time ) ; test . setClock ( clock ) ; test . setJob ( job ) ; OurScheduledExecutorService oddjobServices = new OurScheduledExecutorService ( ) ; test . setScheduleExecutorService ( oddjobServices ) ; test . run ( ) ; assertNotNull ( oddjobServices . runnable ) ; assertEquals ( 0 , oddjobServices . delay ) ; oddjobServices . runnable . run ( ) ; Date expectedNextDue = DateHelper . parseDateTime ( "" ) ; assertEquals ( expectedNextDue , test . getNextDue ( ) ) ; assertEquals ( expectedNextDue . getTime ( ) - clock . getDate ( ) . getTime ( ) , oddjobServices . delay ) ; } public void testOverdueSchedule ( ) throws ParseException { FlagState job = new FlagState ( ) ; job . setState ( JobState . COMPLETE ) ; DailySchedule time = new DailySchedule ( ) ; time . setAt ( "12:00" ) ; ManualClock clock = new ManualClock ( "" ) ; Timer test = new Timer ( ) ; test . setSchedule ( time ) ; test . setClock ( clock ) ; test . setJob ( job ) ; OurScheduledExecutorService oddjobServices = new OurScheduledExecutorService ( ) ; test . setScheduleExecutorService ( oddjobServices ) ; test . run ( ) ; assertNotNull ( oddjobServices . runnable ) ; assertEquals ( 22 * 60 * 60 * 1000 , oddjobServices . delay ) ; clock . setDate ( "" ) ; oddjobServices . runnable . run ( ) ; assertEquals ( 0 , oddjobServices . delay ) ; clock . setDate ( "" ) ; oddjobServices . runnable . run ( ) ; assertEquals ( 18 * 60 * 60 * 1000 , oddjobServices . delay ) ; } public void testSkipMissedSchedule ( ) throws ParseException { FlagState job = new FlagState ( ) ; job . setState ( JobState . COMPLETE ) ; DailySchedule time = new DailySchedule ( ) ; time . setAt ( "12:00" ) ; ManualClock clock = new ManualClock ( "" ) ; Timer test = new Timer ( ) ; test . setSchedule ( time ) ; test . setClock ( clock ) ; test . setJob ( job ) ; test . setSkipMissedRuns ( true ) ; OurScheduledExecutorService oddjobServices = new OurScheduledExecutorService ( ) ; test . setScheduleExecutorService ( oddjobServices ) ; test . run ( ) ; assertNotNull ( oddjobServices . runnable ) ; assertEquals ( 22 * 60 * 60 * 1000 , oddjobServices . delay ) ; clock . setDate ( "" ) ; oddjobServices . runnable . run ( ) ; assertEquals ( 23 * 60 * 60 * 1000 , oddjobServices . delay ) ; } public void testHaltOnFailure ( ) throws ParseException { FlagState job = new FlagState ( ) ; job . setState ( JobState . INCOMPLETE ) ; TimeSchedule time = new TimeSchedule ( ) ; time . setFrom ( "14:45" ) ; time . setTo ( "14:55" ) ; ManualClock clock = new ManualClock ( "" ) ; Timer test = new Timer ( ) ; test . setSchedule ( time ) ; test . setClock ( clock ) ; test . setHaltOnFailure ( true ) ; test . setJob ( job ) ; OurScheduledExecutorService oddjobServices = new OurScheduledExecutorService ( ) ; test . setScheduleExecutorService ( oddjobServices ) ; test . run ( ) ; assertNotNull ( oddjobServices . runnable ) ; assertEquals ( 0 , oddjobServices . delay ) ; oddjobServices . delay = - 1 ; oddjobServices . runnable . run ( ) ; assertEquals ( - 1 , oddjobServices . delay ) ; assertEquals ( null , test . getNextDue ( ) ) ; assertEquals ( ParentState . INCOMPLETE , test . lastStateEvent ( ) . getState ( ) ) ; } public void testTimeZone ( ) throws Exception { TimeZone . setDefault ( TimeZone . getTimeZone ( "GMT" ) ) ; DateSchedule schedule = new DateSchedule ( ) ; schedule . setOn ( "2020-06-21" ) ; DailySchedule daily = new DailySchedule ( ) ; daily . setAt ( "10:00" ) ; schedule . setRefinement ( daily ) ; OurJob ourJob = new OurJob ( ) ; Timer test = new Timer ( ) ; test . setSchedule ( schedule ) ; test . setJob ( ourJob ) ; test . setTimeZone ( "GMT+8" ) ; OurScheduledExecutorService oddjobServices = new OurScheduledExecutorService ( ) ; test . setScheduleExecutorService ( oddjobServices ) ; test . run ( ) ; assertEquals ( DateHelper . parseDateTime ( "" ) , test . getNextDue ( ) ) ; TimeZone . setDefault ( null ) ; } public void testSerialize ( ) throws Exception { FlagState sample = new FlagState ( ) ; sample . setState ( JobState . COMPLETE ) ; Timer test = new Timer ( ) ; IntervalSchedule interval = new IntervalSchedule ( ) ; interval . setInterval ( "00:00:05" ) ; CountSchedule count = new CountSchedule ( ) ; count . setCount ( 2 ) ; count . setRefinement ( interval ) ; ManualClock clock = new ManualClock ( "" ) ; test . setSchedule ( count ) ; test . setJob ( sample ) ; test . setClock ( clock ) ; OurScheduledExecutorService oddjobServices = new OurScheduledExecutorService ( ) ; test . setScheduleExecutorService ( oddjobServices ) ; test . run ( ) ; assertEquals ( 0 , oddjobServices . delay ) ; oddjobServices . runnable . run ( ) ; assertEquals ( 5000 , oddjobServices . delay ) ; Timer copy = ( Timer ) Helper . copy ( test ) ; copy . setClock ( clock ) ; copy . setScheduleExecutorService ( oddjobServices ) ; assertEquals ( 5000 , oddjobServices . delay ) ; Runnable runnable = oddjobServices . runnable ; oddjobServices . runnable = null ; runnable . run ( ) ; assertNull ( copy . getNextDue ( ) ) ; assertNull ( oddjobServices . runnable ) ; } public void testSerializeNotComplete ( ) throws Exception { FlagState sample = new FlagState ( ) ; sample . setState ( JobState . INCOMPLETE ) ; Timer test = new Timer ( ) ; ManualClock clock = new ManualClock ( "" ) ; test . setSchedule ( new NowSchedule ( ) ) ; test . setJob ( sample ) ; test . setClock ( clock ) ; OurScheduledExecutorService oddjobServices = new OurScheduledExecutorService ( ) ; test . setScheduleExecutorService ( oddjobServices ) ; test . run ( ) ; assertEquals ( 0 , oddjobServices . delay ) ; oddjobServices . runnable . run ( ) ; Timer copy = ( Timer ) Helper . copy ( test ) ; assertEquals ( ParentState . READY , copy . lastStateEvent ( ) . getState ( ) ) ; assertEquals ( DateHelper . parseDateTime ( "" ) , test . getLastDue ( ) ) ; assertEquals ( new SimpleScheduleResult ( new SimpleInterval ( DateHelper . parseDateTime ( "" ) ) ) , test . getCurrent ( ) ) ; } private class OurStopServices extends MockScheduledExecutorService { public ScheduledFuture < ? > schedule ( Runnable runnable , long delay , TimeUnit unit ) { if ( delay < 1 ) { new Thread ( runnable ) . start ( ) ; } return new MockScheduledFuture < Void > ( ) { public boolean cancel ( boolean interrupt ) { return false ; } } ; } } ; public void testStop ( ) throws ParseException , InterruptedException , FailedToStopException { final Timer test = new Timer ( ) ; test . setSchedule ( new CountSchedule ( 2 ) ) ; IntervalSchedule interval = new IntervalSchedule ( ) ; interval . setInterval ( "00:15" ) ; final IconSteps checkFirstThreadFinished = new IconSteps ( test ) ; checkFirstThreadFinished . startCheck ( IconHelper . READY , IconHelper . EXECUTING , IconHelper . SLEEPING , IconHelper . EXECUTING , IconHelper . ACTIVE , IconHelper . SLEEPING ) ; Retry retry = new Retry ( ) ; retry . setSchedule ( interval ) ; SimpleJob child = new SimpleJob ( ) { int i ; Runnable [ ] jobs = { new FlagState ( ) , new WaitJob ( ) } ; @ Override protected int execute ( ) throws Throwable { jobs [ i ++ ] . run ( ) ; return 0 ; } } ; retry . setJob ( child ) ; test . setJob ( retry ) ; OurStopServices services = new OurStopServices ( ) ; test . setScheduleExecutorService ( services ) ; retry . setScheduleExecutorService ( services ) ; StateSteps state = new StateSteps ( test ) ; state . startCheck ( ParentState . READY , ParentState . EXECUTING , ParentState . ACTIVE , ParentState . READY ) ; IconSteps icons = new IconSteps ( test ) ; icons . startCheck ( IconHelper . READY , IconHelper . EXECUTING , IconHelper . SLEEPING , IconHelper . EXECUTING , IconHelper . ACTIVE , IconHelper . SLEEPING , IconHelper . STOPPING , IconHelper . READY ) ; test . run ( ) ; checkFirstThreadFinished . checkWait ( ) ; test . stop ( ) ; state . checkWait ( ) ; icons . checkNow ( ) ; test . setJob ( null ) ; retry . destroy ( ) ; test . destroy ( ) ; } public void testStopBeforeTriggered ( ) throws FailedToStopException { class Executor extends MockScheduledExecutorService { boolean canceled ; Runnable job ; @ Override public ScheduledFuture < ? > schedule ( Runnable command , long delay , TimeUnit unit ) { job = command ; return new MockScheduledFuture < Void > ( ) { @ Override public boolean cancel ( boolean mayInterruptIfRunning ) { assertEquals ( false , mayInterruptIfRunning ) ; canceled = true ; job = null ; return true ; } } ; } } Executor executor = new Executor ( ) ; Timer test = new Timer ( ) ; test . setClock ( new ManualClock ( "" ) ) ; test . setScheduleExecutorService ( executor ) ; test . setJob ( new FlagState ( ) ) ; TimeSchedule schedule = new TimeSchedule ( ) ; test . setSchedule ( schedule ) ; StateSteps state = new StateSteps ( test ) ; state . startCheck ( ParentState . READY , ParentState . EXECUTING , ParentState . ACTIVE ) ; IconSteps icons = new IconSteps ( test ) ; icons . startCheck ( IconHelper . READY , IconHelper . EXECUTING , IconHelper . SLEEPING ) ; test . run ( ) ; state . checkNow ( ) ; icons . checkNow ( ) ; state . startCheck ( ParentState . ACTIVE , ParentState . READY ) ; icons . startCheck ( IconHelper . SLEEPING , IconHelper . STOPPING , IconHelper . READY ) ; test . stop ( ) ; state . checkNow ( ) ; icons . checkNow ( ) ; assertEquals ( true , executor . canceled ) ; state . startCheck ( ParentState . READY , ParentState . EXECUTING , ParentState . ACTIVE ) ; test . run ( ) ; state . checkNow ( ) ; state . startCheck ( ParentState . ACTIVE , ParentState . COMPLETE ) ; executor . job . run ( ) ; state . checkNow ( ) ; test . destroy ( ) ; } public void testSerializeUnserializbleSchedule ( ) throws IOException , ClassNotFoundException { Timer test = new Timer ( ) ; test . setSchedule ( new Schedule ( ) { public IntervalTo nextDue ( ScheduleContext context ) { return null ; } } ) ; Timer copy = Helper . copy ( test ) ; assertNull ( copy . getSchedule ( ) ) ; } public void testPersistedScheduleInOddjob ( ) throws FailedToStopException , ArooaPropertyException , ArooaConversionException , InterruptedException , IOException , ParseException { OurDirs dirs = new OurDirs ( ) ; File persistDir = dirs . relative ( "" ) ; if ( persistDir . exists ( ) ) { FileUtils . forceDelete ( persistDir ) ; } Oddjob oddjob1 = new Oddjob ( ) ; oddjob1 . setFile ( dirs . relative ( "" ) ) ; oddjob1 . setExport ( "clock" , new ArooaObject ( new ManualClock ( "" ) ) ) ; oddjob1 . setExport ( "work-dir" , new ArooaObject ( dirs . relative ( "work" ) ) ) ; oddjob1 . run ( ) ; assertEquals ( ParentState . ACTIVE , oddjob1 . lastStateEvent ( ) . getState ( ) ) ; assertEquals ( new SimpleInterval ( DateHelper . parseDateTime ( "" ) , DateHelper . parseDateTime ( "" ) ) , new OddjobLookup ( oddjob1 ) . lookup ( "" ) ) ; assertEquals ( DateHelper . parseDateTime ( "" ) , new OddjobLookup ( oddjob1 ) . lookup ( "" ) ) ; oddjob1 . stop ( ) ; assertEquals ( ParentState . READY , oddjob1 . lastStateEvent ( ) . getState ( ) ) ; oddjob1 . destroy ( ) ; Oddjob oddjob2 = new Oddjob ( ) ; oddjob2 . setFile ( dirs . relative ( "" ) ) ; oddjob2 . setExport ( "clock" , new ArooaObject ( new ManualClock ( "" ) ) ) ; oddjob2 . setExport ( "work-dir" , new ArooaObject ( dirs . relative ( "work" ) ) ) ; oddjob2 . load ( ) ; Oddjob innerOddjob2 = new OddjobLookup ( oddjob2 ) . lookup | |
932 | <s> package com . asakusafw . compiler . operator . processor ; import static org . junit . Assert . * ; import org . junit . Test ; import com . asakusafw . compiler . operator . OperatorCompilerTestRoot ; import com . asakusafw . compiler . operator . model . MockHoge ; import com . asakusafw . utils . graph . Graph ; import com . asakusafw . vocabulary . flow . testing . MockIn ; import com . asakusafw . vocabulary . flow . testing . MockOut ; public class GroupSortOperatorProcessorTest extends OperatorCompilerTestRoot { @ Test public void simple ( ) { add ( "" ) ; ClassLoader loader = start ( new GroupSortOperatorProcessor ( ) ) ; Object factory = create ( loader , "" ) ; MockIn < MockHoge > in = MockIn . of ( MockHoge . class , "in" ) ; MockOut < MockHoge > a = MockOut . of ( MockHoge . class , "a" ) ; MockOut < MockHoge > b = MockOut . of ( MockHoge . class , "b" ) ; Object gs = invoke ( factory , "example" , in ) ; a . add ( output ( MockHoge . class , gs , "first" ) ) ; b . add ( output ( MockHoge . class , gs , "last" ) ) ; Graph < String > graph = toGraph ( in ) ; assertThat ( graph . getConnected ( "in" ) , isJust ( "" ) ) ; assertThat ( graph . getConnected ( "" ) , isJust ( "a" , "b" ) ) ; } @ Test public void parameterized ( ) { add ( "" ) ; ClassLoader | |
933 | <s> package org . oddjob . monitor ; import java . awt . event . ActionEvent ; import java . awt . event . KeyEvent ; import javax . swing . KeyStroke ; public class Standards extends org . oddjob . arooa . design . view . Standards { public static final Integer NEW_MNEMONIC_KEY = new Integer ( KeyEvent . VK_N ) ; public static final KeyStroke NEW_ACCELERATOR_KEY = KeyStroke . getKeyStroke ( KeyEvent . VK_N , ActionEvent . CTRL_MASK ) ; public static final Integer OPEN_MNEMONIC_KEY = new Integer ( KeyEvent . VK_O ) ; public static final KeyStroke OPEN_ACCELERATOR_KEY = KeyStroke . getKeyStroke ( KeyEvent . VK_O , ActionEvent . CTRL_MASK ) ; public static final Integer CLOSE_MNEMONIC_KEY = new Integer ( KeyEvent . VK_C ) ; public static final KeyStroke CLOSE_ACCELERATOR_KEY = KeyStroke . getKeyStroke ( KeyEvent . VK_F4 , ActionEvent . CTRL_MASK ) ; public static final Integer RELOAD_MNEMONIC_KEY = new Integer ( KeyEvent . VK_R ) ; public static final KeyStroke RELOAD_ACCELERATOR_KEY = KeyStroke . getKeyStroke ( KeyEvent . VK_L , ActionEvent . CTRL_MASK ) ; public static final Integer SAVE_MNEMONIC_KEY = new Integer ( KeyEvent . VK_S ) ; public static final KeyStroke SAVE_ACCELERATOR_KEY = KeyStroke . getKeyStroke ( KeyEvent . VK_S , ActionEvent . CTRL_MASK ) ; public static final Integer SAVEAS_MNEMONIC_KEY = new Integer ( KeyEvent . VK_A ) ; public static final KeyStroke SAVEAS_ACCELERATOR_KEY = KeyStroke . getKeyStroke ( KeyEvent . VK_A , ActionEvent . CTRL_MASK ) ; public static final Integer RUN_MNEMONIC_KEY = | |
934 | <s> package org . rubypeople . rdt . internal . ui . text ; import org . eclipse . jface . text . IDocument ; | |
935 | <s> package net . sf . sveditor . core . dirtree ; import java . util . ArrayList ; import java . util . List ; public class SVDBDirTreeNode { private String fName ; private boolean fIsDir ; private SVDBDirTreeNode fParent ; private List < SVDBDirTreeNode > fChildren ; public SVDBDirTreeNode ( SVDBDirTreeNode parent , String name , | |
936 | <s> package org . rubypeople . rdt . internal . corext . util ; import java . io . IOException ; import java . io . InputStream ; import java . io . Reader ; import org . rubypeople . rdt | |
937 | <s> package com . asakusafw . compiler . flow . visualizer ; import java . util . Collections ; import java . util . Set ; import java . util . UUID ; import com . asakusafw . compiler . common . Precondition ; import com . asakusafw . utils . collections . Sets ; public class VisualGraph implements VisualNode { private final UUID id = UUID . randomUUID ( ) ; private final String label ; private final Set < VisualNode > nodes ; public VisualGraph ( String label , Set < ? extends VisualNode > nodes ) { Precondition . checkMustNotBeNull ( nodes , "nodes" ) ; this . label = label ; this . nodes = Sets . from ( nodes ) ; } public String getLabel ( ) { return label ; } @ Override public UUID getId ( ) { return id ; } public Set < VisualNode > getNodes ( ) { return Collections . unmodifiableSet ( nodes ) ; } @ Override public Kind getKind ( ) | |
938 | <s> package net . sf . sveditor . core . db . stmt ; import net . sf . sveditor . core . db . SVDBItemType ; public class SVDBForkStmt | |
939 | <s> package journal . io . util ; import java . util . logging . Level ; import java . util . logging . Logger ; public class LogHelper { private static final Logger LOG = Logger . getLogger ( LogHelper . class . getName ( ) ) ; public static void warn ( String message , Object ... args ) { if ( LOG . isLoggable ( Level . WARNING ) ) { LOG . log ( Level . WARNING , String . format ( message , args ) ) ; } } public static void warn ( Throwable e , String message ) { if ( LOG . isLoggable ( Level . WARNING ) ) { LOG . log ( Level . WARNING , message , e ) ; } } public static void warn ( Throwable e , String message , Object ... args ) { if ( LOG . isLoggable ( Level . WARNING ) ) { LOG . log ( Level . WARNING , String . format ( message , args ) , e ) ; } } public static void error ( String message , Object ... args ) { if ( LOG . isLoggable ( Level . SEVERE ) ) { LOG . log ( Level . SEVERE , String . format ( message , args ) ) ; } } | |
940 | <s> package org . rubypeople . rdt . refactoring . core ; import java . util . ArrayList ; import java . util . Collection ; import org . jruby . ast . ConstNode ; import org . jruby . ast . ModuleNode ; import org . jruby . ast . Node ; import org . rubypeople . rdt . refactoring . documentprovider . IDocumentProvider ; import org . rubypeople . rdt . refactoring . nodewrapper . ModuleNodeWrapper ; public abstract class ModuleNodeProvider { private interface IModuleAcceptor { boolean accept ( ModuleNodeWrapper wrapper ) ; } public static ModuleNodeWrapper getSelectedModuleNode ( Node root , int pos ) { ModuleNode module = ( ModuleNode ) SelectionNodeProvider . getSelectedNodeOfType ( root , pos , ModuleNode . class ) ; if ( module == null ) { return null ; } return createModuleNodeWrapper ( root , module ) ; } private static Collection < ModuleNodeWrapper > findModules ( IDocumentProvider doc , IModuleAcceptor acceptor ) { ArrayList < ModuleNodeWrapper > modules = new ArrayList < ModuleNodeWrapper > ( ) ; for ( String file : doc . getFileNames ( ) ) { for ( Node node : NodeProvider . getSubNodes ( doc . getRootNode ( file ) , ModuleNode . class ) ) { ModuleNode moduleNode = ( ModuleNode ) node ; ModuleNodeWrapper wrapper = createModuleNodeWrapper ( doc . getRootNode ( file ) , moduleNode ) ; if ( acceptor . accept ( wrapper ) ) { modules . add ( wrapper ) ; } } } return modules ; } public static Collection < ModuleNodeWrapper > findOtherParts ( IDocumentProvider doc , final ModuleNodeWrapper module ) { return findModules ( doc , new IModuleAcceptor ( ) { public boolean accept ( ModuleNodeWrapper wrapper ) { return wrapper . getFullName ( ) . equals ( module . getFullName ( ) ) ; } } ) ; } public static Collection < ModuleNodeWrapper > findAllModules ( IDocumentProvider doc ) { return findModules ( doc , new IModuleAcceptor ( ) { | |
941 | <s> package com . asakusafw . yaess . flowlog ; import java . io . File ; import java . nio . charset . Charset ; import java . text . DateFormat ; import java . text . MessageFormat ; import java . text . SimpleDateFormat ; import java . util . Map ; import java . util . TreeMap ; import com . asakusafw . yaess . core . ExecutionContext ; import com . asakusafw . yaess . core . ServiceProfile ; public class FlowLoggerProfile { static final String KEY_DIRECTORY = "directory" ; static final String KEY_ENCODING = "encoding" ; static final String KEY_STEP_UNIT = "stepUnit" ; static final String KEY_DATE_FORMAT = "dateFormat" ; static final String KEY_REPORT_JOB = "reportJob" ; static final String KEY_DELETE_ON_SETUP = "" ; static final String KEY_DELETE_ON_CLEANUP = "" ; static final String DEFAULT_ENCODING = "UTF-8" ; static final String DEFAULT_STEP_UNIT = "0.00" ; static final String DEFAULT_DATE_FORMAT = "" ; static final String DEFAULT_REPORT_JOB = "true" ; static final String DEFAULT_DELETE_ON_SETUP = "true" ; static final String DEFAULT_DELETE_ON_CLEANUP = "true" ; private final File directory ; private final Charset encoding ; private final DateFormat dateFormat ; private final double stepUnit ; private final boolean reportJob ; private final boolean deleteOnSetup ; private final boolean deleteOnCleanup ; FlowLoggerProfile ( File directory , Charset encoding , DateFormat dateFormat , double stepUnit , boolean reportJob , boolean deleteOnSetup , boolean deleteOnCleanup ) { if ( directory == null ) { throw new IllegalArgumentException ( "" ) ; } if ( encoding == null ) { throw new IllegalArgumentException ( "" ) ; } if ( dateFormat == null ) { throw new IllegalArgumentException ( "" ) ; } this . directory = directory ; this . encoding = encoding ; this . dateFormat = dateFormat ; this . stepUnit = stepUnit ; this . reportJob = reportJob ; this . deleteOnSetup = deleteOnSetup ; this . deleteOnCleanup = deleteOnCleanup ; } public File getDirectory ( ) { return directory ; } public Charset getEncoding ( ) { return encoding ; } public DateFormat getDateFormat ( ) { return ( DateFormat ) dateFormat . clone ( ) ; } public double getStepUnit ( ) { return stepUnit ; } public boolean isReportJob ( ) { return reportJob ; } | |
942 | <s> package com . sun . tools . hat . internal . server ; import java . io . PrintWriter ; import com . google . common . base . Function ; import com . google . common . base . Preconditions ; import com . google . common . base . Strings ; import com . google . common . collect . Collections2 ; import com . google . common . collect . ImmutableListMultimap ; import com . google . common . collect . ImmutableMultimap ; import com . google . common . collect . Iterables ; import com . google . common . collect . Multimap ; import com . sun . tools . hat . internal . lang . CollectionModel ; import com . sun . tools . hat . internal . lang . MapModel ; import com . sun . tools . hat . internal . lang . Model ; import com . sun . tools . hat . internal . lang . ModelFactory ; import com . sun . tools . hat . internal . lang . ModelVisitor ; import com . sun . tools . hat . internal . lang . ObjectModel ; import com . sun . tools . hat . internal . lang . ScalarModel ; import com . sun . tools . hat . internal . model . * ; import com . sun . tools . hat . internal . util . Misc ; import java . net . URLEncoder ; import java . util . Collection ; import java . util . Formatter ; import java . util . Map ; import java . io . UnsupportedEncodingException ; abstract class QueryHandler implements Runnable { protected enum GetIdString implements Function < JavaClass , String > { INSTANCE ; @ Override public String apply ( JavaClass clazz ) { return clazz . getIdString ( ) ; } } protected static class ClassResolver implements Function < String , JavaClass > { private final Snapshot snapshot ; private final boolean valueRequired ; public ClassResolver ( Snapshot snapshot , boolean valueRequired ) { this . snapshot = snapshot ; this . valueRequired = valueRequired ; } @ Override public JavaClass apply ( String name ) { if ( name == null && ! valueRequired ) { return null ; } JavaClass result = snapshot . findClass ( name ) ; Preconditions . checkNotNull ( result , "" , name ) ; return result ; } } protected String path ; protected String urlStart ; protected String query ; protected PrintWriter out ; protected Snapshot snapshot ; protected ImmutableListMultimap < String , String > params ; void setPath ( String s ) { path = s ; } void setUrlStart ( String s ) { urlStart = s ; } void setQuery ( String s ) { query = s ; } void setOutput ( PrintWriter o ) { this . out = o ; } void setSnapshot ( Snapshot ss ) { this . snapshot = ss ; } void setParams ( ImmutableListMultimap < String , String > params ) { this . params = params ; } protected static String encodeForURL ( String s ) { try { s = URLEncoder . encode ( s , "UTF-8" ) ; } catch ( UnsupportedEncodingException ex ) { throw new AssertionError ( ex ) ; } return s ; } protected void startHtml ( String title ) { out . print ( "" ) ; print ( title ) ; out . println ( | |
943 | <s> package de . fuberlin . wiwiss . d2rq . values ; import java . util . ArrayList ; import java . util . Collection ; import java . util . HashSet ; import java . util . Iterator ; import java . util . List ; import java . util . Set ; import de . fuberlin . wiwiss . d2rq . algebra . Attribute ; import de . fuberlin . wiwiss . d2rq . algebra . ColumnRenamer ; import de . fuberlin . wiwiss . d2rq . algebra . OrderSpec ; import de . fuberlin . wiwiss . d2rq . algebra . ProjectionSpec ; import de . fuberlin . wiwiss . d2rq . expr . AttributeExpr ; import de . fuberlin . wiwiss . d2rq . expr . Concatenation ; import de . fuberlin . wiwiss . d2rq . expr . Conjunction ; import de . fuberlin . wiwiss . d2rq . expr . Constant ; import de . fuberlin . wiwiss . d2rq . expr . Equality ; import de . fuberlin . wiwiss . d2rq . expr . Expression ; import de . fuberlin . wiwiss . d2rq . nodes . NodeSetFilter ; import de . fuberlin . wiwiss . d2rq . sql . ResultRow ; public class BlankNodeID implements ValueMaker { private final static String DELIMITER = "@@" ; private String classMapID ; private List < Attribute > attributes ; public BlankNodeID ( String classMapID , List < Attribute > attributes ) { this . classMapID = classMapID ; this . attributes = attributes ; } public List < Attribute > attributes ( ) { return this . attributes ; } public String classMapID ( ) { return | |
944 | <s> package net . sf . sveditor . core . tests . index . libIndex ; import java . io . ByteArrayOutputStream ; import java . io . File ; import java . io . PrintStream ; import junit . framework . TestCase ; import net . sf . sveditor . core . SVCorePlugin ; import net . sf . sveditor . core . db . ISVDBItemBase ; import net . sf . sveditor . core . db . SVDBItem ; import net . sf . sveditor . core . db . index . ISVDBIndex ; import net . sf . sveditor . core . db . index . ISVDBItemIterator ; import net . sf . sveditor . core . db . index . SVDBIndexRegistry ; import net . sf . sveditor . core . db . index . SVDBLibPathIndexFactory ; import net . sf . sveditor . core . log . LogFactory ; import net . sf . sveditor . core . log . LogHandle ; import net . sf . sveditor . core . tests . SVCoreTestsPlugin ; import net . sf . sveditor . core . tests . TestIndexCacheFactory ; import net . sf . sveditor . core . tests . utils . BundleUtils ; import net . sf . sveditor . core . tests . utils . TestUtils ; import org . eclipse . core . resources . IProject ; import org . eclipse . core . runtime . NullProgressMonitor ; import org . eclipse . core . runtime . Path ; public class WSLibIndexFileChanges extends TestCase { @ Override protected void setUp ( ) throws Exception { super . setUp ( ) ; } @ Override protected void tearDown ( ) throws Exception { SVDBIndexRegistry rgy = SVCorePlugin . getDefault ( ) . getSVDBIndexRegistry ( ) ; rgy . save_state ( ) ; } public void testMissingIncludeAdded ( ) { SVCorePlugin . getDefault ( ) . enableDebug ( false ) ; File tmpdir = TestUtils . createTempDir ( ) ; try { int_testMissingIncludeAdded ( "" , tmpdir ) ; } catch ( RuntimeException e ) { throw e ; } finally { TestUtils . delete ( tmpdir ) ; } } private void int_testMissingIncludeAdded ( String testname , File tmpdir ) throws RuntimeException { BundleUtils utils = new BundleUtils ( SVCoreTestsPlugin . getDefault ( ) . getBundle ( ) ) ; LogHandle log = LogFactory . getLogHandle ( testname ) ; IProject project_dir = TestUtils . createProject ( "project" ) ; | |
945 | <s> package org . rubypeople . rdt . refactoring . core . renamemethod ; import java . util . ArrayList ; import java . util . Collection ; import org . jruby . ast . CallNode ; import org . jruby . ast . ClassNode ; import org . jruby . ast . FCallNode ; import org . jruby . ast . Node ; import org . jruby . ast . SClassNode ; import org . jruby . ast . SymbolNode ; import org . jruby . ast . VCallNode ; import org . rubypeople . rdt . refactoring . classnodeprovider . ClassNodeProvider ; import org . rubypeople . rdt . refactoring . core . NodeProvider ; import org . rubypeople . rdt . refactoring . core . SelectionNodeProvider ; import org . rubypeople . rdt . refactoring . core . renamefield . FieldRenameEditProvider ; import org . rubypeople . rdt . refactoring . core . renamefield . fielditems . FieldItem ; import org . rubypeople . rdt . refactoring . core . renamemethod . methoditems . CallCandidateItem ; import org . rubypeople . rdt . refactoring . core . renamemethod . methoditems . MethodNameArgumentItem ; import org . rubypeople . rdt . refactoring . core . renamemethod . methoditems . SymbolItem ; import org . rubypeople . rdt . refactoring . editprovider . FileEditProvider ; import org . rubypeople . rdt . refactoring . editprovider . FileMultiEditProvider ; import org . rubypeople . rdt . refactoring . editprovider . IMultiFileEditProvider ; import org . rubypeople . rdt . refactoring . editprovider . MultiFileEditProvider ; import org . rubypeople . rdt . refactoring . exception . NoClassNodeException ; import org . rubypeople . rdt . refactoring . nodewrapper . ClassNodeWrapper ; import org . rubypeople . rdt . refactoring . nodewrapper . INodeWrapper ; import org . rubypeople . rdt . refactoring . nodewrapper . MethodCallNodeWrapper ; import org . rubypeople . rdt . refactoring . nodewrapper . MethodNodeWrapper ; public class MethodRenamer implements IMultiFileEditProvider { private RenameMethodConfig config ; public Collection < String > getAllMethodsFromClass ( ) { Collection < String > names = new ArrayList < String > ( ) ; if ( config . getSelectedClass ( ) != null ) { for ( MethodNodeWrapper method : config . getSelectedClass ( ) . getMethods ( ) ) { names . add ( method . getName ( ) ) ; } } return names ; } public MethodRenamer ( RenameMethodConfig config ) { this . config = config ; Collection < INodeWrapper > probableClass = getCallCandidatesInClass ( ) ; probableClass . addAll ( getSubsequentCalls ( ) ) ; probableClass . addAll ( config . getSelectedCalls ( ) ) ; config . setSelectedCalls ( probableClass ) ; } public Collection < FileMultiEditProvider > getFileEditProviders ( ) { MultiFileEditProvider fileEdits = new MultiFileEditProvider ( ) ; addDefinitionRenamer ( fileEdits ) ; addCallRenamers ( fileEdits ) ; if ( ! config . getTargetMethod ( ) . isClassMethod ( ) ) { addSymbolRenamers ( fileEdits ) ; } return fileEdits . getFileEditProviders ( ) ; } private void addSymbolRenamers ( MultiFileEditProvider fileEdits ) { if ( config . getTargetMethod ( ) . isClassMethod ( ) ) { return ; } String file = config . getDocumentProvider ( ) . getActiveFileName ( ) ; for ( SymbolNode currentNode : getSymbolCandidatesInClass ( ) ) { addSymbolRenamer ( fileEdits , file , currentNode , config . getNewName ( ) ) ; } } private void addSymbolRenamer ( MultiFileEditProvider fileEdits , String file , SymbolNode currentNode , String name ) { SymbolItem currentItem = new SymbolItem ( currentNode ) ; fileEdits . addEditProvider ( new FileEditProvider ( file , new MethodRenameEditProvider ( currentItem , name ) ) ) ; } private void addCallRenamers ( MultiFileEditProvider fileEdits ) { for ( INodeWrapper currentCandidate : config . getSelectedCalls ( ) ) { String file = currentCandidate . getWrappedNode ( ) . getPosition ( ) . getFile ( ) ; String newName = config . getNewName ( ) ; if ( currentCandidate instanceof MethodCallNodeWrapper ) { CallCandidateItem candidateItem = new CallCandidateItem ( ( MethodCallNodeWrapper ) currentCandidate ) ; fileEdits . addEditProvider ( new FileEditProvider ( file , new MethodRenameEditProvider ( candidateItem , newName ) ) ) ; } else if ( config . renameFields ( ) ) { if ( config . getTargetMethod ( ) . isWriter ( ) ) { newName = newName . replace ( "=" , "" ) ; } FieldRenameEditProvider currentRenameProvider = new FieldRenameEditProvider ( ( FieldItem ) currentCandidate , newName ) ; fileEdits . addEditProvider ( new FileEditProvider ( file , currentRenameProvider ) ) ; } } } private void addDefinitionRenamer ( MultiFileEditProvider fileEdits ) { if ( config . getSelectedClass ( ) == null || config . getTargetMethod ( ) . isClassMethod ( ) ) { String file = config . getDocumentProvider ( ) . getActiveFileName ( ) ; MethodNameArgumentItem argumentItem = new MethodNameArgumentItem ( config . getTargetMethod ( ) . getWrappedNode ( ) . getNameNode ( ) ) ; fileEdits . addEditProvider ( new FileEditProvider ( file , new MethodRenameEditProvider ( argumentItem , config . getNewName ( ) ) ) ) ; } else { for ( ClassNodeWrapper currentClassNode : findRelatedClasses ( ) ) { MethodNodeWrapper currentMethodDef = currentClassNode . getMethod ( config . getTargetMethod ( ) . getName ( ) ) ; if ( currentMethodDef == null ) { continue ; } String currentFile = currentMethodDef . getPosition ( ) . getFile ( ) ; addMethodNameRenamer ( fileEdits , currentMethodDef , currentFile , config . getNewName ( ) ) ; } } if ( config . getTargetMethod ( ) . isAccessor ( ) && config . renameFields ( ) ) { String theOtherAccessor ; String newName ; if ( config . getTargetMethod ( ) . isReader ( ) ) { theOtherAccessor = config . getTargetMethod ( ) . getName ( ) + "=" ; newName = config . getNewName ( ) + "=" ; } else { theOtherAccessor = config . getTargetMethod ( ) . getName ( ) . replace ( "=" , "" ) ; newName = config . getNewName ( ) . replace ( "=" , "" ) ; } MethodNodeWrapper method = config . getSelectedClass ( ) . getMethod ( theOtherAccessor ) ; if ( method != null ) { addMethodNameRenamer ( fileEdits , method , method . getPosition ( ) . getFile ( ) , newName ) ; for ( SymbolNode node : method . getSymbolCandidatesInClass ( config . getSelectedClass ( ) ) ) { addSymbolRenamer ( fileEdits , method . getPosition ( ) . getFile ( ) , node , newName ) ; } } } } private void addMethodNameRenamer ( MultiFileEditProvider fileEdits , MethodNodeWrapper currentMethodDef , String currentFile , String newName ) { MethodNameArgumentItem argumentItem = new MethodNameArgumentItem ( currentMethodDef . getWrappedNode ( ) . getNameNode ( ) ) ; fileEdits . addEditProvider ( new FileEditProvider ( currentFile , new MethodRenameEditProvider ( argumentItem , newName ) ) ) ; } private ArrayList < ClassNodeWrapper > findRelatedClasses ( ) { | |
946 | <s> package org . rubypeople . rdt . internal . compiler . util ; public final class HashtableOfLong { public long [ ] keyTable ; public Object [ ] valueTable ; public int elementSize ; int threshold ; public HashtableOfLong ( ) { this ( 13 ) ; } public HashtableOfLong ( int size ) { this . elementSize = 0 ; this . threshold = size ; int extraRoom = ( int ) ( size * 1.75f ) ; if ( this . threshold == extraRoom ) extraRoom ++ ; this . keyTable = new long [ extraRoom ] ; this . valueTable = new Object [ extraRoom ] ; } public boolean containsKey ( long key ) { int length = keyTable . length , index = ( ( int ) ( key >>> 32 ) ) % length ; long currentKey ; while ( ( currentKey = keyTable [ index ] ) != 0 ) { if ( currentKey == key ) return true ; if ( ++ index == length ) { index = 0 ; } } return false ; } public Object get ( long key ) { int length = keyTable . length , index = ( ( int ) ( key >>> 32 ) ) % length ; long currentKey ; while ( ( currentKey = keyTable [ index ] ) != 0 ) { if ( currentKey == key ) return valueTable [ index ] ; if ( ++ index == length ) { index = 0 ; } } return null ; } public Object put ( long key , Object value | |
947 | <s> package fruit ; public class FlavourType implements Flavour { private static final long serialVersionUID = 2010112500L ; private String description ; public | |
948 | <s> package org . oddjob . schedules . regression ; import java . text . ParseException ; import java . util . Date ; import org . apache . log4j . Logger ; import org . oddjob . arooa . utils . DateHelper ; import org . oddjob . schedules . Interval ; import org . oddjob . schedules . IntervalTo ; import org . oddjob . schedules . Schedule ; import org . oddjob . schedules . ScheduleContext ; public class TestScheduleRun { private static final Logger logger = Logger . getLogger ( TestScheduleRun . class ) ; private String testDate ; private String expectedFrom ; private String expectedTo ; public void setExpectedFrom ( String from ) { this . expectedFrom = from ; } public String getExpectedFrom ( | |
949 | <s> package org . rubypeople . rdt . refactoring . tests . core . inlinemethod ; import org . jruby . ast . MethodDefNode ; import org . rubypeople . rdt . refactoring . core . inlinemethod . MethodFinder ; import org . rubypeople . rdt . refactoring . core . inlinemethod . SelectedCallFinder ; import org . rubypeople . rdt . refactoring . core . inlinemethod . TargetClassFinder ; import org . rubypeople . rdt . refactoring . nodewrapper . MethodCallNodeWrapper ; import org . rubypeople . rdt . refactoring . tests . FileTestCase ; import org . rubypeople . rdt . refactoring . tests . core . MultipleDocumentsInOneProvider ; public abstract class FinderTestsBase extends FileTestCase { protected MultipleDocumentsInOneProvider doc ; public FinderTestsBase ( ) { super ( "" ) ; } public FinderTestsBase ( String fileName ) { super ( fileName ) ; } protected MethodCallNodeWrapper findSelected ( int pos , String file ) { SelectedCallFinder finder = new SelectedCallFinder ( ) ; doc . setActive ( file ) ; return finder . findSelectedCall ( pos | |
950 | <s> package org . oddjob . logging . log4j ; import junit . framework . TestCase ; import org . apache . log4j . Level ; import org . apache . log4j . Logger ; import org . oddjob . Structural ; import org . oddjob . logging . LogEnabled ; import org . oddjob . logging . LogEvent ; import org . oddjob . logging . LogLevel ; import org . oddjob . logging . LogListener ; import org . oddjob . logging . MockLogArchiver ; import org . oddjob . structural . ChildHelper ; import org . oddjob . structural . StructuralListener ; public class Log4jArchiverTest extends TestCase { private class X implements LogEnabled { public String loggerName ( ) { return "foo" ; } } private class TestListener implements LogListener { LogEvent le ; public void logEvent ( LogEvent | |
951 | <s> package com . asakusafw . compiler . flow . processor . operator ; import java . util . Arrays ; import javax . annotation . Generated ; import com . asakusafw . compiler . flow . testing . model . Ex1 ; import com . asakusafw . vocabulary . flow . Operator ; import com . asakusafw . vocabulary . flow . Source ; import com . asakusafw . vocabulary . flow . graph . FlowBoundary ; import com . asakusafw . vocabulary . flow . graph . FlowElementResolver ; import com . asakusafw . vocabulary . flow . graph . ObservationCount ; import com . asakusafw . vocabulary . flow . graph . OperatorDescription ; import com . asakusafw . vocabulary . flow . graph . ShuffleKey ; import com . asakusafw . vocabulary . flow . processor . PartialAggregation ; import com . asakusafw . vocabulary . operator . Fold ; @ Generated ( "" ) public class FoldFlowFactory { public static final class Simple implements Operator { private final FlowElementResolver $ ; public final Source < Ex1 > out ; Simple ( Source < Ex1 > in ) { OperatorDescription . Builder builder = new OperatorDescription . Builder ( Fold . class ) ; builder . declare ( FoldFlow . class , FoldFlowImpl . class , "simple" ) ; builder . declareParameter ( Ex1 . class ) ; builder . declareParameter ( Ex1 . class ) ; builder . addInput ( "in" , in , new ShuffleKey ( Arrays . asList ( new String [ ] { "string" } ) , Arrays . asList ( new ShuffleKey . Order [ ] { } ) ) ) ; builder . addOutput ( "out" , in ) ; builder . addAttribute ( FlowBoundary . SHUFFLE ) ; builder . addAttribute ( ObservationCount . DONT_CARE ) ; builder . addAttribute ( PartialAggregation . DEFAULT ) ; this . $ = builder . toResolver ( ) ; this . $ . resolveInput ( "in" , in ) ; this . out = this . $ . resolveOutput ( "out" ) ; } public FoldFlowFactory . Simple as ( String newName ) { this . $ . setName ( newName ) ; return this ; } } public FoldFlowFactory . Simple simple ( Source < Ex1 > in ) { return new FoldFlowFactory . Simple ( in ) ; } public static final class WithParameter implements Operator { private final FlowElementResolver $ ; public final Source < Ex1 > out ; WithParameter ( Source < Ex1 > in , int parameter ) { OperatorDescription . Builder builder0 = new OperatorDescription . Builder ( Fold . class ) ; builder0 . declare ( FoldFlow . class , FoldFlowImpl . class , "" ) ; builder0 | |
952 | <s> package org . oddjob . jobs ; import java . util . LinkedList ; import org . oddjob . Stateful ; import org . oddjob . Stoppable ; import org . oddjob . arooa . deploy . annotations . ArooaAttribute ; import org . oddjob . framework . SimpleJob ; import org . oddjob . scheduling . ExecutorThrottleType ; import org . oddjob . state . IsAnyState ; import org . oddjob . state . IsStoppable ; import org . oddjob . state . State ; import org . oddjob . state . StateCondition ; import org . oddjob . state . StateEvent ; import org . oddjob . state . StateListener ; public class WaitJob extends SimpleJob implements Stoppable { private static final long DEFAULT_WAIT_SLEEP = 1000 ; private long pause ; private Object forProperty ; private boolean forSet ; private StateCondition state ; public void setPause ( long delay ) { this . pause = delay ; } public long getPause ( ) { return pause ; } public int execute ( ) throws Exception { if ( state != null ) { if ( forProperty == null ) { throw new IllegalStateException ( "" ) ; } if ( ! ( forProperty instanceof Stateful ) ) { throw new IllegalStateException ( "" ) ; } waitForState ( ) ; } else if ( forSet ) { logger ( ) . debug ( "" ) ; waitFor ( ) ; } else { simpleWait ( ) ; } return 0 ; } protected void simpleWait ( ) { sleep ( pause ) ; } protected void waitFor ( ) { long sleep = pause ; if ( sleep == 0 ) { sleep = DEFAULT_WAIT_SLEEP ; } while ( ! stop ) { stateHandler . waitToWhen ( new IsStoppable | |
953 | <s> package com . asakusafw . windgate . core . process ; import static org . hamcrest . CoreMatchers . * ; import static org . junit . Assert . * ; import java . io . IOException ; import java . util . Arrays ; import java . util . Collections ; import java . util . List ; import org . junit . Rule ; import org . junit . Test ; import com . asakusafw . runtime . core . context . RuntimeContext ; import com . asakusafw . runtime . core . context . RuntimeContext . ExecutionMode ; import com . asakusafw . runtime . core . context . RuntimeContextKeeper ; import com . asakusafw . windgate . core . DriverScript ; import com . asakusafw . windgate . core . ProcessScript ; import com . asakusafw . windgate . core . ProfileContext ; import com . asakusafw . windgate . core . resource . MockDrainDriver ; import com . asakusafw . windgate . core . resource . MockSourceDriver ; public class BasicProcessProviderTest { @ Rule public final RuntimeContextKeeper rc = new RuntimeContextKeeper ( ) ; BasicProcessProvider provider = new BasicProcessProvider ( ) ; { provider . configure ( new ProcessProfile ( "plain" , BasicProcessProvider . class , ProfileContext . system ( BasicProcessProvider . class . getClassLoader ( ) ) , Collections . < String , String > emptyMap ( ) ) ) ; } @ Test public void execute ( ) throws IOException { MockDriverFactory factory = new MockDriverFactory ( ) ; MockSourceDriver < String > source = factory . add ( "testing" , new MockSourceDriver < String > ( "source" ) ) ; MockDrainDriver < String > drain = factory . add ( "testing" , new MockDrainDriver < String > ( "drain" ) ) ; ProcessScript < String > script = new ProcessScript < String > ( "testing" , "plain" , String . class , driver ( "source" ) , driver ( "drain" ) ) ; List < String > data = Arrays . asList ( "Hello" , "world" , "!" ) ; source . setIterable ( data ) ; provider . execute ( factory , script ) ; assertThat ( drain . getResults ( ) , is ( data ) ) ; } @ Test ( expected = IOException . class ) public void execute_invalid_source ( ) throws IOException { MockDriverFactory factory = new MockDriverFactory ( ) ; ProcessScript < String > script = new ProcessScript < String > ( "testing" , "plain" , String . class , driver ( "source" ) , driver ( "drain" ) | |
954 | <s> package com . asakusafw . utils . java . parser . javadoc ; import static com . asakusafw . utils . java . internal . parser . javadoc . ir . IrDocElementKind . * ; import static org . junit . Assert . * ; import java . util . Arrays ; import java . util . Collections ; import java . util . List ; import java . util . regex . Pattern ; import org . junit . Test ; import com . asakusafw . utils . java . internal . parser . javadoc . ir . IrDocBlock ; import com . asakusafw . utils . java . internal . parser . javadoc . ir . IrDocFragment ; import com . asakusafw . utils . java . internal . parser . javadoc . ir . IrDocSimpleName ; import com . asakusafw . utils . java . internal . parser . javadoc . ir . IrDocText ; import com . asakusafw . utils . java . internal . parser . javadoc . ir . IrLocation ; public class JavadocBlockParserTest extends JavadocTestRoot { @ Test public void testNewBlock ( ) { MockJavadocBlockParser parser = new MockJavadocBlockParser ( ) ; { IrDocBlock block = parser . newBlock ( null , Collections . < IrDocFragment > emptyList ( ) ) ; assertNull ( block . getTag ( ) ) ; assertEquals ( 0 , block . getFragments ( ) . size ( ) ) ; } { IrDocText f0 = new IrDocText ( "" ) ; IrDocBlock block = parser . newBlock ( "code" , Arrays . asList ( f0 ) ) ; assertEquals ( "@code" , block . getTag ( ) ) ; assertEquals ( 1 , block . getFragments ( ) . size ( ) ) ; assertEquals ( f0 , block . getFragments ( ) . get ( 0 ) ) ; } { IrDocSimpleName f0 = new IrDocSimpleName ( "arg0" ) ; IrDocText f1 = new IrDocText ( "Hello!" ) ; IrDocText f2 = new IrDocText ( "This is text" ) ; IrDocBlock block = parser . newBlock ( "param" , Arrays . < IrDocFragment > asList ( f0 , f1 , f2 ) ) ; assertEquals ( "@param" , block . getTag ( ) ) ; assertEquals ( 3 , block . getFragments | |
955 | <s> package com . asakusafw . compiler . flow . processor . flow ; import com . asakusafw . compiler . flow . processor . ExtendFlowProcessor ; import com . asakusafw . compiler . flow . testing . external . Ex1MockImporterDescription ; import com . asakusafw . compiler . flow . testing . external . Ex2MockExporterDescription ; import com . asakusafw . compiler . flow . testing . model . | |
956 | <s> package net . sf . sveditor . core . templates ; import java . io . IOException ; import java . io . InputStream ; import org . eclipse . core . resources . IFile ; import org . eclipse . core . resources . IWorkspaceRoot ; import org . eclipse . core . resources . ResourcesPlugin ; import org . eclipse . core . runtime . CoreException ; import org . eclipse . core . runtime . Path ; public class WSInStreamProvider implements ITemplateInStreamProvider { public InputStream openStream ( String path ) { IWorkspaceRoot root = ResourcesPlugin . getWorkspace ( ) . getRoot ( ) ; InputStream in = null ; try { IFile file = root . getFile ( new Path ( path ) ) ; if ( file . exists ( | |
957 | <s> package net . sf . sveditor . core . db . utils ; import java . util . ArrayList ; import java . util . List ; import net . sf . sveditor . core . db . ISVDBChildItem ; import net . sf . sveditor . core . db . ISVDBChildParent ; import net . sf . sveditor . core . db . ISVDBItemBase ; import net . sf . sveditor . core . db . ISVDBNamedItem ; import net . sf . sveditor . core . db . ISVDBScopeItem ; import net . sf . sveditor . core . db . SVDBItem ; import net . sf . sveditor . core . db . SVDBItemType ; import net . sf . sveditor . core . db . SVDBLocation ; import net . sf . sveditor . core . db . SVDBModIfcDecl ; import net . sf . sveditor . core . db . SVDBScopeItem ; import net . sf . sveditor . core . db . stmt . ISVDBBodyStmt ; import net . sf . sveditor . core . db . stmt . SVDBIfStmt ; import net . sf . sveditor . core . log . ILogLevel ; import net . sf . sveditor . core . log . LogFactory ; import net . sf . sveditor . core . log . LogHandle ; public class SVDBSearchUtils implements ILogLevel { private static final LogHandle fLog ; static { fLog = LogFactory . getLogHandle ( "" ) ; } public static List < ISVDBItemBase > findItemsByType ( SVDBScopeItem scope , SVDBItemType ... types ) { List < ISVDBItemBase > ret = new ArrayList < ISVDBItemBase > ( ) ; for ( ISVDBItemBase it : scope . getChildren ( ) ) { boolean match = ( types . length == 0 ) ; for ( SVDBItemType t : types ) { if ( it . getType ( ) == t ) { match = true ; break ; } } if ( match ) { ret . add ( it ) ; } } return ret ; } public static SVDBModIfcDecl findClassScope ( ISVDBChildItem scope ) { while ( scope != null && scope . getType ( ) != SVDBItemType . ClassDecl ) { scope = scope . getParent ( ) ; } return ( SVDBModIfcDecl ) scope ; } public static List < ISVDBItemBase > findItemsByName ( ISVDBScopeItem scope , String name , SVDBItemType ... types ) { List < ISVDBItemBase > ret = new ArrayList < ISVDBItemBase > ( ) ; for ( ISVDBItemBase it : scope . getItems ( ) ) { boolean type_match = ( types . length == 0 ) ; for ( SVDBItemType t : types ) { if ( it . getType ( ) == t ) { type_match = true ; break ; } } if ( type_match && ( it instanceof ISVDBNamedItem ) && ( ( ISVDBNamedItem ) it ) . getName ( ) != null && ( ( ISVDBNamedItem ) it ) . getName ( ) . equals ( name ) ) { ret . add ( it ) ; } else if ( it instanceof ISVDBScopeItem ) { ret . addAll ( findItemsByName ( ( ISVDBScopeItem ) it , name , types ) ) ; } } return ret ; } public static ISVDBScopeItem findActiveScope ( ISVDBChildParent scope , int lineno ) { ISVDBScopeItem ret = null ; debug ( "" + SVDBItem . getName ( scope ) + " " + lineno ) ; for ( ISVDBItemBase it : scope . getChildren ( ) ) { debug ( " Child: " + SVDBItem . getName ( it ) + " " + ( it instanceof ISVDBScopeItem ) ) ; if ( it instanceof ISVDBBodyStmt && ( ( ISVDBBodyStmt ) it ) . getBody ( ) != null && ( ( ISVDBBodyStmt ) it ) . getBody ( ) instanceof ISVDBScopeItem ) { it = ( ( ISVDBBodyStmt ) it ) . getBody ( ) ; debug ( "" + SVDBItem . getName ( it ) ) ; if ( ( ret = findActiveScope_i ( it , lineno ) ) != null ) { break ; } } else if ( it . getType ( ) == SVDBItemType . IfStmt ) { SVDBIfStmt if_stmt = ( SVDBIfStmt ) it ; if ( if_stmt . getIfStmt ( ) != null ) { if ( ( ret = findActiveScope_i ( if_stmt . getIfStmt ( ) , lineno ) | |
958 | <s> package com . asakusafw . compiler . flow . example ; import com . asakusafw . compiler . operator . model . MockHoge ; import com . asakusafw . vocabulary . flow . Export ; import com . asakusafw . vocabulary . flow . FlowDescription ; import com . asakusafw . vocabulary . flow . Import ; import com . asakusafw . vocabulary . | |
959 | <s> package test . modelgen . model ; import java . io . DataInput ; import java . io . DataOutput ; import java . io . IOException ; import java . math . BigDecimal ; import javax . annotation . Generated ; import org . apache . hadoop . io . Text ; import org . apache . hadoop . io . Writable ; import com . asakusafw . runtime . value . ByteOption ; import com . asakusafw . runtime . value . Date ; import com . asakusafw . runtime . value . DateOption ; import com . asakusafw . runtime . value . DecimalOption ; import com . asakusafw . runtime . value . IntOption ; import com . asakusafw . runtime . value . LongOption ; import com . asakusafw . runtime . value . StringOption ; import com . asakusafw . vocabulary . model . Property ; import com . asakusafw . vocabulary . model . TableModel ; @ TableModel ( name = "foo" , primary = { } ) @ Generated ( "" ) @ SuppressWarnings ( "deprecation" ) public class Foo implements Writable { @ Property ( name = "PK" ) private LongOption pk = new LongOption ( ) ; @ Property ( name = "" ) private StringOption detailGroupId = new StringOption ( ) ; @ Property ( name = "DETAIL_TYPE" ) private StringOption detailType = new StringOption ( ) ; @ Property ( name = "" ) private StringOption detailSenderId = new StringOption ( ) ; @ Property ( name = "" ) private StringOption detailReceiverId = new StringOption ( ) ; @ Property ( name = "" ) private StringOption detailTestType = new StringOption ( ) ; @ Property ( name = "" ) private StringOption detailStatus = new StringOption ( ) ; @ Property ( name = "" ) private IntOption detailLineNo = new IntOption ( ) ; @ Property ( name = "DELETE_FLG" ) private StringOption deleteFlg = new StringOption ( ) ; @ Property ( name = "" ) private DateOption insertDatetime = new DateOption ( ) ; @ Property ( name = "" ) private DateOption updateDatetime = new DateOption ( ) ; @ Property ( name = "PURCHASE_NO" ) private StringOption purchaseNo = new StringOption ( ) ; @ Property ( name = "" ) private StringOption purchaseType = new StringOption ( ) ; @ Property ( name = "TRADE_TYPE" ) private StringOption tradeType = new StringOption ( ) ; @ Property ( name = "TRADE_NO" ) private StringOption tradeNo = new StringOption ( ) ; @ Property ( name = "LINE_NO" ) private ByteOption lineNo = new ByteOption ( ) ; @ Property ( name = "" ) private DateOption deliveryDate = new DateOption ( ) ; @ Property ( name = "STORE_CODE" ) private StringOption storeCode = new StringOption ( ) ; @ Property ( name = "BUYER_CODE" ) private StringOption buyerCode = new StringOption ( ) ; @ Property ( name = "" ) private StringOption salesTypeCode = new StringOption ( ) ; @ Property ( name = "SELLER_CODE" ) private StringOption sellerCode = new StringOption ( ) ; @ Property ( name = "TENANT_CODE" ) private StringOption tenantCode = new StringOption ( ) ; @ Property ( name = "" ) private LongOption netPriceTotal = new LongOption ( ) ; @ Property ( name = "" ) private LongOption sellingPriceTotal = new LongOption ( ) ; @ Property ( name = "" ) private StringOption shipmentStoreCode = new StringOption ( ) ; @ Property ( name = "" ) private StringOption shipmentSalesTypeCode = new StringOption ( ) ; @ Property ( name = "" ) private StringOption deductionCode = new StringOption ( ) ; @ Property ( name = "ACCOUNT_CODE" ) private StringOption accountCode = new StringOption ( ) ; @ Property ( name = "DEC_COL" ) private DecimalOption decCol = new DecimalOption ( ) ; @ Property ( name = "" ) private DateOption ownershipDate = new DateOption ( ) ; @ Property ( name = "CUTOFF_DATE" ) private DateOption cutoffDate = new DateOption ( ) ; @ Property ( name = "PAYOUT_DATE" ) private DateOption payoutDate = new DateOption ( ) ; @ Property ( name = "" ) private StringOption ownershipFlag = new StringOption ( ) ; @ Property ( name = "CUTOFF_FLAG" ) private StringOption cutoffFlag = new StringOption ( ) ; @ Property ( name = "PAYOUT_FLAG" ) private StringOption payoutFlag = new StringOption ( ) ; @ Property ( name = "DISPOSE_NO" ) private StringOption disposeNo = new StringOption ( ) ; @ Property ( name = "DISPOSE_DATE" ) private DateOption disposeDate = new DateOption ( ) ; public long getPk ( ) { return this . pk . get ( ) ; } public void setPk ( long pk ) { this . pk . modify ( pk ) ; } public LongOption getPkOption ( ) { return this . pk ; } public void setPkOption ( LongOption pk ) { this . pk . copyFrom ( pk ) ; } public Text getDetailGroupId ( ) { return this . detailGroupId . get ( ) ; } public void setDetailGroupId ( Text detailGroupId ) { this . detailGroupId . modify ( detailGroupId ) ; } public String getDetailGroupIdAsString ( ) { return this . detailGroupId . getAsString ( ) ; } public void setDetailGroupIdAsString ( String detailGroupId ) { this . detailGroupId . modify ( detailGroupId ) ; } public StringOption getDetailGroupIdOption ( ) { return this . detailGroupId ; } public void setDetailGroupIdOption ( StringOption detailGroupId ) { this . detailGroupId . copyFrom ( detailGroupId ) ; } public Text getDetailType ( ) { return this . detailType . get ( ) ; } public void setDetailType ( Text detailType ) { this . detailType . modify ( detailType ) ; } public String getDetailTypeAsString ( ) { return this . detailType . getAsString ( ) ; } public void setDetailTypeAsString ( String detailType ) { this . detailType . modify ( detailType ) ; } public StringOption getDetailTypeOption ( ) { return this . detailType ; } public void setDetailTypeOption ( StringOption detailType ) { this . detailType . copyFrom ( detailType ) ; } public Text getDetailSenderId ( ) { return this . detailSenderId . get ( ) ; } public void setDetailSenderId ( Text detailSenderId ) { this . detailSenderId . modify ( detailSenderId ) ; } public String getDetailSenderIdAsString ( ) { return this . detailSenderId . getAsString ( ) ; } public void setDetailSenderIdAsString ( String detailSenderId ) { this . detailSenderId . modify ( detailSenderId ) ; } public StringOption getDetailSenderIdOption ( ) { return this . detailSenderId ; } public void setDetailSenderIdOption ( StringOption detailSenderId ) { this . detailSenderId . copyFrom ( detailSenderId ) ; } public Text getDetailReceiverId ( ) { return this . detailReceiverId . get ( ) ; } public void setDetailReceiverId ( Text detailReceiverId ) { this . detailReceiverId . modify ( detailReceiverId ) ; } public String getDetailReceiverIdAsString ( ) { return this . detailReceiverId . getAsString ( ) ; } public void setDetailReceiverIdAsString ( String detailReceiverId ) { this . detailReceiverId . modify ( detailReceiverId ) ; } public StringOption getDetailReceiverIdOption ( ) { return this . detailReceiverId ; } public void setDetailReceiverIdOption ( StringOption detailReceiverId ) { this . detailReceiverId . copyFrom ( detailReceiverId ) ; } public Text getDetailTestType ( ) { return this . detailTestType . get ( ) ; } public void setDetailTestType ( Text detailTestType ) { this . detailTestType . modify ( detailTestType ) ; } public String getDetailTestTypeAsString ( ) { return this . detailTestType . getAsString ( ) ; } public void setDetailTestTypeAsString ( String detailTestType ) { this . detailTestType . modify ( detailTestType ) ; } public StringOption getDetailTestTypeOption ( ) { return this . detailTestType ; } public void setDetailTestTypeOption ( StringOption detailTestType ) { this . detailTestType . copyFrom ( detailTestType ) ; } public Text getDetailStatus ( ) { return this . detailStatus . get ( ) ; } public void setDetailStatus ( Text detailStatus ) { this . detailStatus . modify ( detailStatus ) ; } public String getDetailStatusAsString ( ) { return this . detailStatus . getAsString ( ) ; } public void setDetailStatusAsString ( String detailStatus ) { this . detailStatus . modify ( detailStatus ) ; } public StringOption getDetailStatusOption ( ) { return this . detailStatus ; } public void setDetailStatusOption ( StringOption detailStatus ) { this . detailStatus . copyFrom ( detailStatus ) ; } public int getDetailLineNo ( ) { return this . detailLineNo . get ( ) ; } public void setDetailLineNo ( int detailLineNo ) { this . detailLineNo . modify ( detailLineNo ) ; } public IntOption getDetailLineNoOption ( ) { return this . detailLineNo ; } public void setDetailLineNoOption ( IntOption detailLineNo ) { this . detailLineNo . copyFrom ( detailLineNo ) ; } public Text getDeleteFlg ( ) { return this . deleteFlg . get ( ) ; } public void setDeleteFlg ( Text deleteFlg ) { this . deleteFlg . modify ( deleteFlg ) ; } public String getDeleteFlgAsString ( ) { return this . deleteFlg . getAsString ( ) ; } public void setDeleteFlgAsString ( String deleteFlg ) { this . deleteFlg . modify ( deleteFlg ) ; } public StringOption getDeleteFlgOption ( ) { return this . deleteFlg ; } public void setDeleteFlgOption ( StringOption deleteFlg ) { this . deleteFlg . copyFrom ( deleteFlg ) ; } public Date getInsertDatetime ( ) { return this . insertDatetime . get ( ) ; } public void setInsertDatetime ( Date insertDatetime ) { this . insertDatetime . modify ( insertDatetime ) ; } public DateOption getInsertDatetimeOption ( ) { return this . insertDatetime ; } public void setInsertDatetimeOption ( DateOption insertDatetime ) { this . insertDatetime . copyFrom ( insertDatetime ) ; } public Date getUpdateDatetime ( ) { return this . updateDatetime . get ( ) ; } public void setUpdateDatetime ( Date updateDatetime ) { this . updateDatetime . modify ( updateDatetime ) ; } public DateOption getUpdateDatetimeOption ( ) { return this . updateDatetime ; } public void setUpdateDatetimeOption ( DateOption updateDatetime ) { this . updateDatetime . copyFrom ( updateDatetime ) ; } public Text getPurchaseNo ( ) { return this . purchaseNo . get ( ) ; } public void setPurchaseNo ( Text purchaseNo ) { this . purchaseNo . modify ( purchaseNo ) ; } public String getPurchaseNoAsString ( ) { return this . purchaseNo . getAsString ( ) ; } public void setPurchaseNoAsString ( String purchaseNo ) { this . purchaseNo . modify ( purchaseNo ) ; } public StringOption getPurchaseNoOption ( ) { return this . purchaseNo ; } public void setPurchaseNoOption ( StringOption purchaseNo ) { this . purchaseNo . copyFrom ( purchaseNo ) ; } public Text getPurchaseType ( ) { return this . purchaseType . get ( ) ; } public void setPurchaseType ( Text purchaseType ) { this . purchaseType . modify ( purchaseType ) ; } public String getPurchaseTypeAsString ( ) { return this . purchaseType . getAsString ( ) ; } public void setPurchaseTypeAsString ( String purchaseType ) { this . purchaseType . modify ( purchaseType ) ; } public StringOption getPurchaseTypeOption ( ) { return this . purchaseType ; } public void setPurchaseTypeOption ( StringOption purchaseType ) { this . purchaseType . copyFrom ( purchaseType ) ; } public Text getTradeType ( ) { return this . tradeType . get ( ) ; } public void setTradeType ( Text tradeType ) { this . tradeType . modify ( tradeType ) ; } public String getTradeTypeAsString ( ) { return this . tradeType . getAsString ( ) ; } public void setTradeTypeAsString ( String tradeType ) { this . tradeType . modify ( tradeType ) ; } public StringOption getTradeTypeOption ( ) { return this . tradeType ; } public void setTradeTypeOption ( StringOption tradeType ) { this . tradeType . copyFrom ( tradeType ) ; } public Text getTradeNo ( ) { return this . tradeNo . get ( ) ; } public void setTradeNo ( Text tradeNo ) { this . tradeNo . modify ( tradeNo ) ; } public String getTradeNoAsString ( ) { return this . tradeNo . getAsString ( ) ; } public void setTradeNoAsString ( String tradeNo ) { this . tradeNo . modify ( tradeNo ) ; } public StringOption getTradeNoOption ( ) { return this . tradeNo ; } public void setTradeNoOption ( StringOption tradeNo ) { this . tradeNo . copyFrom ( tradeNo ) ; } public byte getLineNo ( ) { return this . lineNo . get ( ) ; } public void setLineNo ( byte lineNo ) { this . lineNo . modify ( lineNo ) ; } public ByteOption getLineNoOption ( ) { return this . lineNo ; } public void setLineNoOption ( ByteOption lineNo ) { this . lineNo . copyFrom ( lineNo ) ; } public Date getDeliveryDate ( ) { return this . deliveryDate . get ( ) ; } public void setDeliveryDate ( Date deliveryDate ) { this . deliveryDate . modify ( | |
960 | <s> package com . pogofish . jadt . source ; import java . io . File ; import java . io . FilenameFilter ; import java . util . ArrayList ; import java . util . List ; import com . pogofish . jadt . util . Util ; public class FileSourceFactory implements SourceFactory { private static final FilenameFilter FILTER = new FilenameFilter ( ) { @ Override public boolean accept ( File dir , String name ) { return name . endsWith ( ".jadt" ) ; } } ; @ Override public List < FileSource > createSources ( String srcName ) { final File dirOrFile = new File ( srcName ) ; final File [ ] files = dirOrFile . listFiles ( FILTER ) ; if ( files != null ) { final List < FileSource > sources = new ArrayList < FileSource > ( files . length ) ; | |
961 | <s> package de . fuberlin . wiwiss . d2rq . sql ; public class BeanCounter implements Cloneable { public static int totalNumberOfExecutedSQLQueries = 0 ; public static int totalNumberOfReturnedRows = 0 ; public static int totalNumberOfReturnedFields = 0 ; public int numberOfExecutedSQLQueries = 0 ; public int numberOfReturnedRows = 0 ; public int numberOfReturnedFields = 0 ; public long timeMillis ; public void update ( ) { numberOfExecutedSQLQueries = totalNumberOfExecutedSQLQueries ; numberOfReturnedRows = totalNumberOfReturnedRows ; numberOfReturnedFields = totalNumberOfReturnedFields ; timeMillis = System . currentTimeMillis ( ) ; } public void subtract ( BeanCounter minus ) { numberOfExecutedSQLQueries -= minus . numberOfExecutedSQLQueries ; numberOfReturnedRows -= minus . numberOfReturnedRows ; numberOfReturnedFields -= minus . numberOfReturnedFields ; timeMillis -= minus . timeMillis ; } public void div ( int n ) { numberOfExecutedSQLQueries /= n ; numberOfReturnedRows /= n ; numberOfReturnedFields /= n ; timeMillis /= n ; } public BeanCounter ( ) { } public Object clone ( ) { try { return super . clone ( ) ; } catch ( CloneNotSupportedException e ) { throw new RuntimeException ( e ) ; } } public static BeanCounter instance ( ) { BeanCounter inst = new BeanCounter ( ) ; inst . update ( ) ; return inst ; } public static BeanCounter instanceMinus ( BeanCounter minus ) { BeanCounter inst = instance ( ) ; inst . subtract ( minus ) ; return inst ; } public BeanCounter minus ( BeanCounter minus ) { | |
962 | <s> package com . asakusafw . yaess . core . task ; import java . io . IOException ; import java . text . MessageFormat ; import java . util . ArrayList ; import java . util . Collections ; import java . util . HashMap ; import java . util . HashSet ; import java . util . Iterator ; import java . util . LinkedHashMap ; import java . util . LinkedList ; import java . util . List ; import java . util . Map ; import java . util . Properties ; import java . util . Set ; import java . util . TreeMap ; import java . util . UUID ; import java . util . concurrent . BlockingQueue ; import java . util . concurrent . Callable ; import java . util . concurrent . CancellationException ; import java . util . concurrent . ConcurrentHashMap ; import java . util . concurrent . ExecutionException ; import java . util . concurrent . ExecutorService ; import java . util . concurrent . Executors ; import java . util . concurrent . FutureTask ; import java . util . concurrent . LinkedBlockingQueue ; import java . util . concurrent . ThreadFactory ; import org . slf4j . Logger ; import org . slf4j . LoggerFactory ; import com . asakusafw . runtime . core . context . RuntimeContext ; import com . asakusafw . runtime . core . context . RuntimeContext . ExecutionMode ; import com . asakusafw . yaess . core . * ; import com . asakusafw . yaess . core . JobScheduler . ErrorHandler ; public class ExecutionTask { static final String KEY_SKIP_FLOWS = "skipFlows" ; static final String KEY_SERIALIZE_FLOWS = "" ; static final String KEY_VERIFY_APPLICATION = "" ; static final String KEY_VERIFY_DRYRUN = "dryRun" ; static final YaessLogger YSLOG = new YaessCoreLogger ( ExecutionTask . class ) ; static final Logger LOG = LoggerFactory . getLogger ( ExecutionTask . class ) ; private final ExecutionMonitorProvider monitors ; private final ExecutionLockProvider locks ; private final JobScheduler scheduler ; private final HadoopScriptHandler hadoopHandler ; private final Map < String , CommandScriptHandler > commandHandlers ; private final BatchScript script ; private final Map < String , String > batchArguments ; private final Map < String , String > subprocessEnvironmentVaritables = new ConcurrentHashMap < String , String > ( ) ; private final Set < String > skipFlows = Collections . synchronizedSet ( new HashSet < String > ( ) ) ; private volatile RuntimeContext runtimeContext ; private volatile boolean serializeFlows = false ; public ExecutionTask ( ExecutionMonitorProvider monitors , ExecutionLockProvider locks , JobScheduler scheduler , HadoopScriptHandler hadoopHandler , Map < String , CommandScriptHandler > commandHandlers , BatchScript script , Map < String , String > batchArguments ) { if ( monitors == null ) { throw new IllegalArgumentException ( "" ) ; } if ( locks == null ) { throw new IllegalArgumentException ( "" ) ; } if ( scheduler == null ) { throw new IllegalArgumentException ( "" ) ; } if ( hadoopHandler == null ) { throw new IllegalArgumentException ( "" ) ; } if ( commandHandlers == null ) { throw new IllegalArgumentException ( "" ) ; } if ( script == null ) { throw new IllegalArgumentException ( "" ) ; } if ( batchArguments == null ) { throw new IllegalArgumentException ( "" ) ; } this . monitors = monitors ; this . locks = locks ; this . scheduler = scheduler ; this . hadoopHandler = hadoopHandler ; this . commandHandlers = Collections . unmodifiableMap ( new HashMap < String , CommandScriptHandler > ( commandHandlers ) ) ; this . script = script ; this . batchArguments = Collections . unmodifiableMap ( new LinkedHashMap < String , String > ( batchArguments ) ) ; this . runtimeContext = RuntimeContext . get ( ) ; } public static ExecutionTask load ( YaessProfile profile , Properties script , Map < String , String > batchArguments ) throws InterruptedException , IOException { return load ( profile , script , batchArguments , Collections . < String , String > emptyMap ( ) ) ; } public static ExecutionTask load ( YaessProfile profile , Properties script , Map < String , String > batchArguments , Map < String , String > yaessArguments ) throws InterruptedException , IOException { if ( profile == null ) { throw new IllegalArgumentException ( "" ) ; } if ( script == null ) { throw new IllegalArgumentException ( "" ) ; } if ( batchArguments == null ) { throw new IllegalArgumentException ( "" ) ; } if ( yaessArguments == null ) { throw new IllegalArgumentException ( "" ) ; } LOG . debug ( "" ) ; ExecutionMonitorProvider monitors = profile . getMonitors ( ) . newInstance ( ) ; LOG . debug ( "" ) ; ExecutionLockProvider locks = profile . getLocks ( ) . newInstance ( ) ; LOG . debug ( "" ) ; JobScheduler scheduler = profile . getScheduler ( ) . newInstance ( ) ; LOG . debug ( "" ) ; HadoopScriptHandler hadoopHandler = profile . getHadoopHandler ( ) . newInstance ( ) ; LOG . debug ( "" ) ; Map < String , CommandScriptHandler > commandHandlers = new HashMap < String , CommandScriptHandler > ( ) ; for ( Map . Entry < String , ServiceProfile < CommandScriptHandler > > entry : profile . getCommandHandlers ( ) . entrySet ( ) ) { commandHandlers . put ( entry . getKey ( ) , entry . getValue ( ) . newInstance ( ) ) ; } LOG . debug ( "" ) ; BatchScript batch = BatchScript . load ( script ) ; ExecutionTask result = new ExecutionTask ( monitors , locks , scheduler , hadoopHandler , commandHandlers , batch , batchArguments ) ; LOG . debug ( "" ) ; Map < String , String > copyDefinitions = new TreeMap < String , String > ( yaessArguments ) ; consumeRuntimeContext ( result , copyDefinitions , batch ) ; consumeSkipFlows ( result , copyDefinitions , batch ) ; consumeSerializeFlows ( result , copyDefinitions , batch ) ; checkRest ( copyDefinitions ) ; return result ; } private static void consumeRuntimeContext ( ExecutionTask result , Map < String , String > copyDefinitions , BatchScript script ) { assert result != null ; assert copyDefinitions != null ; assert script != null ; RuntimeContext rc = RuntimeContext . get ( ) . batchId ( script . getId ( ) ) . buildId ( script . getBuildId ( ) ) ; Ternary dryRunResult = consumeBoolean ( copyDefinitions , KEY_VERIFY_DRYRUN ) ; if ( dryRunResult == Ternary . TRUE ) { rc = rc . mode ( ExecutionMode . SIMULATION ) ; } else if ( dryRunResult == Ternary . FALSE ) { rc = rc . mode ( ExecutionMode . PRODUCTION ) ; } Ternary verify = consumeBoolean ( copyDefinitions , KEY_VERIFY_APPLICATION ) ; if ( verify == Ternary . FALSE ) { rc = rc . buildId ( null ) ; } result . runtimeContext = rc ; result . getEnv ( ) . putAll ( rc . unapply ( ) ) ; } private static void consumeSkipFlows ( ExecutionTask task , Map < String , String > copyDefinitions , BatchScript script ) { assert task != null ; assert copyDefinitions != null ; assert script != null ; String flows = copyDefinitions . remove ( KEY_SKIP_FLOWS ) ; if ( flows == null || flows . trim ( ) . isEmpty ( ) ) { return ; } LOG . debug ( "" , KEY_SKIP_FLOWS , flows ) ; for ( String flowIdCandidate : flows . split ( "," ) ) { String flowId = flowIdCandidate . trim ( ) ; if ( flowId . isEmpty ( ) == false ) { FlowScript flow = script . findFlow ( flowId ) ; if ( flow == null ) { throw new IllegalArgumentException ( MessageFormat . format ( "" , KEY_SKIP_FLOWS , flowId ) ) ; } task . skipFlows . add ( flowId ) ; } } } private static void consumeSerializeFlows ( ExecutionTask task , Map < String , String > copyDefinitions , BatchScript script ) { assert task != null ; assert copyDefinitions != null ; assert script != null ; Ternary serialize = consumeBoolean ( copyDefinitions , KEY_SERIALIZE_FLOWS ) ; if ( serialize == null ) { return ; } task . serializeFlows = serialize == Ternary . TRUE ; } private static Ternary consumeBoolean ( Map < String , String > copyDefinitions , String key ) { assert copyDefinitions != null ; String value = copyDefinitions . remove ( key ) ; if ( value == null ) { return Ternary . UNDEF ; } value = value . trim ( ) ; LOG . debug ( "" , key , value ) ; if ( value . equalsIgnoreCase ( "true" ) ) { return Ternary . TRUE ; } else if ( value . equalsIgnoreCase ( "false" ) ) { return Ternary . FALSE ; } else { throw new IllegalArgumentException ( MessageFormat . format ( "" , key , value ) ) ; } } private static void checkRest ( Map < String , String > copyDefinitions ) { assert copyDefinitions != null ; if ( copyDefinitions . isEmpty ( ) == false ) { throw new IllegalArgumentException ( MessageFormat . format ( "" , copyDefinitions . keySet ( ) ) ) ; } } Set < String > getSkipFlows ( ) { return skipFlows ; } void setSerializeFlows ( boolean serialize ) { this . serializeFlows = serialize ; } void setRuntimeContext ( RuntimeContext runtimeContext ) { this . runtimeContext = runtimeContext ; } Map < String , String > getEnv ( ) { return this . subprocessEnvironmentVaritables ; } public void executeBatch ( String batchId ) throws InterruptedException , IOException { if ( batchId == null ) { throw new IllegalArgumentException ( "" ) ; } ExecutorService executor = createJobflowExecutor ( batchId ) ; YSLOG . info ( "I01000" , batchId ) ; long start = System . currentTimeMillis ( ) ; try { ExecutionLock lock = acquireExecutionLock ( batchId ) ; try { BatchScheduler batchScheduler = new BatchScheduler ( batchId , script , lock , executor ) ; batchScheduler . run ( ) ; } finally { lock . close ( ) ; } YSLOG . info ( "I01001" , batchId ) ; } catch ( IOException e ) { YSLOG . error ( e , "E01001" , batchId ) ; throw e ; } catch ( InterruptedException e ) { YSLOG . warn ( e , "W01001" , batchId ) ; throw e ; } finally { long end = System . currentTimeMillis ( ) ; YSLOG . info ( "I01999" , batchId , end - start ) ; } } private ExecutionLock acquireExecutionLock ( String batchId ) throws IOException { assert batchId != null ; if ( runtimeContext . canExecute ( locks ) ) { return locks . newInstance ( batchId ) ; } else { return ExecutionLock . NULL ; } } private PhaseMonitor obtainPhaseMonitor ( ExecutionContext context ) throws InterruptedException , IOException { assert context != null ; if ( runtimeContext . canExecute ( monitors ) ) { return monitors . newInstance ( context ) ; } else { return PhaseMonitor . NULL ; } } private ExecutorService createJobflowExecutor ( final String batchId ) { assert batchId != null ; ThreadFactory threadFactory = new ThreadFactory ( ) { @ Override public Thread newThread ( Runnable r ) { Thread thread = new Thread ( r ) ; thread . setName ( MessageFormat . format ( "" , batchId ) ) ; thread . setDaemon ( true ) ; return thread ; } } ; if ( serializeFlows ) { return Executors . newFixedThreadPool ( 1 , threadFactory ) ; } else { return Executors . newCachedThreadPool ( threadFactory ) ; } } public void executeFlow ( String batchId , String flowId , String executionId ) throws InterruptedException , IOException { if ( batchId == null ) { throw new IllegalArgumentException ( "" ) ; } if ( flowId == null ) { throw new IllegalArgumentException ( "" ) ; } if ( executionId == null ) { throw new IllegalArgumentException ( "" ) ; } FlowScript flow = script . findFlow ( flowId ) ; if ( flow == null ) { throw new IllegalArgumentException ( MessageFormat . format ( "" , batchId , flowId , executionId ) ) ; } ExecutionLock lock = acquireExecutionLock ( batchId ) ; try { lock . beginFlow ( flowId , executionId ) ; executeFlow ( batchId , flow , executionId ) ; lock . endFlow ( flowId , executionId ) ; } finally { lock . close ( ) ; } } public void executePhase ( String batchId , String flowId , String executionId , ExecutionPhase phase ) throws InterruptedException , IOException { if ( batchId == null ) { throw new IllegalArgumentException ( "" ) ; } if ( flowId == null ) { throw new IllegalArgumentException ( "" ) ; } if ( executionId == null ) { throw new IllegalArgumentException ( "" ) ; } if ( phase == null ) { throw new IllegalArgumentException ( "" ) ; } ExecutionContext context = new ExecutionContext ( batchId , flowId , executionId , phase , batchArguments , subprocessEnvironmentVaritables ) ; executePhase ( context ) ; } public void executePhase ( ExecutionContext context ) throws InterruptedException , IOException { if ( context == null ) { throw new IllegalArgumentException ( "" ) ; } FlowScript flow = script . findFlow ( context . getFlowId ( ) ) ; if ( flow == null ) { throw new IllegalArgumentException ( MessageFormat . format ( "" , context . getBatchId ( ) , context . getFlowId ( ) , context . getExecutionId ( ) ) ) ; } Set < ExecutionScript > executions = flow . getScripts ( ) . get ( context . getPhase ( ) ) ; ExecutionLock lock = acquireExecutionLock ( context . getBatchId ( ) ) ; try { lock . beginFlow ( context . getFlowId ( ) , context . getExecutionId ( ) ) ; executePhase ( context , executions ) ; lock . endFlow ( context . getFlowId ( ) , context . getExecutionId ( ) ) ; } finally { lock . close ( ) ; } } void executeFlow ( String batchId , FlowScript flow , String executionId ) throws InterruptedException , IOException { assert batchId != null ; assert flow != null ; assert executionId != null ; YSLOG . info ( "I02000" , batchId , flow . getId ( ) , executionId ) ; long start = System . currentTimeMillis ( ) ; try { if ( skipFlows . contains ( flow . getId ( ) ) ) { YSLOG . info ( "I02002" , batchId , flow . getId ( ) , executionId ) ; return ; } executePhase ( batchId , flow , executionId , ExecutionPhase . SETUP ) ; boolean succeed = false ; try { executePhase ( batchId , flow , executionId , ExecutionPhase . INITIALIZE ) ; executePhase ( batchId , flow , executionId , ExecutionPhase . IMPORT ) ; executePhase ( batchId , flow , executionId , ExecutionPhase . PROLOGUE ) ; executePhase ( batchId , flow , executionId , ExecutionPhase . MAIN ) ; executePhase ( batchId , flow , executionId , ExecutionPhase . EPILOGUE ) ; executePhase ( batchId , flow , executionId , ExecutionPhase . EXPORT ) ; succeed = true ; } finally { if ( succeed ) { executePhase ( batchId , flow , executionId , ExecutionPhase . FINALIZE ) ; } else { YSLOG . info ( "I02003" , batchId , flow . getId ( | |
963 | <s> package org . oddjob . designer . elements ; import org . oddjob . arooa . design . DesignFactory ; import org . oddjob . arooa . design . DesignInstance ; import org . oddjob . arooa . design . DesignProperty ; import org . oddjob . arooa . design . DesignValueBase ; import org . oddjob . arooa . design . SimpleTextAttribute ; | |
964 | <s> package net . sf . sveditor . ui . pref ; import java . util . Set ; import org . eclipse . jface . dialogs . Dialog ; import org . eclipse . jface . dialogs . IDialogConstants ; import org . eclipse . jface . resource . JFaceResources ; import org . eclipse . swt . SWT ; import org . eclipse . swt . events . ModifyEvent ; import org . eclipse . swt . events . ModifyListener ; import org . eclipse . swt . layout . GridData ; import org . eclipse . swt . layout . GridLayout ; import org . eclipse . swt . widgets . Composite ; import org . eclipse . swt . widgets . Control ; import org . eclipse . swt . widgets . Label ; import org . eclipse . swt . widgets . Shell ; import org . eclipse . swt . widgets . Text ; public class TemplatePropertyDialog extends Dialog { private Text fParameterId ; private String fParameterIdStr ; private Text fValue ; private String fValueStr ; private Set < String > fTakenIds ; private boolean fCanModifyId ; public TemplatePropertyDialog ( Shell shell , int style , Set < String > taken_ids , boolean modify_id ) { super ( shell ) ; fTakenIds = taken_ids ; fCanModifyId = modify_id ; } @ Override protected boolean isResizable ( ) { return true ; } public void setParameterId ( String path ) { fParameterIdStr = path ; if ( fParameterId != null && ! fParameterId . isDisposed ( ) ) { fParameterId . setText ( fParameterIdStr ) ; } } public String getParameterId ( ) { return fParameterIdStr ; } public void setValue ( String value ) { fValueStr = value ; if ( fValue != null && ! fValue . isDisposed ( ) ) { fValue . setText ( fValueStr ) ; } } public String getValue ( ) { return fValueStr ; } private void validate ( ) { boolean ok = true ; ok &= ( ! fParameterId . getText ( ) . trim ( ) . equals ( "" ) ) ; if ( getButton ( IDialogConstants . OK_ID ) != null ) { getButton ( IDialogConstants . OK_ID ) . setEnabled ( ok ) ; } } @ Override protected Control createButtonBar ( Composite parent ) { Control c = super . createButtonBar ( parent ) ; validate ( ) ; return c ; } @ Override protected Control createContents ( Composite parent ) { Composite c = ( Composite ) super . createContents ( parent ) ; GridData gd ; gd = new GridData ( SWT . FILL , SWT . FILL , true , true ) ; gd . heightHint = 480 ; gd . widthHint = 640 ; c . setLayoutData ( gd ) ; c . layout ( ) ; Composite da = ( Composite ) getDialogArea ( ) ; gd = new GridData ( SWT . FILL , SWT . FILL , true , true ) ; da . setLayoutData ( gd ) ; return c ; } @ Override protected Control createDialogArea ( Composite parent ) { Label l ; Composite frame = new Composite ( parent , SWT . NONE ) ; frame . setLayout ( new GridLayout ( 2 , false ) ) ; GridData gd ; l = new Label ( frame , SWT . NONE ) ; l . setText ( "Parameter:" ) ; | |
965 | <s> package net . sf . sveditor . ui . editor ; import java . util . HashMap ; import java . util . Map ; import org . eclipse . swt . graphics . Color ; import org . eclipse . swt . graphics . RGB ; import org . eclipse . swt . widgets . Display ; public class SVColorManager { private static Map < RGB , Color > fColorMap = new HashMap < RGB , Color > ( ) ; public static synchronized Color getColor ( RGB color ) { Color ret = fColorMap . get ( color ) ; | |
966 | <s> package com . asakusafw . bulkloader . collector ; import java . io . PrintStream ; public final class SystemOutManager { private static final PrintStream OUT = System . out ; private static | |
967 | <s> package com . asakusafw . windgate . core . session ; import java . io . IOException ; import java . text . MessageFormat ; public class SessionException extends IOException { private static final long serialVersionUID = - 819170343696459140L ; private final String sessionId ; private final Reason reason ; public SessionException ( String sessionId , Reason reason , Throwable cause ) { super ( buildMessage ( sessionId , reason ) , cause ) ; this . sessionId = sessionId ; this . reason = reason ; } public String getSessionId ( ) { return sessionId ; } public Reason getReason ( ) { return reason ; } private static String buildMessage ( String sessionId , Reason reason ) { if ( sessionId == null ) { throw new IllegalArgumentException ( "" ) ; } if ( reason == null ) { throw new IllegalArgumentException ( "" ) ; } return MessageFormat . format ( "" , sessionId , reason . getDescription ( ) ) ; } public SessionException ( String sessionId , Reason reason ) { this ( sessionId , reason , null ) ; } public enum Reason { ALREADY_EXIST ( "" ) | |
968 | <s> package org . rubypeople . rdt . internal . ui . preferences ; import java . util . ArrayList ; import java . util . Collections ; import java . util . Comparator ; import java . util . HashMap ; import java . util . Iterator ; import java . util . List ; import java . util . Map ; import org . eclipse . core . commands . Command ; import org . eclipse . core . commands . CommandManager ; import org . eclipse . core . commands . IParameter ; import org . eclipse . core . commands . Parameterization ; import org . eclipse . core . commands . ParameterizedCommand ; import org . eclipse . core . commands . common . NotDefinedException ; import org . eclipse . core . commands . contexts . ContextManager ; import org . eclipse . core . runtime . Assert ; import org . eclipse . jface . bindings . BindingManager ; import org . eclipse . jface . bindings . Scheme ; import org . eclipse . jface . bindings . TriggerSequence ; import org . eclipse . jface . layout . PixelConverter ; import org . eclipse . jface . resource . ImageDescriptor ; import org . eclipse . jface . resource . JFaceResources ; import org . eclipse . jface . viewers . ArrayContentProvider ; import org . eclipse . jface . viewers . CheckStateChangedEvent ; import org . eclipse . jface . viewers . CheckboxTableViewer ; import org . eclipse . jface . viewers . ICheckStateListener ; import org . eclipse . jface . viewers . IStructuredSelection ; import org . eclipse . jface . viewers . ITableLabelProvider ; import org . eclipse . jface . viewers . LabelProvider ; import org . eclipse . jface . viewers . ViewerComparator ; import org . eclipse . swt . SWT ; import org . eclipse . swt . events . SelectionAdapter ; import org . eclipse . swt . events . SelectionEvent ; import org . eclipse . swt . graphics . GC ; import org . eclipse . swt . graphics . Image ; import org . eclipse . swt . layout . GridData ; import org . eclipse . swt . layout . GridLayout ; import org . eclipse . swt . widgets . Button ; import org . eclipse . swt . widgets . Composite ; import org . eclipse . swt . widgets . Control ; import org . eclipse . swt . widgets . Label ; import org . eclipse . swt . widgets . Link ; import org . eclipse . swt . widgets . Table ; import org . eclipse . swt . widgets . TableColumn ; import org . eclipse . ui . PlatformUI ; import org . eclipse . ui . commands . ICommandService ; import org . eclipse . ui . dialogs . PreferencesUtil ; import org . eclipse . ui . keys . IBindingService ; import org . eclipse . ui . preferences . IWorkbenchPreferenceContainer ; import org . eclipse . ui . texteditor . ITextEditorActionDefinitionIds ; import org . rubypeople . rdt . internal . corext . util . Messages ; import org . rubypeople . rdt . internal . ui . RubyPlugin ; import org . rubypeople . rdt . internal . ui . text . ruby . CompletionProposalCategory ; import org . rubypeople . rdt . internal . ui . text . ruby . CompletionProposalComputerRegistry ; import org . rubypeople . rdt . internal . ui . util . SWTUtil ; import org . rubypeople . rdt . internal . ui . wizards . IStatusChangeListener ; import org . rubypeople . rdt . ui . PreferenceConstants ; final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlock { private static final Key PREF_EXCLUDED_CATEGORIES = getRDTUIKey ( PreferenceConstants . CODEASSIST_EXCLUDED_CATEGORIES ) ; private static final Key PREF_CATEGORY_ORDER = getRDTUIKey ( PreferenceConstants . CODEASSIST_CATEGORY_ORDER ) ; private static Key [ ] getAllKeys ( ) { return new Key [ ] { PREF_EXCLUDED_CATEGORIES , PREF_CATEGORY_ORDER } ; } private final class DefaultTableLabelProvider extends LabelProvider implements ITableLabelProvider { public Image getColumnImage ( Object element , int columnIndex ) { if ( columnIndex == 0 ) return ( ( ModelElement ) element ) . getImage ( ) ; return null ; } public String getColumnText ( Object element , int columnIndex ) { switch ( columnIndex ) { case 0 : return ( ( ModelElement ) element ) . getName ( ) ; case 1 : return ( ( ModelElement ) element ) . getKeybindingAsString ( ) ; default : Assert . isTrue ( false ) ; return null ; } } public String getText ( Object element ) { return getColumnText ( element , 0 ) ; } } private final class SeparateTableLabelProvider extends LabelProvider implements ITableLabelProvider { public Image getColumnImage ( Object element , int columnIndex ) { if ( columnIndex == 0 ) return ( ( ModelElement ) element ) . getImage ( ) ; return null ; } public String getColumnText ( Object element , int columnIndex ) { switch ( columnIndex ) { case 0 : return ( ( ModelElement ) element ) . getName ( ) ; default : Assert . isTrue ( false ) ; return null ; } } } private final Comparator fCategoryComparator = new Comparator ( ) { private int getRank ( Object o ) { return ( ( ModelElement ) o ) . getRank ( ) ; } public int compare ( Object o1 , Object o2 ) { return getRank ( o1 ) - getRank ( o2 ) ; } } ; private final class PreferenceModel { private static final int LIMIT = 65535 ; private static final String COLON = ":" ; private static final String SEPARATOR = " " ; private final List < ModelElement > fElements ; final List < ModelElement > elements ; public PreferenceModel ( CompletionProposalComputerRegistry registry ) { List < CompletionProposalCategory > categories = registry . getProposalCategories ( ) ; fElements = new ArrayList < ModelElement > ( ) ; for ( CompletionProposalCategory category : categories ) { if ( category . hasComputers ( ) ) { fElements . add ( new ModelElement ( category , this ) ) ; } } Collections . sort ( fElements , fCategoryComparator ) ; elements = Collections . unmodifiableList ( fElements ) ; } public void moveUp ( ModelElement category ) { int index = fElements . indexOf ( category ) ; if ( index > 0 ) { ModelElement item = fElements . remove ( index ) ; fElements . add ( index - 1 , item ) ; writeOrderPreference ( null , false ) ; } } public void moveDown ( ModelElement category ) { int index = fElements . indexOf ( category ) ; if ( index < fElements . size ( ) - 1 ) { ModelElement item = fElements . remove ( index ) ; fElements . add ( index + 1 , item ) ; writeOrderPreference ( null , false ) ; } } private void writeInclusionPreference ( ModelElement changed , boolean isInDefaultCategory ) { StringBuffer buf = new StringBuffer ( ) ; for ( ModelElement item : fElements ) { boolean included = changed == item ? isInDefaultCategory : item . isInDefaultCategory ( ) ; if ( ! included ) buf . append ( item . getId ( ) + SEPARATOR ) ; } String newValue = buf . toString ( ) ; String oldValue = setValue ( PREF_EXCLUDED_CATEGORIES , newValue ) ; validateSettings ( PREF_EXCLUDED_CATEGORIES , oldValue , newValue ) ; } private void writeOrderPreference ( ModelElement changed , boolean isSeparate ) { StringBuffer buf = new StringBuffer ( ) ; int i = 0 ; for ( Iterator it = fElements . iterator ( ) ; it . hasNext ( ) ; i ++ ) { ModelElement item = ( ModelElement ) it . next ( ) ; boolean separate = changed == item ? isSeparate : item . isSeparateCommand ( ) ; int rank = separate ? i : i + LIMIT ; buf . append ( item . getId ( ) + COLON + rank + SEPARATOR ) ; } String newValue = buf . toString ( ) ; String oldValue = setValue ( PREF_CATEGORY_ORDER , newValue ) ; validateSettings ( PREF_CATEGORY_ORDER , oldValue , newValue ) ; } private boolean readInclusionPreference ( CompletionProposalCategory cat ) { String [ ] ids = getTokens ( getValue ( PREF_EXCLUDED_CATEGORIES ) , SEPARATOR ) ; for ( int i = 0 ; i < ids . length ; i ++ ) { if ( ids [ i ] . equals ( cat . getId ( ) ) ) return false ; } return true ; } private int readOrderPreference ( CompletionProposalCategory cat ) { String [ ] sortOrderIds = getTokens ( getValue ( PREF_CATEGORY_ORDER ) , SEPARATOR ) ; for ( int i = 0 ; i < sortOrderIds . length ; i ++ ) { String [ ] idAndRank = getTokens ( sortOrderIds [ i ] , COLON ) ; if ( idAndRank [ 0 ] . equals ( cat . getId ( ) ) ) return Integer . parseInt ( idAndRank [ 1 ] ) ; } return LIMIT - 1 ; } public void update ( ) { Collections . sort ( fElements , fCategoryComparator ) ; } } private final class ModelElement { private final CompletionProposalCategory fCategory ; private final Command fCommand ; private final IParameter fParam ; private final PreferenceModel fPreferenceModel ; ModelElement ( CompletionProposalCategory category , PreferenceModel model ) { fCategory = category ; ICommandService commandSvc = ( ICommandService ) PlatformUI . getWorkbench ( ) . getAdapter ( ICommandService . class ) ; fCommand = commandSvc . getCommand ( "" ) ; IParameter type ; try { type = fCommand . getParameters ( ) [ 0 ] ; } catch ( NotDefinedException x ) { Assert . isTrue ( false ) ; type = null ; } fParam = type ; fPreferenceModel = model ; } Image getImage ( ) { return CodeAssistAdvancedConfigurationBlock . this . getImage ( fCategory . getImageDescriptor ( ) ) ; } String getName ( ) { return fCategory . getDisplayName ( ) ; } String getKeybindingAsString ( ) { final Parameterization [ ] params = { new Parameterization ( fParam , fCategory . getId ( ) ) } ; final ParameterizedCommand pCmd = new ParameterizedCommand ( fCommand , params ) ; String key = getKeyboardShortcut ( pCmd ) ; return key ; } boolean isInDefaultCategory ( ) { return fPreferenceModel . readInclusionPreference ( fCategory ) ; } void setInDefaultCategory ( boolean included ) { if ( included != isInDefaultCategory ( ) ) fPreferenceModel . writeInclusionPreference ( this , included ) ; } String getId ( ) { return fCategory . getId ( ) ; } int getRank ( ) { int rank = getInternalRank ( ) ; if ( rank > PreferenceModel . LIMIT ) return rank - PreferenceModel . LIMIT ; return rank ; } void moveUp ( ) { fPreferenceModel . moveUp ( this ) ; } void moveDown ( ) { fPreferenceModel . moveDown ( this ) ; } private int getInternalRank ( ) { return fPreferenceModel . readOrderPreference ( fCategory ) ; } boolean isSeparateCommand ( ) { return getInternalRank ( ) < PreferenceModel . LIMIT ; } void setSeparateCommand ( boolean separate ) { if ( separate != isSeparateCommand ( ) ) fPreferenceModel . writeOrderPreference ( this , separate ) ; } void update ( ) { fCategory . setIncluded ( isInDefaultCategory ( ) ) ; int rank = getInternalRank ( ) ; fCategory . setSortOrder ( rank ) ; fCategory . setSeparateCommand ( rank < PreferenceModel . LIMIT ) ; } } private final PreferenceModel fModel ; private final Map fImages = new HashMap ( ) ; private CheckboxTableViewer fDefaultViewer ; private CheckboxTableViewer fSeparateViewer ; private Button fUpButton ; private Button fDownButton ; CodeAssistAdvancedConfigurationBlock ( IStatusChangeListener statusListener , IWorkbenchPreferenceContainer container ) { super ( statusListener , null , getAllKeys ( ) , container ) ; fModel = new PreferenceModel ( CompletionProposalComputerRegistry . getDefault ( ) ) ; } protected Control createContents ( Composite parent ) { ScrolledPageContent scrolled = new ScrolledPageContent ( parent , SWT . H_SCROLL | SWT . V_SCROLL ) ; scrolled . setExpandHorizontal ( true ) ; scrolled . setExpandVertical ( true ) ; Composite composite = new Composite ( scrolled , SWT . NONE ) ; int columns = 2 ; GridLayout layout = new GridLayout ( columns , false ) ; layout . marginWidth = 0 ; layout . marginHeight = 0 ; composite . setLayout ( layout ) ; createDefaultLabel ( composite , columns ) ; createDefaultViewer ( composite , columns ) ; createKeysLink ( composite , columns ) ; createFiller ( composite , columns ) ; createSeparateLabel ( composite , columns ) ; createSeparateSection ( composite ) ; createFiller ( composite , columns ) ; updateControls ( ) ; if ( fModel . elements . size ( ) > 0 ) { fDefaultViewer . getTable ( ) . select ( 0 ) ; fSeparateViewer . getTable ( ) . select ( 0 ) ; handleTableSelection ( ) ; } scrolled . setContent ( composite ) ; scrolled . setMinSize ( composite . computeSize ( SWT . DEFAULT , SWT . DEFAULT ) ) ; return scrolled ; } private void createDefaultLabel ( Composite composite , int h_span ) { final ICommandService commandSvc = ( ICommandService ) PlatformUI . getWorkbench ( ) . getAdapter ( ICommandService . class ) ; final Command command = commandSvc . getCommand ( ITextEditorActionDefinitionIds . CONTENT_ASSIST_PROPOSALS ) ; ParameterizedCommand pCmd = new ParameterizedCommand ( command , null ) ; String key = getKeyboardShortcut ( pCmd ) ; if ( key == null ) key = PreferencesMessages . CodeAssistAdvancedConfigurationBlock_no_shortcut ; PixelConverter pixelConverter = new PixelConverter ( composite ) ; int width = pixelConverter . convertWidthInCharsToPixels ( 40 ) ; Label label = new Label ( composite , SWT . NONE | SWT . WRAP ) ; label . setText ( Messages . format ( PreferencesMessages . CodeAssistAdvancedConfigurationBlock_page_description , new Object [ ] { key } ) ) ; GridData gd = new GridData ( GridData . FILL , GridData . FILL , true , false , h_span , 1 ) ; gd . widthHint = width ; label . setLayoutData ( gd ) ; createFiller ( composite , h_span ) ; label = new Label ( composite , SWT . NONE | SWT . WRAP ) ; label . setText ( PreferencesMessages . CodeAssistAdvancedConfigurationBlock_default_table_description ) ; gd = new GridData ( GridData . FILL , GridData . FILL , true , false , h_span , 1 ) ; gd . widthHint = width ; label . setLayoutData ( gd ) ; } private void createDefaultViewer ( Composite composite , int h_span ) { fDefaultViewer = CheckboxTableViewer . newCheckList ( composite , SWT . SINGLE | SWT . BORDER ) ; Table table = fDefaultViewer . getTable ( ) ; table . setHeaderVisible ( true ) ; table . setLinesVisible ( false ) ; table . setLayoutData ( new GridData ( GridData . FILL , GridData . BEGINNING , false , false , h_span , 1 ) ) ; TableColumn nameColumn = new TableColumn ( table , SWT . NONE ) ; nameColumn . setText ( PreferencesMessages . CodeAssistAdvancedConfigurationBlock_default_table_category_column_title ) ; nameColumn . setResizable ( false ) ; TableColumn keyColumn = new TableColumn ( table , SWT . NONE ) ; keyColumn . setText ( PreferencesMessages . CodeAssistAdvancedConfigurationBlock_default_table_keybinding_column_title ) ; keyColumn . setResizable ( false ) ; fDefaultViewer . addCheckStateListener ( new ICheckStateListener ( ) { public void checkStateChanged ( CheckStateChangedEvent event ) { boolean checked = event . getChecked ( ) ; ModelElement element = ( ModelElement ) event . getElement ( ) ; element . setInDefaultCategory ( checked ) ; } } ) ; fDefaultViewer . setContentProvider ( new ArrayContentProvider ( ) ) ; DefaultTableLabelProvider labelProvider = new DefaultTableLabelProvider ( ) ; fDefaultViewer . setLabelProvider ( labelProvider ) ; fDefaultViewer . setInput ( fModel . elements ) ; fDefaultViewer . setComparator ( new ViewerComparator ( ) ) ; final int ICON_AND_CHECKBOX_WITH = 50 ; final int HEADER_MARGIN = 20 ; int minNameWidth = computeWidth ( table , nameColumn . getText ( ) ) + HEADER_MARGIN ; int minKeyWidth = computeWidth ( table , keyColumn . getText ( ) ) + HEADER_MARGIN ; for ( int i = 0 ; i < fModel . elements . size ( ) ; i ++ ) { minNameWidth = Math . max ( minNameWidth , computeWidth ( table , labelProvider . getColumnText ( fModel . elements . get ( i ) , 0 ) ) + ICON_AND_CHECKBOX_WITH ) ; minKeyWidth = Math . max ( minKeyWidth , computeWidth ( table , labelProvider . getColumnText ( fModel . elements . get ( i ) , 1 ) ) ) ; } nameColumn . setWidth ( minNameWidth ) ; keyColumn . setWidth ( minKeyWidth ) ; } private void createKeysLink ( Composite composite , int h_span ) { Link link = new Link ( composite , SWT . NONE | SWT . WRAP ) ; link . setText ( PreferencesMessages . CodeAssistAdvancedConfigurationBlock_key_binding_hint ) ; link . addSelectionListener ( new SelectionAdapter ( ) { public void widgetSelected ( SelectionEvent e ) { PreferencesUtil . createPreferenceDialogOn ( getShell ( ) , e . text , null , null ) ; } } ) ; PixelConverter pixelConverter = new PixelConverter ( composite ) ; int width = pixelConverter . convertWidthInCharsToPixels ( 40 ) ; GridData gd = new GridData ( GridData . FILL , GridData . FILL , false , false , h_span , 1 ) ; gd . widthHint = width ; link . setLayoutData ( gd ) ; } private void createFiller ( Composite composite , int h_span ) { Label filler = new Label ( composite , SWT . NONE ) ; filler . setVisible ( false ) ; filler . setLayoutData ( new GridData ( SWT . FILL , SWT . FILL , false , false , h_span , 1 ) ) ; } private void createSeparateLabel ( Composite composite , int h_span ) { PixelConverter pixelConverter = new PixelConverter ( composite ) ; int width = pixelConverter . convertWidthInCharsToPixels ( 40 ) ; Label label = new Label ( composite , SWT . NONE | SWT . WRAP ) ; label . setText ( PreferencesMessages . CodeAssistAdvancedConfigurationBlock_separate_table_description ) ; GridData gd = new GridData ( GridData . FILL , GridData . FILL , false , false , h_span , 1 ) ; gd . widthHint = width ; label . setLayoutData ( gd ) ; } private void createSeparateSection ( Composite composite ) { createSeparateViewer ( composite ) ; createButtonList ( composite ) ; } private void createSeparateViewer ( Composite composite ) { fSeparateViewer = CheckboxTableViewer . newCheckList ( composite , SWT . SINGLE | SWT . BORDER ) ; Table table = fSeparateViewer . getTable ( ) ; table . setHeaderVisible ( false ) ; table . setLinesVisible ( false ) ; table . setLayoutData ( new GridData ( GridData . FILL , GridData . BEGINNING , true , false , 1 , 1 ) ) ; TableColumn nameColumn = new TableColumn ( table , SWT . NONE ) ; nameColumn . setText ( PreferencesMessages . CodeAssistAdvancedConfigurationBlock_separate_table_category_column_title ) ; nameColumn . setResizable ( false ) ; fSeparateViewer . setContentProvider ( new ArrayContentProvider ( ) ) ; ITableLabelProvider labelProvider = new SeparateTableLabelProvider ( ) ; fSeparateViewer . setLabelProvider ( labelProvider ) ; fSeparateViewer . setInput ( fModel . elements ) ; final int ICON_AND_CHECKBOX_WITH = 50 ; final int HEADER_MARGIN = 20 ; int minNameWidth = computeWidth ( table , nameColumn . getText ( ) ) + HEADER_MARGIN ; for ( int i = 0 ; i < fModel . elements . size ( ) ; i ++ ) { minNameWidth = Math . max ( minNameWidth , computeWidth ( table , labelProvider . getColumnText ( fModel . elements . get ( i ) , 0 ) ) + ICON_AND_CHECKBOX_WITH ) ; } nameColumn . setWidth ( minNameWidth ) ; fSeparateViewer . addCheckStateListener ( new ICheckStateListener ( ) { public void checkStateChanged ( CheckStateChangedEvent event ) { boolean checked = event . getChecked ( ) ; ModelElement element = ( ModelElement ) event . getElement ( ) ; element . setSeparateCommand ( checked ) ; } } ) ; table . addSelectionListener ( new SelectionAdapter ( ) { public void widgetSelected ( SelectionEvent e ) { handleTableSelection ( ) ; } } ) ; } private void createButtonList ( Composite parent ) { Composite composite = new Composite ( parent , SWT . NONE ) ; composite . setLayoutData ( new GridData ( SWT . BEGINNING , SWT . BEGINNING , false , false ) ) ; GridLayout layout = new GridLayout ( ) ; layout . marginWidth = 0 ; layout . marginHeight = 0 ; composite . setLayout ( layout ) ; fUpButton = new Button ( composite , SWT . PUSH | SWT . CENTER ) ; fUpButton . setText ( PreferencesMessages . CodeAssistAdvancedConfigurationBlock_Up ) ; fUpButton . addSelectionListener ( new SelectionAdapter ( ) { public void widgetSelected ( SelectionEvent e ) { int index = getSelectionIndex ( ) ; if ( index != - 1 ) { ( ( ModelElement ) fModel . elements . get ( index ) ) . moveUp ( ) ; fSeparateViewer . refresh ( ) ; handleTableSelection ( ) ; } } } ) ; fUpButton . setLayoutData ( new GridData ( ) ) ; SWTUtil . setButtonDimensionHint ( fUpButton ) ; | |
969 | <s> package net . heraan . ui ; import java . util . ArrayList ; import java . util . Calendar ; import java . util . Scanner ; import net . heraan . Game ; import net . heraan . Game . Play ; import net . heraan . Game . Result ; import net . heraan . Player . AI . AI ; import net . heraan . Player . AI . AI_Strategy ; import net . heraan . Player . AI . Personality . Personality_Random ; import net . heraan . Player . Human . Human ; import net . heraan . Player . Player ; import net . heraan . Round ; public class CLI { public CLI ( int rounds_per_game ) throws Exception { this . mind = new Personality_Random ( ) ; this . rounds_per_game = rounds_per_game ; this . current_round = 1 ; this . competitors = new ArrayList < Player > ( ) ; this . load_Humans ( ) ; { Player human = new Human ( "HUMAN" ) ; this . competitors . add ( human ) ; Player ai = new AI ( "" , mind ) ; this . competitors . add ( ai ) ; this . current_game = new Game ( this . competitors ) ; } System . out . println ( "" + Calendar . getInstance ( ) . getTime ( ) ) ; String quitString = "noquit" ; while ( ( quitString . equalsIgnoreCase ( "quit" ) == false ) ) { this . gameOverHandler ( ) ; Scanner input = new Scanner ( System . in ) ; System . out . print ( "" ) ; String answer = input . next ( ) ; if ( answer . equalsIgnoreCase ( "quit" ) ) { quitString = "quit" ; System . out . println ( "" ) ; } else if ( answer . equalsIgnoreCase ( "help" | |
970 | <s> package org . rubypeople . rdt . astviewer . preferences ; import org . eclipse . core . runtime . preferences . AbstractPreferenceInitializer ; import org . eclipse . jface . preference . IPreferenceStore ; import org . rubypeople . rdt | |
971 | <s> package com . asakusafw . generator ; import java . io . File ; import java . io . InputStream ; import java . text . MessageFormat ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . Collections ; import java . util . List ; import org . apache . commons . io . FileUtils ; import org . apache . commons . io . IOUtils ; public final class HadoopBulkLoaderDDLGenerator { private static final String [ ] ENV_PREFIX = { "ASAKUSA_" , "NS_" } ; private static final List < String > ENV_BULKLOADER_GENDDL = buildEnvProperties ( "" ) ; private static final List < String > ENV_BULKLOADER_TABLES = buildEnvProperties ( "" ) ; private static final String TEMPLATE_DDL_FILENAME = "" ; private static final String TABLENAME_REPLACE_STRING = "@TABLE_NAME@" ; private static final String OUTPUT_TABLES_PROPERTY = "" ; public static void main ( String [ ] args ) throws Exception { String outputTablesString = findVariable ( ENV_BULKLOADER_TABLES , true ) ; List < String > outputTableList = null ; if ( outputTablesString != null && ! OUTPUT_TABLES_PROPERTY . equals ( outputTablesString ) ) { String [ ] outputTables = outputTablesString . trim ( ) . split ( "\\s+" ) ; outputTableList = Arrays . asList ( | |
972 | <s> package org . oddjob . describe ; import java . util . Map ; import org . oddjob . Describeable ; public class DescribeableDescriber implements Describer { @ Override public Map < String , String > describe | |
973 | <s> package journal . io . api ; import java . io . File ; import java . io . IOException ; import java . io . RandomAccessFile ; import java . util . concurrent . atomic . AtomicInteger ; import journal . io . util . IOHelper ; class DataFile implements Comparable < DataFile > { private final File file ; private final Integer dataFileId ; private final AtomicInteger length ; private volatile DataFile next ; DataFile ( File file , int number ) { this . file = file ; this . dataFileId = Integer . valueOf ( number ) ; this . length = new AtomicInteger ( ( int ) ( file . exists ( ) ? file . length ( ) : 0 ) ) ; } File getFile ( ) { return file ; } Integer getDataFileId ( ) { return dataFileId ; } DataFile getNext ( ) { return next ; } void setNext ( DataFile next ) { this . next = next ; } int getLength ( ) { return this . length . get ( ) ; } void setLength ( int length ) { this . length . set ( length ) ; } | |
974 | <s> package com . asakusafw . modelgen ; import java . io . File ; import java . io . FileInputStream ; import java . io . IOException ; import java . io . InputStream ; import java . sql . SQLException ; import java . text . MessageFormat ; import java . util . ArrayList ; import java . util . List ; import java . util . Properties ; import java . util . Scanner ; import java . util . concurrent . Callable ; import java . util . regex . Pattern ; import java . util . regex . PatternSyntaxException ; import org . slf4j . Logger ; import org . slf4j . LoggerFactory ; import com . asakusafw . modelgen . emitter . AnyModelEntityEmitter ; import com . asakusafw . modelgen . emitter . ModelInputEmitter ; import com . asakusafw . modelgen . emitter . ModelOutputEmitter ; import com . asakusafw . modelgen . model . ModelDescription ; import com . asakusafw . modelgen . model . ModelRepository ; import com . asakusafw . modelgen . source . DatabaseSource ; import com . asakusafw . utils . java . model . syntax . ModelFactory ; import com . asakusafw . utils . java . model . util . Models ; public class Main implements Callable < ModelRepository > { static final Logger LOG = LoggerFactory . getLogger ( Main . class ) ; private Configuration configuration ; public Main ( Configuration configuration ) { if ( configuration == null ) { throw new IllegalArgumentException ( "" ) ; } this . configuration = configuration ; } @ Override public ModelRepository call ( ) { ModelRepository repository = new ModelRepository ( ) ; try { collectFromDb ( repository ) ; } catch ( IOException e ) { LOG . error ( "" , e ) ; return null ; } catch ( SQLException e ) { LOG . error ( "" , e ) ; e . printStackTrace ( ) ; } try { collectFromViews ( repository ) ; } catch ( IOException e ) { LOG . error ( "" , e ) ; return null ; } catch ( SQLException e ) { LOG . error ( "" , e ) ; e . printStackTrace ( ) ; } emit ( repository ) ; return repository ; } private void collectFromDb ( ModelRepository repository ) throws IOException , SQLException { LOG . info ( "" , configuration . getJdbcUrl ( ) ) ; DatabaseSource source = new DatabaseSource ( configuration . getJdbcDriver ( ) , configuration . getJdbcUrl ( ) , configuration . getJdbcUser ( ) , configuration . getJdbcPassword ( ) , configuration . getDatabaseName ( ) ) ; try { List < ModelDescription > collected = source . collectTables ( configuration . getMatcher ( ) ) ; for ( ModelDescription model : collected ) { LOG . info ( "" , model . getReference ( ) ) ; repository . add ( model ) ; } LOG . info ( "" , collected . size ( ) ) ; } finally { source . close ( ) ; } } private void collectFromViews ( ModelRepository repository ) throws IOException , SQLException { LOG . info ( "" , configuration . getJdbcUrl ( ) ) ; DatabaseSource source = new DatabaseSource ( configuration . getJdbcDriver ( ) , configuration . getJdbcUrl ( ) , configuration . getJdbcUser ( ) , configuration . getJdbcPassword ( ) , configuration . getDatabaseName ( ) ) ; try { List < ModelDescription > collected = source . collectViews ( repository , configuration . getMatcher ( ) ) ; for ( ModelDescription model : collected ) { LOG . info ( "" , model . getReference ( ) ) ; repository . add ( model ) ; } LOG . info ( "" , collected . size ( ) ) ; } finally { source . close ( ) ; } } private void emit ( ModelRepository repository ) { List < ModelDescription > models = repository . all ( ) ; int total = models . size ( ) ; LOG . info ( "" , total , configuration . getOutput ( ) ) ; ModelFactory factory = Models . getModelFactory ( ) ; AnyModelEntityEmitter modelEmitter = new AnyModelEntityEmitter ( factory , configuration . getOutput ( ) , configuration . getBasePackage ( ) , configuration . getHeaderComments ( ) ) ; ModelInputEmitter tsvInEmitter = new ModelInputEmitter ( factory , configuration . getOutput ( ) , configuration . getBasePackage ( ) , configuration . getHeaderComments ( ) ) ; ModelOutputEmitter tsvOutEmitter = new ModelOutputEmitter ( factory , configuration . getOutput ( ) , configuration . getBasePackage ( ) , configuration . getHeaderComments ( ) ) ; int successCount = 0 ; int failedCount = 0 ; for ( ModelDescription model : models ) { LOG . info ( "" , model . getReference ( ) , ( total - successCount - failedCount ) ) ; try { modelEmitter . emit ( model ) ; tsvInEmitter . emit ( model ) ; tsvOutEmitter . emit ( model ) ; successCount ++ ; } catch ( Exception e ) { LOG . error ( MessageFormat . format ( "" , model . getReference ( ) ) , e ) ; failedCount ++ ; } } if ( failedCount >= 1 ) { LOG . error ( "" , failedCount ) ; } else { LOG . info ( "" , total ) ; } } public static void main ( String ... args ) { Configuration conf = loadConfigurationFromEnvironment ( ) ; new Main ( conf ) . call ( ) ; } public static Configuration loadConfigurationFromEnvironment ( ) { Configuration result = new Configuration ( ) ; String jdbc = findVariable ( Constants . ENV_JDBC_PROPERTIES , true ) ; try { Properties jdbcProps = loadProperties ( jdbc ) ; result . setJdbcDriver ( findProperty ( jdbcProps , Constants . K_JDBC_DRIVER ) ) ; result . setJdbcUrl ( findProperty ( jdbcProps , Constants . K_JDBC_URL ) ) ; result . setJdbcUser ( findProperty ( jdbcProps , Constants . K_JDBC_USER ) ) ; result . setJdbcPassword ( findProperty ( jdbcProps , Constants . K_JDBC_PASSWORD ) ) ; result . setDatabaseName ( findProperty ( jdbcProps , Constants . K_DATABASE_NAME ) ) ; LOG . info ( "" , jdbcProps | |
975 | <s> package com . asakusafw . compiler . operator . model ; import java . util . List ; import javax . lang . model . element . Element ; import javax . lang . model . element . ElementKind ; import javax . lang . model . element . ExecutableElement ; import javax . lang . model . element . TypeElement ; import javax . lang . model . element . TypeParameterElement ; import javax . lang . model . type . DeclaredType ; import javax . lang . model . type . TypeKind ; import javax . lang . model . type . TypeMirror ; import javax . lang . model . type . TypeVariable ; import javax . lang . model . util . Types ; import com . asakusafw . compiler . common . JavaName ; import com . asakusafw . compiler . operator . DataModelMirror . PropertyMirror ; import com . asakusafw . compiler . operator . OperatorCompilingEnvironment ; import com . asakusafw . runtime . model . DataModel ; import com . asakusafw . runtime . model . DataModelKind ; import com . asakusafw . vocabulary . flow . FlowDescription ; final class Util { static boolean isConcrete ( OperatorCompilingEnvironment environment , TypeMirror type ) { assert environment != null ; assert type != null ; if ( type . getKind ( ) != TypeKind . DECLARED ) { return false ; } if ( isKindMatched ( environment , type ) == false ) { return false ; } TypeMirror datamodel = environment . getDeclaredType ( DataModel . class ) ; return environment . getTypeUtils ( ) . isSubtype ( type , datamodel ) ; } static boolean isPartial ( OperatorCompilingEnvironment environment , TypeMirror type ) { assert environment != null ; assert type != null ; if ( type . getKind ( ) != TypeKind . TYPEVAR ) { return false ; } TypeVariable var = ( TypeVariable ) type ; TypeParameterElement parameter = ( TypeParameterElement ) var . asElement ( ) ; if ( hasKindMatched ( environment , parameter ) == false ) { return false ; } Element parent = parameter . getEnclosingElement ( ) ; if ( parent == null ) { return true ; } return | |
976 | <s> package com . asakusafw . testtools . inspect ; import java . lang . reflect . InvocationTargetException ; import java . lang . reflect . Method ; import java . util . ArrayList ; import java . util . Comparator ; import java . util . Iterator ; import java . util . List ; import org . apache . hadoop . io . Writable ; import com . asakusafw . runtime . value . ValueOption ; import com . asakusafw . testtools . ColumnInfo ; import com . asakusafw . testtools . ModelComparator ; import com . asakusafw . testtools . RowMatchingCondition ; import com . asakusafw . testtools . TestDataHolder ; import com . asakusafw . testtools . inspect . Cause . Type ; public abstract class AbstractInspector implements Inspector { private List < ColumnInfo > columnInfos ; private List < ColumnInfo > keyColumnInfos = new ArrayList < ColumnInfo > ( ) ; private long startTime ; private long finishTime = 0 ; private List < Cause > causes = new ArrayList < Cause > ( ) ; protected abstract void inspect ( Writable expectRow , Writable actualRow ) ; protected final void fail ( Type type , Writable expect , Writable actual ) { String tableNameString = "table = " + columnInfos . get ( 0 ) . getTableName ( ) + "," ; String keyValueString ; if ( actual != null ) { keyValueString = getKeyValueString ( actual ) ; } else { keyValueString = getKeyValueString ( expect ) ; } Cause cause = new Cause ( type , tableNameString + keyValueString , expect , actual ) ; causes . add ( cause ) ; } protected final void fail ( Type type , Writable expect , Writable actual , ValueOption < ? > expectVal , ValueOption < ? > actualVal , ColumnInfo columnInfo ) { String format = "" ; String additionalMessage = String . format ( format , columnInfo . getTableName ( ) , getKeyValueString ( actual ) , columnInfo . getColumnName ( ) , expectVal . toString ( ) , actualVal . toString ( ) ) ; Cause cause = new Cause ( type , additionalMessage , expect , actual , expectVal , actualVal , columnInfo ) ; causes . add ( cause ) ; } private String getKeyValueString ( Writable model ) { StringBuilder sb = new StringBuilder ( ) ; sb . append ( " Key = (" ) ; boolean first = true ; for ( ColumnInfo info : getKeyColumnInfos ( ) ) { if ( info . isKey ( ) ) { if ( first ) { first = false ; } else { sb . append ( ", " ) ; } sb . append ( info . getColumnName ( ) ) ; sb . append ( " = " ) ; sb . append ( getValue ( model , info ) . toString ( ) ) ; } } sb . append ( ")" ) ; return sb . toString ( ) ; } protected final List < ColumnInfo > getColumnInfos ( ) { return columnInfos ; } @ Override public void setColumnInfos ( List < ColumnInfo > columnInfos ) { this . columnInfos = columnInfos ; for ( ColumnInfo info : columnInfos ) { keyColumnInfos . add ( info ) ; } } protected final List < ColumnInfo > getKeyColumnInfos ( ) { return keyColumnInfos ; } @ Override public void setStartTime ( long startTime ) { this . | |
977 | <s> package com . asakusafw . dmdl . thundergate . model ; public enum Aggregator { IDENT { @ Override public PropertyType inferType ( PropertyType original ) { return original ; } } , SUM { @ Override public PropertyType inferType ( PropertyType original ) { switch ( original . getKind ( ) ) { case BYTE : case SHORT : case INT : case LONG : return new BasicType ( PropertyTypeKind . LONG ) ; case BIG_DECIMAL : return original ; default : return null ; } } } , COUNT { @ Override public PropertyType inferType ( PropertyType original ) { return new BasicType ( PropertyTypeKind . LONG ) ; } } , MAX { @ Override public PropertyType inferType ( PropertyType original ) { switch ( original . getKind ( ) ) { case INT : case LONG : | |
978 | <s> package net . ggtools . grand . ui ; import java . io . File ; import java . io . FileNotFoundException ; import java . io . IOException ; import java . util . prefs . BackingStoreException ; import java . util . prefs . Preferences ; import net . ggtools . grand . ui . prefs . ComplexPreferenceStore ; import net . ggtools . grand . ui . prefs . GraphPreferencePage ; import net . ggtools . grand . ui . prefs . LinksPreferencePage ; import net . ggtools . grand . ui . | |
979 | <s> package org . rubypeople . rdt . internal . ui . packageview ; import org . eclipse . jface . action . Action ; import org . eclipse . jface . dialogs . IDialogConstants ; import org . eclipse . jface . dialogs . MessageDialog ; import org . eclipse . jface . dialogs . ProgressMonitorDialog ; import org . eclipse . jface . viewers . IStructuredSelection ; import org . eclipse . jface . viewers . StructuredSelection ; import org . eclipse . swt . widgets . Shell ; import org . eclipse . ui . PlatformUI ; import org . eclipse . ui . dialogs . SelectionDialog ; import org . rubypeople . rdt . core . IRubyElement ; import org . rubypeople . rdt . core . IRubyScript ; import org . rubypeople . rdt . core . IType ; import org . rubypeople . rdt . core . RubyModelException ; import org . rubypeople . rdt . core . search . IRubySearchConstants ; import org . rubypeople . rdt . core . search . SearchEngine ; | |
980 | <s> package org . rubypeople . rdt . refactoring . tests . core . inlineclass ; import junit . framework . Test ; import junit . framework . TestSuite ; import org . rubypeople . rdt . refactoring . tests . | |
981 | <s> package com . asakusafw . yaess . tools ; import java . text . MessageFormat ; import java . util . Map ; import java . util . Properties ; import java . util . SortedMap ; import java . util . TreeMap ; import org . apache . commons . cli . BasicParser ; import org . apache . commons . cli . CommandLine ; import org . apache . commons . cli . CommandLineParser ; import org . apache . commons . cli . HelpFormatter ; import org . apache . commons . cli . Option ; import org . apache . commons . cli . Options ; import org . apache . commons . cli . ParseException ; public final class GenerateExecutionId { static final Option OPT_BATCH_ID ; static final Option OPT_FLOW_ID ; static final Option OPT_ARGUMENT ; private static final Options OPTIONS ; static { OPT_BATCH_ID = new Option ( "batch" , true , "batch ID" ) ; OPT_BATCH_ID . setArgName ( "batch_id" ) ; OPT_BATCH_ID . setRequired ( true ) ; OPT_FLOW_ID = new Option ( "flow" , true , "flow ID" ) ; OPT_FLOW_ID . setArgName ( "flow_id" ) ; OPT_FLOW_ID . setRequired ( true ) ; OPT_ARGUMENT = new Option ( "A" , true , "" ) ; OPT_ARGUMENT . setArgs ( 2 ) ; OPT_ARGUMENT . setValueSeparator ( '=' ) ; OPT_ARGUMENT . setArgName ( "name=value" ) ; OPT_ARGUMENT . setRequired ( false ) ; OPTIONS = new Options ( ) ; OPTIONS . addOption ( OPT_BATCH_ID ) ; OPTIONS . addOption ( OPT_FLOW_ID ) ; OPTIONS . addOption ( OPT_ARGUMENT ) ; } private GenerateExecutionId ( ) { return ; } public static void main ( String ... args ) { int status = execute ( args ) ; System . exit ( status ) ; } static int execute ( String [ ] args ) { assert args != null ; Configuration conf ; try { conf = parseConfiguration ( args ) ; } catch ( Exception e ) { HelpFormatter formatter = new HelpFormatter ( ) ; formatter . setWidth ( Integer . MAX_VALUE ) ; formatter . printHelp ( MessageFormat . format ( "" , GenerateExecutionId . class . getName ( ) ) , OPTIONS , true ) ; e . printStackTrace ( System . out ) ; return 1 ; } try { String executionId = computeExecutionId ( conf ) ; System . out . print ( executionId ) ; } catch ( Exception e ) { e | |
982 | <s> package com . asakusafw . compiler . operator . processor ; import static org . junit . Assert . * ; import org . junit . Test ; import com . asakusafw . compiler . operator . OperatorCompilerTestRoot ; import com . asakusafw . compiler . operator . model . MockHoge ; import com . asakusafw . compiler . operator . model . MockSummarized ; import com . asakusafw . utils . graph . Graph ; import com . asakusafw . vocabulary . flow . testing . MockIn ; import com . asakusafw . vocabulary . flow . testing . MockOut ; public class SummarizeOperatorProcessorTest extends OperatorCompilerTestRoot { @ Test public void simple ( ) { add ( "" ) ; ClassLoader loader = start ( new SummarizeOperatorProcessor ( ) ) ; Object factory = create ( loader , "" ) ; MockIn < MockHoge > in = MockIn . of ( MockHoge . class , "in" ) ; MockOut < MockSummarized > out = MockOut . of ( MockSummarized . class , "out" ) ; Object summarize = invoke ( factory , "example" , in ) ; out . add ( output ( MockSummarized . class , summarize , "out" ) ) ; Graph < String > graph = toGraph ( in ) ; assertThat ( graph . getConnected ( "in" ) , isJust ( "" ) | |
983 | <s> package org . oddjob . sql ; import junit . framework . TestCase ; import org . oddjob . Oddjob ; import org . oddjob . OddjobLookup ; import org . oddjob . arooa . convert . ArooaConversionException ; import org . oddjob . arooa . reflect . ArooaPropertyException ; import org . oddjob . arooa . xml . XMLConfiguration ; import org . oddjob . state . ParentState ; public class DB2Test extends TestCase { public void testCallable ( ) throws ArooaPropertyException , ArooaConversionException { if ( System . getProperty ( "db2.home" ) == null ) { return ; } Oddjob oddjob = new Oddjob ( ) ; oddjob . setConfiguration ( new XMLConfiguration ( "" , getClass ( ) . getClassLoader ( ) ) ) ; oddjob . run ( | |
984 | <s> package com . asakusafw . runtime . stage . directio ; import org . apache . hadoop . io . Writable ; import org . apache . hadoop . util . ReflectionUtils ; import com . asakusafw . runtime . directio . DataFormat ; import com . asakusafw . runtime . io . util . WritableRawComparableUnion ; public class DirectOutputSpec { private final Class < ? extends Writable > valueType ; private final String path ; private final Class < ? extends DataFormat < ? > > formatClass ; private final Class < ? extends StringTemplate > namingClass ; private final Class < ? extends DirectOutputOrder > orderClass ; public DirectOutputSpec ( Class < ? extends Writable > valueType , String path , Class < ? extends DataFormat < ? > > formatClass , Class < ? extends StringTemplate > namingClass , Class < ? extends DirectOutputOrder > orderClass ) { if ( valueType == null ) { throw new IllegalArgumentException ( "" ) ; } if ( path == null ) { throw new IllegalArgumentException ( "" ) ; } if ( formatClass == null ) { throw new IllegalArgumentException ( "" ) ; } if ( namingClass == null ) { throw new IllegalArgumentException ( "" ) ; } if ( orderClass == null ) { throw new IllegalArgumentException ( "" ) ; } this . valueType = valueType ; this . path = path ; this . formatClass = formatClass ; this . namingClass = namingClass ; this . orderClass = orderClass ; } static Class < ? > [ ] getValueTypes ( DirectOutputSpec [ ] specs ) { if ( specs == null ) { throw new IllegalArgumentException ( "" ) ; } Class < ? > [ ] results = new Class < ? > [ specs . length ] ; for ( int i = 0 ; i < specs . length ; i ++ ) { DirectOutputSpec spec = specs [ i ] ; if ( spec == null ) { results [ i ] = DirectOutputGroup . EMPTY . getDataType ( ) ; } else { results [ i ] = specs [ i ] . valueType ; } } return results ; } static WritableRawComparableUnion createGroupUnion ( DirectOutputSpec [ ] specs ) { if ( specs == null ) { throw new IllegalArgumentException ( "" ) ; } DirectOutputGroup [ ] elements = new DirectOutputGroup [ specs . | |
985 | <s> package org . rubypeople . rdt . refactoring . core . formatsource ; import org . rubypeople . rdt . refactoring . core . IRefactoringConfig ; import org . rubypeople . rdt . refactoring . documentprovider . DocumentProvider ; import org . rubypeople . rdt . refactoring . documentprovider . IDocumentProvider ; public class FormatSourceConfig implements IRefactoringConfig { private IDocumentProvider documentProvider ; public FormatSourceConfig ( DocumentProvider documentProvider ) { this . documentProvider = documentProvider ; } public IDocumentProvider getDocumentProvider | |
986 | <s> package net . sf . sveditor . core . db . stmt ; import java . util . ArrayList ; import java . util . List ; | |
987 | <s> package net . sf . sveditor . ui . prop_pages ; import net . sf . sveditor . core . db . project . SVProjectFileWrapper ; import org . eclipse . swt . | |
988 | <s> package com . asakusafw . testdriver . excel ; import static org . hamcrest . Matchers . * ; import static org . junit . Assert . * ; import java . io . File ; import java . io . FileInputStream ; import java . io . IOException ; import java . io . InputStream ; import java . net . URI ; import java . net . URISyntaxException ; import java . net . URL ; import java . util . HashSet ; import java . util . Map ; import java . util . Set ; import java . util . TreeMap ; import org . apache . poi . hssf . usermodel . HSSFWorkbook ; import org . apache . poi . ss . usermodel . Row ; import org . apache . poi . ss . usermodel . Sheet ; import org . apache . poi . ss . usermodel . Workbook ; import org . junit . Rule ; import org . junit . Test ; import org . junit . rules . TemporaryFolder ; import com . asakusafw . testdriver . core . DataModelDefinition ; import com . asakusafw . testdriver . core . DataModelReflection ; import com . asakusafw . testdriver . core . DataModelSink ; import com . asakusafw . testdriver . core . PropertyName ; import com . asakusafw . testdriver . core . PropertyType ; import com . asakusafw . testdriver . core . TestContext ; import com . asakusafw . testdriver . model . SimpleDataModelDefinition ; public class ExcelSheetSinkTest { static final DataModelDefinition < Simple > SIMPLE = new SimpleDataModelDefinition < Simple > ( Simple . class ) ; @ Rule public final TemporaryFolder folder = new TemporaryFolder ( ) ; @ Test public void simple ( ) throws Exception { verify ( "simple.xls" ) ; } @ Test public void create_folder ( ) throws Exception { File container = folder . newFolder ( "middle" ) ; File file = new File ( container , "file.xls" ) ; assertThat ( container . delete ( ) , is ( true ) ) ; assertThat ( file . isFile ( ) , is ( false ) ) ; ExcelSheetSinkFactory factory = new ExcelSheetSinkFactory ( file ) ; DataModelSink sink = factory . createSink ( SIMPLE , new TestContext . Empty ( ) ) ; try { sink . put ( SIMPLE . toReflection ( new Simple ( ) ) ) ; } finally { sink . close ( ) ; } assertThat ( file . isFile ( ) , is ( true ) ) ; } @ Test public void multiple ( ) throws Exception { verify ( "multiple.xls" ) ; } @ Test public void blank_cell | |
989 | <s> package org . rubypeople . rdt . refactoring . core . inlinelocal ; import java . util . ArrayList ; import java . util . Collection ; import org . rubypeople . rdt . refactoring . core . RefactoringContext ; import org . rubypeople . rdt . refactoring . core . extractmethod . ExtractMethodConditionChecker ; import org . rubypeople . rdt . refactoring . core . extractmethod . ExtractMethodConfig ; import org . rubypeople . rdt . refactoring . core . extractmethod . MethodExtractor ; import org . rubypeople . rdt . refactoring . editprovider . DeleteEditProvider ; import org . rubypeople . rdt . refactoring . editprovider . EditProvider ; import org . rubypeople . rdt . refactoring . editprovider . MultiEditProvider ; import org . rubypeople . | |
990 | <s> package org . rubypeople . rdt . internal . debug . ui ; import org . eclipse . core . runtime . IAdapterFactory ; import org . eclipse . ui . IActionFilter ; import org . rubypeople . rdt . debug . core . model . IRubyVariable ; class ActionFilterAdapterFactory implements IAdapterFactory , IActionFilter { public Object getAdapter ( Object obj , Class adapterType ) { if ( adapterType . isInstance ( obj ) ) { return obj ; } if ( adapterType != IActionFilter . class ) { return null ; } if | |
991 | <s> package com . asakusafw . windgate . hadoopfs . jsch ; import static org . hamcrest . CoreMatchers . * ; import static org . junit . Assert . * ; import java . io . ByteArrayOutputStream ; import java . io . File ; import java . io . FileInputStream ; import java . io . FileOutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . OutputStream ; import java . io . UnsupportedEncodingException ; import java . util . Arrays ; import java . util . Collection ; import java . util . HashMap ; import java . util . Map ; import java . util . Properties ; import java . util . Scanner ; import org . apache . hadoop . conf . Configuration ; import org . junit . Assume ; import org . junit . Before ; import org . junit . Rule ; import org . junit . Test ; import org . junit . rules . TemporaryFolder ; import com . asakusafw . runtime . core . context . RuntimeContext ; import com . asakusafw . runtime . core . context . RuntimeContext . ExecutionMode ; import com . asakusafw . runtime . core . context . RuntimeContextKeeper ; import com . asakusafw . windgate . core . ProfileContext ; import com . asakusafw . windgate . core . resource . ResourceProfile ; import com . asakusafw . windgate . hadoopfs . ssh . SshProfile ; public class JschConnectionTest { @ Rule public final RuntimeContextKeeper rc = new RuntimeContextKeeper ( ) ; @ Rule public TemporaryFolder folder = new TemporaryFolder ( ) ; private SshProfile profile ; private File target ; @ Before public void setUp ( ) throws Exception { Properties p = new Properties ( ) ; InputStream in = getClass ( ) . getResourceAsStream ( "" ) ; if ( in == null ) { System . err . println ( "" ) ; Assume . assumeNotNull ( in ) ; return ; } try { p . load ( in ) ; } finally { in . close ( ) ; } target = folder . newFolder ( "" ) ; putScript ( target , SshProfile . COMMAND_GET ) ; putScript ( target , SshProfile . COMMAND_PUT ) ; putScript ( target , SshProfile . COMMAND_DELETE ) ; p . setProperty ( "" , target . getAbsolutePath ( ) ) ; Collection < ? extends ResourceProfile > rps = ResourceProfile . loadFrom ( p , ProfileContext . system ( getClass ( ) . getClassLoader ( ) ) ) ; assertThat ( rps . size ( ) , is ( 1 ) ) ; ResourceProfile rp = rps . iterator ( ) . next ( ) ; this . profile = SshProfile . convert ( new Configuration ( ) , rp ) ; } private void putScript ( File directory , String sourcePath ) throws IOException { String targetPath = sourcePath ; putScript ( directory , sourcePath , targetPath ) ; } private void putScript ( File directory , String sourcePath , String targetPath ) throws IOException { InputStream in = getClass ( ) . getResourceAsStream ( sourcePath ) ; assertThat ( sourcePath , in , is ( notNullValue ( ) ) ) ; try { File targetFile = new File ( directory , targetPath ) ; targetFile . getParentFile ( ) . mkdirs ( ) ; FileOutputStream output = new FileOutputStream ( targetFile ) ; byte [ ] buf = new byte [ 256 ] ; while ( true ) { int read = in . read ( buf ) ; if ( read < 0 ) { break ; } output . write ( buf , 0 , read ) ; } output . close ( ) ; assertThat ( targetFile . getName ( ) , targetFile . setExecutable ( true ) , is ( true ) ) ; } finally { in . close ( ) ; } } @ Test public void get ( ) throws Exception { File file = folder . newFile ( "testing" ) ; put ( file , "" ) ; JschConnection conn = new JschConnection ( profile , Arrays . asList ( profile . getGetCommand ( ) , file . getAbsolutePath ( ) ) ) ; try { InputStream output = conn . openStandardOutput ( ) ; conn . connect ( ) ; String result = get ( output ) ; assertThat ( result , is ( "" ) ) ; int exit = conn . waitForExit ( 10000 ) ; assertThat ( exit , is ( 0 ) ) ; } finally { conn . close ( ) ; } } @ Test public void put ( ) throws Exception { File file = folder . newFile ( "testing" ) ; | |
992 | <s> package org . rubypeople . rdt . refactoring . core . renamemodule ; import java . util . ArrayList ; import java . util . Collection ; import org . jruby . ast . IScopingNode ; import org . rubypeople . rdt . refactoring . core . ModuleNodeProvider ; import org . rubypeople . rdt . refactoring . editprovider . FileMultiEditProvider ; import org . rubypeople . rdt . refactoring . editprovider . IMultiFileEditProvider ; import org . rubypeople . rdt . refactoring . editprovider . MultiFileEditProvider ; import org . rubypeople . rdt . refactoring . editprovider . ScopingNodeRenameEditProvider ; import org . rubypeople . rdt . refactoring . nodewrapper . ModuleNodeWrapper ; public class RenameModuleEditProvider implements IMultiFileEditProvider { private final RenameModuleConfig | |
993 | <s> package org . rubypeople . rdt . debug . core . tests ; import java . io . BufferedReader ; import java . io . File ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . net . Socket ; import java . text . DecimalFormat ; import java . text . DecimalFormatSymbols ; import java . util . Locale ; public class NonBlockingSocketReader { private Socket socket ; private PrintWriter out ; private BufferedReader reader ; private Process process ; private OutputRedirectorThread rubyStdoutRedirectorThread ; public void setUp ( ) throws Exception { String binDir = this . getClass ( ) . getResource ( "/" ) . getFile ( ) ; if ( binDir . startsWith ( "/" ) && File . separatorChar == '\\' ) { binDir = | |
994 | <s> package org . oddjob . framework ; import junit . framework . TestCase ; public class ProxyGeneratorTest extends TestCase { interface Fruit { String getType ( ) ; } class Apple implements Fruit { @ Override public String getType ( ) { return "apple" ; } } interface Snack { public void eat ( ) ; } class FruitWrapper implements ComponentWrapper , Snack { final Fruit fruit ; int eaten ; String type ; public FruitWrapper ( Fruit fruit ) { this . fruit = fruit ; } @ Override public void eat ( ) { ++ eaten ; type = fruit . getType ( ) ; } } public void testGenerate ( ) { ProxyGenerator < Fruit > test = new ProxyGenerator < Fruit > ( ) ; final Fruit fruit = new Apple ( ) ; final FruitWrapper wrapper = new FruitWrapper ( fruit ) ; Object proxy = test . generate ( fruit , new WrapperFactory < ProxyGeneratorTest . Fruit > ( ) { @ Override public Class < ? > [ ] wrappingInterfacesFor ( Fruit wrapped ) { return new Class [ ] { Snack . class } ; } @ Override public ComponentWrapper wrapperFor ( Fruit wrapped , Object proxy ) { return wrapper ; } } , getClass ( ) . getClassLoader ( ) ) ; assertTrue ( proxy instanceof Fruit ) ; assertTrue ( proxy instanceof Snack ) ; assertEquals ( "apple" , ( ( Fruit ) proxy ) . getType ( ) ) ; ( ( Snack ) proxy | |
995 | <s> package com . asakusafw . testdata . generator . excel ; import static org . hamcrest . Matchers . * ; import static org . junit . Assert . * ; import java . io . File ; import java . io . FileInputStream ; import java . io . FileOutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . OutputStream ; import java . util . ArrayList ; import java . util . Collections ; import java . util . List ; import org . apache . poi . hssf . usermodel . HSSFWorkbook ; import org . junit . Test ; public class MainTest extends ExcelTesterRoot { @ Test public void simple ( ) throws Exception { File output = folder . newFolder ( "output" ) ; File source = folder . newFolder ( "source" ) ; deploy ( "simple.dmdl" , source ) ; List < String > args = new ArrayList < String > ( ) ; Collections . addAll ( args , "-output" , output . getAbsolutePath ( ) ) ; Collections . addAll ( args , "-source" , source . getAbsolutePath ( ) ) ; Collections . addAll ( args , "-format" , WorkbookFormat . DATA . name ( ) ) ; int exit = Main . start ( args . toArray ( new String [ args . size ( ) ] ) ) ; assertThat ( exit , is ( 0 ) ) ; HSSFWorkbook book = open ( output , "simple" ) ; assertThat ( cell ( book . getSheetAt ( 0 ) , 0 , 0 ) , is ( "value" ) ) ; } @ Test public void less ( ) { List < String > args = new ArrayList < String > ( ) ; Collections . addAll ( args ) ; int exit = Main . start ( args . toArray ( new String [ args . size ( ) ] ) ) ; assertThat ( exit , not ( 0 ) ) ; } @ Test public void invalid_dmdl ( ) throws Exception { File output = folder . newFolder ( "output" ) ; File source = folder . newFolder ( "source" ) ; deploy ( "invalid.dmdl" , source ) ; List < String > args = new ArrayList < String > ( ) ; Collections . addAll ( args , "-output" , output . getAbsolutePath ( ) ) ; Collections . addAll ( args , "-source" , | |
996 | <s> package org . oddjob . jmx . handlers ; import java . io . Serializable ; import java . lang . reflect . UndeclaredThrowableException ; import java . util . ArrayList ; import java . util . LinkedList ; import java . util . List ; import javax . management . JMException ; import javax . management . MBeanAttributeInfo ; import javax . management . MBeanException ; import javax . management . MBeanNotificationInfo ; import javax . management . MBeanOperationInfo ; import javax . management . Notification ; import javax . management . NotificationListener ; import javax . management . ObjectName ; import javax . management . ReflectionException ; import org . apache . log4j . Logger ; import org . oddjob . Structural ; import org . oddjob . jmx . RemoteOperation ; import org . oddjob . jmx . client . ClientHandlerResolver ; import org . oddjob . jmx . client . ClientInterfaceHandlerFactory ; import org . oddjob . jmx . client . ClientSideToolkit ; import org . oddjob . jmx . client . HandlerVersion ; import org . oddjob . jmx . client . SimpleHandlerResolver ; import org . oddjob . jmx . client . Synchronizer ; import org . oddjob . jmx . server . JMXOperationPlus ; import org . oddjob . jmx . server . ServerInterfaceHandler ; import org . oddjob . jmx . server . ServerInterfaceHandlerFactory ; import org . oddjob . jmx . server . ServerLoopBackException ; import org . oddjob . jmx . server . ServerSideToolkit ; import org . oddjob . structural . ChildHelper ; import org . oddjob . structural . ChildMatch ; import org . oddjob . structural . StructuralEvent ; import org . oddjob . structural . StructuralListener ; public class StructuralHandlerFactory implements ServerInterfaceHandlerFactory < Structural , Structural > { private static final Logger logger = Logger . getLogger ( StructuralHandlerFactory . class ) ; public static final HandlerVersion VERSION = new HandlerVersion ( 1 , 0 ) ; public static final String STRUCTURAL_NOTIF_TYPE = "" ; static final JMXOperationPlus < Notification [ ] > SYNCHRONIZE = new JMXOperationPlus < Notification [ ] > ( "" , "" , Notification [ ] . class , MBeanOperationInfo . INFO ) ; public Class < Structural > interfaceClass ( ) { return Structural . class ; } public MBeanAttributeInfo [ ] getMBeanAttributeInfo ( ) { return new MBeanAttributeInfo [ 0 ] ; } public MBeanOperationInfo [ ] getMBeanOperationInfo ( ) { return new MBeanOperationInfo [ ] { SYNCHRONIZE . getOpInfo ( ) } ; } public MBeanNotificationInfo [ ] getMBeanNotificationInfo ( ) { MBeanNotificationInfo [ ] nInfo = new MBeanNotificationInfo [ ] { new MBeanNotificationInfo ( new String [ ] { STRUCTURAL_NOTIF_TYPE } , Notification . class . getName ( ) , "" ) } ; return nInfo ; } public ServerInterfaceHandler createServerHandler ( Structural structural , ServerSideToolkit ojmb ) { ServerStructuralHelper structuralHelper = new ServerStructuralHelper ( structural , ojmb ) ; return structuralHelper ; } public ClientHandlerResolver < Structural > clientHandlerFactory ( ) { return new SimpleHandlerResolver < Structural > ( ClientStructuralHandlerFactory . class . getName ( ) , VERSION ) ; } public static class ClientStructuralHandlerFactory implements ClientInterfaceHandlerFactory < Structural > { public Class < Structural > interfaceClass ( ) { return Structural . class ; } public HandlerVersion getVersion ( ) { return VERSION ; } public Structural createClientHandler ( Structural proxy , ClientSideToolkit toolkit ) { return new ClientStructuralHandler ( proxy , toolkit ) ; } } static class ClientStructuralHandler implements Structural { private final Structural proxy ; private ChildHelper < Object > structuralHelper ; private final ClientSideToolkit toolkit ; private Synchronizer synchronizer ; private List < ObjectName > childNames ; ClientStructuralHandler ( Structural proxy , ClientSideToolkit toolkit ) { this . proxy = proxy ; this . toolkit = toolkit ; } public void addStructuralListener ( StructuralListener listener ) { synchronized ( this ) { if ( structuralHelper == null ) { this . structuralHelper = new ChildHelper < Object > ( proxy ) ; this . childNames = new ArrayList < ObjectName > ( ) ; synchronizer = new Synchronizer ( new NotificationListener ( ) { public void handleNotification ( Notification notification , Object arg1 ) { ChildData childData = ( ChildData ) notification . getUserData ( ) ; new ChildMatch < ObjectName > ( childNames ) { protected void insertChild ( int index , ObjectName childName ) { Object childProxy = toolkit . getClientSession ( ) . create ( childName ) ; structuralHelper . insertChild ( index , childProxy ) ; } ; @ Override protected void removeChildAt ( int index ) { Object child = structuralHelper . removeChildAt ( index ) ; toolkit . getClientSession ( ) . destroy ( child ) ; } } . match ( childData . getChildObjectNames ( ) ) ; } } ) ; toolkit . registerNotificationListener ( STRUCTURAL_NOTIF_TYPE , synchronizer ) ; Notification [ ] lastNotifications = null ; try { lastNotifications = toolkit . invoke ( SYNCHRONIZE ) ; } catch ( Throwable e ) { throw new UndeclaredThrowableException ( e ) ; } synchronizer . synchronize ( lastNotifications ) ; } } structuralHelper . addStructuralListener ( listener ) ; } public void removeStructuralListener ( StructuralListener listener ) { synchronized ( this ) { if ( structuralHelper != null ) { structuralHelper . removeStructuralListener ( listener ) ; if ( structuralHelper . isNoListeners ( ) ) { toolkit . removeNotificationListener ( STRUCTURAL_NOTIF_TYPE , synchronizer ) ; synchronizer = null ; structuralHelper = null ; } } } } } class ServerStructuralHelper implements ServerInterfaceHandler { private final Structural structural ; private final ServerSideToolkit toolkit ; private boolean duplicate ; private final LinkedList < ObjectName > children = new LinkedList < ObjectName > ( ) ; private final StructuralListener listener = new StructuralListener ( ) { public void childAdded ( final StructuralEvent e ) { final ObjectName child ; Object childComponent = e . getChild ( ) ; try { child = toolkit . getServerSession ( ) . createMBeanFor ( childComponent , toolkit . getContext ( ) . addChild ( childComponent ) ) ; } catch ( ServerLoopBackException e1 ) { logger . info ( "" ) ; duplicate = true ; return ; } catch ( JMException e2 ) { logger . error ( "" + childComponent + "]" , e2 ) ; return ; } final int index = e . getIndex ( ) ; ChildData newEvent = null ; synchronized ( children ) { children . add ( index , child ) ; newEvent = new ChildData ( children . toArray ( new ObjectName [ children . size ( ) ] ) ) ; } final Notification notification = toolkit . createNotification ( STRUCTURAL_NOTIF_TYPE ) ; notification . setUserData ( newEvent ) ; toolkit . runSynchronized ( new | |
997 | <s> package org . rubypeople . rdt . refactoring . core . splitlocal ; import org . rubypeople . rdt . refactoring . core . IRefactoringContext ; import org . rubypeople . rdt . refactoring . core . RubyRefactoring ; import org . rubypeople . rdt . refactoring . ui . pages . SplitLocalPage ; public | |
998 | <s> package org . oddjob . schedules ; import java . text . ParseException ; import org . oddjob . arooa . utils . DateHelper ; import junit . framework . TestCase ; public class SimpleScheduleResultTest extends TestCase { public void testEquals ( ) throws ParseException { Object o1 , o2 ; o1 = new SimpleScheduleResult ( new IntervalTo ( DateHelper . parseDateTime ( "" ) , DateHelper . parseDateTime ( "" ) ) ) ; o2 = new SimpleScheduleResult ( new IntervalTo ( DateHelper . parseDateTime ( "" ) , DateHelper . parseDateTime ( "" ) ) ) ; assertEquals ( o1 , o2 ) ; o1 = new SimpleScheduleResult ( new IntervalTo ( DateHelper . parseDateTime ( "" ) , DateHelper . parseDateTime ( "" ) ) , null ) ; o2 = new SimpleScheduleResult ( new IntervalTo ( DateHelper | |
999 | <s> package org . oddjob . monitor . context ; public class AncestorSearch { private final ExplorerContext start ; public AncestorSearch ( ExplorerContext |
Subsets and Splits