XTML


Source link: https://github.com/metalurgus/XTML

XTML

GSON analog for serialization/deserialization of Java objects into HTML code and back

Work in progress, a basic data is supported so far.

For the sample see TestClass.java

Contribution is welcome!

How to use?

Add dependency ( XTML is available through jitpack.io):

repositories {

  maven {
 url "https://jitpack.io" 
}
 
}
 dependencies {

 compile 'com.github.metalurgus:XTML:0.0.2' 
}
 

Sample HTML to deserialize:

 "<div test1 = '111'>" +
  "<div id='testId' test2='222'/>" +
  "<div test2='333'/>" +
  "<div id='testId2'>" +

"<div test2='333'/>" +

"<div test2='333'/>" +

"<div test2='333'/>" +
  "</div>" +
  "<div id='testId3'>" +

"<div test2='333'>222.22</div>" +

"<div test2='333'>333.33</div>" +

"<div test2='333'>444.44</div>" +
  "</div>" + "</div>";

Annotate your model class with @XTMLClass annotation:

@XTMLClass public class TestClass {
 ... 
}

Annotate every field to be deserialized with @XTMLMapping annotation:

@XTMLMapping(type = XTMLMapping.Type.ATTRIBUTE, name = "test1") public int field1; //Non-siple data types are supported as well. @XTMLMapping(type = XTMLMapping.Type.TAG, select = "#testId") public InnerTestClass innerTestClass1; @XTMLMapping(type = XTMLMapping.Type.TAG, index = 1) public InnerTestClass innerTestClass2; //as well as collections @XTMLMapping(type = XTMLMapping.Type.COLLECTION, select = "#testId2 > *") public List<InnerTestClass> innerTestClassList; @XTMLMapping(type = XTMLMapping.Type.COLLECTION, select = "#testId3 > *") public List<Double> integerList;  @XTMLClass class InnerTestClass {

  @XTMLMapping(type = XTMLMapping.Type.ATTRIBUTE, name = "test2")
  public String field3; 
}

Call XTML.fromHTML():

TestClass testClass = XTML.fromHTML(Jsoup.parse(TestClass.HTML).body().child(0), TestClass.class);

type attribute: @XTMLMapping.Type.ATTRIBUTE will pick an attribute lavue into the annitated field @XTMLMapping.Type.TAG will parse an HTML tag into annotated field, doing it recursively, if field class is annotated with @XTMLClass, and trying to assign the attribute text to the field if not annotated. @XTMLMapping.Type.COLLECTION will parse a list of elements, provided with a select attribute.

name attribute - specifies HTML attribute name to be parsed with @XTMLMapping.Type.ATTRIBUTE annotation, or an element with specified name( <div name='someName'/>)

id attribute - specifies id of an element to be parsed into the annotated field

index attribute - specifies an index of the element inside a list, provided by select attribute, or an index of a child element to be parsed into an annotated field

select attribute - a CSS selector to select a list of nodes for collection, or a single node (using index, or picking `st element) for parsing.

Resources

VectAlign (a.k.a. VectorDrawableAlign) is a command line tool which automagically aligns two VectorDrawable "pathData" strings in order to allow morphing animations between them through an AnimatedVectorDrawable.

StringPicker is a library to provides a custom view and dialog fragment to pick string value.

This app is designed to demonstrate the various components of the Android Support libraries, in particular, showing how to implement Material design into your app, using these controls.

A motion-driven animation framework for Android.

Backboard is a framework on top of rebound that makes it easier to use by coupling it to views and motions.

Fully customizable widget for representing data like hashtags collection and similar.

This is example of application built with VIPER architecture.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes