-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8fd9a96
commit 2a4f96b
Showing
11 changed files
with
245 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
Source/Json/src/ca/uqac/lif/azrael/json/EnumPrintHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
Azrael, a serializer for Java objects | ||
Copyright (C) 2016-2019 Sylvain Hallé | ||
Laboratoire d'informatique formelle | ||
Université du Québec à Chicoutimi, Canada | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Lesser General Public License as published | ||
by the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Lesser General Public License for more details. | ||
You should have received a copy of the GNU Lesser General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package ca.uqac.lif.azrael.json; | ||
|
||
import ca.uqac.lif.azrael.PrintException; | ||
import ca.uqac.lif.json.JsonElement; | ||
|
||
public class EnumPrintHandler extends JsonPrintHandler | ||
{ | ||
public EnumPrintHandler(JsonPrinter printer) | ||
{ | ||
super(printer); | ||
} | ||
|
||
@Override | ||
public boolean canHandle(Object o) | ||
{ | ||
return o.getClass().isEnum(); | ||
} | ||
|
||
@Override | ||
public JsonElement handle(Object o) throws PrintException | ||
{ | ||
return m_printer.wrap(o, m_printer.print(o.toString())); | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
Source/Json/src/ca/uqac/lif/azrael/json/EnumReadHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
Azrael, a serializer for Java objects | ||
Copyright (C) 2016-2019 Sylvain Hallé | ||
Laboratoire d'informatique formelle | ||
Université du Québec à Chicoutimi, Canada | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Lesser General Public License as published | ||
by the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Lesser General Public License for more details. | ||
You should have received a copy of the GNU Lesser General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package ca.uqac.lif.azrael.json; | ||
|
||
import ca.uqac.lif.azrael.ReadException; | ||
import ca.uqac.lif.json.JsonElement; | ||
import ca.uqac.lif.json.JsonString; | ||
|
||
public class EnumReadHandler extends JsonReadHandler | ||
{ | ||
|
||
public EnumReadHandler(JsonReader reader) | ||
{ | ||
super(reader); | ||
} | ||
|
||
@Override | ||
public boolean canHandle(JsonElement o) throws ReadException | ||
{ | ||
if (!m_reader.isWrapped(o)) | ||
{ | ||
return false; | ||
} | ||
Class<?> clazz = m_reader.unwrapType(o); | ||
return clazz.isEnum(); | ||
} | ||
|
||
@Override | ||
public String handle(JsonElement o) throws ReadException | ||
{ | ||
//Class<?> clazz = m_reader.unwrapType(o); | ||
JsonString s = (JsonString) m_reader.unwrapContents(o); | ||
return s.stringValue(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
Source/Xml/src/ca/uqac/lif/azrael/xml/EnumPrintHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
Azrael, a serializer for Java objects | ||
Copyright (C) 2016-2019 Sylvain Hallé | ||
Laboratoire d'informatique formelle | ||
Université du Québec à Chicoutimi, Canada | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Lesser General Public License as published | ||
by the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Lesser General Public License for more details. | ||
You should have received a copy of the GNU Lesser General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package ca.uqac.lif.azrael.xml; | ||
|
||
import ca.uqac.lif.azrael.PrintException; | ||
import ca.uqac.lif.xml.XmlElement; | ||
|
||
public class EnumPrintHandler extends XmlPrintHandler | ||
{ | ||
public EnumPrintHandler(XmlPrinter printer) | ||
{ | ||
super(printer); | ||
} | ||
|
||
@Override | ||
public boolean canHandle(Object o) | ||
{ | ||
return o.getClass().isEnum(); | ||
} | ||
|
||
@Override | ||
public XmlElement handle(Object o) throws PrintException | ||
{ | ||
return m_printer.wrap(o, m_printer.print(o.toString())); | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
Source/Xml/src/ca/uqac/lif/azrael/xml/EnumReadHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
Azrael, a serializer for Java objects | ||
Copyright (C) 2016-2019 Sylvain Hallé | ||
Laboratoire d'informatique formelle | ||
Université du Québec à Chicoutimi, Canada | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Lesser General Public License as published | ||
by the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Lesser General Public License for more details. | ||
You should have received a copy of the GNU Lesser General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package ca.uqac.lif.azrael.xml; | ||
|
||
import ca.uqac.lif.azrael.ReadException; | ||
import ca.uqac.lif.xml.XmlElement; | ||
|
||
public class EnumReadHandler extends XmlReadHandler | ||
{ | ||
|
||
public EnumReadHandler(XmlReader reader) | ||
{ | ||
super(reader); | ||
} | ||
|
||
@Override | ||
public boolean canHandle(XmlElement o) throws ReadException | ||
{ | ||
if (!m_reader.isWrapped(o)) | ||
{ | ||
return false; | ||
} | ||
Class<?> clazz = m_reader.unwrapType(o); | ||
return clazz.isEnum(); | ||
} | ||
|
||
@Override | ||
public String handle(XmlElement o) throws ReadException | ||
{ | ||
String s = (String) m_reader.unwrapContents(o); | ||
return s; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package ca.uqac.lif.azrael.xml; | ||
|
||
import ca.uqac.lif.azrael.ReadHandler; | ||
import ca.uqac.lif.xml.XmlElement; | ||
|
||
public abstract class XmlReadHandler implements ReadHandler<XmlElement> | ||
{ | ||
protected XmlReader m_reader; | ||
|
||
public XmlReadHandler(XmlReader printer) | ||
{ | ||
super(); | ||
m_reader = printer; | ||
} | ||
} |