blob: 4b4b16d4df622e59d87c0e2260be282ddec4f557 [file] [log] [blame]
Michael Wright10ca09d2012-05-17 17:40:58 -07001/*
2 * Copyright (C) 2012 The Android Open Source Project
3 *
4 * Licensed under the Eclipse Public License, Version 1.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.eclipse.org/org/documents/epl-v10.php
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
17package com.android.validator;
18
19import java.io.File;
20import java.io.FileInputStream;
21import java.io.FileNotFoundException;
22
23import com.android.dvlib.DeviceSchema;
24
25public class DeviceValidator {
26
27 public static void main(String[] args) {
28 if (args.length == 0){
29 printHelp();
30 System.exit(1);
31 }
32 int ret = 0;
33 for (String a : args) {
34 File f = new File(a);
35 try {
36 if (!DeviceSchema.validate(new FileInputStream(f), System.err, f.getParentFile())) {
37 System.err.println("Error validating " + f.getAbsolutePath());
38 System.out.println();
39 ret = 1;
40 } else {
41 System.out.println(f.getAbsolutePath() + " validated successfully.");
42 }
43 } catch (FileNotFoundException e) {
44 System.err.println("File not found: " + a);
45 ret = 1;
46 }
47 }
48 System.exit(ret);
49 }
50
51 private static void printHelp() {
52 System.err.printf("Usage: device_validator [files to validate]...\n");
53 }
54
55}