GithubHelp home page GithubHelp logo

jalphabet's Introduction

The Java Alphabet Library (JAL)#

JAL is an utility library intended to help people to create manipulate custom Alphabets. This is particularly useful, for example, for identification code generators.

This library conveniently treats alphabets as a Mathematical Numeral System. The goal is to be able to easily convert between alphabets and to make arithmetic operations on your custom alphabets.

You can easily create your custom Alphabets by extending the Alphabet abstract class, but JAL has some common alphabets previously packaged:

  • Binary
  • Octal
  • Decimal
  • Hexadecimal
  • Uppercase latin alphabet
  • Lowercase latin alphabet
  • ASCII
  • Base64
  • Code39
  • DNA

Example

Just a simple example of conversion between alphabets. Sugar syntax for ya!

Binary b = new Binary();
Decimal d = new Decimal();

Word<Decimal> w1 = d.createWord("10"); // Use the alphabet to create valid words
Word<Binary> w2 = w1.convert().to(b); // Pass in an Alphabet implementation
Word<Hexadecimal> w3 = w1.convert().to(Hexadecimal.class); // Or just an Alphabet class. JAL instantiates the Alphabet for you!

System.out.println(w1+" "+w2+" "+w3);
// Prints "10 1010 A"

Imagine you want to implement a POS software. You may want to get the corresponding Code39 barcode string from the automatically generated database id.

Long idFromDatabase = 54341L;

Code39 c = new Code39();
Word<Code39> code = c.parseLong(idFromDatabase);

System.out.println(code);
// prints "S31"

JAL supports exclusions. Imagine that you don't want to consider the whole set of an Alphabet. You can create an Alphabet, providing the characters you want to exclude.

// Create a Code39 alphabet without special characters (for readability purposes, for example)
Code39 c = new Code39("* -$%./+");
// Use alphabet normally

TODO

  • add support for arithmetic operations (It would be neat to be able to sum words)
  • add support for the creation of "composite alphabets" through concatenation. For example, an Alphabet defined by Decimal+"/"+Code39. You could have a graph of alphabets, how awesome is that?
  • unit testing
  • more alphabets
  • complete javadoc
  • maybe the algorythms' performance can be improved

jalphabet's People

Contributors

miguelcobain avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

yuxiaohui78

jalphabet's Issues

Next Letter?

Is there a way to ask the Alphabet, I'm at Letter 'D', give me the next letter: 'E'?

Or, if I made a custom alphabet of '0123456789abcdefghijklmnopqrstuvwxyz', could I keep calling a getNext() type function to go from 009 -> 00a, and ultimately, 00z to 010?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.