Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/efrain-svg/Potes_Freddy_ProgInterfacesG_U3/llms.txt

Use this file to discover all available pages before exploring further.

Contact Management App stores every contact as a persona object in memory and persists the contact list as a semicolon-delimited CSV file on disk. This page documents the persona entity—its fields, constructors, and serialization methods—and the personaDAO data-access object that manages the CSV file.

persona fields

FieldTypeRequiredDefaultNotes
nombreStringYes""Contact’s full name. Trimmed and null-guarded by limpiar().
telefonoStringYes""Phone number stored as a string to preserve leading zeros and formatting.
emailStringYes""Email address.
categoriaStringYes""One of the three category codes: FAMILY, FRIENDS, or WORK.
favoritobooleanNofalseWhether the contact is marked as a favourite.
fechaRegistroLocalDateNotodayDate the contact was first added. Set to LocalDate.now() when not supplied.
All string fields pass through the private limpiar(String) method, which trims whitespace and converts null to an empty string. This prevents malformed CSV lines caused by accidental null values.

Constructors

persona.java
// Default constructor — all strings empty, favorito=false, fechaRegistro=today
persona()

// Standard constructor — fechaRegistro set to LocalDate.now()
persona(String nombre, String telefono, String email,
        String categoria, boolean favorito)

// Full constructor — explicit fechaRegistro (used when loading from CSV)
persona(String nombre, String telefono, String email,
        String categoria, boolean favorito, LocalDate fechaRegistro)
The full constructor is used exclusively by personaDAO.leerArchivo() when reconstructing contacts from the 6-column CSV format. The standard constructor is used when the user creates a new contact through the UI.

Serialization methods

datosContacto() — CSV serialization

Returns a semicolon-delimited string suitable for appending to the CSV file:
persona.java
public String datosContacto() {
    return String.format("%s;%s;%s;%s;%s;%s",
        nombre, telefono, email, categoria, favorito, fechaRegistro);
}
Output format:
Ana García;+34 612 345 678;[email protected];FAMILY;true;2024-03-15
The fields map to the CSV header NOMBRE;TELEFONO;EMAIL;CATEGORIA;FAVORITO;FECHA_REGISTRO.

comoFilaTabla() — JTable row

Returns an Object[] that the controller inserts directly into the DefaultTableModel:
persona.java
public Object[] comoFilaTabla() {
    return new Object[] {
        nombre,
        telefono,
        email,
        categoria,
        favorito ? "★" : "☆"   // star character for visual favourite indicator
    };
}
The table displays five visible columns. fechaRegistro is not shown in the table but is preserved in the in-memory persona object and written back to disk on every save.

Category codes

The application uses three stable category codes internally. Display names are provided in three languages and mapped to codes by personaDAO.normalizarCategoria().
CodeSpanishEnglishPortuguese
FAMILYFamiliaFamilyFamília
FRIENDSAmigosFriendsAmigos
WORKTrabajoWorkTrabalho
normalizarCategoria() performs a case-insensitive match, so data imported from external CSV files in any supported language will load correctly without manual correction.

CSV file format

The contact list is stored at a fixed location:
c:/gestionContactos/datosContactos.csv
personaDAO.prepararArchivo() creates both the directory and the file with its header row if they do not yet exist.

Current format (6 columns)

datosContactos.csv
NOMBRE;TELEFONO;EMAIL;CATEGORIA;FAVORITO;FECHA_REGISTRO
Ana García;+34 612 345 678;[email protected];FAMILY;true;2024-03-15
Bob Smith;+1 555 0100;[email protected];WORK;false;2024-04-02

Legacy format (5 columns)

Files written by earlier versions of the application omit the FECHA_REGISTRO column:
datosContactos.csv (legacy)
NOMBRE;TELEFONO;EMAIL;CATEGORIA;FAVORITO
Ana García;+34 612 345 678;[email protected];FAMILY;true
Bob Smith;+1 555 0100;[email protected];WORK;false

Backward compatibility

leerArchivo() detects the number of columns in each data row and handles both formats:
personaDAO.java
// Inside leerArchivo() — parses a single data line
String[] partes = linea.split(";", -1);
if (partes.length == 6) {
    // New format — parse fechaRegistro from column 5
    LocalDate fecha = LocalDate.parse(partes[5].trim());
    return new persona(partes[0], partes[1], partes[2],
                       normalizarCategoria(partes[3]),
                       Boolean.parseBoolean(partes[4].trim()),
                       fecha);
} else if (partes.length == 5) {
    // Legacy format — fechaRegistro defaults to today
    return new persona(partes[0], partes[1], partes[2],
                       normalizarCategoria(partes[3]),
                       Boolean.parseBoolean(partes[4].trim()));
}
When a legacy 5-column file is loaded and then saved by the current version, all contacts without an explicit registration date will receive today’s date. This is a one-time migration and cannot be reversed.

CSV escaping

Values are written with RFC 4180 escaping via armarLineaCsv(String[]) and escaparCsv(String):
  • Fields containing the separator (;), double quotes ("), or newlines are wrapped in double quotes.
  • Existing double-quote characters inside a field are escaped as "".

personaDAO method reference

MethodAccessSignatureDescription
ConstructorpublicpersonaDAO(persona)Initializes the DAO with the contact to operate on and sets the file path.
escribirArchivopublicboolean escribirArchivo()Appends the current persona to the CSV file. Returns false if persona is null.
leerArchivopublicList<persona> leerArchivo() throws IOExceptionReads the entire file, skips the header and blank lines, parses 5- or 6-column rows, normalizes categories.
actualizarContactospublicvoid actualizarContactos(List<persona>) throws IOExceptionRewrites the entire CSV file from a provided list (used for edits and deletes).
exportarCsv (default)publicvoid exportarCsv(File, List<persona>)Exports contacts to a user-chosen file using the default header row.
exportarCsv (custom)publicvoid exportarCsv(File, String[], List<String[]>)Exports with caller-supplied column headers and pre-formatted row data.
prepararArchivoprivatevoid prepararArchivo()Creates the directory and file with header if they do not exist. Called from constructor.
normalizarCategoriaprivateString normalizarCategoria(String)Maps a multilingual display name to a category code (FAMILY/FRIENDS/WORK).
armarLineaCsvprivateString armarLineaCsv(String[])Joins an array of values into a semicolon-delimited line with RFC 4180 escaping.
escaparCsvprivateString escaparCsv(String)Wraps and escapes a single field value per RFC 4180.

Architecture overview

Package structure, technology stack, and key design decisions.

MVC pattern implementation

How the view exposes components and how the controller wires events.

Build docs developers (and LLMs) love