当前位置: 首页>>代码示例>>Java>>正文


Java Util类代码示例

本文整理汇总了Java中edu.umd.cs.findbugs.util.Util的典型用法代码示例。如果您正苦于以下问题:Java Util类的具体用法?Java Util怎么用?Java Util使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Util类属于edu.umd.cs.findbugs.util包,在下文中一共展示了Util类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addAccess

import edu.umd.cs.findbugs.util.Util; //导入依赖的package包/类
public void addAccess(MethodDescriptor method, InstructionHandle handle, boolean isLocked) {
    if (!interesting)
        return;
    if (!SYNC_ACCESS && isLocked)
        return;

    if (!servletField && !isLocked && syncAccessList.size() == 0 && unsyncAccessList.size() > 6) {
        interesting = false;
        syncAccessList = null;
        unsyncAccessList = null;
        return;
    }
    FieldAccess fa = new FieldAccess(method, handle.getPosition());
    if (isLocked)
        syncAccessList = Util.addTo(syncAccessList, fa);
    else
        unsyncAccessList = Util.addTo(unsyncAccessList, fa);
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:19,代码来源:FindInconsistentSync2.java

示例2: visitClass

import edu.umd.cs.findbugs.util.Util; //导入依赖的package包/类
@Override
public void visitClass(ClassDescriptor classDescriptor) throws CheckedAnalysisException {

    if (!checked) {
        checked = true;
        Collection<TypeQualifierValue<?>> allKnownTypeQualifiers = TypeQualifierValue.getAllKnownTypeQualifiers();
        int size = allKnownTypeQualifiers.size();
        if (size == 1) {
            TypeQualifierValue<?> value = Util.first(allKnownTypeQualifiers);
            if (!value.typeQualifier.getClassName().equals(NONNULL_ANNOTATION))
                shouldRunAnalysis = true;

        } else if (size > 1)
            shouldRunAnalysis = true;
    }

    if (shouldRunAnalysis)
        super.visitClass(classDescriptor);
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:20,代码来源:CheckTypeQualifiers.java

示例3: handleXArgs

import edu.umd.cs.findbugs.util.Util; //导入依赖的package包/类
/**
 * Handle -xargs command line option by reading jar file names from standard
 * input and adding them to the project.
 *
 * @throws IOException
 */
public void handleXArgs() throws IOException {
    if (getXargs()) {
        BufferedReader in = UTF8.bufferedReader(System.in);
        try {
        while (true) {
            String s = in.readLine();
            if (s == null)
                break;
            project.addFile(s);
        }
        } finally {
         Util.closeSilently(in);
        }
    }
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:22,代码来源:TextUICommandLine.java

示例4: getInstanceHash

import edu.umd.cs.findbugs.util.Util; //导入依赖的package包/类
/**
 * @return Returns the instanceHash.
 */

public String getInstanceHash() {
    String hash = instanceHash;
    if (hash != null)
        return hash;

    MessageDigest digest = Util.getMD5Digest();
    String key = getInstanceKey();
    byte[] data;
    try {
        data = digest.digest(key.getBytes("UTF-8"));
    } catch (UnsupportedEncodingException e) {
        throw new IllegalStateException(e);
    }
    hash = new BigInteger(1, data).toString(16);
    instanceHash = hash;
    return hash;
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:22,代码来源:BugInstance.java

示例5: checkAuthorized

import edu.umd.cs.findbugs.util.Util; //导入依赖的package包/类
private boolean checkAuthorized(URL response) throws IOException {
    HttpURLConnection connection = (HttpURLConnection) response.openConnection();

    int responseCode = connection.getResponseCode();
    if (responseCode == 200) {
        InputStream in = connection.getInputStream();
        BufferedReader reader = UTF8.bufferedReader(in);
        try {
            String status = reader.readLine();
            sessionId = Long.parseLong(reader.readLine());
            username = reader.readLine();
            Util.closeSilently(reader);
            if ("OK".equals(status)) {
                LOGGER.info("Authorized session " + sessionId);
                return true;
            }
        } finally {
            reader.close();
        }

    }
    connection.disconnect();
    return false;
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:25,代码来源:WebCloudNameLookup.java

示例6: computeHash

import edu.umd.cs.findbugs.util.Util; //导入依赖的package包/类
/**
 * Compute hash on given method.
 * 
 * @param method
 *            the method
 * @return this object
 */
public MethodHash computeHash(Method method) {
    final MessageDigest digest = Util.getMD5Digest();

    byte[] code;
    if (method.getCode() == null || method.getCode().getCode() == null) {
        code = new byte[0];
    } else {
        code = method.getCode().getCode();
    }

    BytecodeScanner.Callback callback = new BytecodeScanner.Callback() {
        public void handleInstruction(int opcode, int index) {
            digest.update((byte) opcode);
        }
    };

    BytecodeScanner bytecodeScanner = new BytecodeScanner();
    bytecodeScanner.scan(code, callback);

    hash = digest.digest();

    return this;
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:31,代码来源:MethodHash.java

示例7: getAnalysisOptionProperties

import edu.umd.cs.findbugs.util.Util; //导入依赖的package包/类
public static ArrayList<String> getAnalysisOptionProperties(boolean ignoreComments, boolean ignoreBlankLines) {
    ArrayList<String> resultList = new ArrayList<String>();
    URL u = DetectorFactoryCollection.getCoreResource("analysisOptions.properties");
    if (u != null) {
        BufferedReader reader = null;
        try {
            reader = UTF8.bufferedReader(u.openStream());
            addCommandLineOptions(resultList, reader, ignoreComments, ignoreBlankLines);
        } catch (IOException e) {
            AnalysisContext.logError("unable to load analysisOptions.properties", e);
        } finally {
            Util.closeSilently(reader);
        }
    }
    return resultList;
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:17,代码来源:CommandLine.java

示例8: compareTo

import edu.umd.cs.findbugs.util.Util; //导入依赖的package包/类
public int compareTo(BugDesignation o) {
    if (this == o)
        return 0;
    int result = Util.compare(o.timestamp, this.timestamp);
    if (result != 0)
        return result;

    result = Util.nullSafeCompareTo(this.user, o.user);
    if (result != 0)
        return result;

    result = this.designation.compareTo(o.designation);
    if (result != 0)
        return result;
    result = Util.nullSafeCompareTo(this.annotationText, o.annotationText);
    if (result != 0)
        return result;

    return 0;

}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:22,代码来源:BugDesignation.java

示例9: verifyURL

import edu.umd.cs.findbugs.util.Util; //导入依赖的package包/类
public static boolean verifyURL(URL u) {
    if (u == null)
        return false;

    InputStream i = null;

    try {
        URLConnection uc = u.openConnection();
        i = uc.getInputStream();
        int firstByte = i.read();
        i.close();
        return firstByte >= 0;
    }

    catch (Exception e) {
        return false;
    } finally {
        Util.closeSilently(i);
    }

}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:22,代码来源:IO.java

示例10: ProjectPackagePrefixes

import edu.umd.cs.findbugs.util.Util; //导入依赖的package包/类
public ProjectPackagePrefixes() {
    URL u = DetectorFactoryCollection.getCoreResource("projectPaths.properties");
    if (u != null) {

        BufferedReader in = null;
        try {
             in = UTF8.bufferedReader(u.openStream());
            while (true) {
                String s = in.readLine();
                if (s == null)
                    break;
                String[] parts = s.split("=");
                if (parts.length == 2 && !map.containsKey(parts[0]))
                    map.put(parts[0], new PrefixFilter(parts[1]));
            }
        } catch (IOException e1) {

            AnalysisContext.logError("Error loading projects paths", e1);
        } finally {
           Util.closeSilently(in);
        }

    }

}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:26,代码来源:ProjectPackagePrefixes.java

示例11: startUpdateCheckThread

import edu.umd.cs.findbugs.util.Util; //导入依赖的package包/类
private void startUpdateCheckThread(final URI url, final Collection<Plugin> plugins, final CountDownLatch latch) {
    if (url == null) {
        logError(Level.INFO, "Not checking for plugin updates w/ blank URL: " + getPluginNames(plugins));
        return;
    }
    final String entryPoint = getEntryPoint();
    if ((entryPoint.contains("edu.umd.cs.findbugs.FindBugsTestCase") 
            || entryPoint.contains("edu.umd.cs.findbugs.cloud.appEngine.AbstractWebCloudTest"))
            && (url.getScheme().equals("http") || url.getScheme().equals("https"))) {
        LOGGER.fine("Skipping update check because we're running in FindBugsTestCase and using "
                + url.getScheme());
        return;
    }
    Util.runInDameonThread(new Runnable() {
        public void run() {
            try {
                actuallyCheckforUpdates(url, plugins, entryPoint);
            } catch (Exception e) {
                if (e instanceof IllegalStateException && e.getMessage().contains("Shutdown in progress"))
                    return;
                logError(e, "Error doing update check at " + url);
            } finally {
                latch.countDown();
            }
        }
    }, "Check for updates");
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:28,代码来源:UpdateChecker.java

示例12: parseUpdateXml

import edu.umd.cs.findbugs.util.Util; //导入依赖的package包/类
@SuppressWarnings({ "unchecked" })
    void parseUpdateXml(URI url, Collection<Plugin> plugins, @WillClose
    InputStream inputStream) {
        try {
            Document doc = new SAXReader().read(inputStream);
//            StringWriter stringWriter = new StringWriter();
//            XMLWriter xmlWriter = new XMLWriter(stringWriter);
//            xmlWriter.write(doc);
//            xmlWriter.close();
//            System.out.println("UPDATE RESPONSE: " + stringWriter.toString());
            List<Element> pluginEls =  XMLUtil.selectNodes(doc, "fb-plugin-updates/plugin");
            Map<String, Plugin> map = new HashMap<String, Plugin>();
            for (Plugin p : plugins)
                map.put(p.getPluginId(), p);
            for (Element pluginEl : pluginEls) {
                String id = pluginEl.attributeValue("id");
                Plugin plugin = map.get(id);
                if (plugin != null) {
                    checkPlugin(pluginEl, plugin);
                }

            }
        } catch (Exception e) {
            logError(e, "Could not parse plugin version update for " + url);
        } finally {
            Util.closeSilently(inputStream);
        }
    }
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:29,代码来源:UpdateChecker.java

示例13: getAnnotationWithRole

import edu.umd.cs.findbugs.util.Util; //导入依赖的package包/类
/** Get the first bug annotation with the specified class and role; return null if no
 * such annotation exists;
 * @param role
 * @return
 */
public @CheckForNull <A extends BugAnnotation> A getAnnotationWithRole(Class<A> c, String role) {
    for(BugAnnotation a : annotationList) {
        if (c.isInstance(a) && Util.nullSafeEquals(role, a.getDescription()))
            return c.cast(a);
    }
    return null;

}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:14,代码来源:BugInstance.java

示例14: ClassInfo

import edu.umd.cs.findbugs.util.Util; //导入依赖的package包/类
/**
 *
 * @param classDescriptor
 *            ClassDescriptor representing the class name
 * @param superclassDescriptor
 *            ClassDescriptor representing the superclass name
 * @param interfaceDescriptorList
 *            ClassDescriptors representing implemented interface names
 * @param codeBaseEntry
 *            codebase entry class was loaded from
 * @param accessFlags
 *            class's access flags
 * @param referencedClassDescriptorList
 *            ClassDescriptors of all classes/interfaces referenced by the
 *            class
 * @param calledClassDescriptors
 *            TODO
 * @param fieldDescriptorList
 *            FieldDescriptors of fields defined in the class
 * @param methodInfoList
 *            MethodDescriptors of methods defined in the class
 * @param usesConcurrency
 *            TODO
 * @param hasStubs
 *            TODO
 */
private ClassInfo(ClassDescriptor classDescriptor, String classSourceSignature, ClassDescriptor superclassDescriptor,
        ClassDescriptor[] interfaceDescriptorList, ICodeBaseEntry codeBaseEntry, int accessFlags, String source,
        int majorVersion, int minorVersion, Collection<ClassDescriptor> referencedClassDescriptorList,
        Set<ClassDescriptor> calledClassDescriptors, Map<ClassDescriptor, AnnotationValue> classAnnotations,
        FieldInfo[] fieldDescriptorList, MethodInfo[] methodInfoList, ClassDescriptor immediateEnclosingClass,
        boolean usesConcurrency, boolean hasStubs) {
    super(classDescriptor, superclassDescriptor, interfaceDescriptorList, codeBaseEntry, accessFlags,
            referencedClassDescriptorList, calledClassDescriptors, majorVersion, minorVersion);
    this.source = source;
    this.classSourceSignature = classSourceSignature;
    if (fieldDescriptorList.length == 0)
        fieldDescriptorList = FieldInfo.EMPTY_ARRAY;
    this.xFields = fieldDescriptorList;
    this.xMethods = methodInfoList;
    this.immediateEnclosingClass = immediateEnclosingClass;
    this.classAnnotations = Util.immutableMap(classAnnotations);
    this.usesConcurrency = usesConcurrency;
    this.hasStubs = hasStubs;
    this.methodsInCallOrder = computeMethodsInCallOrder();
    if (false) {
        System.out.println("Methods in call order for " + classDescriptor);
        for (MethodInfo m : methodsInCallOrder) {
            System.out.println("  " + m);
        }
        System.out.println();
    }
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:54,代码来源:ClassInfo.java

示例15: MethodInfo

import edu.umd.cs.findbugs.util.Util; //导入依赖的package包/类
MethodInfo(@SlashedClassName String className, String methodName, String methodSignature, String methodSourceSignature,
        int accessFlags, boolean isUnconditionalThrower, boolean isUnsupported, boolean usesConcurrency,
        boolean hasBackBranch, boolean isStub, boolean isIdentity,
        int methodCallCount, @CheckForNull String[] exceptions, @CheckForNull MethodDescriptor accessMethodForMethod,
        @CheckForNull FieldDescriptor accessMethodForField,
        Map<ClassDescriptor, AnnotationValue> methodAnnotations,
        Map<Integer, Map<ClassDescriptor, AnnotationValue>> methodParameterAnnotations, long variableIsSynthetic) {
    super(className, methodName, methodSignature, (accessFlags & Constants.ACC_STATIC) != 0);
    this.accessFlags = accessFlags;
    this.exceptions = exceptions;
    if (exceptions != null)
        for (int i = 0; i < exceptions.length; i++)
            exceptions[i] = DescriptorFactory.canonicalizeString(exceptions[i]);
    this.methodSourceSignature = DescriptorFactory.canonicalizeString(methodSourceSignature);
    this.methodAnnotations = Util.immutableMap(methodAnnotations);
    this.methodParameterAnnotations = Util.immutableMap(methodParameterAnnotations);
    if (isUnconditionalThrower)
        unconditionalThrowers.put(this, null);
    if (isUnsupported)
        unsupportedMethods.put(this, null);
    if (accessMethodForMethod != null)
        MethodInfo.accessMethodForMethod.put(this, accessMethodForMethod);
    if (accessMethodForField!= null)
        MethodInfo.accessMethodForField.put(this, accessMethodForField);
    if (isIdentity) {
        MethodInfo.identifyMethods.put(this, null);
    }

    this.usesConcurrency = usesConcurrency;
    this.hasBackBranch = hasBackBranch;
    this.isStub = isStub;
    this.methodCallCount = methodCallCount;
    this.variableIsSynthetic = variableIsSynthetic;
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:35,代码来源:MethodInfo.java


注:本文中的edu.umd.cs.findbugs.util.Util类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。