Michael Wright | 10ca09d | 2012-05-17 17:40:58 -0700 | [diff] [blame^] | 1 | /* |
| 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 | |
| 17 | package com.android.validator; |
| 18 | |
| 19 | import java.io.File; |
| 20 | import java.io.FileInputStream; |
| 21 | import java.io.FileNotFoundException; |
| 22 | |
| 23 | import com.android.dvlib.DeviceSchema; |
| 24 | |
| 25 | public 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 | } |