Skip to content

Commit

Permalink
first commit for the Json loader, test broken for hasanth
Browse files Browse the repository at this point in the history
  • Loading branch information
torifat committed Nov 1, 2011
1 parent 8f9c078 commit 29396e5
Show file tree
Hide file tree
Showing 4 changed files with 2,766 additions and 1 deletion.
Binary file added lib/gson-1.7.1.jar
Binary file not shown.
57 changes: 57 additions & 0 deletions src/com/omicronlab/avro/PhoneticJsonLoader.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
=============================================================================
*****************************************************************************
The contents of this file are subject to the Mozilla Public License
Version 1.1 (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.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS"
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
License for the specific language governing rights and limitations
under the License.
The Original Code is JAvroPhonetic
The Initial Developer of the Original Code is
Rifat Nabi <[email protected]>
Copyright (C) OmicronLab (http://www.omicronlab.com). All Rights Reserved.
Contributor(s): ______________________________________.
*****************************************************************************
=============================================================================
*/

package com.omicronlab.avro;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.net.MalformedURLException;
import java.net.URL;

import com.google.gson.Gson;
import com.google.gson.JsonIOException;
import com.google.gson.JsonSyntaxException;
import com.omicronlab.avro.phonetic.*;

public class PhoneticJsonLoader implements PhoneticLoader {

private URL url = null;

public PhoneticJsonLoader() {
this.url = Data.class.getResource("phonetic.json");
}

public PhoneticJsonLoader(String path) throws MalformedURLException {
this.url = new URL(path);
}

public Data getData() throws JsonSyntaxException, JsonIOException, FileNotFoundException {
Gson gson = new Gson();
Data data = (Data) gson.fromJson(new FileReader(this.url.getFile()), Data.class);
return data;
}
}
Loading

0 comments on commit 29396e5

Please sign in to comment.