• Stars
    star
    609
  • Rank 73,614 (Top 2 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created almost 11 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Because pretty-printing text tables in Java should be easy.

Flip Tables

Because pretty-printing text tables in Java should be easy.

(โ•ฏยฐโ–กยฐ๏ผ‰โ•ฏ๏ธต โ”ปโ”โ”ป

Development on this project has basically stopped. You can find a more comprehensive and actively-developed text table library at https://github.com/JakeWharton/picnic.

Usage

A FlipTable requires headers and data in string form:

String[] headers = { "Test", "Header" };
String[][] data = {
    { "Foo", "Bar" },
    { "Kit", "Kat" },
};
System.out.println(FlipTable.of(headers, data));
โ•”โ•โ•โ•โ•โ•โ•โ•คโ•โ•โ•โ•โ•โ•โ•โ•โ•—
โ•‘ Test โ”‚ Header โ•‘
โ• โ•โ•โ•โ•โ•โ•โ•ชโ•โ•โ•โ•โ•โ•โ•โ•โ•ฃ
โ•‘ Foo  โ”‚ Bar    โ•‘
โ•Ÿโ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ข
โ•‘ Kit  โ”‚ Kat    โ•‘
โ•šโ•โ•โ•โ•โ•โ•โ•งโ•โ•โ•โ•โ•โ•โ•โ•โ•

They can be empty:

String[] headers = { "Test", "Header" };
String[][] data = {};
System.out.println(FlipTable.of(headers, data));
โ•”โ•โ•โ•โ•โ•โ•โ•คโ•โ•โ•โ•โ•โ•โ•โ•โ•—
โ•‘ Test โ”‚ Header โ•‘
โ• โ•โ•โ•โ•โ•โ•โ•งโ•โ•โ•โ•โ•โ•โ•โ•โ•ฃ
โ•‘ (empty)       โ•‘
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

Newlines are supported:

String[] headers = { "One Two\nThree", "Four" };
String[][] data = { { "Five", "Six\nSeven Eight" } };
System.out.println(FlipTable.of(headers, data));
โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•คโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
โ•‘ One Two โ”‚ Four        โ•‘
โ•‘ Three   โ”‚             โ•‘
โ• โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ชโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ฃ
โ•‘ Five    โ”‚ Six         โ•‘
โ•‘         โ”‚ Seven Eight โ•‘
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•งโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

Which means tables can be nested:

String[] innerHeaders = { "One", "Two" };
String[][] innerData = { { "1", "2" } };
String inner = FlipTable.of(innerHeaders, innerData);
String[] headers = { "Left", "Right" };
String[][] data = { { inner, inner } };
System.out.println(FlipTable.of(headers, data));
โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•คโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
โ•‘ Left          โ”‚ Right         โ•‘
โ• โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ชโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ฃ
โ•‘ โ•”โ•โ•โ•โ•โ•โ•คโ•โ•โ•โ•โ•โ•— โ”‚ โ•”โ•โ•โ•โ•โ•โ•คโ•โ•โ•โ•โ•โ•— โ•‘
โ•‘ โ•‘ One โ”‚ Two โ•‘ โ”‚ โ•‘ One โ”‚ Two โ•‘ โ•‘
โ•‘ โ• โ•โ•โ•โ•โ•โ•ชโ•โ•โ•โ•โ•โ•ฃ โ”‚ โ• โ•โ•โ•โ•โ•โ•ชโ•โ•โ•โ•โ•โ•ฃ โ•‘
โ•‘ โ•‘ 1   โ”‚ 2   โ•‘ โ”‚ โ•‘ 1   โ”‚ 2   โ•‘ โ•‘
โ•‘ โ•šโ•โ•โ•โ•โ•โ•งโ•โ•โ•โ•โ•โ• โ”‚ โ•šโ•โ•โ•โ•โ•โ•งโ•โ•โ•โ•โ•โ• โ•‘
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•งโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

Helper methods convert from types like lists:

List<Person> people = Arrays.asList(new Person("Foo", "Bar"), new Person("Kit", "Kat"));
System.out.println(FlipTableConverters.fromIterable(people, Person.class));
โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•คโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
โ•‘ FirstName โ”‚ LastName โ•‘
โ• โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ชโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ฃ
โ•‘ Foo       โ”‚ Bar      โ•‘
โ•Ÿโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ข
โ•‘ Kit       โ”‚ Kat      โ•‘
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•งโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

Or a database result:

ResultSet resultSet = statement.executeQuery("SELECT first_name, last_name FROM users");
System.out.println(FlipTableConverters.fromResultSet(resultSet));
โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•คโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
โ•‘ first_name โ”‚ last_name โ•‘
โ• โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ชโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ฃ
โ•‘ Jake       โ”‚ Wharton   โ•‘
โ•Ÿโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ข
โ•‘ Edward     โ”‚ Snowden   โ•‘
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•งโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

Arbitrary objects are also supported:

String[] headers = { "First Name", "Last Name", "Age", "Type" };
Object[][] data = {
    { "Big", "Bird", 16, PersonType.COSTUME },
    { "Joe", "Smith", 42, PersonType.HUMAN },
    { "Oscar", "Grouchant", 8, PersonType.PUPPET }
};
System.out.println(FlipTableConverters.fromObjects(headers, data));
โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•คโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•คโ•โ•โ•โ•โ•โ•คโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
โ•‘ First Name โ”‚ Last Name โ”‚ Age โ”‚ Type    โ•‘
โ• โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ชโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ชโ•โ•โ•โ•โ•โ•ชโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ฃ
โ•‘ Big        โ”‚ Bird      โ”‚ 16  โ”‚ COSTUME โ•‘
โ•Ÿโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ข
โ•‘ Joe        โ”‚ Smith     โ”‚ 42  โ”‚ HUMAN   โ•‘
โ•Ÿโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ข
โ•‘ Oscar      โ”‚ Grouchant โ”‚ 8   โ”‚ PUPPET  โ•‘
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•งโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•งโ•โ•โ•โ•โ•โ•งโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

Download

Download the latest jar or reference on Maven central as com.jakewharton.fliptables:fliptables:1.1.0.

Snapshots of the development version are available in Sonatype's snapshots repository.

License

Copyright 2014 Jake Wharton

Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

More Repositories

1

butterknife

Bind Android views and callbacks to fields and methods.
Java
25,610
star
2

timber

A logger with a small, extensible API which provides utility on top of Android's normal Log class.
Kotlin
10,406
star
3

ViewPagerIndicator

Paging indicator widgets compatible with the ViewPager from the Android Support Library and ActionBarSherlock.
Java
10,166
star
4

RxBinding

RxJava binding APIs for Android's UI widgets.
Kotlin
9,693
star
5

hugo

Annotation-triggered method call logging for your debug builds.
Java
7,892
star
6

ActionBarSherlock

[DEPRECATED] Action bar implementation which uses the native action bar on Android 4.0+ and a custom implementation on pre-4.0 through a single API and theme.
Java
7,130
star
7

DiskLruCache

Java implementation of a Disk-based LRU cache which specifically targets Android compatibility.
Java
5,766
star
8

u2020

A sample Android app which showcases advanced usage of Dagger among other open source libraries.
Java
5,682
star
9

pidcat

Colored logcat script which only shows log entries for a specific application package.
Python
4,723
star
10

NineOldAndroids

[DEPRECATED] Android library for using the Honeycomb animation API on all versions of the platform back to 1.0!
Java
4,508
star
11

ThreeTenABP

An adaptation of the JSR-310 backport for Android.
Java
3,540
star
12

scalpel

A surgical debugging tool to uncover the layers under your app.
Java
2,770
star
13

RxRelay

RxJava types that are both an Observable and a Consumer.
Java
2,475
star
14

Telecine

Record full-resolution video on your Android devices.
Java
2,472
star
15

kotterknife

View "injection" library for Android.
Kotlin
2,231
star
16

SdkSearch

An Android app and Chrome extension for searching the Android SDK documentation.
Kotlin
2,034
star
17

retrofit2-kotlin-coroutines-adapter

A Retrofit 2 adapter for Kotlin coroutine's Deferred type.
Kotlin
1,961
star
18

ProcessPhoenix

Process Phoenix facilitates restarting your application process.
Java
1,786
star
19

diffuse

Diffuse is a tool for diffing APKs, AABs, AARs, and JARs
Kotlin
1,779
star
20

mosaic

An experimental tool for building console UI in Kotlin using the Jetpack Compose compiler/runtime
Kotlin
1,500
star
21

sdk-manager-plugin

DEPRECATED Gradle plugin which downloads and manages your Android SDK.
Groovy
1,414
star
22

Android-DirectionalViewPager

[DEPRECATED] Implementation of the compatibility library ViewPager class that supports paging both vertically and horizontally.
Java
1,038
star
23

DrawerBehavior

A CoordinatorLayout behavior which mimics the functionality of DrawerLayout.
Java
894
star
24

adb-event-mirror

Mirror the touch/key/button events of one device onto one or more other devices in real-time
Kotlin
873
star
25

retrofit2-kotlinx-serialization-converter

A Retrofit 2 Converter.Factory for Kotlin serialization.
Kotlin
848
star
26

picnic

A Kotlin DSL and Java/Kotlin builder API for constructing HTML-like tables which can be rendered to text
Kotlin
838
star
27

retrofit2-rxjava2-adapter

An RxJava 2 CallAdapter.Factory implementation for Retrofit 2.
812
star
28

dependency-tree-diff

An intelligent diff tool for the output of Gradle's dependencies task
Kotlin
704
star
29

wormhole

A time-traveling bytecode rewriter which adds future APIs to android.jar
Kotlin
664
star
30

picasso2-okhttp3-downloader

A OkHttp 3 downloader implementation for Picasso 2.
Java
659
star
31

dagger-reflect

A reflection-based implementation of the Dagger dependency injection library for fast IDE builds.
Java
655
star
32

RxReplayingShare

An RxJava transformer which combines replay(1), publish(), and refCount() operators.
Java
629
star
33

SwipeToDismissNOA

Backport of Roman Nurik's "Swipe-to-dismiss" sample code using NineOldAndroids to work on all API levels.
Java
552
star
34

salvage

Generic view recycler and ViewPager PagerAdapter implementation.
Java
467
star
35

okhttp-idling-resource

An Espresso IdlingResource for OkHttp.
Java
459
star
36

madge

A debugging tool to determine whether or not your bitmaps are being drawn at their native resolution.
Java
392
star
37

Reagent

Experiments for future reactive libraries.
Kotlin
364
star
38

double-espresso

[DEPRECATED] A pure Gradle port of the Espresso testing utility for Android!
Java
340
star
39

docker-gphotos-sync

A Docker image for synchronizing your original-quality Google Photos
Shell
336
star
40

gradle-android-test-plugin

[DEPRECATED] A Gradle plugin which enables good 'ol fashioned unit tests for Android builds.
Java
328
star
41

nopen

An error-prone checker which requires that classes be final, abstract or annotated with @ Open.
Java
316
star
42

mkvdts2ac3

Bash script to convert DTS audio to AC3 within a matroska file.
Shell
314
star
43

RxWindowIfChanged

An RxJava 2 operator which splits an observable into windows using a key selector.
Java
307
star
44

OverloadReturn

Bytecode rewriter that creates overloads of methods which vary only by return type.
Kotlin
300
star
45

paraphrase

An experimental Gradle plugin which generates compile-safe format string builders.
Java
281
star
46

gitout

A command-line tool and Docker image to automatically backup Git repositories from GitHub or anywhere
Rust
259
star
47

dependency-watch

Script to wait for an artifact to appear in a Maven repository or to monitor coordinates for new versions.
Kotlin
240
star
48

confundus

Kotlin compiler plugin which brings Kotlin/JS's unsafeCast to Kotlin/JVM
Kotlin
236
star
49

AutoValueAnnotations

A standalone packaging of the annotations from Google's AutoValue library.
Shell
222
star
50

adjacent-fragment-pager-sample

Demonstrates how to manage two fragments where portrait displays them in a ViewPager and landscape displays them side-by-side.
Java
214
star
51

retrofit1-okhttp3-client

A OkHttp 3 client implementation for Retrofit 1.
Java
194
star
52

retrofit2-reactor-adapter

A Project Reactor CallAdapter.Factory implementation for Retrofit 2.
Java
183
star
53

jardiff

A Python script which quickly creates diffs of the public API between two JAR files
Python
183
star
54

sdk-artifact-sync

A script which synchronizes all of the artifacts in your local Android SDK to a remote Maven artifact host.
Python
182
star
55

dodo

Synchronize your Twitter timeline to a local database for archival and search
Kotlin
182
star
56

shimo

Shimo is an adapter for Moshi which randomizes the order of keys when serializing and deserializing
Java
178
star
57

cite

A Kotlin compiler plugin for embedding information about the file being compiled
Kotlin
178
star
58

PxJava

An experiment which interprets RxJava as an entirely pull-based system written in Kotlin.
Kotlin
173
star
59

HanselAndGretel

Android library providing bread crumbs to the support library fragments.
Java
163
star
60

byteunits

Utility classes for converting between granularities of SI and IEC byte units and bit units.
Kotlin
159
star
61

agp-java-support

Tracking your ability to use new Java language features and APIs in an Android app
Java
151
star
62

crossword

A 2D canvas for rendering text, usually for console applications.
Kotlin
142
star
63

NotificationCompat2

[DEPRECATED] Please use the support library r11 or newer for these features.
Java
132
star
64

dalvik-dx

A standalone packaging of AOSP's platform/dalvik dx library.
Shell
125
star
65

NormallyClosed

Open and close your garage door with a Raspberry Pi
Rust
117
star
66

jakewharton.com

Personal website and blog.
HTML
117
star
67

plex-orphaned-files

Find files in your Plex libraries which are not indexed
Kotlin
114
star
68

AndroidDesignKeynoteTheme

A simple theme for Apple Keynote which adheres to the clean look of the Android Design website.
92
star
69

py-videodownloader

[DEPRECATED] Python module and script for downloading video source files from the major online streaming sites (YouTube, Vimeo, etc.)
Python
90
star
70

jax-rs-moshi

A JAX-RS message body reader/writer and parameter converter which uses Moshi to handle JSON
Java
89
star
71

ActionBarSherlock-Plugin-Maps

[DEPRECATED] Plugin for ActionBarSherlock which provides a base activity that can be used for adding a MapView to your action bar-enabled layouts.
Java
89
star
72

dockerfile-shebang

Treat your Dockerfiles as self-contained, editable scripts
Shell
86
star
73

singular-solution

Keep your Twitter follower count at zero by blocking and then quickly unblocking any new followers
Kotlin
86
star
74

ActivityCompat2

[DEPRECATED] Please use the support library r13 or newer for these features.
Java
76
star
75

docker-mbsync

A Docker container which runs the mbsync tool automatically to synchronize your email
Shell
74
star
76

RxJava2-Java6

An automated backport of RxJava 2 to support Java 6.
Java
73
star
77

PosterBox

Rotating display of Movie and TV posters
Kotlin
72
star
78

jax-rs-kotlinx-serialization

A JAX-RS message body reader/writer and parameter converter which uses Kotlinx Serialization
Kotlin
70
star
79

gradle-like-bazel

A demo showing that you can (probably) structure Gradle projects like you would Bazel
Java
67
star
80

gms-mvn-install

[DEPRECATED] Installs Google Play Services to your local Maven repo or deploys it to a remote repo.
Shell
64
star
81

SMSBarrage

An Android application which allows you send mass repeated SMS messages to any number of contacts.
Java
63
star
82

platform-collections

Kotlin multiplatform collections which use platform-optimized storage
Kotlin
63
star
83

SMSMorse

An Android service that vibrates incoming SMS messages in Morse code.
Java
63
star
84

uniqtoo

A version of `sort | uniq -c` with output that updates in real-time as each line is parsed
Rust
62
star
85

snooker

[DEPRECATED] Please use the support library v20.0.0 or newer for these features.
Java
62
star
86

rebaseandsqua.sh

Utility and website which makes it easy to rebase and squash your branches.
56
star
87

asciinema-vsync

Batch the commands inside an Asciinema JSON file to reduce flickering
Kotlin
56
star
88

ActionBarSherlock-Gradle-Sample

[DEPRECATED] A tiny sample project that uses ActionBarSherlock via Gradle
Groovy
52
star
89

trakt-java

A Java wrapper around the Trakt RESTful API and a simple DSL for easy interaction.
Java
48
star
90

google-maven-exploder

Kotlin
48
star
91

resourcefs

A minimal FileSystem which exposes resources inside the current class loader.
Java
45
star
92

TronWallpaper

An Android live wallpaper which races lightcycles around your icons against Master Control.
Java
45
star
93

dumbo

Import a Twitter archive into a Mastodon database.
Kotlin
40
star
94

ui-spy

Monitor products on the Ubiquiti Store and receive notifications when their availability changes.
Kotlin
40
star
95

twirl-maven-plugin

A Maven plugin which compiles Twirl templates into Scala source files.
Java
40
star
96

uglify-js-middleware

Connect middleware which will automatically uglify your JS files.
JavaScript
38
star
97

SnakeWallpaper

An Android live wallpaper which plays the classic game of snake around your icons. Available on the Android Market.
Java
36
star
98

libcore-dex

A standalone packaging of AOSP's platform/libcore dex library.
Shell
32
star
99

tools-apksig

A standalone packaging of AOSP's platform/tools/apksig library.
28
star
100

WritingAgileAPKs

AnDevCon III Presentation: Writing Agile APKs
Java
26
star