jdk/src/java.base/share/classes/jdk/internal/jimage/Resource.java
author chegar
Wed, 03 Dec 2014 14:22:58 +0000
changeset 27565 729f9700483a
permissions -rw-r--r--
8049367: Modular Run-Time Images Reviewed-by: chegar, dfuchs, ihse, joehw, mullan, psandoz, wetmore Contributed-by: alan.bateman@oracle.com, alex.buckley@oracle.com, bradford.wetmore@oracle.com, chris.hegarty@oracle.com, erik.joelsson@oracle.com, james.laskey@oracle.com, jonathan.gibbons@oracle.com, karen.kinnear@oracle.com, magnus.ihse.bursie@oracle.com, mandy.chung@oracle.com, mark.reinhold@oracle.com, paul.sandoz@oracle.com, sundararajan.athijegannathan@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
     1
/*
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
     2
 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
     4
 *
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    10
 *
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    15
 * accompanied this code).
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    16
 *
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    20
 *
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    23
 * questions.
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    24
 */
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    25
package jdk.internal.jimage;
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    26
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    27
/**
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    28
 * Resource is a class or resource file.
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    29
 */
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    30
public class Resource {
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    31
    private final String name;
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    32
    private final long size;
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    33
    private final long csize;
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    34
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    35
    public Resource(String name, long size, long csize) {
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    36
        this.name = name;
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    37
        this.size = size;
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    38
        this.csize = csize;
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    39
    }
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    40
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    41
    /**
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    42
     * Returns the name of this entry.
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    43
     */
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    44
    public String name() {
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    45
        return name;
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    46
    }
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    47
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    48
    /**
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    49
     * Returns the number of uncompressed bytes for this entry.
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    50
     */
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    51
    public long size() {
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    52
        return size;
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    53
    }
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    54
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    55
    /**
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    56
     * Returns the number of compressed bytes for this entry; 0 if
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    57
     * uncompressed.
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    58
     */
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    59
    public long csize() {
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    60
        return csize;
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    61
    }
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    62
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    63
    @Override
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    64
    public String toString() {
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    65
        return String.format("%s uncompressed size %d compressed size %d", name, size, csize);
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    66
    }
729f9700483a 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    67
}