net.sf.jsqlparser.util.deparser.GrantDeParser Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jsqlparser Show documentation
Show all versions of jsqlparser Show documentation
JSqlParser parses an SQL statement and translate it into a hierarchy of Java classes.
The generated hierarchy can be navigated using the Visitor Pattern.
/*-
* #%L
* JSQLParser library
* %%
* Copyright (C) 2004 - 2020 JSQLParser
* %%
* Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.util.deparser;
import java.util.Iterator;
import net.sf.jsqlparser.statement.grant.Grant;
public class GrantDeParser extends AbstractDeParser {
public GrantDeParser(StringBuilder buffer) {
super(buffer);
}
@Override
public void deParse(Grant grant) {
buffer.append("GRANT ");
if (grant.getRole() != null) {
buffer.append(grant.getRole());
} else {
for (Iterator iter = grant.getPrivileges().iterator(); iter.hasNext();) {
String privilege = iter.next();
buffer.append(privilege);
if (iter.hasNext()) {
buffer.append(", ");
}
}
buffer.append(" ON ");
buffer.append(grant.getObjectName());
}
buffer.append(" TO ");
for (Iterator iter = grant.getUsers().iterator(); iter.hasNext();) {
String user = iter.next();
buffer.append(user);
if (iter.hasNext()) {
buffer.append(", ");
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy