org.apache.poi.hpsf.ClassID Maven / Gradle / Ivy
Show all versions of apache-poi Show documentation
/* ====================================================================
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.poi.hpsf;
import java.util.Arrays;
import org.apache.poi.util.HexDump;
/**
* Represents a class ID (16 bytes). Unlike other little-endian
* type the {@link ClassID} is not just 16 bytes stored in the wrong
* order. Instead, it is a double word (4 bytes) followed by two
* words (2 bytes each) followed by 8 bytes.
*
* The ClassID (or CLSID) is a UUID - see RFC 4122
*/
public class ClassID {
/** @deprecated use enum {@link ClassIDPredefined} */ @Deprecated
public static final ClassID OLE10_PACKAGE = ClassIDPredefined.OLE_V1_PACKAGE.getClassID();
/** @deprecated use enum {@link ClassIDPredefined} */ @Deprecated
public static final ClassID PPT_SHOW = ClassIDPredefined.POWERPOINT_V8.getClassID();
/** @deprecated use enum {@link ClassIDPredefined} */ @Deprecated
public static final ClassID XLS_WORKBOOK = ClassIDPredefined.EXCEL_V7_WORKBOOK.getClassID();
/** @deprecated use enum {@link ClassIDPredefined} */ @Deprecated
public static final ClassID TXT_ONLY = ClassIDPredefined.TXT_ONLY.getClassID();
/** @deprecated use enum {@link ClassIDPredefined} */ @Deprecated
public static final ClassID EXCEL_V3 = ClassIDPredefined.EXCEL_V3.getClassID();
/** @deprecated use enum {@link ClassIDPredefined} */ @Deprecated
public static final ClassID EXCEL_V3_CHART = ClassIDPredefined.EXCEL_V3_CHART.getClassID();
/** @deprecated use enum {@link ClassIDPredefined} */ @Deprecated
public static final ClassID EXCEL_V3_MACRO = ClassIDPredefined.EXCEL_V3_MACRO.getClassID();
/** @deprecated use enum {@link ClassIDPredefined} */ @Deprecated
public static final ClassID EXCEL95 = ClassIDPredefined.EXCEL_V7.getClassID();
/** @deprecated use enum {@link ClassIDPredefined} */ @Deprecated
public static final ClassID EXCEL95_CHART = ClassIDPredefined.EXCEL_V7_CHART.getClassID();
/** @deprecated use enum {@link ClassIDPredefined} */ @Deprecated
public static final ClassID EXCEL97 = ClassIDPredefined.EXCEL_V8.getClassID();
/** @deprecated use enum {@link ClassIDPredefined} */ @Deprecated
public static final ClassID EXCEL97_CHART = ClassIDPredefined.EXCEL_V8_CHART.getClassID();
/** @deprecated use enum {@link ClassIDPredefined} */ @Deprecated
public static final ClassID EXCEL2003 = ClassIDPredefined.EXCEL_V11.getClassID();
/** @deprecated use enum {@link ClassIDPredefined} */ @Deprecated
public static final ClassID EXCEL2007 = ClassIDPredefined.EXCEL_V12.getClassID();
/** @deprecated use enum {@link ClassIDPredefined} */ @Deprecated
public static final ClassID EXCEL2007_MACRO= ClassIDPredefined.EXCEL_V12_MACRO.getClassID();
/** @deprecated use enum {@link ClassIDPredefined} */ @Deprecated
public static final ClassID EXCEL2007_XLSB = ClassIDPredefined.EXCEL_V12_XLSB.getClassID();
/** @deprecated use enum {@link ClassIDPredefined} */ @Deprecated
public static final ClassID EXCEL2010 = ClassIDPredefined.EXCEL_V14.getClassID();
/** @deprecated use enum {@link ClassIDPredefined} */ @Deprecated
public static final ClassID EXCEL2010_CHART= ClassIDPredefined.EXCEL_V14_CHART.getClassID();
/** @deprecated use enum {@link ClassIDPredefined} */ @Deprecated
public static final ClassID EXCEL2010_ODS = ClassIDPredefined.EXCEL_V14_ODS.getClassID();
/** @deprecated use enum {@link ClassIDPredefined} */ @Deprecated
public static final ClassID WORD95 = ClassIDPredefined.WORD_V7.getClassID();
/** @deprecated use enum {@link ClassIDPredefined} */ @Deprecated
public static final ClassID WORD97 = ClassIDPredefined.WORD_V8.getClassID();
/** @deprecated use enum {@link ClassIDPredefined} */ @Deprecated
public static final ClassID WORD2007 = ClassIDPredefined.WORD_V12.getClassID();
/** @deprecated use enum {@link ClassIDPredefined} */ @Deprecated
public static final ClassID WORD2007_MACRO = ClassIDPredefined.WORD_V12_MACRO.getClassID();
/** @deprecated use enum {@link ClassIDPredefined} */ @Deprecated
public static final ClassID POWERPOINT97 = ClassIDPredefined.POWERPOINT_V8.getClassID();
/** @deprecated use enum {@link ClassIDPredefined} */ @Deprecated
public static final ClassID POWERPOINT95 = ClassIDPredefined.POWERPOINT_V7.getClassID();
/** @deprecated use enum {@link ClassIDPredefined} */ @Deprecated
public static final ClassID POWERPOINT2007 = ClassIDPredefined.POWERPOINT_V12.getClassID();
/** @deprecated use enum {@link ClassIDPredefined} */ @Deprecated
public static final ClassID POWERPOINT2007_MACRO = ClassIDPredefined.POWERPOINT_V12_MACRO.getClassID();
/** @deprecated use enum {@link ClassIDPredefined} */ @Deprecated
public static final ClassID EQUATION30 = ClassIDPredefined.EQUATION_V3.getClassID();
/** The number of bytes occupied by this object in the byte stream. */
public static final int LENGTH = 16;
/**
* The bytes making out the class ID in correct order, i.e. big-endian.
*/
private final byte[] bytes = new byte[LENGTH];
/**
* Creates a {@link ClassID} and reads its value from a byte array.
*
* @param src The byte array to read from.
* @param offset The offset of the first byte to read.
*/
public ClassID(final byte[] src, final int offset) {
read(src, offset);
}
/**
* Creates a {@link ClassID} and initializes its value with 0x00 bytes.
*/
public ClassID() {
Arrays.fill(bytes, (byte)0);
}
/**
* Creates a {@link ClassID} from a human-readable representation of the Class ID in standard
* format {@code "{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}"}.
*
* @param externalForm representation of the Class ID represented by this object.
*/
public ClassID(String externalForm) {
String clsStr = externalForm.replaceAll("[{}-]", "");
for (int i=0; i