Changed the parsing logic to refer to EAN-8 and EAN-13 as UPCs as well, so that the...
[zxing.git] / core / src / com / google / zxing / client / result / AbstractNDEFParsedResult.java
1 /*
2  * Copyright 2008 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package com.google.zxing.client.result;
18
19 import java.io.UnsupportedEncodingException;
20
21 /**
22  * <p>Superclass for classes encapsulating results in the NDEF format.
23  * See <a href="http://www.nfc-forum.org/specs/">http://www.nfc-forum.org/specs/</a>.</p>
24  *
25  * <p>This code supports a limited subset of NDEF messages, ones that are plausibly
26  * useful in 2D barcode formats. This generally includes 1-record messages, no chunking,
27  * "short record" syntax, no ID field.</p>
28  *
29  * @author srowen@google.com (Sean Owen)
30  */
31 abstract class AbstractNDEFParsedResult extends ParsedReaderResult {
32
33   AbstractNDEFParsedResult(ParsedReaderResultType type) {
34     super(type);
35   }
36
37   static String bytesToString(byte[] bytes, int offset, int length, String encoding) {
38     try {
39       return new String(bytes, offset, length, encoding);
40     } catch (UnsupportedEncodingException uee) {
41       // This should only be used when 'encoding' is an encoding that must necessarily
42       // be supported by the JVM, like UTF-8
43       throw new RuntimeException("Platform does not support required encoding: " + uee);
44     }
45   }
46
47 }