#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Dedicated to all the losers (including me) who have to write Java
# code and refuse to use an IDE - the bean generator.
#

"""Java Bean generator

J.Lo steht für "Java Looser".
"""

import re
import sys

s = re.compile(r'^([ \t]+)private[ ]+([A-Za-z_][A-Za-z0-9_]*)[ ]+([A-Za-z_][A-Za-z0-9_]*);')

start_marker = re.compile(r'^/* {BEANGEN')
end_marker = re.compile(r'^/* NEGNAEB}')

cached = []
ignore = False

for line in sys.stdin:
    if start_marker.match(line):
        ignore = True
    if not ignore:
        sys.stdout.write(line)
    if ignore and end_marker.match(line):
        ignore = False
    if line.strip() == '' and len(cached):
        print '/* {BEANGEN */'
        sys.stdout.write('\n'.join(cached))
        print '\n/* NEGNAEB} */'
        cached = []
    m = s.match(line)
    if m is not None:
        (whitespace, t, id) = m.groups()
        idc = id[0].upper() + id[1:]
        cached.append(whitespace+'public '+t+' get'+idc+'() { return '+id+'; }')
        cached.append(whitespace+'public void set'+idc+'('+t+' '+id+') { this.'+id+' = '+id+'; }')


