modifyingtestfinder.java.svn-base
来自「cqME :java framework for TCK test.」· SVN-BASE 代码 · 共 209 行
SVN-BASE
209 行
/* * $Id$ * * Copyright 1996-2007 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License version * 2 only, as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License version 2 for more details (a copy is * included at /legal/license.txt). * * You should have received a copy of the GNU General Public License * version 2 along with this work; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA * * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa * Clara, CA 95054 or visit www.sun.com if you need additional * information or have any questions. * */package com.sun.tck.j2me.javatest;import java.io.File;import java.util.Comparator;import java.util.Set;import java.util.TreeSet;import com.sun.javatest.TestDescription;import com.sun.javatest.TestEnvironment;import com.sun.javatest.TestFinder;/** * Special purpose TestFinder that decorates another finder and modifies on the * fly the tests found by the decorated finder, based on the strategy supplied * by {@link com.sun.tck.j2me.javatest.TestDescriptionModifier}. */public class ModifyingTestFinder extends TestFinder { /** * Creates a decorating finder with the specified base finder and test * description modifier. Most of this finder's work is delegated to the * base finder. * * @param baseFinder * The base finder. * @param modifier * The test description modifier. */ public ModifyingTestFinder(TestFinder baseFinder, TestDescriptionModifier modifier) { if (baseFinder == null || modifier == null) { throw new NullPointerException( "TestFinder and Modifier should not be null"); } this.baseFinder = baseFinder; this.modifier = modifier; } /** * This implementation simply delegates its work to the base finder. */ public void init(String[] args, File testSuiteRoot, TestEnvironment env) throws Fault { baseFinder.init(args, testSuiteRoot, env); } /** * This implementation simply delegates its work to the base finder. */ public TestDescriptionModifier getDescriptionModifier() { return modifier; } /** * This implementation simply delegates its work to the base finder. */ public File getRoot() { return baseFinder.getRoot(); } /** * This implementation simply delegates its work to the base finder. */ public File getRootDir() { return baseFinder.getRootDir(); } /** * This implementation simply delegates its work to the base finder. */ public void setComparator(Comparator c) { baseFinder.setComparator(c); } /** * This implementation simply delegates its work to the base finder. */ public Comparator getComparator() { return baseFinder.getComparator(); } /** * This implementation simply delegates its work to the base finder. */ public ErrorHandler getErrorHandler() { return baseFinder.getErrorHandler(); } /** * This implementation simply delegates its work to the base finder. */ public void setErrorHandler(ErrorHandler h) { baseFinder.setErrorHandler(h); } public int getErrorCount() { return baseFinder.getErrorCount(); } /** * This implementation simply delegates its work to the base finder. */ public String[] getErrors() { return baseFinder.getErrors(); } /** * This implementation simply delegates its work to the base finder. */ public void clearErrors() { baseFinder.clearErrors(); } public void read(File file) { baseFinder.read(file); } /** * This implementation simply delegates its work to the base finder. */ public File[] getFiles() { return baseFinder.getFiles(); } /** * This method must not be called. * It always throws <code>IllegalStateException</code>. * @throws IllegalStateException */ public void scan(File file) { throw new IllegalStateException("Must not be called"); } /** * Returns an array of test descriptions, found by the base finder and then * modified by {@link com.sun.tck.j2me.javatest.TestDescriptionModifier}. * * @return The array of modified test descriptions. */ public TestDescription[] getTests() { TestDescription[] origDescrs = baseFinder.getTests(); Set modifiedDescriptions = new TreeSet(new Comparator() { public boolean equals(Object obj) { return getComparator().equals(obj); } public int hashCode() { return getComparator().hashCode(); } public int compare(Object o1, Object o2) { if (o1 instanceof TestDescription && o2 instanceof TestDescription) { return getComparator().compare( ((TestDescription) o1).getRootRelativeURL(), ((TestDescription) o2).getRootRelativeURL()); } else { return 0; } } }); for (int i = 0; i < origDescrs.length; i++) { TestDescription td = origDescrs[i]; if (modifier.isModifiable(td)) { Set mDescrs = modifier.modify(td); modifiedDescriptions.addAll(mDescrs); } else { modifiedDescriptions.add(td); } } return (TestDescription[]) modifiedDescriptions.toArray( new TestDescription[0]); } private TestFinder baseFinder = null; private TestDescriptionModifier modifier = null;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?