commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kinow <...@git.apache.org>
Subject [GitHub] commons-lang pull request #231: Evaluate Architecure
Date Thu, 09 Mar 2017 08:52:33 GMT
Github user kinow commented on a diff in the pull request:

    https://github.com/apache/commons-lang/pull/231#discussion_r105108009
  
    --- Diff: src/main/java/org/apache/commons/lang3/ArchUtils.java ---
    @@ -0,0 +1,446 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *      http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.commons.lang3;
    +
    +import java.util.Map;
    +import java.util.concurrent.ConcurrentHashMap;
    +
    +/**
    + * An utility class for the os.arch System Property. The class defines methods for
    + * identifying the architecture of the current JVM.
    + * <p>
    + * <p>
    + * Important: The os.arch System Property returns the architecture used by the JVM
    + * not of the operating system.
    + * </p>
    + *
    + * @author Tomschi
    + */
    +public class ArchUtils {
    +
    +    /**
    +     * This {@link Map} contains the the possible os.arch property {@link String}'s.
    +     */
    +    private static final Map<String, String> map;
    +
    +    /**
    +     * The value for x86 architecture.
    +     */
    +    private static final String X86 = "x86";
    +
    +    /**
    +     * The value for x86_64 architecture.
    +     */
    +    private static final String X86_64 = "x86_64";
    +
    +    /**
    +     * The value for ia64_32 architecture.
    +     */
    +    private static final String IA64_32 = "ia64_32";
    +
    +    /**
    +     * The value for ia64 architecture.
    +     */
    +    private static final String IA64 = "ia64";
    +
    +    /**
    +     * The value for ppc architecture.
    +     */
    +    private static final String PPC = "ppc";
    +
    +    /**
    +     * The value for ppc64 architecture.
    +     */
    +    private static final String PPC64 = "ppc64";
    +
    +    static {
    +        map = new ConcurrentHashMap<>();
    +
    +        // x86 mappings
    +        addX86(X86);
    +        addX86("i386");
    +        addX86("i486");
    +        addX86("i586");
    +        addX86("i686");
    +        addX86("pentium");
    +
    +        // x86_64 mappings
    +        addX86_64(X86_64);
    +        addX86_64("amd64");
    +        addX86_64("em64t");
    +        addX86_64("universal"); // Needed for openjdk7 in Mac
    +
    +        // Itenium 64-bit mappings
    +        addIA64(IA64);
    +        addIA64("ia64w");
    +
    +        // Itenium 32-bit mappings, usually an HP-UX construct
    +        addIA64_32(IA64_32);
    +        addIA64_32("ia64n");
    +
    +        // PowerPC mappings
    +        addPPC(PPC);
    +        addPPC("power");
    +        addPPC("powerpc");
    +        addPPC("power_pc");
    +        addPPC("power_rs");
    +
    +        // PowerPC 64bit mappings
    +        addPPC64(PPC64);
    +        addPPC64("power64");
    +        addPPC64("powerpc64");
    +        addPPC64("power_pc64");
    +        addPPC64("power_rs64");
    +    }
    +
    +    /**
    +     * Possibility to add {@link String}, representing the <code>System.getProperty("os.arch")</code>
    +     * to x86 architecture.
    +     *
    +     * @param value The {@link String} to add.
    +     */
    +    public static final void addX86(String value) {
    +        map.put(value, X86);
    +    }
    +
    +    /**
    +     * Checks if the current running JVM is a JVM for x86 architecture.
    +     * It returns <code>true</code>, if the os.arch System Property matches
the following {@link String}'s:
    +     * <ul>
    +     * <li>x86</li>
    +     * <li>i386</li>
    +     * <li>i486</li>
    +     * <li>i586</li>
    +     * <li>i686</li>
    +     * <li>pentium</li>
    +     * </ul>
    +     * <p>
    +     * It is possible to extend the {@link String}'s above using method {@link ArchUtils#addX86(String)}.
    +     * <p>
    --- End diff --
    
    
    
    Minor bug in Javadoc HTML. Extra opening paragraph. Can be fixed later too.



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message