Feld implements Comparable<Feld>, Cloneable { public final void setInhalt(final String s) { int anzahlBytes = this.getAnzahlBytes(); if (s.length() > anzahlBytes) { throw new IllegalArgumentException("Feld " + this.getBezeichner() + ": Parameter \"" + s + "\" ist laenger als " + anzahlBytes + " Zeichen!"); } this.resetInhalt(); switch (this.ausrichtung) { case LEFT: this.inhalt.replace(0, s.length(), s); break; case RIGHT: int l = s.length(); int start = anzahlBytes - l; this.inhalt.replace(start, start + l, s); break; default: throw new IllegalStateException("object was not properly initialized"); } } Feld();  Feld(final Enum feldX);  Feld(final Enum feldX, final FeldInfo info);  Feld(final String name, final String s, final Align alignment);  Feld(final Bezeichner name, final int start, final String s, final Align alignment);  Feld(final Bezeichner bezeichner, final int length, final int start, final Align alignment);  Feld(final String name, final int length, final int start, final char c, final Align alignment);  Feld(final String name, final int length, final int start, final String s, final Align alignment);  Feld(final String name, final int start, final char c);  Feld(final int start, final String s, final Align alignment);  Feld(final int length, final Align alignment);  Feld(final int length, final int start, final Align alignment);  Feld(final Feld other); static Feld createFeld(final Enum feldX, final FeldInfo info); String getBezeichnung(); Bezeichner getBezeichner(); final void setInhalt(final String s); void setInhalt(final int n); void setInhalt(final char c); void setInhalt(final char c, final int i); String getInhalt(); void resetInhalt(); void setAnzahlBytes(final int n); final int getAnzahlBytes(); final int getByteAdresse(); final int getEndAdresse(); final boolean overlapsWith(final Feld other); final void write(final Writer writer); boolean isEmpty(); boolean hasValue(); boolean isValid(); boolean isInvalid(); List<ConstraintViolation> validate(); String format(); @Override String toString(); @Override final boolean equals(final Object obj); @Override final int hashCode(); @Override final int compareTo(final Feld other); static Bezeichner getAsBezeichner(final Enum feldX); static String getAsBezeichnung(final Enum feldX); static String toBezeichnung(final Enum name); @SuppressWarnings("squid:S2975") @Override Object clone(); static final Feld NULL_FELD; }
@Test public void testSetInhalt() { Feld linksbuendig = new Feld("f1", "hello", Align.LEFT); linksbuendig.setInhalt("abc"); assertEquals("abc ", linksbuendig.getInhalt()); Feld rechtsbuendig = new Feld("f2", "world", Align.RIGHT); rechtsbuendig.setInhalt("hi"); assertEquals(" hi", rechtsbuendig.getInhalt()); }