Class ReportJSONBuilder
java.lang.Object
br.ufsc.labsec.signature.conformanceVerifier.report.builder.ReportJSONBuilder
- All Implemented Interfaces:
ReportBuilder<org.json.JSONObject, org.json.JSONObject>
public class ReportJSONBuilder
extends Object
implements ReportBuilder<org.json.JSONObject, org.json.JSONObject>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReportBuilder<org.json.JSONObject, org.json.JSONObject> createElement(ReportElement value) Cria um elemento baseado em um relatório.ReportBuilder<org.json.JSONObject, org.json.JSONObject> createElement(String tag) ReportBuilder<org.json.JSONObject, org.json.JSONObject> createElement(String tag, boolean value) Cria um elemento com um conteúdo booleanoReportBuilder<org.json.JSONObject, org.json.JSONObject> createElement(String tag, Number value) Cria um elemento com um conteúdo numéricoReportBuilder<org.json.JSONObject, org.json.JSONObject> createElement(String tag, String value) Cria um elemento com um conteúdo de textoReportBuilder<org.json.JSONObject, org.json.JSONObject> createElement(String tag, Consumer<ReportBuilder<org.json.JSONObject, org.json.JSONObject>> consumer) Cria um elemento e o constrói com base em uma função anônima, esse método abstrai a pilha para a criação de elementos complexos.
Um exemplo do uso é na criação do elemento de certificado em DigitalIdentityReportReportBuilder<org.json.JSONObject, org.json.JSONObject> createElementForEach(String tag, String pluralTag, Collection<String> values) Cria um elemento lista (plural tag) e elementos filhos dele com a tag<T> ReportBuilder<org.json.JSONObject, org.json.JSONObject> createElementForEach(String tag, String pluralTag, Collection<T> values, BiConsumer<T, ReportBuilder<org.json.JSONObject, org.json.JSONObject>> consumer) Cria uma lista de elementos e os constrói com base em uma função anônima.ReportBuilder<org.json.JSONObject, org.json.JSONObject> createElementForEach(Collection<? extends ReportElement> values) Este método leva em conta a possibilidade de relatórios de tipos diferentes estarem presentes na lista.org.json.JSONObjectObtém o elemento atualorg.json.JSONObjectgetRoot()Obtém o elemento raizvoidgoToElement(String tag) org.json.JSONObjectvoidsetCurrentElement(String tag) Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ReportBuilder
createElement
-
Constructor Details
-
ReportJSONBuilder
public ReportJSONBuilder()
-
-
Method Details
-
createElement
Description copied from interface:ReportBuilderCria um elemento baseado em um relatório. O builder é 'emprestado' para o relatório, assim, o elemento a ser criado é adicionado ao topo da pilha e depois é removido- Specified by:
createElementin interfaceReportBuilder<org.json.JSONObject, org.json.JSONObject>- Parameters:
value- relatório- Returns:
- builder
-
createElement
- Specified by:
createElementin interfaceReportBuilder<org.json.JSONObject, org.json.JSONObject>
-
createElement
public ReportBuilder<org.json.JSONObject, org.json.JSONObject> createElement(String tag, String value) Description copied from interface:ReportBuilderCria um elemento com um conteúdo de texto- Specified by:
createElementin interfaceReportBuilder<org.json.JSONObject, org.json.JSONObject>- Parameters:
tag- tag do elementovalue- valor do elemento- Returns:
- builder
-
createElement
public ReportBuilder<org.json.JSONObject, org.json.JSONObject> createElement(String tag, Number value) Description copied from interface:ReportBuilderCria um elemento com um conteúdo numérico- Specified by:
createElementin interfaceReportBuilder<org.json.JSONObject, org.json.JSONObject>- Parameters:
tag- tag do elementovalue- valor do elemento- Returns:
- builder
-
createElement
public ReportBuilder<org.json.JSONObject, org.json.JSONObject> createElement(String tag, boolean value) Description copied from interface:ReportBuilderCria um elemento com um conteúdo booleano- Specified by:
createElementin interfaceReportBuilder<org.json.JSONObject, org.json.JSONObject>- Parameters:
tag- tag do elementovalue- valor do elemento- Returns:
- builder
-
createElement
public ReportBuilder<org.json.JSONObject, org.json.JSONObject> createElement(String tag, Consumer<ReportBuilder<org.json.JSONObject, org.json.JSONObject>> consumer) Description copied from interface:ReportBuilderCria um elemento e o constrói com base em uma função anônima, esse método abstrai a pilha para a criação de elementos complexos.
Um exemplo do uso é na criação do elemento de certificado em DigitalIdentityReport- Specified by:
createElementin interfaceReportBuilder<org.json.JSONObject, org.json.JSONObject>- Parameters:
tag- tag do elementoconsumer- função de criação do elemento- Returns:
- builder
- See Also:
-
createElementForEach
public <T> ReportBuilder<org.json.JSONObject, org.json.JSONObject> createElementForEach(String tag, String pluralTag, Collection<T> values, BiConsumer<T, ReportBuilder<org.json.JSONObject, org.json.JSONObject>> consumer) Description copied from interface:ReportBuilderCria uma lista de elementos e os constrói com base em uma função anônima. Esse método abstrai a pilha para a criação de elementos complexos.
O uso desse método é recomendado para a criação de listas de elementos que não são relatórios. O consumer, ou a função que o implementa, deve receber de argumento o valor T e o builder, nesta ordem.
Um exemplo do uso é na criação do elemento conformities emReport.buildConformity(SignatureReport.Conformity, ReportBuilder)(SignatureReport.Conformity, ReportBuilder) Report#buildConformity}- Specified by:
createElementForEachin interfaceReportBuilder<org.json.JSONObject, org.json.JSONObject>- Type Parameters:
T- tipo dos valores- Parameters:
tag- tag do elementopluralTag- tag da listavalues- valores da listaconsumer- função de criação do elemento- Returns:
- builder
-
createElementForEach
public ReportBuilder<org.json.JSONObject, org.json.JSONObject> createElementForEach(Collection<? extends ReportElement> values) Description copied from interface:ReportBuilderEste método leva em conta a possibilidade de relatórios de tipos diferentes estarem presentes na lista. Primeiramente, os relatório são agrupados pela tag pluralizada e são adicionados ao elemento com esta tag.
Caso o elemento com a tag pluralizada não exista, ele é criado.
- Specified by:
createElementForEachin interfaceReportBuilder<org.json.JSONObject, org.json.JSONObject>- Parameters:
values- relatórios- Returns:
- builder
-
createElementForEach
public ReportBuilder<org.json.JSONObject, org.json.JSONObject> createElementForEach(String tag, String pluralTag, Collection<String> values) Description copied from interface:ReportBuilderCria um elemento lista (plural tag) e elementos filhos dele com a tag- Specified by:
createElementForEachin interfaceReportBuilder<org.json.JSONObject, org.json.JSONObject>- Parameters:
tag- tag dos elementospluralTag- tag listavalues- valor dos elementos- Returns:
- builder
-
getCurrentElement
public org.json.JSONObject getCurrentElement()Description copied from interface:ReportBuilderObtém o elemento atual- Specified by:
getCurrentElementin interfaceReportBuilder<org.json.JSONObject, org.json.JSONObject>- Returns:
- elemento atual
-
getRoot
public org.json.JSONObject getRoot()Description copied from interface:ReportBuilderObtém o elemento raiz- Specified by:
getRootin interfaceReportBuilder<org.json.JSONObject, org.json.JSONObject>- Returns:
- elemento raiz
-
setCurrentElement
- Specified by:
setCurrentElementin interfaceReportBuilder<org.json.JSONObject, org.json.JSONObject>
-
goToElement
- Specified by:
goToElementin interfaceReportBuilder<org.json.JSONObject, org.json.JSONObject>
-
popElement
public org.json.JSONObject popElement()- Specified by:
popElementin interfaceReportBuilder<org.json.JSONObject, org.json.JSONObject>
-