1package org.bouncycastle.asn1;
2
3public class ASN1ObjectIdentifier
4    extends DERObjectIdentifier
5{
6    public ASN1ObjectIdentifier(String identifier)
7    {
8        super(identifier);
9    }
10
11    ASN1ObjectIdentifier(byte[] bytes)
12    {
13        super(bytes);
14    }
15
16    ASN1ObjectIdentifier(ASN1ObjectIdentifier oid, String branch)
17    {
18        super(oid, branch);
19    }
20
21    /**
22     * Return an OID that creates a branch under the current one.
23     *
24     * @param branchID node numbers for the new branch.
25     * @return the OID for the new created branch.
26     */
27    public ASN1ObjectIdentifier branch(String branchID)
28    {
29        return new ASN1ObjectIdentifier(this, branchID);
30    }
31
32    /**
33     * Return  true if this oid is an extension of the passed in branch, stem.
34     * @param stem the arc or branch that is a possible parent.
35     * @return  true if the branch is on the passed in stem, false otherwise.
36     */
37    public boolean on(ASN1ObjectIdentifier stem)
38    {
39        String id = getId(), stemId = stem.getId();
40        return id.length() > stemId.length() && id.charAt(stemId.length()) == '.' && id.startsWith(stemId);
41    }
42}
43